public class Command extends AbstractMessage
Operation.QUERY
messages. We don't use
the Query class as a base class as it adds a lot of weight to the commands.Modifier and Type | Field and Description |
---|---|
static String |
COMMAND_COLLECTION
The collection to use when issuing commands to the database.
|
HEADER_SIZE, myCollectionName, myDatabaseName
Constructor and Description |
---|
Command(String databaseName,
String collectionName,
Document commandDocument)
Create a new Command.
|
Command(String databaseName,
String collectionName,
Document commandDocument,
Document routingDocument,
ReadPreference readPreference,
VersionRange requiredServerVersion)
Create a new Command.
|
Command(String databaseName,
String collectionName,
Document commandDocument,
ReadPreference readPreference)
Create a new Command.
|
Command(String databaseName,
String collectionName,
Document commandDocument,
ReadPreference readPreference,
VersionRange requiredServerVersion)
Create a new Command.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object object)
Determines if the passed object is of this same type as this object and
if so that its fields are equal.
|
Document |
getCommand()
Returns the command's document.
|
String |
getOperationName()
Returns a short name for the operation.
|
Document |
getRoutingDocument()
Returns the routingDocument value.
|
int |
hashCode()
Computes a reasonable hash code.
|
boolean |
isAllowJumbo()
Returns true if the command document is allowed to slightly exceed the
document size limit.
|
void |
setAllowJumbo(boolean allowJumbo)
If set to true then the command document is allowed to slightly exceed
the document size limit.
|
int |
size()
Returns the total size of the message on the wire.
|
String |
toString() |
void |
validateSize(SizeOfVisitor visitor,
int maxDocumentSize)
Validates that the documents with the message do not exceed the maximum
document size specified.
|
void |
write(int messageId,
BsonOutputStream out)
Writes the message from the stream.
|
void |
write(int messageId,
BufferingBsonOutputStream out)
Writes the message from the stream.
|
finishHeader, getCollectionName, getDatabaseName, getReadPreference, getRequiredVersionRange, init, writeHeader, writeHeader
public static final String COMMAND_COLLECTION
public Command(String databaseName, String collectionName, Document commandDocument)
databaseName
- The name of the database.collectionName
- The name of the collection the command is using. This should
be the real collection and not "$cmd" if
the real collection is known.commandDocument
- The command document containing the command and options.public Command(String databaseName, String collectionName, Document commandDocument, Document routingDocument, ReadPreference readPreference, VersionRange requiredServerVersion)
databaseName
- The name of the database.collectionName
- The name of the collection the command is using. This should
be the real collection and not "$cmd" if
the real collection is known.commandDocument
- The command document containing the command and options.routingDocument
- The document that should be used for routing the command.readPreference
- The preference for which servers to use to retrieve the
results.requiredServerVersion
- The required version of the server to support processing the
message.public Command(String databaseName, String collectionName, Document commandDocument, ReadPreference readPreference)
databaseName
- The name of the database.collectionName
- The name of the collection the command is using. This should
be the real collection and not "$cmd" if
the real collection is known.commandDocument
- The command document containing the command and options.readPreference
- The preference for which servers to use to retrieve the
results.public Command(String databaseName, String collectionName, Document commandDocument, ReadPreference readPreference, VersionRange requiredServerVersion)
databaseName
- The name of the database.collectionName
- The name of the collection the command is using. This should
be the real collection and not "$cmd" if
the real collection is known.commandDocument
- The command document containing the command and options.readPreference
- The preference for which servers to use to retrieve the
results.requiredServerVersion
- The required version of the server to support processing the
message.public boolean equals(Object object)
equals
in class AbstractMessage
object
- The object to compare to.Object.equals(java.lang.Object)
public Document getCommand()
public String getOperationName()
Overridden to return the command name.
public Document getRoutingDocument()
public int hashCode()
hashCode
in class AbstractMessage
public boolean isAllowJumbo()
public void setAllowJumbo(boolean allowJumbo)
allowJumbo
- If true then the command document is allowed to slightly
exceed the document size limit.public int size()
Overridden to return the size of the Command
.
public String toString()
Overridden to return a human readable form of the command.
public void validateSize(SizeOfVisitor visitor, int maxDocumentSize) throws DocumentToLargeException
Overridden to make sure the command document is not too large.
visitor
- The SizeOfVisitor
to compute the size of the document.maxDocumentSize
- The maximum document size to validate against.DocumentToLargeException
- If one of the documents in the message is too large or the
documents in aggregate are too large.public void write(int messageId, BsonOutputStream out) throws IOException
Overridden to write the Command as a Operation.QUERY
message.
messageId
- The id to be assigned to the message.out
- The sink for data written.IOException
- On an error writing to the stream.public void write(int messageId, BufferingBsonOutputStream out) throws IOException
Overridden to write the Command as a Operation.QUERY
message.
messageId
- The id to be assigned to the message.out
- The sink for data written.IOException
- On an error writing to the stream.Copyright © 2011–2014 Allanbank Consulting, Inc.. All rights reserved.