Package com.yahoo.vespa.config.protocol
Class JRTServerConfigRequestV3
java.lang.Object
com.yahoo.vespa.config.protocol.JRTServerConfigRequestV3
- All Implemented Interfaces:
GetConfigRequest,JRTConfigRequest,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 Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddCommonReturnValues(com.fasterxml.jackson.core.JsonGenerator jsonGenerator) voidaddErrorResponse(int errorCode, String name) Signal error when handling this request.voidaddOkResponse(Payload payload, long generation, boolean applyOnRestart, PayloadChecksums checksums) Signal that the request was handled and provide return values typically needed by a client.booleanReturns the payload checksums from the config request.static JRTServerConfigRequestV3createFromRequest(com.yahoo.jrt.Request req) protected static com.fasterxml.jackson.core.JsonGeneratorcreateJsonGenerator(ByteArrayOutputStream byteArrayOutputStream) protected static com.yahoo.jrt.ValuecreateResponseValue(ByteArrayOutputStream byteArrayOutputStream) intReturns the error code of this requestReturn the error message of this request, mostly corresponding to theErrorCode.Returns the host name of the client that is requesting config.protected CompressionTypeConfigKey<?>Returns the config key of the config request.The def file contents in the request, or empty array if not sent/not supportedlongReturns the config protocol versioncom.yahoo.jrt.RequestReturns the JRT request object for this config request.Returns the generation of the requested config.Returns the md5 of the config definition in the request.longGet the current config generation of the client config.Get the request trace for this request.Returns a short hand description of this request.longReturns the server timeout of this request.Returns the Vespa version of the client that initiated the requestbooleanCheck whether or not this request is delayed.booleannoCache()Whether or not the config can be retrieved from or stored in a cache.payloadFromResponse(ConfigResponse response) Extract the appropriate payload for this request type for a given config response.voidsetDelayedResponse(boolean delayedResponse) Notify this request that its delayed due to no new config being available at this point.protected static voidsetResponseField(com.fasterxml.jackson.core.JsonGenerator jsonGenerator, String fieldName, boolean value) protected static voidsetResponseField(com.fasterxml.jackson.core.JsonGenerator jsonGenerator, String fieldName, long value) protected static voidsetResponseField(com.fasterxml.jackson.core.JsonGenerator jsonGenerator, String fieldName, String value) toString()booleanPerforms request parameter validation of this config request.
-
Field Details
-
log
-
request
protected final com.yahoo.jrt.Request request
-
-
Constructor Details
-
JRTServerConfigRequestV3
protected JRTServerConfigRequestV3(com.yahoo.jrt.Request request)
-
-
Method Details
-
createJsonGenerator
protected static com.fasterxml.jackson.core.JsonGenerator createJsonGenerator(ByteArrayOutputStream byteArrayOutputStream) throws IOException - Throws:
IOException
-
createResponseValue
protected static com.yahoo.jrt.Value createResponseValue(ByteArrayOutputStream byteArrayOutputStream) -
setResponseField
protected static void setResponseField(com.fasterxml.jackson.core.JsonGenerator jsonGenerator, String fieldName, String value) throws IOException - Throws:
IOException
-
setResponseField
protected static void setResponseField(com.fasterxml.jackson.core.JsonGenerator jsonGenerator, String fieldName, long value) throws IOException - Throws:
IOException
-
setResponseField
protected static void setResponseField(com.fasterxml.jackson.core.JsonGenerator jsonGenerator, String fieldName, boolean value) throws IOException - Throws:
IOException
-
addOkResponse
public void addOkResponse(Payload payload, long generation, boolean applyOnRestart, PayloadChecksums checksums) Description copied from interface:JRTServerConfigRequestSignal that the request was handled and provide return values typically needed by a client.- Specified by:
addOkResponsein interfaceJRTServerConfigRequest- 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 awaychecksums- checksums of the given payload.
-
getProtocolVersion
public long getProtocolVersion()Description copied from interface:JRTConfigRequestReturns the config protocol version- Specified by:
getProtocolVersionin interfaceJRTConfigRequest- Returns:
- a protocol version number.
-
applyOnRestart
public boolean applyOnRestart()- Specified by:
applyOnRestartin interfaceJRTServerConfigRequest
-
createFromRequest
-
getConfigKey
Description copied from interface:JRTConfigRequestReturns the config key of the config request.- Specified by:
getConfigKeyin interfaceGetConfigRequest- Specified by:
getConfigKeyin interfaceJRTConfigRequest- Returns:
- a
ConfigKey.
-
getDefContent
Description copied from interface:GetConfigRequestThe def file contents in the request, or empty array if not sent/not supported- Specified by:
getDefContentin interfaceGetConfigRequest- Returns:
- the contents (payload) of the def schema
-
noCache
public boolean noCache()Description copied from interface:GetConfigRequestWhether or not the config can be retrieved from or stored in a cache.- Specified by:
noCachein interfaceGetConfigRequest- Returns:
- true if content should _not_ be cached, false if it should.
-
toString
-
payloadFromResponse
Description copied from interface:JRTServerConfigRequestExtract the appropriate payload for this request type for a given config response.- Specified by:
payloadFromResponsein interfaceJRTServerConfigRequest- Parameters:
response-ConfigResponseto get payload from.- Returns:
- A
Payloadthat satisfies this request format.
-
getClientHostName
Description copied from interface:JRTConfigRequestReturns the host name of the client that is requesting config.- Specified by:
getClientHostNamein interfaceJRTConfigRequest- Returns:
- hostname of the client.
-
getRequestTrace
Description copied from interface:JRTServerConfigRequestGet 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:
getRequestTracein interfaceJRTServerConfigRequest- Returns:
- a
Traceinstance.
-
getRequest
public com.yahoo.jrt.Request getRequest()Description copied from interface:JRTConfigRequestReturns the JRT request object for this config request. TODO: This method leaks the internal jrt stuff :(- Specified by:
getRequestin interfaceJRTConfigRequest- Returns:
- a
Requestobject.
-
validateParameters
public boolean validateParameters()Description copied from interface:JRTConfigRequestPerforms request parameter validation of this config request. This method should be called before fetching any kind of config protocol-specific parameter.- Specified by:
validateParametersin interfaceJRTConfigRequest- Returns:
- true if valid, false if not.
-
getRequestDefMd5
Description copied from interface:JRTServerConfigRequestReturns the md5 of the config definition in the request.- Specified by:
getRequestDefMd5in interfaceGetConfigRequest- Specified by:
getRequestDefMd5in interfaceJRTConfigRequest- Specified by:
getRequestDefMd5in interfaceJRTServerConfigRequest- Returns:
- an md5 of config definition in request.
-
getRequestConfigChecksums
Description copied from interface:JRTConfigRequestReturns 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:
getRequestConfigChecksumsin interfaceJRTConfigRequest- Returns:
- a config checksum.
-
setDelayedResponse
public void setDelayedResponse(boolean delayedResponse) Description copied from interface:JRTServerConfigRequestNotify this request that its delayed due to no new config being available at this point. The value provided in this function should be returned when callingJRTServerConfigRequest.isDelayedResponse().- Specified by:
setDelayedResponsein interfaceJRTServerConfigRequest- Parameters:
delayedResponse- true if response is delayed, false if not.
-
addErrorResponse
Description copied from interface:JRTServerConfigRequestSignal error when handling this request. The error should be reflected in the request state and propagated back to the client.- Specified by:
addErrorResponsein interfaceJRTServerConfigRequest- Parameters:
errorCode- error code, as described inErrorCode.name- message to display for this error, typically printed by client.
-
addCommonReturnValues
protected void addCommonReturnValues(com.fasterxml.jackson.core.JsonGenerator jsonGenerator) throws IOException - Throws:
IOException
-
getRequestGeneration
public long getRequestGeneration()Description copied from interface:JRTServerConfigRequestGet the current config generation of the client config.- Specified by:
getRequestGenerationin interfaceJRTConfigRequest- Specified by:
getRequestGenerationin interfaceJRTServerConfigRequest- Returns:
- the current config generation.
-
isDelayedResponse
public boolean isDelayedResponse()Description copied from interface:JRTServerConfigRequestCheck whether or not this request is delayed.- Specified by:
isDelayedResponsein interfaceJRTServerConfigRequest- Returns:
- true if delayed, false if not.
-
errorCode
public int errorCode()Description copied from interface:JRTConfigRequestReturns the error code of this request- Specified by:
errorCodein interfaceJRTConfigRequest- Returns:
- the error code as defined in
ErrorCode.
-
errorMessage
Description copied from interface:JRTConfigRequestReturn the error message of this request, mostly corresponding to theErrorCode.- Specified by:
errorMessagein interfaceJRTConfigRequest- Returns:
- the error message.
-
getShortDescription
Description copied from interface:JRTConfigRequestReturns a short hand description of this request.- Specified by:
getShortDescriptionin interfaceJRTConfigRequest- Returns:
- a short description
-
getCompressionType
-
getTimeout
public long getTimeout()Description copied from interface:JRTConfigRequestReturns the server timeout of this request.- Specified by:
getTimeoutin interfaceJRTConfigRequest- Returns:
- the timeout given to the server
-
getVespaVersion
Description copied from interface:JRTConfigRequestReturns the Vespa version of the client that initiated the request- Specified by:
getVespaVersionin interfaceGetConfigRequest- Specified by:
getVespaVersionin interfaceJRTConfigRequest- Returns:
- Vespa version of the client
-
configPayloadChecksums
Description copied from interface:JRTServerConfigRequestReturns the payload checksums from the config request.- Specified by:
configPayloadChecksumsin interfaceGetConfigRequest- Specified by:
configPayloadChecksumsin interfaceJRTServerConfigRequest- Returns:
- the payload checksumss from request.
-