public interface Connection extends Closeable, Flushable
| Modifier and Type | Field and Description |
|---|---|
static String |
COMMAND_COLLECTION
The collection to use when issuing commands to the database.
|
static String |
OPEN_PROP_NAME
The property for if the connection is open or not.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addPropertyChangeListener(PropertyChangeListener listener)
Adds a
PropertyChangeListener to this connection. |
int |
getPendingCount()
Returns the number of messages that are pending responses from the
server.
|
String |
getServerName()
Returns the name of a server the connection is currently connected to.
|
boolean |
isAvailable()
Returns true if the connection is open and not shutting down, false
otherwise.
|
boolean |
isIdle()
Determines if the connection is idle.
|
boolean |
isOpen()
Determines if the connection is open.
|
boolean |
isShuttingDown()
Returns true if the connection is being gracefully closed, false
otherwise.
|
void |
raiseErrors(MongoDbException exception)
Notifies the call backs for the pending and optionally the to be sent
messages that there has been an external, unrecoverable error.
|
void |
removePropertyChangeListener(PropertyChangeListener listener)
Removes a
PropertyChangeListener from this connection. |
void |
send(Message message1,
Message message2,
ReplyCallback replyCallback)
Sends a message on the connection.
|
void |
send(Message message,
ReplyCallback replyCallback)
Sends a message on the connection.
|
void |
shutdown(boolean force)
Notifies the connection that once all outstanding requests have been sent
and all replies received the Connection should be closed.
|
void |
waitForClosed(int timeout,
TimeUnit timeoutUnits)
Waits for the connection to become idle.
|
static final String COMMAND_COLLECTION
static final String OPEN_PROP_NAME
void addPropertyChangeListener(PropertyChangeListener listener)
PropertyChangeListener to this connection. Events are
fired as the state of the connection changes.listener - The listener for the change events.int getPendingCount()
String getServerName()
boolean isAvailable()
boolean isIdle()
boolean isOpen()
boolean isShuttingDown()
void raiseErrors(MongoDbException exception)
exception - The error condition.void removePropertyChangeListener(PropertyChangeListener listener)
PropertyChangeListener from this connection.listener - The listener for the change events.void send(Message message1, Message message2, ReplyCallback replyCallback) throws MongoDbException
message1 - 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.void send(Message message, ReplyCallback replyCallback) throws MongoDbException
message - 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.void shutdown(boolean force)
force - If true then the connection can be immediately closed as the
caller knows there are no outstanding requests to the server.void waitForClosed(int timeout,
TimeUnit timeoutUnits)
timeout - The amount of time to wait for the connection to become idle.timeoutUnits - The units for the amount of time to wait for the connection to
become idle.Copyright © 2011–2014 Allanbank Consulting, Inc.. All rights reserved.