voldemort.server.rest
Class VoldemortRestRequestHandler

java.lang.Object
  extended by org.jboss.netty.channel.SimpleChannelUpstreamHandler
      extended by voldemort.server.rest.VoldemortRestRequestHandler
All Implemented Interfaces:
org.jboss.netty.channel.ChannelHandler, org.jboss.netty.channel.ChannelUpstreamHandler

public class VoldemortRestRequestHandler
extends org.jboss.netty.channel.SimpleChannelUpstreamHandler

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
org.jboss.netty.channel.ChannelHandler.Sharable
 
Field Summary
 org.jboss.netty.handler.codec.http.HttpRequest request
           
 
Constructor Summary
VoldemortRestRequestHandler()
           
VoldemortRestRequestHandler(StoreRepository storeRepository)
           
 
Method Summary
 void exceptionCaught(org.jboss.netty.channel.ChannelHandlerContext ctx, org.jboss.netty.channel.ExceptionEvent e)
           
protected  Store<ByteArray,byte[],byte[]> getStore(java.lang.String name, RequestRoutingType type)
          Gets the store for the store name and routing type.
 void messageReceived(org.jboss.netty.channel.ChannelHandlerContext ctx, org.jboss.netty.channel.MessageEvent messageEvent)
           
protected  int parseZoneId()
          Retrieve and validate the zone id value from the REST request.
 
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
 

Field Detail

request

public org.jboss.netty.handler.codec.http.HttpRequest request
Constructor Detail

VoldemortRestRequestHandler

public VoldemortRestRequestHandler()

VoldemortRestRequestHandler

public VoldemortRestRequestHandler(StoreRepository storeRepository)
Method Detail

messageReceived

public void messageReceived(org.jboss.netty.channel.ChannelHandlerContext ctx,
                            org.jboss.netty.channel.MessageEvent messageEvent)
                     throws java.lang.Exception
Overrides:
messageReceived in class org.jboss.netty.channel.SimpleChannelUpstreamHandler
Throws:
java.lang.Exception

exceptionCaught

public void exceptionCaught(org.jboss.netty.channel.ChannelHandlerContext ctx,
                            org.jboss.netty.channel.ExceptionEvent e)
                     throws java.lang.Exception
Overrides:
exceptionCaught in class org.jboss.netty.channel.SimpleChannelUpstreamHandler
Throws:
java.lang.Exception

getStore

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.

Parameters:
name - - store name
type - - routing type from the request
Returns:
Store for given store name and routing.

parseZoneId

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

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


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