final class MultiServerCluster extends BaseCluster
| Modifier and Type | Class and Description |
|---|---|
private class |
MultiServerCluster.DefaultServerStateListener |
private static class |
MultiServerCluster.ServerTuple |
| Modifier and Type | Field and Description |
|---|---|
private java.util.concurrent.ConcurrentMap<ServerAddress,MultiServerCluster.ServerTuple> |
addressToServerTupleMap |
private ClusterType |
clusterType |
private static java.util.logging.Logger |
LOGGER |
private ObjectId |
maxElectionId |
private java.lang.Integer |
maxSetVersion |
private java.lang.String |
replicaSetName |
| Constructor and Description |
|---|
MultiServerCluster(java.lang.String clusterId,
ClusterSettings settings,
ClusterableServerFactory serverFactory,
ClusterListener clusterListener) |
| Modifier and Type | Method and Description |
|---|---|
private void |
addHostsToSet(java.util.Set<java.lang.String> hosts,
java.util.Set<ServerAddress> retVal) |
private void |
addNewHosts(java.util.Set<java.lang.String> hosts) |
private void |
addServer(ServerAddress serverAddress) |
void |
close()
Closes connections to the servers in the cluster.
|
protected void |
connect()
Try to connect to all servers
|
private void |
ensureServers(ServerDescription description) |
private java.util.Set<ServerAddress> |
getAllServerAddresses(ServerDescription serverDescription) |
private ServerDescription |
getConnectingServerDescription(ServerAddress serverAddress) |
private java.util.List<ServerDescription> |
getNewServerDescriptionList() |
protected ClusterableServer |
getServer(ServerAddress serverAddress)
Return the server at the given address.
|
private boolean |
handleReplicaSetMemberChanged(ServerDescription newDescription) |
private boolean |
handleShardRouterChanged(ServerDescription newDescription) |
private boolean |
handleStandAloneChanged(ServerDescription newDescription) |
private boolean |
hasPrimary() |
private void |
invalidateOldPrimaries(ServerAddress newPrimary) |
private boolean |
isNotAlreadyPrimary(ServerAddress address) |
private boolean |
isStalePrimary(ServerDescription newDescription) |
private void |
onChange(ChangeEvent<ServerDescription> event) |
private void |
removeExtraHosts(ServerDescription serverDescription) |
private void |
removeServer(ServerAddress serverAddress) |
private void |
updateDescription() |
createServer, fireChangeEvent, getCurrentDescription, getDescription, getServer, getSettings, isClosed, updateDescriptionprivate static final java.util.logging.Logger LOGGER
private ClusterType clusterType
private java.lang.String replicaSetName
private ObjectId maxElectionId
private java.lang.Integer maxSetVersion
private final java.util.concurrent.ConcurrentMap<ServerAddress,MultiServerCluster.ServerTuple> addressToServerTupleMap
public MultiServerCluster(java.lang.String clusterId,
ClusterSettings settings,
ClusterableServerFactory serverFactory,
ClusterListener clusterListener)
protected void connect()
BaseClusterconnect in class BaseClusterpublic void close()
Clusterclose in interface Clusterclose in class BaseClusterprotected ClusterableServer getServer(ServerAddress serverAddress)
BaseClustergetServer in class BaseClusterserverAddress - the addressprivate void onChange(ChangeEvent<ServerDescription> event)
private boolean handleReplicaSetMemberChanged(ServerDescription newDescription)
private boolean isStalePrimary(ServerDescription newDescription)
private boolean isNotAlreadyPrimary(ServerAddress address)
private boolean handleShardRouterChanged(ServerDescription newDescription)
private boolean handleStandAloneChanged(ServerDescription newDescription)
private void addServer(ServerAddress serverAddress)
private void removeServer(ServerAddress serverAddress)
private void invalidateOldPrimaries(ServerAddress newPrimary)
private ServerDescription getConnectingServerDescription(ServerAddress serverAddress)
private void updateDescription()
private java.util.List<ServerDescription> getNewServerDescriptionList()
private void ensureServers(ServerDescription description)
private boolean hasPrimary()
private void addNewHosts(java.util.Set<java.lang.String> hosts)
private void removeExtraHosts(ServerDescription serverDescription)
private java.util.Set<ServerAddress> getAllServerAddresses(ServerDescription serverDescription)
private void addHostsToSet(java.util.Set<java.lang.String> hosts,
java.util.Set<ServerAddress> retVal)