public class ReplicaSetConnection extends AbstractProxyConnection
Connection implementation for connecting to a replica-set
environment.AbstractProxyConnection.ProxiedChangeListener| Modifier and Type | Field and Description |
|---|---|
protected static Logger |
LOG
The logger for the
ReplicaSetConnectionFactory. |
myConfigCOMMAND_COLLECTION, OPEN_PROP_NAME| Constructor and Description |
|---|
ReplicaSetConnection(Connection proxiedConnection,
ServerState server,
ClusterState cluster,
ProxiedConnectionFactory factory,
MongoClientConfiguration config)
Creates a new
ReplicaSetConnection. |
| Modifier and Type | Method and Description |
|---|---|
protected String |
doSend(Connection conn,
Message message1,
Message message2,
Callback<Reply> reply)
Sends the message on the connection.
|
protected List<ServerState> |
findPotentialServers(Message message1,
Message message2)
Locates the set of servers that can be used to send the specified
messages.
|
protected Connection |
reconnect(Connection conn)
Reconnects the connection.
|
String |
send(Message message,
Callback<Reply> replyCallback)
Sends a message on the connection.
|
String |
send(Message message1,
Message message2,
Callback<Reply> replyCallback)
Sends a message on the connection.
|
String |
toString() |
protected String |
trySend(List<ServerState> servers,
Message message1,
Message message2,
Callback<Reply> reply)
Tries to send the messages to the first server with either an open
connection or that we can open a connection to.
|
protected String |
trySendToOpenConnection(List<ServerState> servers,
Message message1,
Message message2,
Callback<Reply> reply)
Tries to send the messages to the first server with an open connection.
|
addPending, addPropertyChangeListener, close, drainPending, flush, getPendingCount, getProxiedConnection, getServerName, isIdle, isOpen, onExceptin, raiseErrors, removePropertyChangeListener, shutdown, waitForClosedprotected static final Logger LOG
ReplicaSetConnectionFactory.public ReplicaSetConnection(Connection proxiedConnection, ServerState server, ClusterState cluster, ProxiedConnectionFactory factory, MongoClientConfiguration config)
ReplicaSetConnection.proxiedConnection - The connection being proxied.server - The primary server this connection is connected to.cluster - The state of the cluster for finding secondary connections.factory - The connection factory for opening secondary connections.config - The MongoDB client configuration.public String send(Message message, Callback<Reply> replyCallback) throws MongoDbException
Forwards the call to the proxied Connection.
Locates all of the potential servers that can receive all of the messages. Tries to then send the messages to a server with a connection already open or failing that tries to open a connection to open of the servers.
send in interface Connectionsend in class AbstractProxyConnectionmessage - The message to send on the connection.replyCallback - The callback to notify of responses to the messages. May be
null.MongoDbException - On an error sending the message.public String send(Message message1, Message message2, Callback<Reply> replyCallback) throws MongoDbException
Forwards the call to the proxied Connection.
Locates all of the potential servers that can receive all of the messages. Tries to then send the messages to a server with a connection already open or failing that tries to open a connection to open of the servers.
send in interface Connectionsend in class AbstractProxyConnectionmessage1 - The first message to send on the connection.message2 - The second message to send on the connection.replyCallback - The callback to notify of responses to the message2.
May be null.MongoDbException - On an error sending the message.public String toString()
Overridden to return the socket information.
protected String doSend(Connection conn, Message message1, Message message2, Callback<Reply> reply)
conn - The connection to send on.message1 - The first message to send.message2 - The second message to send, may be null.reply - The reply Callback.protected List<ServerState> findPotentialServers(Message message1, Message message2) throws MongoDbException
message1 - The first message to send.message2 - The second message to send. May be null.MongoDbException - On a failure to locate a server that all messages can be sent
to.protected Connection reconnect(Connection conn)
conn - The connection to reconnect.protected String trySend(List<ServerState> servers, Message message1, Message message2, Callback<Reply> reply)
servers - The servers the messages can be sent to.message1 - The first message to send.message2 - The second message to send. May be null.reply - The callback for the replies.null if the messages could not be sent.protected String trySendToOpenConnection(List<ServerState> servers, Message message1, Message message2, Callback<Reply> reply)
servers - The servers the messages can be sent to.message1 - The first message to send.message2 - The second message to send. May be null.reply - The callback for the replies.null if the messages could not be sent.Copyright © 2011-2013 Allanbank Consulting, Inc.. All Rights Reserved.