Class RestServerRequestHandler

  extended by org.jboss.netty.channel.SimpleChannelUpstreamHandler
      extended by voldemort.rest.AbstractRestRequestHandler
          extended by voldemort.rest.server.RestServerRequestHandler
All Implemented Interfaces:
org.jboss.netty.channel.ChannelHandler, org.jboss.netty.channel.ChannelUpstreamHandler

public class RestServerRequestHandler
extends AbstractRestRequestHandler

Class to handle a REST request and send response back to the client

Nested Class Summary
Nested classes/interfaces inherited from interface org.jboss.netty.channel.ChannelHandler
Field Summary
Fields inherited from class voldemort.rest.AbstractRestRequestHandler
Constructor Summary
RestServerRequestHandler(StoreRepository storeRepository)
Method Summary
protected  Store<ByteArray,byte[],byte[]> getStore(java.lang.String name, RequestRoutingType type)
          Gets the store for the store name and routing type.
protected  int parseZoneId()
          Retrieve and validate the zone id value from the REST request.
protected  void registerRequest(RestRequestValidator requestValidator, org.jboss.netty.channel.ChannelHandlerContext ctx, org.jboss.netty.channel.MessageEvent messageEvent)
          Constructs a valid request and passes it on to the next handler.
Methods inherited from class voldemort.rest.AbstractRestRequestHandler
exceptionCaught, messageReceived
Methods inherited from class org.jboss.netty.channel.SimpleChannelUpstreamHandler
channelBound, channelClosed, channelConnected, channelDisconnected, channelInterestChanged, channelOpen, channelUnbound, childChannelClosed, childChannelOpen, handleUpstream, writeComplete
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public RestServerRequestHandler()


public RestServerRequestHandler(StoreRepository storeRepository)
Method Detail


protected Store<ByteArray,byte[],byte[]> getStore(java.lang.String name,
                                                  RequestRoutingType type)
Gets the store for the store name and routing type. At this point we already know that the routing type is valid . So we dont throw Voldemort Exception for unknown routing type.

name - - store name
type - - routing type from the request


protected int parseZoneId()
Retrieve and validate the zone id value from the REST request. "X-VOLD-Zone-Id" is the zone id header.

valid zone id or -1 if there is no/invalid zone id


protected void registerRequest(RestRequestValidator requestValidator,
                               org.jboss.netty.channel.ChannelHandlerContext ctx,
                               org.jboss.netty.channel.MessageEvent messageEvent)
Constructs a valid request and passes it on to the next handler. It also creates the 'Store' object corresponding to the store name specified in the REST request.

Specified by:
registerRequest in class AbstractRestRequestHandler
requestValidator - The Validator object used to construct the request object
ctx - Context of the Netty channel
messageEvent - Message Event used to write the response / exception

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