Class DocumentProtocol
java.lang.Object
com.yahoo.documentapi.messagebus.protocol.DocumentProtocol
- All Implemented Interfaces:
com.yahoo.messagebus.Protocol
Implements the message bus protocol that is used by all components of Vespa.
- Author:
- Simon Thoresen Hult
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Defines the different priorities allowed for document api messages. -
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
static final int
Operation cut short and aborted.static final int
Bucket recently removed, such that operation cannot be performed.static final int
Bucket given in operation not found due to bucket database inconsistencies between storage and distributor nodes.static final int
Node too busy to process request (Typically full queues)static final int
We failed accessing the disk, which we think is a disk hardware problem.static final int
Operation cannot be performed because token already exist.static final int
Document in operation cannot be found.static final int
Request was not handled correctly.static final int
Parameters given in request is illegal.static final int
We failed in some way we didn't expect to fail.static final int
We failed during an IO operation, we dont think is a specific disk hardware problem.static final int
Used by policies to indicate an inappropriate message.static final int
Not enough free space on disk to perform operation.static final int
Node not ready to perform operation.static final int
Lost connection with the node we requested something from.static final int
Node have not implemented support for the given operation.static final int
Used for error policy when policy creation failed.static final int
Failed to process the given request.static final int
Node refuse to perform operation.static final int
Content node received a timestamp that is stale.static final int
The given node have gotten a critical error and have suspended itself.static final int
Test and set condition (selection) failed.static final int
Unique timestamp specified for new operation is already in use.static final int
Unknown request received.static final int
Request cannot be decoded.static final int
Wrong node to talk to in current state.static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final com.yahoo.text.Utf8String
The name of this protocol.static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
-
Constructor Summary
ConstructorDescriptionDocumentProtocol
(com.yahoo.document.DocumentTypeManager docMan) DocumentProtocol
(com.yahoo.document.DocumentTypeManager documentTypeManager, DocumentProtocolPoliciesConfig policiesConfig, com.yahoo.vespa.config.content.DistributionConfig distributionConfig) DocumentProtocol
(com.yahoo.document.DocumentTypeManager docMan, String configId) -
Method Summary
Modifier and TypeMethodDescriptioncom.yahoo.messagebus.routing.RoutingPolicy
createPolicy
(String name, 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) final com.yahoo.document.DocumentTypeManager
static String
getErrorName
(int code) Returns a string representation of the given error code.getName()
static DocumentProtocol.Priority
getPriority
(int val) Get a priority enum instance by its value.static DocumentProtocol.Priority
getPriorityByName
(String name) Get priority enum instance by its name.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
This method implements the common way to merge document replies for whatever routing policy.static com.yahoo.messagebus.Reply
This method implements the common way to merge document replies for whatever routing policy.putRoutableFactory
(int type, RoutableFactory factory, com.yahoo.component.VersionSpecification version) Adds a new routable factory to this protocol.putRoutableFactory
(int type, RoutableFactory factory, List<com.yahoo.component.VersionSpecification> versions) Convenience method to callputRoutableFactory(int, RoutableFactory, com.yahoo.component.VersionSpecification)
for multiple version specifications.putRoutingPolicyFactory
(String name, RoutingPolicyFactory factory) Adds a new routable factory to this protocol.
-
Field Details
-
NAME
public static final com.yahoo.text.Utf8String NAMEThe name of this protocol. -
DOCUMENT_MESSAGE
public static final int DOCUMENT_MESSAGE- See Also:
-
MESSAGE_GETDOCUMENT
public static final int MESSAGE_GETDOCUMENT- See Also:
-
MESSAGE_PUTDOCUMENT
public static final int MESSAGE_PUTDOCUMENT- See Also:
-
MESSAGE_REMOVEDOCUMENT
public static final int MESSAGE_REMOVEDOCUMENT- See Also:
-
MESSAGE_UPDATEDOCUMENT
public static final int MESSAGE_UPDATEDOCUMENT- See Also:
-
MESSAGE_CREATEVISITOR
public static final int MESSAGE_CREATEVISITOR- See Also:
-
MESSAGE_DESTROYVISITOR
public static final int MESSAGE_DESTROYVISITOR- See Also:
-
MESSAGE_VISITORINFO
public static final int MESSAGE_VISITORINFO- See Also:
-
MESSAGE_MAPVISITOR
public static final int MESSAGE_MAPVISITOR- See Also:
-
MESSAGE_GETBUCKETSTATE
public static final int MESSAGE_GETBUCKETSTATE- See Also:
-
MESSAGE_STATBUCKET
public static final int MESSAGE_STATBUCKET- See Also:
-
MESSAGE_GETBUCKETLIST
public static final int MESSAGE_GETBUCKETLIST- See Also:
-
MESSAGE_DOCUMENTLIST
public static final int MESSAGE_DOCUMENTLIST- See Also:
-
MESSAGE_EMPTYBUCKETS
public static final int MESSAGE_EMPTYBUCKETS- See Also:
-
MESSAGE_REMOVELOCATION
public static final int MESSAGE_REMOVELOCATION- See Also:
-
MESSAGE_QUERYRESULT
public static final int MESSAGE_QUERYRESULT- See Also:
-
DOCUMENT_REPLY
public static final int DOCUMENT_REPLY- See Also:
-
REPLY_GETDOCUMENT
public static final int REPLY_GETDOCUMENT- See Also:
-
REPLY_PUTDOCUMENT
public static final int REPLY_PUTDOCUMENT- See Also:
-
REPLY_REMOVEDOCUMENT
public static final int REPLY_REMOVEDOCUMENT- See Also:
-
REPLY_UPDATEDOCUMENT
public static final int REPLY_UPDATEDOCUMENT- See Also:
-
REPLY_CREATEVISITOR
public static final int REPLY_CREATEVISITOR- See Also:
-
REPLY_DESTROYVISITOR
public static final int REPLY_DESTROYVISITOR- See Also:
-
REPLY_VISITORINFO
public static final int REPLY_VISITORINFO- See Also:
-
REPLY_MAPVISITOR
public static final int REPLY_MAPVISITOR- See Also:
-
REPLY_GETBUCKETSTATE
public static final int REPLY_GETBUCKETSTATE- See Also:
-
REPLY_STATBUCKET
public static final int REPLY_STATBUCKET- See Also:
-
REPLY_GETBUCKETLIST
public static final int REPLY_GETBUCKETLIST- See Also:
-
REPLY_DOCUMENTLIST
public static final int REPLY_DOCUMENTLIST- See Also:
-
REPLY_EMPTYBUCKETS
public static final int REPLY_EMPTYBUCKETS- See Also:
-
REPLY_REMOVELOCATION
public static final int REPLY_REMOVELOCATION- See Also:
-
REPLY_QUERYRESULT
public static final int REPLY_QUERYRESULT- See Also:
-
REPLY_WRONGDISTRIBUTION
public static final int REPLY_WRONGDISTRIBUTION- See Also:
-
REPLY_DOCUMENTIGNORED
public static final int REPLY_DOCUMENTIGNORED- See Also:
-
ERROR_MESSAGE_IGNORED
public static final int ERROR_MESSAGE_IGNOREDUsed by policies to indicate an inappropriate message.- See Also:
-
ERROR_POLICY_FAILURE
public static final int ERROR_POLICY_FAILUREUsed for error policy when policy creation failed.- See Also:
-
ERROR_DOCUMENT_NOT_FOUND
public static final int ERROR_DOCUMENT_NOT_FOUNDDocument in operation cannot be found. (VDS Get and Remove)- See Also:
-
ERROR_DOCUMENT_EXISTS
public static final int ERROR_DOCUMENT_EXISTSOperation cannot be performed because token already exist. (Create bucket, create visitor)- See Also:
-
ERROR_NOT_IMPLEMENTED
public static final int ERROR_NOT_IMPLEMENTEDNode have not implemented support for the given operation.- See Also:
-
ERROR_ILLEGAL_PARAMETERS
public static final int ERROR_ILLEGAL_PARAMETERSParameters given in request is illegal.- See Also:
-
ERROR_UNKNOWN_COMMAND
public static final int ERROR_UNKNOWN_COMMANDUnknown request received. (New client requesting from old server)- See Also:
-
ERROR_UNPARSEABLE
public static final int ERROR_UNPARSEABLERequest cannot be decoded.- See Also:
-
ERROR_NO_SPACE
public static final int ERROR_NO_SPACENot enough free space on disk to perform operation.- See Also:
-
ERROR_IGNORED
public static final int ERROR_IGNOREDRequest was not handled correctly.- See Also:
-
ERROR_INTERNAL_FAILURE
public static final int ERROR_INTERNAL_FAILUREWe failed in some way we didn't expect to fail.- See Also:
-
ERROR_REJECTED
public static final int ERROR_REJECTEDNode refuse to perform operation. (Illegally formed message?)- See Also:
-
ERROR_TEST_AND_SET_CONDITION_FAILED
public static final int ERROR_TEST_AND_SET_CONDITION_FAILEDTest and set condition (selection) failed.- See Also:
-
ERROR_PROCESSING_FAILURE
public static final int ERROR_PROCESSING_FAILUREFailed to process the given request. (Used by docproc)- See Also:
-
ERROR_TIMESTAMP_EXIST
public static final int ERROR_TIMESTAMP_EXISTUnique timestamp specified for new operation is already in use.- See Also:
-
ERROR_NODE_NOT_READY
public static final int ERROR_NODE_NOT_READYNode not ready to perform operation. (Initializing VDS nodes)- See Also:
-
ERROR_WRONG_DISTRIBUTION
public static final int ERROR_WRONG_DISTRIBUTIONWrong node to talk to in current state. (VDS system state disagreement)- See Also:
-
ERROR_ABORTED
public static final int ERROR_ABORTEDOperation cut short and aborted. (Destroy visitor, node stopping)- See Also:
-
ERROR_BUSY
public static final int ERROR_BUSYNode too busy to process request (Typically full queues)- See Also:
-
ERROR_NOT_CONNECTED
public static final int ERROR_NOT_CONNECTEDLost connection with the node we requested something from.- See Also:
-
ERROR_DISK_FAILURE
public static final int ERROR_DISK_FAILUREWe failed accessing the disk, which we think is a disk hardware problem.- See Also:
-
ERROR_IO_FAILURE
public static final int ERROR_IO_FAILUREWe failed during an IO operation, we dont think is a specific disk hardware problem.- See Also:
-
ERROR_BUCKET_NOT_FOUND
public static final int ERROR_BUCKET_NOT_FOUNDBucket given in operation not found due to bucket database inconsistencies between storage and distributor nodes.- See Also:
-
ERROR_BUCKET_DELETED
public static final int ERROR_BUCKET_DELETEDBucket recently removed, such that operation cannot be performed. Differs from BUCKET_NOT_FOUND in that there is no db inconsistency.- See Also:
-
ERROR_STALE_TIMESTAMP
public static final int ERROR_STALE_TIMESTAMPContent node received a timestamp that is stale. Likely clock skew.- See Also:
-
ERROR_SUSPENDED
public static final int ERROR_SUSPENDEDThe given node have gotten a critical error and have suspended itself.- See Also:
-
-
Constructor Details
-
DocumentProtocol
public DocumentProtocol(com.yahoo.document.DocumentTypeManager docMan) -
DocumentProtocol
public DocumentProtocol(com.yahoo.document.DocumentTypeManager documentTypeManager, DocumentProtocolPoliciesConfig policiesConfig, com.yahoo.vespa.config.content.DistributionConfig distributionConfig) -
DocumentProtocol
-
-
Method Details
-
getPriority
Get a priority enum instance by its value.- Parameters:
val
- the value of the priority to return- Returns:
- the priority enum instance
- Throws:
IllegalArgumentException
- if the priority value is unknown
-
getPriorityByName
Get priority enum instance by its name.- Parameters:
name
- name of priority.- Returns:
- priority enum instance, given that
name
is valid - Throws:
IllegalArgumentException
- if priority name is unknown
-
putRoutingPolicyFactory
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 addfactory
- 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 tofactory
- the factory to addversion
- the version for which this factory can be used- Returns:
- this, to allow chaining
-
putRoutableFactory
public DocumentProtocol putRoutableFactory(int type, RoutableFactory factory, 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 tofactory
- the factory to addversions
- the versions for which this factory can be used- Returns:
- this, to allow chaining
-
getErrorName
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
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 mergemask
- the indexes of the children to skip
-
merge
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 errorerrCode
- the error code to check for- Returns:
- whether or not the reply has only the given error code
-
getName
- Specified by:
getName
in interfacecom.yahoo.messagebus.Protocol
-
createPolicy
- 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
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()
-