public abstract class AbstractMessage extends Object implements Message
Modifier and Type | Field and Description |
---|---|
static int |
HEADER_SIZE
The size of a message header.
|
protected String |
myCollectionName
The name of the collection to operate on.
|
protected String |
myDatabaseName
The name of the database to operate on.
|
Constructor and Description |
---|
AbstractMessage()
Create a new AbstractMessage.
|
AbstractMessage(String databaseName,
String collectionName,
ReadPreference readPreference)
Create a new AbstractMessage.
|
AbstractMessage(String databaseName,
String collectionName,
ReadPreference readPreference,
VersionRange versionRange)
Creates a new AbstractMessage.
|
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.
|
protected void |
finishHeader(BufferingBsonOutputStream stream,
long start)
Writes the MsgHeader messageLengthField in the header stream.
|
String |
getCollectionName()
Returns the name of the collection.
|
String |
getDatabaseName()
Returns the name of the database.
|
ReadPreference |
getReadPreference()
Provides the details on which servers are eligible to receive the
message.
|
VersionRange |
getRequiredVersionRange()
Returns the required version range for the message.
|
int |
hashCode()
Computes a reasonable hash code.
|
protected void |
init(String name)
Initializes the database and collection name from the full database name.
|
protected void |
writeHeader(BsonOutputStream stream,
int requestId,
int responseTo,
Operation op,
int length)
Writes the MsgHeader to the stream.
|
protected long |
writeHeader(BufferingBsonOutputStream stream,
int requestId,
int responseTo,
Operation op)
Writes the MsgHeader to the stream.
|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
getOperationName, size, validateSize, write, write
public static final int HEADER_SIZE
protected String myCollectionName
protected String myDatabaseName
public AbstractMessage()
public AbstractMessage(String databaseName, String collectionName, ReadPreference readPreference)
databaseName
- The name of the database.collectionName
- The name of the collection.readPreference
- The preferences for which servers to send the message.public AbstractMessage(String databaseName, String collectionName, ReadPreference readPreference, VersionRange versionRange)
databaseName
- The name of the database.collectionName
- The name of the collection.readPreference
- The preferences for which servers to send the message.versionRange
- The required range of versions of the server to support
processing the message.public boolean equals(Object object)
equals
in class Object
object
- The object to compare to.Object.equals(java.lang.Object)
public String getCollectionName()
public String getDatabaseName()
getDatabaseName
in interface Message
public ReadPreference getReadPreference()
Returns the message's read preference.
getReadPreference
in interface Message
ReadPreference
for which servers should be sent the
request.public VersionRange getRequiredVersionRange()
This may be null
which should be interpreted to mean that all
versions of the server support the message's operation. In reality that
is probably more accurately stated as all supported versions.
getRequiredVersionRange
in interface Message
public int hashCode()
protected void finishHeader(BufferingBsonOutputStream stream, long start)
struct MsgHeader {
int32 messageLength; // total message size, including this
int32 requestID; // identifier for this message
int32 responseTo; // requestID from the original request
// (used in reponses from db)
int32 opCode; // request type - see table below
}
stream
- The stream to write to.start
- The position of the start of the header for the message.protected void init(String name)
name
- The full database name.protected void writeHeader(BsonOutputStream stream, int requestId, int responseTo, Operation op, int length)
struct MsgHeader {
int32 messageLength; // total message size, including this
int32 requestID; // identifier for this message
int32 responseTo; // requestID from the original request
// (used in reponses from db)
int32 opCode; // request type - see table below
}
stream
- The stream to write to.requestId
- The requestID from above.responseTo
- The responseTo from above.op
- The operation for the opCode field.length
- The length of the message including the header.protected long writeHeader(BufferingBsonOutputStream stream, int requestId, int responseTo, Operation op)
struct MsgHeader {
int32 messageLength; // total message size, including this
int32 requestID; // identifier for this message
int32 responseTo; // requestID from the original request
// (used in reponses from db)
int32 opCode; // request type - see table below
}
stream
- The stream to write to.requestId
- The requestID from above.responseTo
- The responseTo from above.op
- The operation for the opCode field.Copyright © 2011–2014 Allanbank Consulting, Inc.. All rights reserved.