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 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 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, String hostname, DefContent defSchema, PayloadChecksums payloadChecksums, long generation, long timeout, Trace trace, CompressionType compressionType, 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, Optional<VespaVersion> vespaVersion)
static <T extends com.yahoo.config.ConfigInstance>
JRTClientConfigRequestcreateFromSub(JRTConfigSubscription<T> sub, Trace trace, CompressionType compressionType, Optional<VespaVersion> vespaVersion)
static JRTClientConfigRequest
createWithParams(ConfigKey<?> reqKey, DefContent defContent, String hostname, PayloadChecksums payloadChecksums, long generation, long serverTimeout, Trace trace, CompressionType compressionType, Optional<VespaVersion> vespaVersion)
protected static String
encodeAsUtf8String(com.yahoo.slime.Slime data)
int
errorCode()
Returns the error code of this requestString
errorMessage()
Return the error message of this request, mostly corresponding to theErrorCode
.String
getClientHostName()
Returns the host name of the client that is requesting config.ConfigKey<?>
getConfigKey()
Returns the config key of the config request.DefContent
getDefContent()
Get config definition content.protected String
getJRTMethodName()
PayloadChecksums
getNewChecksums()
Gets the config checksums 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()
Returns the config protocol versioncom.yahoo.jrt.Request
getRequest()
Returns the JRT request object for this config request.PayloadChecksums
getRequestConfigChecksums()
Returns the generation of the requested config.String
getRequestDefMd5()
Returns the md5 of the config definition in the request.long
getRequestGeneration()
Returns 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.String
getShortDescription()
Returns a short hand description of this request.long
getTimeout()
Returns the server timeout of this request.Optional<VespaVersion>
getVespaVersion()
Returns 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 PayloadChecksums
newConfigChecksums()
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
responseIsApplyOnRestart()
Returns true if this config should only be applied at the last restart, false if it should be applied immediatelyString
toString()
boolean
validateParameters()
Performs request parameter validation of this config request.boolean
validateResponse()
Validate config response given by the server.
-
-
-
Field Detail
-
log
protected static final Logger log
-
requestData
protected final com.yahoo.vespa.config.protocol.SlimeRequestData requestData
-
request
protected final com.yahoo.jrt.Request request
-
-
Constructor Detail
-
JRTClientConfigRequestV3
protected JRTClientConfigRequestV3(ConfigKey<?> key, String hostname, DefContent defSchema, PayloadChecksums payloadChecksums, long generation, long timeout, Trace trace, CompressionType compressionType, Optional<VespaVersion> vespaVersion)
-
-
Method Detail
-
encodeAsUtf8String
protected static String encodeAsUtf8String(com.yahoo.slime.Slime data)
-
getJRTMethodName
protected 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
Returns 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, Optional<VespaVersion> vespaVersion)
-
createFromRaw
public static JRTClientConfigRequest createFromRaw(RawConfig config, long serverTimeout, Trace trace, CompressionType compressionType, Optional<VespaVersion> vespaVersion)
-
createWithParams
public static JRTClientConfigRequest createWithParams(ConfigKey<?> reqKey, DefContent defContent, String hostname, PayloadChecksums payloadChecksums, long generation, long serverTimeout, Trace trace, CompressionType compressionType, Optional<VespaVersion> vespaVersion)
-
getVespaVersion
public Optional<VespaVersion> getVespaVersion()
Description copied from interface:JRTConfigRequest
Returns 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
Returns the config key of the config request.- Specified by:
getConfigKey
in interfaceJRTConfigRequest
- Returns:
- a
ConfigKey
.
-
getClientHostName
public String getClientHostName()
Description copied from interface:JRTConfigRequest
Returns 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
Returns 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
Returns the error code of this request- Specified by:
errorCode
in interfaceJRTConfigRequest
- Returns:
- the error code as defined in
ErrorCode
.
-
errorMessage
public 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 String getShortDescription()
Description copied from interface:JRTConfigRequest
Returns 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
Returns the server timeout of this request.- Specified by:
getTimeout
in interfaceJRTConfigRequest
- Returns:
- the timeout given to the server
-
newConfigChecksums
protected PayloadChecksums newConfigChecksums()
-
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
.
-
getRequestDefMd5
public String getRequestDefMd5()
Description copied from interface:JRTConfigRequest
Returns the md5 of the config definition in the request.- Specified by:
getRequestDefMd5
in interfaceJRTConfigRequest
- Returns:
- an md5 of config definition in request.
-
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 interfaceJRTConfigRequest
- Returns:
- a config checksum.
-
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
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 interfaceJRTConfigRequest
- Returns:
- true if valid, false if not.
-
getNewChecksums
public PayloadChecksums getNewChecksums()
Description copied from interface:JRTClientConfigRequest
Gets the config checksums of the config returned by the server. Returns an empty string if no response has been returned.- Specified by:
getNewChecksums
in interfaceJRTClientConfigRequest
- Returns:
- a config checksum.
-
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.
-
responseIsApplyOnRestart
public boolean responseIsApplyOnRestart()
Description copied from interface:JRTClientConfigRequest
Returns true if this config should only be applied at the last restart, false if it should be applied immediately- Specified by:
responseIsApplyOnRestart
in interfaceJRTClientConfigRequest
-
getRequestGeneration
public long getRequestGeneration()
Description copied from interface:JRTConfigRequest
Returns 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()
-
-