voldemort.server.rest
Class RestServerRequestValidator

java.lang.Object
  extended by voldemort.server.rest.RestServerRequestValidator
Direct Known Subclasses:
RestServerDeleteRequestValidator, RestServerGetRequestValidator, RestServerPutRequestValidator

public abstract class RestServerRequestValidator
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
           
protected  StoreRepository storeRepository
           
 
Constructor Summary
RestServerRequestValidator(org.jboss.netty.handler.codec.http.HttpRequest request, org.jboss.netty.channel.MessageEvent messageEvent, StoreRepository storeRepository)
           
 
Method Summary
abstract  CompositeVoldemortRequest<ByteArray,byte[]> constructCompositeVoldemortRequestObject()
           
 RequestRoutingType getParsedRoutingType()
           
 java.lang.String getStoreName()
           
protected  boolean hasKey()
          Retrieve and validate the key from the REST request.
protected  boolean hasRoutingCodeHeader()
          Retrieve and validate the routing type value 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()
          Retrieve and validate vector clock value from the REST request.
protected  boolean isStoreValid()
          Retrieve and validate store name from the REST request.
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  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

storeRepository

protected StoreRepository storeRepository

logger

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

RestServerRequestValidator

public RestServerRequestValidator(org.jboss.netty.handler.codec.http.HttpRequest request,
                                  org.jboss.netty.channel.MessageEvent messageEvent,
                                  StoreRepository storeRepository)
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

hasRoutingCodeHeader

protected boolean hasRoutingCodeHeader()
Retrieve and validate the routing type value from the REST request. "X_VOLD_ROUTING_TYPE_CODE" is the routing type header. TODO REST-Server 1. Change the header name to a better name. 2. Assumes that integer is passed in the header

Returns:
true if present, false if missing

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()
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()


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