voldemort.rest
Class RestRequestValidator

java.lang.Object
  extended by voldemort.rest.RestRequestValidator
Direct Known Subclasses:
RestDeleteRequestValidator, RestGetRequestValidator, RestPutRequestValidator

public abstract class RestRequestValidator
extends java.lang.Object

Super class to parse, validate REST requests


Field Summary
protected  org.apache.log4j.Logger logger
           
protected  org.jboss.netty.channel.MessageEvent messageEvent
           
protected  java.util.List<ByteArray> parsedKeys
           
protected  byte parsedOperationType
           
protected  long parsedRequestOriginTimeInMs
           
protected  RequestRoutingType parsedRoutingType
           
protected  long parsedTimeoutInMs
           
protected  byte[] parsedValue
           
protected  VectorClock parsedVectorClock
           
protected  org.jboss.netty.handler.codec.http.HttpRequest request
           
protected  CompositeVoldemortRequest<ByteArray,byte[]> requestObject
           
protected  java.lang.String storeName
           
 
Constructor Summary
RestRequestValidator(org.jboss.netty.handler.codec.http.HttpRequest request, org.jboss.netty.channel.MessageEvent messageEvent)
           
 
Method Summary
abstract  CompositeVoldemortRequest<ByteArray,byte[]> constructCompositeVoldemortRequestObject()
           
protected  void debugLog(java.lang.String operationType, java.lang.Long receivedTimeInMs)
          Prints a debug log message that details the time taken for the Http request to be parsed by the coordinator
 RequestRoutingType getParsedRoutingType()
           
 java.lang.String getStoreName()
           
protected  boolean hasKey()
          Retrieve and validate the key from the REST request.
protected  boolean hasTimeOutHeader()
          Retrieve and validate the timeout value from the REST request.
protected  boolean hasTimeStampHeader()
          Retrieve and validate the timestamp value from the REST request.
protected  boolean hasVectorClock(boolean isVectorClockOptional)
          Retrieve and validate vector clock value from the REST request.
protected  boolean isStoreValid()
          Retrieve and validate store name from the REST request.
protected  java.lang.String keysHexString(java.util.List<ByteArray> keys)
           
protected  boolean parseAndValidateRequest()
          Validations common for all operations are done here
protected  void parseKeys(java.lang.String requestURI)
          Method to read a key (or keys) present in the HTTP request URI.
protected  void parseRoutingCodeHeader()
          Retrieve the routing type value from the REST request.
protected  java.lang.String parseStoreName(java.lang.String requestURI)
          Parses the store name HTTP request URI.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

requestObject

protected CompositeVoldemortRequest<ByteArray,byte[]> requestObject

storeName

protected java.lang.String storeName

parsedKeys

protected java.util.List<ByteArray> parsedKeys

parsedValue

protected byte[] parsedValue

parsedVectorClock

protected VectorClock parsedVectorClock

parsedTimeoutInMs

protected long parsedTimeoutInMs

parsedOperationType

protected byte parsedOperationType

parsedRequestOriginTimeInMs

protected long parsedRequestOriginTimeInMs

parsedRoutingType

protected RequestRoutingType parsedRoutingType

messageEvent

protected org.jboss.netty.channel.MessageEvent messageEvent

request

protected org.jboss.netty.handler.codec.http.HttpRequest request

logger

protected final org.apache.log4j.Logger logger
Constructor Detail

RestRequestValidator

public RestRequestValidator(org.jboss.netty.handler.codec.http.HttpRequest request,
                            org.jboss.netty.channel.MessageEvent messageEvent)
Method Detail

constructCompositeVoldemortRequestObject

public abstract CompositeVoldemortRequest<ByteArray,byte[]> constructCompositeVoldemortRequestObject()

parseAndValidateRequest

protected boolean parseAndValidateRequest()
Validations common for all operations are done here

Returns:
true if request is valid else false

hasTimeOutHeader

protected boolean hasTimeOutHeader()
Retrieve and validate the timeout value from the REST request. "X_VOLD_REQUEST_TIMEOUT_MS" is the timeout header.

Returns:
true if present, false if missing

parseRoutingCodeHeader

protected void parseRoutingCodeHeader()
Retrieve the routing type value from the REST request. "X_VOLD_ROUTING_TYPE_CODE" is the routing type header. By default, the routing code is set to NORMAL TODO REST-Server 1. Change the header name to a better name. 2. Assumes that integer is passed in the header


hasTimeStampHeader

protected boolean hasTimeStampHeader()
Retrieve and validate the timestamp value from the REST request. "X_VOLD_REQUEST_ORIGIN_TIME_MS" is timestamp header TODO REST-Server 1. Change Time stamp header to a better name.

Returns:
true if present, false if missing

hasVectorClock

protected boolean hasVectorClock(boolean isVectorClockOptional)
Retrieve and validate vector clock value from the REST request. "X_VOLD_VECTOR_CLOCK" is the vector clock header.

Returns:
true if present, false if missing

hasKey

protected boolean hasKey()
Retrieve and validate the key from the REST request.

Returns:
true if present, false if missing

parseKeys

protected void parseKeys(java.lang.String requestURI)
Method to read a key (or keys) present in the HTTP request URI. The URI must be of the format //[,,...]

Parameters:
requestURI - The URI of the HTTP request

isStoreValid

protected boolean isStoreValid()
Retrieve and validate store name from the REST request.

Returns:
true if valid, false otherwise

parseStoreName

protected java.lang.String parseStoreName(java.lang.String requestURI)
Parses the store name HTTP request URI. The URI must be of the format //[,,...]

Parameters:
requestURI -
Returns:
a String representing store name

getStoreName

public java.lang.String getStoreName()

getParsedRoutingType

public RequestRoutingType getParsedRoutingType()

debugLog

protected void debugLog(java.lang.String operationType,
                        java.lang.Long receivedTimeInMs)
Prints a debug log message that details the time taken for the Http request to be parsed by the coordinator

Parameters:
operationType -
receivedTimeInMs -

keysHexString

protected java.lang.String keysHexString(java.util.List<ByteArray> keys)


Jay Kreps, Roshan Sumbaly, Alex Feinberg, Bhupesh Bansal, Lei Gao, Chinmay Soman, Vinoth Chandar, Zhongjie Wu