NodeIDType
- * This class is a wrapper around NodeConfig to ensure that it is
consistent, i.e., it returns consistent results even if it changes
midway. In particular, it does not allow the use of a method like
getNodeIDs().
It also has consistent hashing utility methods.public class ConsistentReconfigurableNodeConfig<NodeIDType> extends ConsistentNodeConfig<NodeIDType> implements ModifiableActiveConfig<NodeIDType>, ModifiableRCConfig<NodeIDType>
Constructor and Description |
---|
ConsistentReconfigurableNodeConfig(ReconfigurableNodeConfig<NodeIDType> nc) |
Modifier and Type | Method and Description |
---|---|
java.net.InetSocketAddress |
addActiveReplica(NodeIDType id,
java.net.InetSocketAddress sockAddr) |
java.net.InetSocketAddress |
addReconfigurator(NodeIDType id,
java.net.InetSocketAddress sockAddr) |
boolean |
checkSameGroup(java.util.Set<java.lang.String> names) |
java.util.Set<NodeIDType> |
getActiveReplicas() |
java.util.Set<java.net.InetSocketAddress> |
getActiveReplicaSocketAddresses() |
java.util.Set<java.net.InetSocketAddress> |
getActiveReplicaSocketAddresses(int limit)
This method tries to return a limited number of active replica socket
addresses that to the extent possible have distinct IPs.
|
java.util.Map<java.lang.String,java.net.InetSocketAddress> |
getAllActiveReplicas() |
java.net.InetSocketAddress |
getBindSocketAddress(NodeIDType id)
Returns the bindable socket address of the public host corresponding to
this id.
|
NodeIDType |
getFirstReconfigurator(java.lang.String name) |
java.util.Set<NodeIDType> |
getIPToActiveReplicaIDs(java.util.ArrayList<java.net.InetAddress> newAddresses,
java.util.Set<NodeIDType> oldNodes)
This method maps a set of addresses, newAddresses, to a set of nodes such
that there is maximal overlap with the specified set of nodes, oldNodes.
|
java.util.Set<NodeIDType> |
getNodeIDs() |
java.util.Set<NodeIDType> |
getNodeIDs(java.util.Set<java.lang.String> newActives) |
java.util.ArrayList<java.net.InetAddress> |
getNodeIPs(java.util.Set<NodeIDType> nodeIDs)
Consistent coz it always consults nodeConfig.
|
java.net.InetSocketAddress |
getNodeSocketAddress(NodeIDType id)
Returns the socket address of the public host corresponding to this id.
|
java.util.Set<java.net.InetSocketAddress> |
getRandomActiveReplica() |
NodeIDType |
getReconfiguratorHash(java.lang.String name)
Deprecated.
|
java.util.Set<NodeIDType> |
getReconfigurators() |
java.util.Set<java.net.InetSocketAddress> |
getReconfiguratorsAsAddresses(java.lang.String name) |
java.util.Set<NodeIDType> |
getReplicatedActives(java.lang.String name) |
java.util.ArrayList<java.net.InetAddress> |
getReplicatedActivesIPs(java.lang.String name) |
java.util.Set<NodeIDType> |
getReplicatedReconfigurators(java.lang.String name) |
ReconfigurableNodeConfig<NodeIDType> |
getUnderlyingNodeConfig()
This method should not be used.
|
java.util.Set<NodeIDType> |
getValuesFromJSONArray(org.json.JSONArray array) |
java.util.Set<NodeIDType> |
getValuesFromStringSet(java.util.Set<java.lang.String> strNodes)
Converts a set of string node ids using valueOf.
|
long |
getVersion()
Unused.
|
java.net.InetSocketAddress |
removeActiveReplica(NodeIDType id) |
boolean |
removeActivesSlatedForRemoval() |
java.net.InetSocketAddress |
removeReconfigurator(NodeIDType id) |
boolean |
removeReconfiguratorsSlatedForRemoval() |
java.net.InetSocketAddress |
slateForRemovalActive(NodeIDType id) |
java.net.InetSocketAddress |
slateForRemovalReconfigurator(NodeIDType id) |
static java.util.Collection<java.util.Set<java.lang.String>> |
splitIntoRCGroups(java.util.Set<java.lang.String> names,
java.util.Set<?> reconfigurators)
A utility method to split a collection of names into batches wherein
names in each batch map to the same reconfigurator group.
|
java.lang.String |
toString() |
getBindAddress, getNodeAddress, getNodePort, getReplicatedServers, nodeExists, valueOf
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getActiveReplicasMap
getActiveReplicasReadOnly, getReconfiguratorsReadOnly
getBindAddress, getNodeAddress, getNodePort, nodeExists
valueOf
public ConsistentReconfigurableNodeConfig(ReconfigurableNodeConfig<NodeIDType> nc)
nc
- public java.util.Set<NodeIDType> getValuesFromStringSet(java.util.Set<java.lang.String> strNodes)
Stringifiable
getValuesFromStringSet
in interface Stringifiable<NodeIDType>
getValuesFromStringSet
in class ConsistentNodeConfig<NodeIDType>
public java.util.Set<NodeIDType> getValuesFromJSONArray(org.json.JSONArray array) throws org.json.JSONException
getValuesFromJSONArray
in interface Stringifiable<NodeIDType>
getValuesFromJSONArray
in class ConsistentNodeConfig<NodeIDType>
org.json.JSONException
public java.util.Set<NodeIDType> getNodeIDs()
getNodeIDs
in interface NodeConfig<NodeIDType>
getNodeIDs
in class ConsistentNodeConfig<NodeIDType>
public java.util.Set<NodeIDType> getActiveReplicas()
getActiveReplicas
in interface ReconfigurableNodeConfig<NodeIDType>
public java.util.Set<java.net.InetSocketAddress> getActiveReplicaSocketAddresses()
public java.util.Set<java.net.InetSocketAddress> getActiveReplicaSocketAddresses(int limit)
limit
- public java.util.Set<NodeIDType> getReconfigurators()
getReconfigurators
in interface ReconfigurableNodeConfig<NodeIDType>
public java.util.ArrayList<java.net.InetAddress> getNodeIPs(java.util.Set<NodeIDType> nodeIDs)
nodeIDs
- nodeIDs
.public java.util.Set<NodeIDType> getReplicatedReconfigurators(java.lang.String name)
name
- name
hashes
on the consistent hash ring.public java.util.Set<java.net.InetSocketAddress> getReconfiguratorsAsAddresses(java.lang.String name)
name
- public NodeIDType getFirstReconfigurator(java.lang.String name)
name
- name
hashes on the
consistent hash ring.@Deprecated public NodeIDType getReconfiguratorHash(java.lang.String name)
name
- public java.util.Set<NodeIDType> getReplicatedActives(java.lang.String name)
name
- name
hashes on the
consistent hash ring of all active replica nodes.public java.util.ArrayList<java.net.InetAddress> getReplicatedActivesIPs(java.lang.String name)
name
- name
hashes on the
consistent hash ring of all active replica nodes.public java.util.Set<java.net.InetSocketAddress> getRandomActiveReplica()
public java.util.Set<NodeIDType> getIPToActiveReplicaIDs(java.util.ArrayList<java.net.InetAddress> newAddresses, java.util.Set<NodeIDType> oldNodes)
newAddresses
- oldNodes
- newAddresses
that have high overlap with the set of old active replica nodes
oldNodes
.public ReconfigurableNodeConfig<NodeIDType> getUnderlyingNodeConfig()
public java.net.InetSocketAddress addReconfigurator(NodeIDType id, java.net.InetSocketAddress sockAddr)
addReconfigurator
in interface ModifiableRCConfig<NodeIDType>
public java.net.InetSocketAddress getNodeSocketAddress(NodeIDType id)
getNodeSocketAddress
in class ConsistentNodeConfig<NodeIDType>
id
- id
.public java.net.InetSocketAddress getBindSocketAddress(NodeIDType id)
id
- public java.net.InetSocketAddress removeReconfigurator(NodeIDType id)
removeReconfigurator
in interface ModifiableRCConfig<NodeIDType>
id
was mapped.public static java.util.Collection<java.util.Set<java.lang.String>> splitIntoRCGroups(java.util.Set<java.lang.String> names, java.util.Set<?> reconfigurators)
names
- reconfigurators
- public boolean checkSameGroup(java.util.Set<java.lang.String> names)
names
- public java.net.InetSocketAddress slateForRemovalReconfigurator(NodeIDType id)
id
- public java.net.InetSocketAddress slateForRemovalActive(NodeIDType id)
id
- public boolean removeReconfiguratorsSlatedForRemoval()
public boolean removeActivesSlatedForRemoval()
public java.net.InetSocketAddress addActiveReplica(NodeIDType id, java.net.InetSocketAddress sockAddr)
addActiveReplica
in interface ModifiableActiveConfig<NodeIDType>
public java.net.InetSocketAddress removeActiveReplica(NodeIDType id)
removeActiveReplica
in interface ModifiableActiveConfig<NodeIDType>
id
was mapped.public long getVersion()
ModifiableActiveConfig
getVersion
in interface ModifiableActiveConfig<NodeIDType>
public java.lang.String toString()
toString
in class java.lang.Object
public java.util.Map<java.lang.String,java.net.InetSocketAddress> getAllActiveReplicas()
public java.util.Set<NodeIDType> getNodeIDs(java.util.Set<java.lang.String> newActives)
newActives
-