abstract class WriteCommandProtocol extends java.lang.Object implements Protocol<BulkWriteResult>
Modifier and Type | Field and Description |
---|---|
private java.lang.Boolean |
bypassDocumentValidation |
private CommandListener |
commandListener |
private MongoNamespace |
namespace |
private boolean |
ordered |
private WriteConcern |
writeConcern |
Constructor and Description |
---|
WriteCommandProtocol(MongoNamespace namespace,
boolean ordered,
WriteConcern writeConcern,
java.lang.Boolean bypassDocumentValidation)
Construct an instance.
|
Modifier and Type | Method and Description |
---|---|
protected abstract BaseWriteCommandMessage |
createRequestMessage(MessageSettings messageSettings) |
BulkWriteResult |
execute(InternalConnection connection)
Execute the protocol.
|
void |
executeAsync(InternalConnection connection,
SingleResultCallback<BulkWriteResult> callback)
Execute the protocol asynchronously.
|
private void |
executeBatchesAsync(InternalConnection connection,
BaseWriteCommandMessage message,
BulkWriteBatchCombiner bulkWriteBatchCombiner,
int batchNum,
int currentRangeStartIndex,
SingleResultCallback<BulkWriteResult> callback) |
java.lang.Boolean |
getBypassDocumentValidation()
Gets the bypass document validation flag
|
protected abstract Logger |
getLogger()
Gets the logger.
|
MongoNamespace |
getNamespace()
Gets the namespace to execute the protocol in.
|
protected abstract WriteRequest.Type |
getType() |
WriteConcern |
getWriteConcern()
Gets the write concern.
|
protected boolean |
isOrdered()
Gets whether the writes must be executed in order.
|
private BsonDocument |
receiveMessage(InternalConnection connection,
RequestMessage message) |
private void |
sendFailedEvent(InternalConnection connection,
BaseWriteCommandMessage message,
long startTimeNanos,
java.lang.Throwable t) |
private BaseWriteCommandMessage |
sendMessage(InternalConnection connection,
BaseWriteCommandMessage message,
int batchNum) |
private void |
sendMessageAsync(InternalConnection connection,
ByteBufferBsonOutput buffer,
BaseWriteCommandMessage message,
long startTimeNanos,
SingleResultCallback<BulkWriteResult> clientCallback,
SingleResultCallback<BsonDocument> callback) |
private void |
sendStartedEvent(InternalConnection connection,
BaseWriteCommandMessage message,
ByteBufferBsonOutput bsonOutput,
RequestMessage.EncodingMetadata encodingMetadata) |
private void |
sendSucceededEvent(InternalConnection connection,
BaseWriteCommandMessage message,
long startTimeNanos,
BsonDocument result) |
void |
setCommandListener(CommandListener commandListener) |
private final MongoNamespace namespace
private final boolean ordered
private final WriteConcern writeConcern
private final java.lang.Boolean bypassDocumentValidation
private CommandListener commandListener
public WriteCommandProtocol(MongoNamespace namespace, boolean ordered, WriteConcern writeConcern, java.lang.Boolean bypassDocumentValidation)
namespace
- the namespaceordered
- whether the inserts are orderedwriteConcern
- the write concernbypassDocumentValidation
- the bypass documentation validation flagpublic void setCommandListener(CommandListener commandListener)
setCommandListener
in interface Protocol<BulkWriteResult>
public WriteConcern getWriteConcern()
public java.lang.Boolean getBypassDocumentValidation()
public BulkWriteResult execute(InternalConnection connection)
Protocol
execute
in interface Protocol<BulkWriteResult>
connection
- the connection to execute the protocol onpublic void executeAsync(InternalConnection connection, SingleResultCallback<BulkWriteResult> callback)
Protocol
executeAsync
in interface Protocol<BulkWriteResult>
connection
- the connection to execute the protocol oncallback
- the callback that is passed the result of the executionprivate void executeBatchesAsync(InternalConnection connection, BaseWriteCommandMessage message, BulkWriteBatchCombiner bulkWriteBatchCombiner, int batchNum, int currentRangeStartIndex, SingleResultCallback<BulkWriteResult> callback)
protected abstract WriteRequest.Type getType()
protected abstract BaseWriteCommandMessage createRequestMessage(MessageSettings messageSettings)
private BaseWriteCommandMessage sendMessage(InternalConnection connection, BaseWriteCommandMessage message, int batchNum)
private void sendStartedEvent(InternalConnection connection, BaseWriteCommandMessage message, ByteBufferBsonOutput bsonOutput, RequestMessage.EncodingMetadata encodingMetadata)
private void sendSucceededEvent(InternalConnection connection, BaseWriteCommandMessage message, long startTimeNanos, BsonDocument result)
private void sendFailedEvent(InternalConnection connection, BaseWriteCommandMessage message, long startTimeNanos, java.lang.Throwable t)
private BsonDocument receiveMessage(InternalConnection connection, RequestMessage message)
private void sendMessageAsync(InternalConnection connection, ByteBufferBsonOutput buffer, BaseWriteCommandMessage message, long startTimeNanos, SingleResultCallback<BulkWriteResult> clientCallback, SingleResultCallback<BsonDocument> callback)
public MongoNamespace getNamespace()
protected abstract Logger getLogger()
protected boolean isOrdered()