Class DocumentProtocol
- java.lang.Object
-
- com.yahoo.documentapi.messagebus.protocol.DocumentProtocol
-
- All Implemented Interfaces:
com.yahoo.messagebus.Protocol
public class DocumentProtocol extends java.lang.Object implements com.yahoo.messagebus.Protocol
Implements the message bus protocol that is used by all components of Vespa.- Author:
- Simon Thoresen Hult
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DocumentProtocol.Priority
Define the different priorities allowed for document api messages.
-
Field Summary
Fields Modifier and Type Field Description static int
DOCUMENT_MESSAGE
All message types that are implemented by this protocol.static int
DOCUMENT_REPLY
All reply types that are implemented by this protocol.static int
ERROR_ABORTED
Operation cut short and aborted.static int
ERROR_BUCKET_DELETED
Bucket recently removed, such that operation cannot be performed.static int
ERROR_BUCKET_NOT_FOUND
Bucket given in operation not found due to bucket database inconsistencies between storage and distributor nodes.static int
ERROR_BUSY
Node too busy to process request (Typically full queues)static int
ERROR_DISK_FAILURE
We failed accessing the disk, which we think is a disk hardware problem.static int
ERROR_DOCUMENT_EXISTS
Operation cannot be performed because token already exist.static int
ERROR_DOCUMENT_NOT_FOUND
Document in operation cannot be found.static int
ERROR_IGNORED
Request was not handled correctly.static int
ERROR_ILLEGAL_PARAMETERS
Parameters given in request is illegal.static int
ERROR_INTERNAL_FAILURE
We failed in some way we didn't expect to fail.static int
ERROR_IO_FAILURE
We failed during an IO operation, we dont think is a specific disk hardware problem.static int
ERROR_MESSAGE_IGNORED
Used by policies to indicate an inappropriate message.static int
ERROR_NO_SPACE
Not enough free space on disk to perform operation.static int
ERROR_NODE_NOT_READY
Node not ready to perform operation.static int
ERROR_NOT_CONNECTED
Lost connection with the node we requested something from.static int
ERROR_NOT_IMPLEMENTED
Node have not implemented support for the given operation.static int
ERROR_POLICY_FAILURE
Used for error policy when policy creation failed.static int
ERROR_PROCESSING_FAILURE
Failed to process the given request.static int
ERROR_REJECTED
Node refuse to perform operation.static int
ERROR_STALE_TIMESTAMP
Storage node received a timestamp that is stale.static int
ERROR_SUSPENDED
The given node have gotten a critical error and have suspended itself.static int
ERROR_TEST_AND_SET_CONDITION_FAILED
Test and set condition (selection) failed.static int
ERROR_TIMESTAMP_EXIST
Unique timestamp specified for new operation is already in use.static int
ERROR_UNKNOWN_COMMAND
Unknown request received.static int
ERROR_UNPARSEABLE
Request cannot be decoded.static int
ERROR_WRONG_DISTRIBUTION
Wrong node to talk to in current state.static int
MESSAGE_CREATEVISITOR
static int
MESSAGE_DESTROYVISITOR
static int
MESSAGE_DOCUMENTLIST
static int
MESSAGE_DOCUMENTSUMMARY
static int
MESSAGE_EMPTYBUCKETS
static int
MESSAGE_GETBUCKETLIST
static int
MESSAGE_GETBUCKETSTATE
static int
MESSAGE_GETDOCUMENT
static int
MESSAGE_MAPVISITOR
static int
MESSAGE_PUTDOCUMENT
static int
MESSAGE_QUERYRESULT
static int
MESSAGE_REMOVEDOCUMENT
static int
MESSAGE_REMOVELOCATION
static int
MESSAGE_SEARCHRESULT
static int
MESSAGE_STATBUCKET
static int
MESSAGE_UPDATEDOCUMENT
static int
MESSAGE_VISITORINFO
static com.yahoo.text.Utf8String
NAME
The name of this protocol.static int
REPLY_CREATEVISITOR
static int
REPLY_DESTROYVISITOR
static int
REPLY_DOCUMENTIGNORED
static int
REPLY_DOCUMENTLIST
static int
REPLY_DOCUMENTSUMMARY
static int
REPLY_EMPTYBUCKETS
static int
REPLY_GETBUCKETLIST
static int
REPLY_GETBUCKETSTATE
static int
REPLY_GETDOCUMENT
static int
REPLY_MAPVISITOR
static int
REPLY_PUTDOCUMENT
static int
REPLY_QUERYRESULT
static int
REPLY_REMOVEDOCUMENT
static int
REPLY_REMOVELOCATION
static int
REPLY_SEARCHRESULT
static int
REPLY_STATBUCKET
static int
REPLY_UPDATEDOCUMENT
static int
REPLY_VISITORINFO
static int
REPLY_WRONGDISTRIBUTION
-
Constructor Summary
Constructors Constructor Description DocumentProtocol(com.yahoo.document.DocumentTypeManager docMan)
DocumentProtocol(com.yahoo.document.DocumentTypeManager docMan, java.lang.String configId)
DocumentProtocol(com.yahoo.document.DocumentTypeManager docMan, java.lang.String configId, com.yahoo.documentapi.messagebus.loadtypes.LoadTypeSet set)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description com.yahoo.messagebus.routing.RoutingPolicy
createPolicy(java.lang.String name, java.lang.String param)
com.yahoo.messagebus.Routable
decode(com.yahoo.component.Version version, byte[] data)
byte[]
encode(com.yahoo.component.Version version, com.yahoo.messagebus.Routable routable)
com.yahoo.document.DocumentTypeManager
getDocumentTypeManager()
static java.lang.String
getErrorName(int code)
Returns a string representation of the given error code.java.lang.String
getName()
static DocumentProtocol.Priority
getPriority(int val)
Get a priority enum instance by its value.static DocumentProtocol.Priority
getPriorityByName(java.lang.String name)
Get priority enum instance by its name.java.util.List<java.lang.Integer>
getRoutableTypes(com.yahoo.component.Version version)
Returns a list of routable types that support the given version.static boolean
hasOnlyErrorsOfType(com.yahoo.messagebus.Reply reply, int errCode)
Returns true if the given reply has at least one error, and all errors are of the given type.static void
merge(com.yahoo.messagebus.routing.RoutingContext ctx)
This is a convenient entry to themerge(RoutingContext,Set)
method by way of a routing context object.static void
merge(com.yahoo.messagebus.routing.RoutingContext ctx, java.util.Set<java.lang.Integer> mask)
This method implements the common way to merge document replies for whatever routing policy.static com.yahoo.messagebus.Reply
merge(java.util.List<com.yahoo.messagebus.Reply> replies)
This method implements the common way to merge document replies for whatever routing policy.DocumentProtocol
putRoutableFactory(int type, RoutableFactory factory, com.yahoo.component.VersionSpecification version)
Adds a new routable factory to this protocol.DocumentProtocol
putRoutableFactory(int type, RoutableFactory factory, java.util.List<com.yahoo.component.VersionSpecification> versions)
Convenience method to callputRoutableFactory(int, RoutableFactory, com.yahoo.component.VersionSpecification)
for multiple version specifications.DocumentProtocol
putRoutingPolicyFactory(java.lang.String name, RoutingPolicyFactory factory)
Adds a new routable factory to this protocol.
-
-
-
Field Detail
-
NAME
public static final com.yahoo.text.Utf8String NAME
The name of this protocol.
-
DOCUMENT_MESSAGE
public static final int DOCUMENT_MESSAGE
All message types that are implemented by this protocol.- See Also:
- Constant Field Values
-
MESSAGE_GETDOCUMENT
public static final int MESSAGE_GETDOCUMENT
- See Also:
- Constant Field Values
-
MESSAGE_PUTDOCUMENT
public static final int MESSAGE_PUTDOCUMENT
- See Also:
- Constant Field Values
-
MESSAGE_REMOVEDOCUMENT
public static final int MESSAGE_REMOVEDOCUMENT
- See Also:
- Constant Field Values
-
MESSAGE_UPDATEDOCUMENT
public static final int MESSAGE_UPDATEDOCUMENT
- See Also:
- Constant Field Values
-
MESSAGE_CREATEVISITOR
public static final int MESSAGE_CREATEVISITOR
- See Also:
- Constant Field Values
-
MESSAGE_DESTROYVISITOR
public static final int MESSAGE_DESTROYVISITOR
- See Also:
- Constant Field Values
-
MESSAGE_VISITORINFO
public static final int MESSAGE_VISITORINFO
- See Also:
- Constant Field Values
-
MESSAGE_SEARCHRESULT
public static final int MESSAGE_SEARCHRESULT
- See Also:
- Constant Field Values
-
MESSAGE_DOCUMENTSUMMARY
public static final int MESSAGE_DOCUMENTSUMMARY
- See Also:
- Constant Field Values
-
MESSAGE_MAPVISITOR
public static final int MESSAGE_MAPVISITOR
- See Also:
- Constant Field Values
-
MESSAGE_GETBUCKETSTATE
public static final int MESSAGE_GETBUCKETSTATE
- See Also:
- Constant Field Values
-
MESSAGE_STATBUCKET
public static final int MESSAGE_STATBUCKET
- See Also:
- Constant Field Values
-
MESSAGE_GETBUCKETLIST
public static final int MESSAGE_GETBUCKETLIST
- See Also:
- Constant Field Values
-
MESSAGE_DOCUMENTLIST
public static final int MESSAGE_DOCUMENTLIST
- See Also:
- Constant Field Values
-
MESSAGE_EMPTYBUCKETS
public static final int MESSAGE_EMPTYBUCKETS
- See Also:
- Constant Field Values
-
MESSAGE_REMOVELOCATION
public static final int MESSAGE_REMOVELOCATION
- See Also:
- Constant Field Values
-
MESSAGE_QUERYRESULT
public static final int MESSAGE_QUERYRESULT
- See Also:
- Constant Field Values
-
DOCUMENT_REPLY
public static final int DOCUMENT_REPLY
All reply types that are implemented by this protocol.- See Also:
- Constant Field Values
-
REPLY_GETDOCUMENT
public static final int REPLY_GETDOCUMENT
- See Also:
- Constant Field Values
-
REPLY_PUTDOCUMENT
public static final int REPLY_PUTDOCUMENT
- See Also:
- Constant Field Values
-
REPLY_REMOVEDOCUMENT
public static final int REPLY_REMOVEDOCUMENT
- See Also:
- Constant Field Values
-
REPLY_UPDATEDOCUMENT
public static final int REPLY_UPDATEDOCUMENT
- See Also:
- Constant Field Values
-
REPLY_CREATEVISITOR
public static final int REPLY_CREATEVISITOR
- See Also:
- Constant Field Values
-
REPLY_DESTROYVISITOR
public static final int REPLY_DESTROYVISITOR
- See Also:
- Constant Field Values
-
REPLY_VISITORINFO
public static final int REPLY_VISITORINFO
- See Also:
- Constant Field Values
-
REPLY_SEARCHRESULT
public static final int REPLY_SEARCHRESULT
- See Also:
- Constant Field Values
-
REPLY_DOCUMENTSUMMARY
public static final int REPLY_DOCUMENTSUMMARY
- See Also:
- Constant Field Values
-
REPLY_MAPVISITOR
public static final int REPLY_MAPVISITOR
- See Also:
- Constant Field Values
-
REPLY_GETBUCKETSTATE
public static final int REPLY_GETBUCKETSTATE
- See Also:
- Constant Field Values
-
REPLY_STATBUCKET
public static final int REPLY_STATBUCKET
- See Also:
- Constant Field Values
-
REPLY_GETBUCKETLIST
public static final int REPLY_GETBUCKETLIST
- See Also:
- Constant Field Values
-
REPLY_DOCUMENTLIST
public static final int REPLY_DOCUMENTLIST
- See Also:
- Constant Field Values
-
REPLY_EMPTYBUCKETS
public static final int REPLY_EMPTYBUCKETS
- See Also:
- Constant Field Values
-
REPLY_REMOVELOCATION
public static final int REPLY_REMOVELOCATION
- See Also:
- Constant Field Values
-
REPLY_QUERYRESULT
public static final int REPLY_QUERYRESULT
- See Also:
- Constant Field Values
-
REPLY_WRONGDISTRIBUTION
public static final int REPLY_WRONGDISTRIBUTION
- See Also:
- Constant Field Values
-
REPLY_DOCUMENTIGNORED
public static final int REPLY_DOCUMENTIGNORED
- See Also:
- Constant Field Values
-
ERROR_MESSAGE_IGNORED
public static final int ERROR_MESSAGE_IGNORED
Used by policies to indicate an inappropriate message.- See Also:
- Constant Field Values
-
ERROR_POLICY_FAILURE
public static final int ERROR_POLICY_FAILURE
Used for error policy when policy creation failed.- See Also:
- Constant Field Values
-
ERROR_DOCUMENT_NOT_FOUND
public static final int ERROR_DOCUMENT_NOT_FOUND
Document in operation cannot be found. (VDS Get and Remove)- See Also:
- Constant Field Values
-
ERROR_DOCUMENT_EXISTS
public static final int ERROR_DOCUMENT_EXISTS
Operation cannot be performed because token already exist. (Create bucket, create visitor)- See Also:
- Constant Field Values
-
ERROR_NOT_IMPLEMENTED
public static final int ERROR_NOT_IMPLEMENTED
Node have not implemented support for the given operation.- See Also:
- Constant Field Values
-
ERROR_ILLEGAL_PARAMETERS
public static final int ERROR_ILLEGAL_PARAMETERS
Parameters given in request is illegal.- See Also:
- Constant Field Values
-
ERROR_UNKNOWN_COMMAND
public static final int ERROR_UNKNOWN_COMMAND
Unknown request received. (New client requesting from old server)- See Also:
- Constant Field Values
-
ERROR_UNPARSEABLE
public static final int ERROR_UNPARSEABLE
Request cannot be decoded.- See Also:
- Constant Field Values
-
ERROR_NO_SPACE
public static final int ERROR_NO_SPACE
Not enough free space on disk to perform operation.- See Also:
- Constant Field Values
-
ERROR_IGNORED
public static final int ERROR_IGNORED
Request was not handled correctly.- See Also:
- Constant Field Values
-
ERROR_INTERNAL_FAILURE
public static final int ERROR_INTERNAL_FAILURE
We failed in some way we didn't expect to fail.- See Also:
- Constant Field Values
-
ERROR_REJECTED
public static final int ERROR_REJECTED
Node refuse to perform operation. (Illegally formed message?)- See Also:
- Constant Field Values
-
ERROR_TEST_AND_SET_CONDITION_FAILED
@Beta public static final int ERROR_TEST_AND_SET_CONDITION_FAILED
Test and set condition (selection) failed.- See Also:
- Constant Field Values
-
ERROR_PROCESSING_FAILURE
public static final int ERROR_PROCESSING_FAILURE
Failed to process the given request. (Used by docproc)- See Also:
- Constant Field Values
-
ERROR_TIMESTAMP_EXIST
public static final int ERROR_TIMESTAMP_EXIST
Unique timestamp specified for new operation is already in use.- See Also:
- Constant Field Values
-
ERROR_NODE_NOT_READY
public static final int ERROR_NODE_NOT_READY
Node not ready to perform operation. (Initializing VDS nodes)- See Also:
- Constant Field Values
-
ERROR_WRONG_DISTRIBUTION
public static final int ERROR_WRONG_DISTRIBUTION
Wrong node to talk to in current state. (VDS system state disagreement)- See Also:
- Constant Field Values
-
ERROR_ABORTED
public static final int ERROR_ABORTED
Operation cut short and aborted. (Destroy visitor, node stopping)- See Also:
- Constant Field Values
-
ERROR_BUSY
public static final int ERROR_BUSY
Node too busy to process request (Typically full queues)- See Also:
- Constant Field Values
-
ERROR_NOT_CONNECTED
public static final int ERROR_NOT_CONNECTED
Lost connection with the node we requested something from.- See Also:
- Constant Field Values
-
ERROR_DISK_FAILURE
public static final int ERROR_DISK_FAILURE
We failed accessing the disk, which we think is a disk hardware problem.- See Also:
- Constant Field Values
-
ERROR_IO_FAILURE
public static final int ERROR_IO_FAILURE
We failed during an IO operation, we dont think is a specific disk hardware problem.- See Also:
- Constant Field Values
-
ERROR_BUCKET_NOT_FOUND
public static final int ERROR_BUCKET_NOT_FOUND
Bucket given in operation not found due to bucket database inconsistencies between storage and distributor nodes.- See Also:
- Constant Field Values
-
ERROR_BUCKET_DELETED
public static final int ERROR_BUCKET_DELETED
Bucket recently removed, such that operation cannot be performed. Differs from BUCKET_NOT_FOUND in that there is no db inconsistency.- See Also:
- Constant Field Values
-
ERROR_STALE_TIMESTAMP
public static final int ERROR_STALE_TIMESTAMP
Storage node received a timestamp that is stale. Likely clock skew.- See Also:
- Constant Field Values
-
ERROR_SUSPENDED
public static final int ERROR_SUSPENDED
The given node have gotten a critical error and have suspended itself.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DocumentProtocol
public DocumentProtocol(com.yahoo.document.DocumentTypeManager docMan)
-
DocumentProtocol
public DocumentProtocol(com.yahoo.document.DocumentTypeManager docMan, java.lang.String configId)
-
DocumentProtocol
public DocumentProtocol(com.yahoo.document.DocumentTypeManager docMan, java.lang.String configId, com.yahoo.documentapi.messagebus.loadtypes.LoadTypeSet set)
-
-
Method Detail
-
getPriority
public static DocumentProtocol.Priority getPriority(int val)
Get a priority enum instance by its value.- Parameters:
val
- The value of the priority to return.- Returns:
- The priority enum instance.
- Throws:
java.lang.IllegalArgumentException
- If priority value is unknown.
-
getPriorityByName
public static DocumentProtocol.Priority getPriorityByName(java.lang.String name)
Get priority enum instance by its name.- Parameters:
name
- Name of priority.- Returns:
- Priority enum instance, given that
name
is valid. - Throws:
java.lang.IllegalArgumentException
- If priority name is unknown.
-
putRoutingPolicyFactory
public DocumentProtocol putRoutingPolicyFactory(java.lang.String name, RoutingPolicyFactory factory)
Adds a new routable factory to this protocol. This method is thread-safe, and may be invoked on a protocol object that is already in use by a message bus instance. Notice that the name you supply for a factory is the case-sensitive name that will be referenced by routes.- Parameters:
name
- The name of the factory to add.factory
- The factory to add.- Returns:
- This, to allow chaining.
-
putRoutableFactory
public DocumentProtocol putRoutableFactory(int type, RoutableFactory factory, com.yahoo.component.VersionSpecification version)
Adds a new routable factory to this protocol. This method is thread-safe, and may be invoked on a protocol object that is already in use by a message bus instance. Notice that you must explicitly register a factory for each supported version. You can always bypass this by passing a default version specification object to this function, because that object will match any version.- Parameters:
type
- The routable type to assign a factory to.factory
- The factory to add.version
- The version for which this factory can be used.- Returns:
- This, to allow chaining.
-
putRoutableFactory
public DocumentProtocol putRoutableFactory(int type, RoutableFactory factory, java.util.List<com.yahoo.component.VersionSpecification> versions)
Convenience method to callputRoutableFactory(int, RoutableFactory, com.yahoo.component.VersionSpecification)
for multiple version specifications.- Parameters:
type
- The routable type to assign a factory to.factory
- The factory to add.versions
- The versions for which this factory can be used.- Returns:
- This, to allow chaining.
-
getErrorName
public static java.lang.String getErrorName(int code)
Returns a string representation of the given error code.- Parameters:
code
- The code whose string symbol to return.- Returns:
- The error string.
-
merge
public static void merge(com.yahoo.messagebus.routing.RoutingContext ctx)
This is a convenient entry to themerge(RoutingContext,Set)
method by way of a routing context object. The replies of all child contexts are merged and stored in the context.- Parameters:
ctx
- The context whose children to merge.
-
merge
public static void merge(com.yahoo.messagebus.routing.RoutingContext ctx, java.util.Set<java.lang.Integer> mask)
This method implements the common way to merge document replies for whatever routing policy. In case of an error in any of the replies, it will prepare an EmptyReply() and add all errors to it. If there are no errors, this method will use the first reply in the list and transfer whatever feed answers might exist in the replies to it.- Parameters:
ctx
- The context whose children to merge.mask
- The indexes of the children to skip.
-
merge
public static com.yahoo.messagebus.Reply merge(java.util.List<com.yahoo.messagebus.Reply> replies)
This method implements the common way to merge document replies for whatever routing policy. In case of an error in any of the replies, it will prepare an EmptyReply() and add all errors to it. If there are no errors, this method will use the first reply in the list and transfer whatever feed answers might exist in the replies to it.- Parameters:
replies
- The replies to merge.- Returns:
- The merged Reply.
-
hasOnlyErrorsOfType
public static boolean hasOnlyErrorsOfType(com.yahoo.messagebus.Reply reply, int errCode)
Returns true if the given reply has at least one error, and all errors are of the given type.- Parameters:
reply
- The reply to check for error.errCode
- The error code to check for.- Returns:
- Whether or not the reply has only the given error code.
-
getName
public java.lang.String getName()
- Specified by:
getName
in interfacecom.yahoo.messagebus.Protocol
-
createPolicy
public com.yahoo.messagebus.routing.RoutingPolicy createPolicy(java.lang.String name, java.lang.String param)
- Specified by:
createPolicy
in interfacecom.yahoo.messagebus.Protocol
-
encode
public byte[] encode(com.yahoo.component.Version version, com.yahoo.messagebus.Routable routable)
- Specified by:
encode
in interfacecom.yahoo.messagebus.Protocol
-
decode
public com.yahoo.messagebus.Routable decode(com.yahoo.component.Version version, byte[] data)
- Specified by:
decode
in interfacecom.yahoo.messagebus.Protocol
-
getRoutableTypes
public java.util.List<java.lang.Integer> getRoutableTypes(com.yahoo.component.Version version)
Returns a list of routable types that support the given version.- Parameters:
version
- The version to return types for.- Returns:
- The list of supported types.
-
getDocumentTypeManager
public final com.yahoo.document.DocumentTypeManager getDocumentTypeManager()
-
-