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 Logger |
LOGGER |
private ObjectId |
maxElectionId |
private java.lang.Integer |
maxSetVersion |
private java.lang.String |
replicaSetName |
Constructor and Description |
---|
MultiServerCluster(ClusterId clusterId,
ClusterSettings settings,
ClusterableServerFactory serverFactory) |
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() |
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(ServerDescriptionChangedEvent event) |
private void |
removeExtraHosts(ServerDescription serverDescription) |
private void |
removeServer(ServerAddress serverAddress) |
private ClusterDescription |
updateDescription() |
createServer, fireChangeEvent, getClusterId, getCurrentDescription, getDescription, getServerFactory, getSettings, isClosed, selectServer, selectServerAsync, updateDescription
private static final 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
MultiServerCluster(ClusterId clusterId, ClusterSettings settings, ClusterableServerFactory serverFactory)
protected void connect()
connect
in class BaseCluster
public void close()
Cluster
close
in interface Cluster
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class BaseCluster
protected ClusterableServer getServer(ServerAddress serverAddress)
BaseCluster
getServer
in class BaseCluster
serverAddress
- the addressprivate void onChange(ServerDescriptionChangedEvent 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 ClusterDescription 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)