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 |
addPending(List<PendingMessage> pending)
Adds the pending messages from the specified list.
|
void |
addPropertyChangeListener(PropertyChangeListener listener)
Adds a
PropertyChangeListener to this connection. |
void |
drainPending(List<PendingMessage> pending)
Removes any to be sent pending messages into the specified list.
|
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 |
isIdle()
Determines if the connection is idle.
|
boolean |
isOpen()
Determines if the connection is open.
|
void |
raiseErrors(MongoDbException exception,
boolean notifyToBeSent)
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. |
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.
|
void |
shutdown()
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 addPending(List<PendingMessage> pending) throws InterruptedException
pending
- The list to populate the pending list with.InterruptedException
- On the thread being interrupted while copying the messages.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.void drainPending(List<PendingMessage> pending)
pending
- The list to populate with the pending messages.int getPendingCount()
String getServerName()
boolean isIdle()
boolean isOpen()
void raiseErrors(MongoDbException exception, boolean notifyToBeSent)
exception
- The error condition.notifyToBeSent
- If true then the to be sent message's callback are also
notified, otherwise just the pending messages are notified.void removePropertyChangeListener(PropertyChangeListener listener)
PropertyChangeListener
from this connection.listener
- The listener for the change events.String send(Message message, Callback<Reply> 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.String send(Message message1, Message message2, Callback<Reply> 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 shutdown()
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-2013 Allanbank Consulting, Inc.. All Rights Reserved.