Class JRTServerConfigRequestV3

  • All Implemented Interfaces:
    GetConfigRequest, JRTConfigRequest, JRTServerConfigRequest

    public class JRTServerConfigRequestV3
    extends java.lang.Object
    implements JRTServerConfigRequest
    The V3 config protocol implemented on the server side. The V3 protocol uses 2 fields: * A metadata field containing json data describing config generation, md5 and compression info * A data field containing compressed or uncompressed json config payload The implementation of addOkResponse is optimized for doing as little copying of payload data as possible, ensuring that we get a lower memory footprint.
    Author:
    Ulf Lilleengen
    • Field Detail

      • log

        protected static final java.util.logging.Logger log
      • request

        protected final com.yahoo.jrt.Request request
    • Constructor Detail

      • JRTServerConfigRequestV3

        protected JRTServerConfigRequestV3​(com.yahoo.jrt.Request request)
    • Method Detail

      • createJsonGenerator

        protected static com.fasterxml.jackson.core.JsonGenerator createJsonGenerator​(java.io.ByteArrayOutputStream byteArrayOutputStream)
                                                                               throws java.io.IOException
        Throws:
        java.io.IOException
      • createResponseValue

        protected static com.yahoo.jrt.Value createResponseValue​(java.io.ByteArrayOutputStream byteArrayOutputStream)
      • setResponseField

        protected static void setResponseField​(com.fasterxml.jackson.core.JsonGenerator jsonGenerator,
                                               java.lang.String fieldName,
                                               java.lang.String value)
                                        throws java.io.IOException
        Throws:
        java.io.IOException
      • setResponseField

        protected static void setResponseField​(com.fasterxml.jackson.core.JsonGenerator jsonGenerator,
                                               java.lang.String fieldName,
                                               long value)
                                        throws java.io.IOException
        Throws:
        java.io.IOException
      • setResponseField

        protected static void setResponseField​(com.fasterxml.jackson.core.JsonGenerator jsonGenerator,
                                               java.lang.String fieldName,
                                               boolean value)
                                        throws java.io.IOException
        Throws:
        java.io.IOException
      • addOkResponse

        public void addOkResponse​(Payload payload,
                                  long generation,
                                  boolean applyOnRestart,
                                  PayloadChecksums payloadChecksums)
        Description copied from interface: JRTServerConfigRequest
        Signal that the request was handled and provide return values typically needed by a client.
        Specified by:
        addOkResponse in interface JRTServerConfigRequest
        Parameters:
        payload - The config payload that the client should receive.
        generation - The config generation of the given payload.
        applyOnRestart - true if this config should only be applied on the next restart, false if it should be applied right away
        payloadChecksums - checksums of the given payload.
      • getDefContent

        public DefContent getDefContent()
        Description copied from interface: GetConfigRequest
        The def file contents in the request, or empty array if not sent/not supported
        Specified by:
        getDefContent in interface GetConfigRequest
        Returns:
        the contents (payload) of the def schema
      • noCache

        public boolean noCache()
        Description copied from interface: GetConfigRequest
        Whether or not the config can be retrieved from or stored in a cache.
        Specified by:
        noCache in interface GetConfigRequest
        Returns:
        true if content should _not_ be cached, false if it should.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getClientHostName

        public java.lang.String getClientHostName()
        Description copied from interface: JRTConfigRequest
        Returns the host name of the client that is requesting config.
        Specified by:
        getClientHostName in interface JRTConfigRequest
        Returns:
        hostname of the client.
      • getRequestTrace

        public Trace getRequestTrace()
        Description copied from interface: JRTServerConfigRequest
        Get the request trace for this request. The trace can be used to trace config execution to provide useful debug info in production environments.
        Specified by:
        getRequestTrace in interface JRTServerConfigRequest
        Returns:
        a Trace instance.
      • getRequest

        public com.yahoo.jrt.Request getRequest()
        Description copied from interface: JRTConfigRequest
        Returns the JRT request object for this config request. TODO: This method leaks the internal jrt stuff :(
        Specified by:
        getRequest in interface JRTConfigRequest
        Returns:
        a Request object.
      • validateParameters

        public boolean validateParameters()
        Description copied from interface: JRTConfigRequest
        Performs request parameter validation of this config request. This method should be called before fetching any kind of config protocol-specific parameter.
        Specified by:
        validateParameters in interface JRTConfigRequest
        Returns:
        true if valid, false if not.
      • getRequestConfigChecksums

        public PayloadChecksums getRequestConfigChecksums()
        Description copied from interface: JRTConfigRequest
        Returns the generation of the requested config. If none has been given, 0 should be returned. Returns the checksum of the config request. Return an empty string if no response has been returned.
        Specified by:
        getRequestConfigChecksums in interface JRTConfigRequest
        Returns:
        a config checksum.
      • addErrorResponse

        public void addErrorResponse​(int errorCode,
                                     java.lang.String name)
        Description copied from interface: JRTServerConfigRequest
        Signal error when handling this request. The error should be reflected in the request state and propagated back to the client.
        Specified by:
        addErrorResponse in interface JRTServerConfigRequest
        Parameters:
        errorCode - error code, as described in ErrorCode.
        name - message to display for this error, typically printed by client.
      • addCommonReturnValues

        protected void addCommonReturnValues​(com.fasterxml.jackson.core.JsonGenerator jsonGenerator)
                                      throws java.io.IOException
        Throws:
        java.io.IOException
      • errorMessage

        public java.lang.String errorMessage()
        Description copied from interface: JRTConfigRequest
        Return the error message of this request, mostly corresponding to the ErrorCode.
        Specified by:
        errorMessage in interface JRTConfigRequest
        Returns:
        the error message.
      • getShortDescription

        public java.lang.String getShortDescription()
        Description copied from interface: JRTConfigRequest
        Returns a short hand description of this request.
        Specified by:
        getShortDescription in interface JRTConfigRequest
        Returns:
        a short description
      • getTimeout

        public long getTimeout()
        Description copied from interface: JRTConfigRequest
        Returns the server timeout of this request.
        Specified by:
        getTimeout in interface JRTConfigRequest
        Returns:
        the timeout given to the server