Class DocumentProtocol

java.lang.Object
com.yahoo.documentapi.messagebus.protocol.DocumentProtocol
All Implemented Interfaces:
com.yahoo.messagebus.Protocol

public class DocumentProtocol extends Object implements com.yahoo.messagebus.Protocol
Implements the message bus protocol that is used by all components of Vespa.
Author:
Simon Thoresen Hult
  • Field Details

    • NAME

      public static final com.yahoo.text.Utf8String NAME
      The 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_SEARCHRESULT

      public static final int MESSAGE_SEARCHRESULT
      See Also:
    • MESSAGE_DOCUMENTSUMMARY

      public static final int MESSAGE_DOCUMENTSUMMARY
      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_SEARCHRESULT

      public static final int REPLY_SEARCHRESULT
      See Also:
    • REPLY_DOCUMENTSUMMARY

      public static final int REPLY_DOCUMENTSUMMARY
      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_IGNORED
      Used by policies to indicate an inappropriate message.
      See Also:
    • ERROR_POLICY_FAILURE

      public static final int ERROR_POLICY_FAILURE
      Used for error policy when policy creation failed.
      See Also:
    • ERROR_DOCUMENT_NOT_FOUND

      public static final int ERROR_DOCUMENT_NOT_FOUND
      Document in operation cannot be found. (VDS Get and Remove)
      See Also:
    • ERROR_DOCUMENT_EXISTS

      public static final int ERROR_DOCUMENT_EXISTS
      Operation cannot be performed because token already exist. (Create bucket, create visitor)
      See Also:
    • ERROR_NOT_IMPLEMENTED

      public static final int ERROR_NOT_IMPLEMENTED
      Node have not implemented support for the given operation.
      See Also:
    • ERROR_ILLEGAL_PARAMETERS

      public static final int ERROR_ILLEGAL_PARAMETERS
      Parameters given in request is illegal.
      See Also:
    • ERROR_UNKNOWN_COMMAND

      public static final int ERROR_UNKNOWN_COMMAND
      Unknown request received. (New client requesting from old server)
      See Also:
    • ERROR_UNPARSEABLE

      public static final int ERROR_UNPARSEABLE
      Request cannot be decoded.
      See Also:
    • ERROR_NO_SPACE

      public static final int ERROR_NO_SPACE
      Not enough free space on disk to perform operation.
      See Also:
    • ERROR_IGNORED

      public static final int ERROR_IGNORED
      Request was not handled correctly.
      See Also:
    • ERROR_INTERNAL_FAILURE

      public static final int ERROR_INTERNAL_FAILURE
      We failed in some way we didn't expect to fail.
      See Also:
    • ERROR_REJECTED

      public static final int ERROR_REJECTED
      Node refuse to perform operation. (Illegally formed message?)
      See Also:
    • ERROR_TEST_AND_SET_CONDITION_FAILED

      public static final int ERROR_TEST_AND_SET_CONDITION_FAILED
      Test and set condition (selection) failed.
      See Also:
    • ERROR_PROCESSING_FAILURE

      public static final int ERROR_PROCESSING_FAILURE
      Failed to process the given request. (Used by docproc)
      See Also:
    • ERROR_TIMESTAMP_EXIST

      public static final int ERROR_TIMESTAMP_EXIST
      Unique timestamp specified for new operation is already in use.
      See Also:
    • ERROR_NODE_NOT_READY

      public static final int ERROR_NODE_NOT_READY
      Node not ready to perform operation. (Initializing VDS nodes)
      See Also:
    • ERROR_WRONG_DISTRIBUTION

      public static final int ERROR_WRONG_DISTRIBUTION
      Wrong node to talk to in current state. (VDS system state disagreement)
      See Also:
    • ERROR_ABORTED

      public static final int ERROR_ABORTED
      Operation cut short and aborted. (Destroy visitor, node stopping)
      See Also:
    • ERROR_BUSY

      public static final int ERROR_BUSY
      Node too busy to process request (Typically full queues)
      See Also:
    • ERROR_NOT_CONNECTED

      public static final int ERROR_NOT_CONNECTED
      Lost connection with the node we requested something from.
      See Also:
    • 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:
    • 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:
    • 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:
    • 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:
    • ERROR_STALE_TIMESTAMP

      public static final int ERROR_STALE_TIMESTAMP
      Storage node received a timestamp that is stale. Likely clock skew.
      See Also:
    • ERROR_SUSPENDED

      public static final int ERROR_SUSPENDED
      The 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 docMan, String configId)
    • DocumentProtocol

      public DocumentProtocol(com.yahoo.document.DocumentTypeManager documentTypeManager, DocumentProtocolPoliciesConfig policiesConfig, com.yahoo.vespa.config.content.DistributionConfig distributionConfig)
    • DocumentProtocol

      @Deprecated(forRemoval=true) public DocumentProtocol(com.yahoo.document.DocumentTypeManager documentTypeManager, LoadTypeSet loadTypes, DocumentProtocolPoliciesConfig policiesConfig, com.yahoo.vespa.config.content.DistributionConfig distributionConfig)
      Deprecated, for removal: This API element is subject to removal in a future version.
      load types are deprecated. Use constructor without LoadTypeSet instead.
    • DocumentProtocol

      @Deprecated(forRemoval=true) public DocumentProtocol(com.yahoo.document.DocumentTypeManager docMan, String configId, LoadTypeSet set)
      Deprecated, for removal: This API element is subject to removal in a future version.
      load types are deprecated. Use constructor without LoadTypeSet instead.
  • Method Details

    • 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:
      IllegalArgumentException - if the priority value is unknown
    • getPriorityByName

      public static DocumentProtocol.Priority getPriorityByName(String name)
      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

      public DocumentProtocol putRoutingPolicyFactory(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, List<com.yahoo.component.VersionSpecification> versions)
      Convenience method to call putRoutableFactory(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 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 the merge(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, Set<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(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 String getName()
      Specified by:
      getName in interface com.yahoo.messagebus.Protocol
    • createPolicy

      public com.yahoo.messagebus.routing.RoutingPolicy createPolicy(String name, String param)
      Specified by:
      createPolicy in interface com.yahoo.messagebus.Protocol
    • encode

      public byte[] encode(com.yahoo.component.Version version, com.yahoo.messagebus.Routable routable)
      Specified by:
      encode in interface com.yahoo.messagebus.Protocol
    • decode

      public com.yahoo.messagebus.Routable decode(com.yahoo.component.Version version, byte[] data)
      Specified by:
      decode in interface com.yahoo.messagebus.Protocol
    • getRoutableTypes

      public List<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()