Package com.yahoo.vespa.config.protocol
Class JRTClientConfigRequestV3
- java.lang.Object
-
- com.yahoo.vespa.config.protocol.JRTClientConfigRequestV3
-
- All Implemented Interfaces:
JRTClientConfigRequest
,JRTConfigRequest
public class JRTClientConfigRequestV3 extends java.lang.Object implements JRTClientConfigRequest
Represents version 3 config request for config clients. Provides methods for inspecting request and response values. SeeJRTServerConfigRequestV3
for protocol details.- Author:
- Ulf Lilleengen
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.util.logging.Logger
log
protected com.yahoo.jrt.Request
request
protected com.yahoo.vespa.config.protocol.SlimeRequestData
requestData
-
Constructor Summary
Constructors Modifier Constructor Description protected
JRTClientConfigRequestV3(ConfigKey<?> key, java.lang.String hostname, DefContent defSchema, java.lang.String configMd5, long generation, long timeout, Trace trace, CompressionType compressionType, java.util.Optional<VespaVersion> vespaVersion)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
checkReturnTypes(com.yahoo.jrt.Request request)
static JRTClientConfigRequest
createFromRaw(RawConfig config, long serverTimeout, Trace trace, CompressionType compressionType, java.util.Optional<VespaVersion> vespaVersion)
static <T extends com.yahoo.config.ConfigInstance>
JRTClientConfigRequestcreateFromSub(JRTConfigSubscription<T> sub, Trace trace, CompressionType compressionType, java.util.Optional<VespaVersion> vespaVersion)
static JRTClientConfigRequest
createWithParams(ConfigKey<?> reqKey, DefContent defContent, java.lang.String hostname, java.lang.String configMd5, long generation, long serverTimeout, Trace trace, CompressionType compressionType, java.util.Optional<VespaVersion> vespaVersion)
protected static java.lang.String
encodeAsUtf8String(com.yahoo.slime.Slime data)
int
errorCode()
Get the error code of this requestjava.lang.String
errorMessage()
Return the error message of this request, mostly corresponding to theErrorCode
.java.lang.String
getClientHostName()
Get the host name of the client that is requesting config.ConfigKey<?>
getConfigKey()
Get the config key of the config request.DefContent
getDefContent()
Get config definition content.protected java.lang.String
getJRTMethodName()
java.lang.String
getNewConfigMd5()
Get the config md5 of the config returned by the server.long
getNewGeneration()
Get the generation of the newly provided config.Payload
getNewPayload()
Return the payload in the response given by the server.long
getProtocolVersion()
Get the config protocol versioncom.yahoo.jrt.Request
getRequest()
Get the JRT request object for this config request.java.lang.String
getRequestConfigMd5()
Get the config md5 of the config request.long
getRequestGeneration()
Get the generation of the requested config.protected com.yahoo.vespa.config.protocol.SlimeResponseData
getResponseData()
Trace
getResponseTrace()
Get theTrace
given in the response by the server.java.lang.String
getShortDescription()
Get a short hand description of this request.long
getTimeout()
Get the server timeout of this request.java.util.Optional<VespaVersion>
getVespaVersion()
Get the Vespa version of the client that initiated the requestboolean
hasUpdatedConfig()
Test whether or not the response contains an updated config or not.boolean
hasUpdatedGeneration()
Test whether ot not the returned config has an updated generation.boolean
isError()
Test whether or not the returned request is an error.protected java.lang.String
newConfMd5()
protected long
newGen()
JRTClientConfigRequest
nextRequest(long timeout)
Create a newJRTClientConfigRequest
based on this request based on the same request parameters, but having the timeout changed.boolean
responseIsInternalRedeploy()
Returns whether this config change is due to an internal change not an application package changejava.lang.String
toString()
boolean
validateParameters()
Perform request parameter validation of this config request.boolean
validateResponse()
Validate config response given by the server.
-
-
-
Constructor Detail
-
JRTClientConfigRequestV3
protected JRTClientConfigRequestV3(ConfigKey<?> key, java.lang.String hostname, DefContent defSchema, java.lang.String configMd5, long generation, long timeout, Trace trace, CompressionType compressionType, java.util.Optional<VespaVersion> vespaVersion)
-
-
Method Detail
-
encodeAsUtf8String
protected static java.lang.String encodeAsUtf8String(com.yahoo.slime.Slime data)
-
getJRTMethodName
protected java.lang.String getJRTMethodName()
-
checkReturnTypes
protected boolean checkReturnTypes(com.yahoo.jrt.Request request)
-
getNewPayload
public Payload getNewPayload()
Description copied from interface:JRTClientConfigRequest
Return the payload in the response given by the server. The payload will be empty if no response was given.- Specified by:
getNewPayload
in interfaceJRTClientConfigRequest
- Returns:
- the config payload.
-
getProtocolVersion
public long getProtocolVersion()
Description copied from interface:JRTConfigRequest
Get the config protocol version- Specified by:
getProtocolVersion
in interfaceJRTConfigRequest
- Returns:
- a protocol version number.
-
nextRequest
public JRTClientConfigRequest nextRequest(long timeout)
Description copied from interface:JRTClientConfigRequest
Create a newJRTClientConfigRequest
based on this request based on the same request parameters, but having the timeout changed.- Specified by:
nextRequest
in interfaceJRTClientConfigRequest
- Parameters:
timeout
- server timeout of the new request.- Returns:
- a new
JRTClientConfigRequest
instance.
-
createFromSub
public static <T extends com.yahoo.config.ConfigInstance> JRTClientConfigRequest createFromSub(JRTConfigSubscription<T> sub, Trace trace, CompressionType compressionType, java.util.Optional<VespaVersion> vespaVersion)
-
createFromRaw
public static JRTClientConfigRequest createFromRaw(RawConfig config, long serverTimeout, Trace trace, CompressionType compressionType, java.util.Optional<VespaVersion> vespaVersion)
-
createWithParams
public static JRTClientConfigRequest createWithParams(ConfigKey<?> reqKey, DefContent defContent, java.lang.String hostname, java.lang.String configMd5, long generation, long serverTimeout, Trace trace, CompressionType compressionType, java.util.Optional<VespaVersion> vespaVersion)
-
getVespaVersion
public java.util.Optional<VespaVersion> getVespaVersion()
Description copied from interface:JRTConfigRequest
Get the Vespa version of the client that initiated the request- Specified by:
getVespaVersion
in interfaceJRTConfigRequest
- Returns:
- Vespa version of the client
-
getConfigKey
public ConfigKey<?> getConfigKey()
Description copied from interface:JRTConfigRequest
Get the config key of the config request.- Specified by:
getConfigKey
in interfaceJRTConfigRequest
- Returns:
- a
ConfigKey
.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getClientHostName
public java.lang.String getClientHostName()
Description copied from interface:JRTConfigRequest
Get the host name of the client that is requesting config.- Specified by:
getClientHostName
in interfaceJRTConfigRequest
- Returns:
- hostname of the client.
-
getRequest
public com.yahoo.jrt.Request getRequest()
Description copied from interface:JRTConfigRequest
Get the JRT request object for this config request. TODO: This method leaks the internal jrt stuff :(- Specified by:
getRequest
in interfaceJRTConfigRequest
- Returns:
- a
Request
object.
-
errorCode
public int errorCode()
Description copied from interface:JRTConfigRequest
Get the error code of this request- Specified by:
errorCode
in interfaceJRTConfigRequest
- Returns:
- the error code as defined in
ErrorCode
.
-
errorMessage
public java.lang.String errorMessage()
Description copied from interface:JRTConfigRequest
Return the error message of this request, mostly corresponding to theErrorCode
.- Specified by:
errorMessage
in interfaceJRTConfigRequest
- Returns:
- the error message.
-
getShortDescription
public java.lang.String getShortDescription()
Description copied from interface:JRTConfigRequest
Get a short hand description of this request.- Specified by:
getShortDescription
in interfaceJRTConfigRequest
- Returns:
- a short description
-
hasUpdatedGeneration
public boolean hasUpdatedGeneration()
Description copied from interface:JRTClientConfigRequest
Test whether ot not the returned config has an updated generation. This should return false if no response have been given.- Specified by:
hasUpdatedGeneration
in interfaceJRTClientConfigRequest
- Returns:
- true if generation is updated, false if not.
-
getTimeout
public long getTimeout()
Description copied from interface:JRTConfigRequest
Get the server timeout of this request.- Specified by:
getTimeout
in interfaceJRTConfigRequest
- Returns:
- the timeout given to the server
-
newConfMd5
protected java.lang.String newConfMd5()
-
newGen
protected long newGen()
-
getDefContent
public DefContent getDefContent()
Description copied from interface:JRTClientConfigRequest
Get config definition content.- Specified by:
getDefContent
in interfaceJRTClientConfigRequest
- Returns:
- def as lines.
-
isError
public boolean isError()
Description copied from interface:JRTClientConfigRequest
Test whether or not the returned request is an error.- Specified by:
isError
in interfaceJRTClientConfigRequest
- Returns:
- true if error, false if not.
-
hasUpdatedConfig
public boolean hasUpdatedConfig()
Description copied from interface:JRTClientConfigRequest
Test whether or not the response contains an updated config or not. False if no response has been returned.- Specified by:
hasUpdatedConfig
in interfaceJRTClientConfigRequest
- Returns:
- true if config is updated, false if not.
-
getResponseTrace
public Trace getResponseTrace()
Description copied from interface:JRTClientConfigRequest
Get theTrace
given in the response by the server. TheTrace
can be used to add further tracing and later printed to provide useful debug info.- Specified by:
getResponseTrace
in interfaceJRTClientConfigRequest
- Returns:
- a
Trace
.
-
getRequestConfigMd5
public java.lang.String getRequestConfigMd5()
Description copied from interface:JRTConfigRequest
Get the config md5 of the config request. Return an empty string if no response has been returned.- Specified by:
getRequestConfigMd5
in interfaceJRTConfigRequest
- Returns:
- a config md5.
-
validateResponse
public boolean validateResponse()
Description copied from interface:JRTClientConfigRequest
Validate config response given by the server. If none is given, or an error occurred, this should return false.- Specified by:
validateResponse
in interfaceJRTClientConfigRequest
- Returns:
- true if valid response, false if not.
-
validateParameters
public boolean validateParameters()
Description copied from interface:JRTConfigRequest
Perform 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 interfaceJRTConfigRequest
- Returns:
- true if valid, false if not.
-
getNewConfigMd5
public java.lang.String getNewConfigMd5()
Description copied from interface:JRTClientConfigRequest
Get the config md5 of the config returned by the server. Return an empty string if no response has been returned.- Specified by:
getNewConfigMd5
in interfaceJRTClientConfigRequest
- Returns:
- a config md5.
-
getNewGeneration
public long getNewGeneration()
Description copied from interface:JRTClientConfigRequest
Get the generation of the newly provided config. If none has been given, 0 should be returned.- Specified by:
getNewGeneration
in interfaceJRTClientConfigRequest
- Returns:
- the new generation.
-
responseIsInternalRedeploy
public boolean responseIsInternalRedeploy()
Description copied from interface:JRTClientConfigRequest
Returns whether this config change is due to an internal change not an application package change- Specified by:
responseIsInternalRedeploy
in interfaceJRTClientConfigRequest
-
getRequestGeneration
public long getRequestGeneration()
Description copied from interface:JRTConfigRequest
Get the generation of the requested config. If none has been given, 0 should be returned.- Specified by:
getRequestGeneration
in interfaceJRTConfigRequest
- Returns:
- the generation in the request.
-
getResponseData
protected com.yahoo.vespa.config.protocol.SlimeResponseData getResponseData()
-
-