abstract class WriteProtocol extends java.lang.Object implements Protocol<WriteConcernResult>
Modifier and Type | Class and Description |
---|---|
private class |
WriteProtocol.UnacknowledgedWriteResultCallback |
private class |
WriteProtocol.WriteResultCallback |
Modifier and Type | Field and Description |
---|---|
private CommandListener |
commandListener |
private MongoNamespace |
namespace |
private boolean |
ordered |
private WriteConcern |
writeConcern |
Constructor and Description |
---|
WriteProtocol(MongoNamespace namespace,
boolean ordered,
WriteConcern writeConcern)
Construct a new instance.
|
Modifier and Type | Method and Description |
---|---|
protected abstract void |
appendToWriteCommandResponseDocument(RequestMessage curMessage,
RequestMessage nextMessage,
WriteConcernResult writeConcernResult,
BsonDocument response) |
private BsonDocument |
createGetLastErrorCommandDocument() |
protected abstract RequestMessage |
createRequestMessage(MessageSettings settings)
Create the initial request message for the write.
|
WriteConcernResult |
execute(InternalConnection connection)
Execute the protocol.
|
void |
executeAsync(InternalConnection connection,
SingleResultCallback<WriteConcernResult> callback)
Execute the protocol asynchronously.
|
private void |
executeAsync(RequestMessage requestMessage,
InternalConnection connection,
SingleResultCallback<WriteConcernResult> callback) |
protected abstract BsonDocument |
getAsWriteCommand(ByteBufferBsonOutput bsonOutput,
int firstDocumentPosition) |
protected BsonDocument |
getBaseCommandDocument(java.lang.String commandName) |
protected java.lang.String |
getCommandName(RequestMessage message) |
protected abstract Logger |
getLogger()
Gets the logger.
|
protected MongoNamespace |
getNamespace()
Gets the namespace.
|
private BsonDocument |
getResponseDocument(RequestMessage curMessage,
RequestMessage nextMessage,
WriteConcernResult writeConcernResult,
WriteConcernException writeConcernException) |
protected WriteConcern |
getWriteConcern()
Gets the write concern.
|
protected boolean |
isOrdered()
Gets whether the writes are ordered.
|
private void |
sendFailedEvent(InternalConnection connection,
RequestMessage message,
boolean sentCommandStartedEvent,
java.lang.Throwable t,
long startTimeNanos) |
private void |
sendStartedEvent(InternalConnection connection,
RequestMessage message,
RequestMessage.EncodingMetadata encodingMetadata,
ByteBufferBsonOutput bsonOutput) |
private void |
sendSucceededEvent(InternalConnection connection,
RequestMessage message,
BsonDocument responseDocument,
long startTimeNanos) |
private void |
sendSucceededEvent(InternalConnection connection,
RequestMessage message,
RequestMessage nextMessage,
WriteConcernException e,
long startTimeNanos) |
private void |
sendSucceededEvent(InternalConnection connection,
RequestMessage message,
RequestMessage nextMessage,
WriteConcernResult writeConcernResult,
long startTimeNanos) |
void |
setCommandListener(CommandListener commandListener) |
private boolean |
shouldAcknowledge(RequestMessage nextMessage) |
private final MongoNamespace namespace
private final boolean ordered
private final WriteConcern writeConcern
private CommandListener commandListener
public WriteProtocol(MongoNamespace namespace, boolean ordered, WriteConcern writeConcern)
namespace
- the namespaceordered
- whether the inserts are orderedwriteConcern
- the write concernpublic void setCommandListener(CommandListener commandListener)
setCommandListener
in interface Protocol<WriteConcernResult>
public WriteConcernResult execute(InternalConnection connection)
Protocol
execute
in interface Protocol<WriteConcernResult>
connection
- the connection to execute the protocol onprotected abstract void appendToWriteCommandResponseDocument(RequestMessage curMessage, RequestMessage nextMessage, WriteConcernResult writeConcernResult, BsonDocument response)
public void executeAsync(InternalConnection connection, SingleResultCallback<WriteConcernResult> callback)
Protocol
executeAsync
in interface Protocol<WriteConcernResult>
connection
- the connection to execute the protocol oncallback
- the callback that is passed the result of the executionprivate void executeAsync(RequestMessage requestMessage, InternalConnection connection, SingleResultCallback<WriteConcernResult> callback)
protected abstract BsonDocument getAsWriteCommand(ByteBufferBsonOutput bsonOutput, int firstDocumentPosition)
protected BsonDocument getBaseCommandDocument(java.lang.String commandName)
protected java.lang.String getCommandName(RequestMessage message)
private void sendStartedEvent(InternalConnection connection, RequestMessage message, RequestMessage.EncodingMetadata encodingMetadata, ByteBufferBsonOutput bsonOutput)
private void sendSucceededEvent(InternalConnection connection, RequestMessage message, RequestMessage nextMessage, WriteConcernException e, long startTimeNanos)
private void sendSucceededEvent(InternalConnection connection, RequestMessage message, RequestMessage nextMessage, WriteConcernResult writeConcernResult, long startTimeNanos)
private void sendSucceededEvent(InternalConnection connection, RequestMessage message, BsonDocument responseDocument, long startTimeNanos)
private void sendFailedEvent(InternalConnection connection, RequestMessage message, boolean sentCommandStartedEvent, java.lang.Throwable t, long startTimeNanos)
private BsonDocument getResponseDocument(RequestMessage curMessage, RequestMessage nextMessage, WriteConcernResult writeConcernResult, WriteConcernException writeConcernException)
private boolean shouldAcknowledge(RequestMessage nextMessage)
private BsonDocument createGetLastErrorCommandDocument()
protected abstract RequestMessage createRequestMessage(MessageSettings settings)
settings
- the message settingsprotected MongoNamespace getNamespace()
protected boolean isOrdered()
protected WriteConcern getWriteConcern()
protected abstract Logger getLogger()