Class 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 Detail

      • NAME

        public static final com.yahoo.text.Utf8String NAME
        The name of this protocol.
      • MESSAGE_DOCUMENTSUMMARY

        public static final int MESSAGE_DOCUMENTSUMMARY
        See Also:
        Constant Field Values
      • REPLY_WRONGDISTRIBUTION

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

        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,
                                String configId)
      • DocumentProtocol

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

        public DocumentProtocol​(com.yahoo.document.DocumentTypeManager docMan,
                                String configId,
                                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:
        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
      • 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()