class DefaultServerConnection extends AbstractReferenceCounted implements Connection, AsyncConnection
Modifier and Type | Field and Description |
---|---|
private ClusterConnectionMode |
clusterConnectionMode |
private static Logger |
LOGGER |
private ProtocolExecutor |
protocolExecutor |
private InternalConnection |
wrapped |
Constructor and Description |
---|
DefaultServerConnection(InternalConnection wrapped,
ProtocolExecutor protocolExecutor,
ClusterConnectionMode clusterConnectionMode) |
Modifier and Type | Method and Description |
---|---|
<T> T |
command(java.lang.String database,
BsonDocument command,
boolean slaveOk,
FieldNameValidator fieldNameValidator,
Decoder<T> commandResultDecoder)
Execute the command.
|
<T> void |
commandAsync(java.lang.String database,
BsonDocument command,
boolean slaveOk,
FieldNameValidator fieldNameValidator,
Decoder<T> commandResultDecoder,
SingleResultCallback<T> callback)
Execute the command asynchronously.
|
WriteConcernResult |
delete(MongoNamespace namespace,
boolean ordered,
WriteConcern writeConcern,
java.util.List<DeleteRequest> deletes)
Delete the documents using the delete wire protocol and apply the write concern.
|
void |
deleteAsync(MongoNamespace namespace,
boolean ordered,
WriteConcern writeConcern,
java.util.List<DeleteRequest> deletes,
SingleResultCallback<WriteConcernResult> callback)
Delete the documents using the delete wire protocol and apply the write concern asynchronously.
|
BulkWriteResult |
deleteCommand(MongoNamespace namespace,
boolean ordered,
WriteConcern writeConcern,
java.util.List<DeleteRequest> deletes)
Delete the documents using the delete command.
|
void |
deleteCommandAsync(MongoNamespace namespace,
boolean ordered,
WriteConcern writeConcern,
java.util.List<DeleteRequest> deletes,
SingleResultCallback<BulkWriteResult> callback)
Delete the documents using the delete command asynchronously.
|
private <T> T |
executeProtocol(Protocol<T> protocol) |
private <T> void |
executeProtocolAsync(Protocol<T> protocol,
SingleResultCallback<T> callback) |
ConnectionDescription |
getDescription()
Gets the description of the connection.
|
<T> QueryResult<T> |
getMore(MongoNamespace namespace,
long cursorId,
int numberToReturn,
Decoder<T> resultDecoder)
Get more result documents from a cursor.
|
<T> void |
getMoreAsync(MongoNamespace namespace,
long cursorId,
int numberToReturn,
Decoder<T> resultDecoder,
SingleResultCallback<QueryResult<T>> callback)
Get more result documents from a cursor asynchronously.
|
private boolean |
getSlaveOk(boolean slaveOk) |
WriteConcernResult |
insert(MongoNamespace namespace,
boolean ordered,
WriteConcern writeConcern,
java.util.List<InsertRequest> inserts)
Insert the documents using the insert wire protocol and apply the write concern.
|
void |
insertAsync(MongoNamespace namespace,
boolean ordered,
WriteConcern writeConcern,
java.util.List<InsertRequest> inserts,
SingleResultCallback<WriteConcernResult> callback)
Insert the documents using the insert wire protocol and apply the write concern asynchronously.
|
BulkWriteResult |
insertCommand(MongoNamespace namespace,
boolean ordered,
WriteConcern writeConcern,
java.lang.Boolean bypassDocumentValidation,
java.util.List<InsertRequest> inserts)
Insert the documents using the insert command.
|
BulkWriteResult |
insertCommand(MongoNamespace namespace,
boolean ordered,
WriteConcern writeConcern,
java.util.List<InsertRequest> inserts)
Insert the documents using the insert command.
|
void |
insertCommandAsync(MongoNamespace namespace,
boolean ordered,
WriteConcern writeConcern,
java.lang.Boolean bypassDocumentValidation,
java.util.List<InsertRequest> inserts,
SingleResultCallback<BulkWriteResult> callback)
Insert the documents using the insert command asynchronously.
|
void |
insertCommandAsync(MongoNamespace namespace,
boolean ordered,
WriteConcern writeConcern,
java.util.List<InsertRequest> inserts,
SingleResultCallback<BulkWriteResult> callback)
Insert the documents using the insert command asynchronously.
|
void |
killCursor(java.util.List<java.lang.Long> cursors)
Kills the given list of cursors.
|
void |
killCursor(MongoNamespace namespace,
java.util.List<java.lang.Long> cursors)
Kills the given list of cursors.
|
void |
killCursorAsync(java.util.List<java.lang.Long> cursors,
SingleResultCallback<java.lang.Void> callback)
Asynchronously Kills the given list of cursors.
|
void |
killCursorAsync(MongoNamespace namespace,
java.util.List<java.lang.Long> cursors,
SingleResultCallback<java.lang.Void> callback)
Asynchronously Kills the given list of cursors.
|
<T> QueryResult<T> |
query(MongoNamespace namespace,
BsonDocument queryDocument,
BsonDocument fields,
int numberToReturn,
int skip,
boolean slaveOk,
boolean tailableCursor,
boolean awaitData,
boolean noCursorTimeout,
boolean partial,
boolean oplogReplay,
Decoder<T> resultDecoder)
Execute the query.
|
<T> QueryResult<T> |
query(MongoNamespace namespace,
BsonDocument queryDocument,
BsonDocument fields,
int skip,
int limit,
int batchSize,
boolean slaveOk,
boolean tailableCursor,
boolean awaitData,
boolean noCursorTimeout,
boolean partial,
boolean oplogReplay,
Decoder<T> resultDecoder)
Execute the query.
|
<T> void |
queryAsync(MongoNamespace namespace,
BsonDocument queryDocument,
BsonDocument fields,
int numberToReturn,
int skip,
boolean slaveOk,
boolean tailableCursor,
boolean awaitData,
boolean noCursorTimeout,
boolean partial,
boolean oplogReplay,
Decoder<T> resultDecoder,
SingleResultCallback<QueryResult<T>> callback)
Execute the query asynchronously.
|
<T> void |
queryAsync(MongoNamespace namespace,
BsonDocument queryDocument,
BsonDocument fields,
int skip,
int limit,
int batchSize,
boolean slaveOk,
boolean tailableCursor,
boolean awaitData,
boolean noCursorTimeout,
boolean partial,
boolean oplogReplay,
Decoder<T> resultDecoder,
SingleResultCallback<QueryResult<T>> callback)
Execute the query asynchronously.
|
void |
release()
Release a reference to this object.
|
DefaultServerConnection |
retain()
Retain an additional reference to this object.
|
WriteConcernResult |
update(MongoNamespace namespace,
boolean ordered,
WriteConcern writeConcern,
java.util.List<UpdateRequest> updates)
Update the documents using the update wire protocol and apply the write concern.
|
void |
updateAsync(MongoNamespace namespace,
boolean ordered,
WriteConcern writeConcern,
java.util.List<UpdateRequest> updates,
SingleResultCallback<WriteConcernResult> callback)
Update the documents using the update wire protocol and apply the write concern asynchronously.
|
BulkWriteResult |
updateCommand(MongoNamespace namespace,
boolean ordered,
WriteConcern writeConcern,
java.lang.Boolean bypassDocumentValidation,
java.util.List<UpdateRequest> updates)
Update the documents using the update command.
|
BulkWriteResult |
updateCommand(MongoNamespace namespace,
boolean ordered,
WriteConcern writeConcern,
java.util.List<UpdateRequest> updates)
Update the documents using the update command.
|
void |
updateCommandAsync(MongoNamespace namespace,
boolean ordered,
WriteConcern writeConcern,
java.lang.Boolean bypassDocumentValidation,
java.util.List<UpdateRequest> updates,
SingleResultCallback<BulkWriteResult> callback)
Update the documents using the update command asynchronously.
|
void |
updateCommandAsync(MongoNamespace namespace,
boolean ordered,
WriteConcern writeConcern,
java.util.List<UpdateRequest> updates,
SingleResultCallback<BulkWriteResult> callback)
Update the documents using the update command asynchronously.
|
getCount
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getCount
private static final Logger LOGGER
private final InternalConnection wrapped
private final ProtocolExecutor protocolExecutor
private final ClusterConnectionMode clusterConnectionMode
public DefaultServerConnection(InternalConnection wrapped, ProtocolExecutor protocolExecutor, ClusterConnectionMode clusterConnectionMode)
public DefaultServerConnection retain()
ReferenceCounted
retain
in interface ReferenceCounted
retain
in interface AsyncConnection
retain
in interface Connection
retain
in class AbstractReferenceCounted
public void release()
ReferenceCounted
release
in interface ReferenceCounted
release
in class AbstractReferenceCounted
public ConnectionDescription getDescription()
Connection
getDescription
in interface AsyncConnection
getDescription
in interface Connection
public WriteConcernResult insert(MongoNamespace namespace, boolean ordered, WriteConcern writeConcern, java.util.List<InsertRequest> inserts)
Connection
insert
in interface Connection
namespace
- the namespaceordered
- whether the writes are orderedwriteConcern
- the write concerninserts
- the insertspublic void insertAsync(MongoNamespace namespace, boolean ordered, WriteConcern writeConcern, java.util.List<InsertRequest> inserts, SingleResultCallback<WriteConcernResult> callback)
AsyncConnection
insertAsync
in interface AsyncConnection
namespace
- the namespaceordered
- whether the writes are orderedwriteConcern
- the write concerninserts
- the insertscallback
- the callback to be passed the write resultpublic WriteConcernResult update(MongoNamespace namespace, boolean ordered, WriteConcern writeConcern, java.util.List<UpdateRequest> updates)
Connection
update
in interface Connection
namespace
- the namespaceordered
- whether the writes are orderedwriteConcern
- the write concernupdates
- the updatespublic void updateAsync(MongoNamespace namespace, boolean ordered, WriteConcern writeConcern, java.util.List<UpdateRequest> updates, SingleResultCallback<WriteConcernResult> callback)
AsyncConnection
updateAsync
in interface AsyncConnection
namespace
- the namespaceordered
- whether the writes are orderedwriteConcern
- the write concernupdates
- the updatescallback
- the callback to be passed the write resultpublic WriteConcernResult delete(MongoNamespace namespace, boolean ordered, WriteConcern writeConcern, java.util.List<DeleteRequest> deletes)
Connection
delete
in interface Connection
namespace
- the namespaceordered
- whether the writes are orderedwriteConcern
- the write concerndeletes
- the deletespublic void deleteAsync(MongoNamespace namespace, boolean ordered, WriteConcern writeConcern, java.util.List<DeleteRequest> deletes, SingleResultCallback<WriteConcernResult> callback)
AsyncConnection
deleteAsync
in interface AsyncConnection
namespace
- the namespaceordered
- whether the writes are orderedwriteConcern
- the write concerndeletes
- the deletescallback
- the callback to be passed the write resultpublic BulkWriteResult insertCommand(MongoNamespace namespace, boolean ordered, WriteConcern writeConcern, java.util.List<InsertRequest> inserts)
Connection
insertCommand
in interface Connection
namespace
- the namespaceordered
- whether the writes are orderedwriteConcern
- the write concerninserts
- the insertspublic BulkWriteResult insertCommand(MongoNamespace namespace, boolean ordered, WriteConcern writeConcern, java.lang.Boolean bypassDocumentValidation, java.util.List<InsertRequest> inserts)
Connection
insertCommand
in interface Connection
namespace
- the namespaceordered
- whether the writes are orderedwriteConcern
- the write concernbypassDocumentValidation
- the bypassDocumentValidation flaginserts
- the insertspublic void insertCommandAsync(MongoNamespace namespace, boolean ordered, WriteConcern writeConcern, java.util.List<InsertRequest> inserts, SingleResultCallback<BulkWriteResult> callback)
AsyncConnection
insertCommandAsync
in interface AsyncConnection
namespace
- the namespaceordered
- whether the writes are orderedwriteConcern
- the write concerninserts
- the insertscallback
- the callback to be passed the bulk write resultpublic void insertCommandAsync(MongoNamespace namespace, boolean ordered, WriteConcern writeConcern, java.lang.Boolean bypassDocumentValidation, java.util.List<InsertRequest> inserts, SingleResultCallback<BulkWriteResult> callback)
AsyncConnection
insertCommandAsync
in interface AsyncConnection
namespace
- the namespaceordered
- whether the writes are orderedwriteConcern
- the write concernbypassDocumentValidation
- the bypassDocumentValidation flaginserts
- the insertscallback
- the callback to be passed the bulk write resultpublic BulkWriteResult updateCommand(MongoNamespace namespace, boolean ordered, WriteConcern writeConcern, java.util.List<UpdateRequest> updates)
Connection
updateCommand
in interface Connection
namespace
- the namespaceordered
- whether the writes are orderedwriteConcern
- the write concernupdates
- the updatespublic BulkWriteResult updateCommand(MongoNamespace namespace, boolean ordered, WriteConcern writeConcern, java.lang.Boolean bypassDocumentValidation, java.util.List<UpdateRequest> updates)
Connection
updateCommand
in interface Connection
namespace
- the namespaceordered
- whether the writes are orderedwriteConcern
- the write concernbypassDocumentValidation
- the bypassDocumentValidation flagupdates
- the updatespublic void updateCommandAsync(MongoNamespace namespace, boolean ordered, WriteConcern writeConcern, java.util.List<UpdateRequest> updates, SingleResultCallback<BulkWriteResult> callback)
AsyncConnection
updateCommandAsync
in interface AsyncConnection
namespace
- the namespaceordered
- whether the writes are orderedwriteConcern
- the write concernupdates
- the updatescallback
- the callback to be passed the BulkWriteResultpublic void updateCommandAsync(MongoNamespace namespace, boolean ordered, WriteConcern writeConcern, java.lang.Boolean bypassDocumentValidation, java.util.List<UpdateRequest> updates, SingleResultCallback<BulkWriteResult> callback)
AsyncConnection
updateCommandAsync
in interface AsyncConnection
namespace
- the namespaceordered
- whether the writes are orderedwriteConcern
- the write concernbypassDocumentValidation
- the bypassDocumentValidation flagupdates
- the updatescallback
- the callback to be passed the BulkWriteResultpublic BulkWriteResult deleteCommand(MongoNamespace namespace, boolean ordered, WriteConcern writeConcern, java.util.List<DeleteRequest> deletes)
Connection
deleteCommand
in interface Connection
namespace
- the namespaceordered
- whether the writes are orderedwriteConcern
- the write concerndeletes
- the deletespublic void deleteCommandAsync(MongoNamespace namespace, boolean ordered, WriteConcern writeConcern, java.util.List<DeleteRequest> deletes, SingleResultCallback<BulkWriteResult> callback)
AsyncConnection
deleteCommandAsync
in interface AsyncConnection
namespace
- the namespaceordered
- whether the writes are orderedwriteConcern
- the write concerndeletes
- the deletescallback
- the callback to be passed the BulkWriteResultpublic <T> T command(java.lang.String database, BsonDocument command, boolean slaveOk, FieldNameValidator fieldNameValidator, Decoder<T> commandResultDecoder)
Connection
command
in interface Connection
T
- the type of the resultdatabase
- the database to execute the command incommand
- the command documentslaveOk
- whether the command can run on a secondaryfieldNameValidator
- the field name validator for the command documentcommandResultDecoder
- the decoder for the resultpublic <T> void commandAsync(java.lang.String database, BsonDocument command, boolean slaveOk, FieldNameValidator fieldNameValidator, Decoder<T> commandResultDecoder, SingleResultCallback<T> callback)
AsyncConnection
commandAsync
in interface AsyncConnection
T
- the type of the resultdatabase
- the database to execute the command incommand
- the command documentslaveOk
- whether the command can run on a secondaryfieldNameValidator
- the field name validator for the command documentcommandResultDecoder
- the decoder for the resultcallback
- the callback to be passed the command resultpublic <T> QueryResult<T> query(MongoNamespace namespace, BsonDocument queryDocument, BsonDocument fields, int numberToReturn, int skip, boolean slaveOk, boolean tailableCursor, boolean awaitData, boolean noCursorTimeout, boolean partial, boolean oplogReplay, Decoder<T> resultDecoder)
Connection
query
in interface Connection
T
- the query result document typenamespace
- the namespace to queryqueryDocument
- the query documentfields
- the field to include or excludenumberToReturn
- the number of documents to returnskip
- the number of documents to skipslaveOk
- whether the query can run on a secondarytailableCursor
- whether to return a tailable cursorawaitData
- whether a tailable cursor should wait before returning if no documents are availablenoCursorTimeout
- whether the cursor should not timeoutpartial
- whether partial results from sharded clusters are acceptableoplogReplay
- whether to replay the oplogresultDecoder
- the decoder for the query result documentspublic <T> QueryResult<T> query(MongoNamespace namespace, BsonDocument queryDocument, BsonDocument fields, int skip, int limit, int batchSize, boolean slaveOk, boolean tailableCursor, boolean awaitData, boolean noCursorTimeout, boolean partial, boolean oplogReplay, Decoder<T> resultDecoder)
Connection
query
in interface Connection
T
- the query result document typenamespace
- the namespace to queryqueryDocument
- the query documentfields
- the field to include or excludeskip
- the number of documents to skiplimit
- the maximum number of documents to return in all batchesbatchSize
- the maximum number of documents to return in this batchslaveOk
- whether the query can run on a secondarytailableCursor
- whether to return a tailable cursorawaitData
- whether a tailable cursor should wait before returning if no documents are availablenoCursorTimeout
- whether the cursor should not timeoutpartial
- whether partial results from sharded clusters are acceptableoplogReplay
- whether to replay the oplogresultDecoder
- the decoder for the query result documentspublic <T> void queryAsync(MongoNamespace namespace, BsonDocument queryDocument, BsonDocument fields, int numberToReturn, int skip, boolean slaveOk, boolean tailableCursor, boolean awaitData, boolean noCursorTimeout, boolean partial, boolean oplogReplay, Decoder<T> resultDecoder, SingleResultCallback<QueryResult<T>> callback)
AsyncConnection
queryAsync
in interface AsyncConnection
T
- the query result document typenamespace
- the namespace to queryqueryDocument
- the query documentfields
- the field to include or excludenumberToReturn
- the number of documents to returnskip
- the number of documents to skipslaveOk
- whether the query can run on a secondarytailableCursor
- whether to return a tailable cursorawaitData
- whether a tailable cursor should wait before returning if no documents are availablenoCursorTimeout
- whether the cursor should not timeoutpartial
- whether partial results from sharded clusters are acceptableoplogReplay
- whether to replay the oplogresultDecoder
- the decoder for the query result documentscallback
- the callback to be passed the write resultpublic <T> void queryAsync(MongoNamespace namespace, BsonDocument queryDocument, BsonDocument fields, int skip, int limit, int batchSize, boolean slaveOk, boolean tailableCursor, boolean awaitData, boolean noCursorTimeout, boolean partial, boolean oplogReplay, Decoder<T> resultDecoder, SingleResultCallback<QueryResult<T>> callback)
AsyncConnection
queryAsync
in interface AsyncConnection
T
- the query result document typenamespace
- the namespace to queryqueryDocument
- the query documentfields
- the field to include or excludeskip
- the number of documents to skiplimit
- the maximum number of documents to return in all batchesbatchSize
- the maximum number of documents to return in this batchslaveOk
- whether the query can run on a secondarytailableCursor
- whether to return a tailable cursorawaitData
- whether a tailable cursor should wait before returning if no documents are availablenoCursorTimeout
- whether the cursor should not timeoutpartial
- whether partial results from sharded clusters are acceptableoplogReplay
- whether to replay the oplogresultDecoder
- the decoder for the query result documentscallback
- the callback to be passed the write resultpublic <T> QueryResult<T> getMore(MongoNamespace namespace, long cursorId, int numberToReturn, Decoder<T> resultDecoder)
Connection
getMore
in interface Connection
T
- the type of the query result documentsnamespace
- the namespace to get more documents fromcursorId
- the cursor idnumberToReturn
- the number of documents to returnresultDecoder
- the decoder for the query resultspublic <T> void getMoreAsync(MongoNamespace namespace, long cursorId, int numberToReturn, Decoder<T> resultDecoder, SingleResultCallback<QueryResult<T>> callback)
AsyncConnection
getMoreAsync
in interface AsyncConnection
T
- the type of the query result documentsnamespace
- the namespace to get more documents fromcursorId
- the cursor idnumberToReturn
- the number of documents to returnresultDecoder
- the decoder for the query result documentscallback
- the callback to be passed the query resultpublic void killCursor(java.util.List<java.lang.Long> cursors)
Connection
killCursor
in interface Connection
cursors
- the cursorspublic void killCursor(MongoNamespace namespace, java.util.List<java.lang.Long> cursors)
Connection
killCursor
in interface Connection
namespace
- the namespace to in which the cursors livecursors
- the cursorspublic void killCursorAsync(java.util.List<java.lang.Long> cursors, SingleResultCallback<java.lang.Void> callback)
AsyncConnection
killCursorAsync
in interface AsyncConnection
cursors
- the cursorscallback
- the callback that is called once the cursors have been killedpublic void killCursorAsync(MongoNamespace namespace, java.util.List<java.lang.Long> cursors, SingleResultCallback<java.lang.Void> callback)
AsyncConnection
killCursorAsync
in interface AsyncConnection
namespace
- the namespace in which the cursors livecursors
- the cursorscallback
- the callback that is called once the cursors have been killedprivate boolean getSlaveOk(boolean slaveOk)
private <T> T executeProtocol(Protocol<T> protocol)
private <T> void executeProtocolAsync(Protocol<T> protocol, SingleResultCallback<T> callback)