bamboo.dht
Class GatewayClient

java.lang.Object
  extended by bamboo.util.StandardStage
      extended by bamboo.dht.GatewayClient
All Implemented Interfaces:
EventHandlerIF, SingleThreadedEventHandlerIF

public class GatewayClient
extends StandardStage

An event-driven gateway client.

Version:
$Id: GatewayClient.java,v 1.11 2005/03/02 02:25:13 srhea Exp $
Author:
Sean C. Rhea

Nested Class Summary
static interface GatewayClient.GetDoneCb
           
protected  class GatewayClient.MySelectableCb
           
static interface GatewayClient.PutDoneCb
           
static class GatewayClient.Request
           
static class GatewayClient.Response
           
 
Field Summary
protected static ByteBuffer bbuf
           
protected  SocketChannel channel
           
protected  InetSocketAddress gateway
           
protected  LinkedList<ostore.util.NodeId> gateways
           
protected  ostore.util.NodeId gnid
           
protected  Gateway gway_inst
           
protected  NioMultiplePacketInputBuffer ib
           
protected  Map<Integer,GatewayClient.Request> inflight
           
protected static int KEY_LEN
           
protected  ostore.util.NodeId last_gw
           
protected  int next_read_size
           
protected  int next_xact_id
           
protected  ByteBuffer read_buf
           
protected  Simulator simulator
           
protected  SelectionKey skey
           
protected  Runnable try_next_gateway_cb
           
protected  LinkedList<QueueElementIF> waiting
           
protected  ByteBuffer write_buf
           
 
Fields inherited from class bamboo.util.StandardStage
acore, classifier, DEBUG, event_types, inb_msg_types, logger, my_node_id, my_sink, outb_msg_types, sim_running
 
Constructor Summary
GatewayClient()
           
 
Method Summary
protected  void application_enqueue(SinkIF sink, QueueElementIF item)
           
 void get_done(int xact_id, bamboo_get_res res)
           
 void get(bamboo_get_args get_args, Curry.Thunk1<bamboo_get_res> thunk)
           
 void get(bamboo_get_args get_args, GatewayClient.GetDoneCb cb, Object user_data)
           
 void handleEvent(QueueElementIF item)
           
 void init(ConfigDataIF config)
           
 void put_done(int xact_id, int result)
           
 void put(bamboo_put_args put_args, Curry.Thunk1<Integer> thunk)
           
 void put(bamboo_put_args put_args, GatewayClient.PutDoneCb cb, Object user_data)
           
protected  void try_next_gateway()
           
 
Methods inherited from class bamboo.util.StandardStage
BUG, BUG, BUG, config_get_boolean, config_get_double, config_get_int, config_get_string, configGetInt, destroy, dispatch, enqueue, handleEvents, lookup_stage, now_ms, timer_ms
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

KEY_LEN

protected static final int KEY_LEN
See Also:
Constant Field Values

channel

protected SocketChannel channel

read_buf

protected ByteBuffer read_buf

write_buf

protected ByteBuffer write_buf

waiting

protected LinkedList<QueueElementIF> waiting

inflight

protected Map<Integer,GatewayClient.Request> inflight

next_xact_id

protected int next_xact_id

ib

protected NioMultiplePacketInputBuffer ib

next_read_size

protected int next_read_size

gateway

protected InetSocketAddress gateway

skey

protected SelectionKey skey

gway_inst

protected Gateway gway_inst

simulator

protected Simulator simulator

gnid

protected ostore.util.NodeId gnid

bbuf

protected static ByteBuffer bbuf

gateways

protected LinkedList<ostore.util.NodeId> gateways

last_gw

protected ostore.util.NodeId last_gw

try_next_gateway_cb

protected Runnable try_next_gateway_cb
Constructor Detail

GatewayClient

public GatewayClient()
Method Detail

get

public void get(bamboo_get_args get_args,
                GatewayClient.GetDoneCb cb,
                Object user_data)

get

public void get(bamboo_get_args get_args,
                Curry.Thunk1<bamboo_get_res> thunk)

put

public void put(bamboo_put_args put_args,
                GatewayClient.PutDoneCb cb,
                Object user_data)

put

public void put(bamboo_put_args put_args,
                Curry.Thunk1<Integer> thunk)

put_done

public void put_done(int xact_id,
                     int result)

get_done

public void get_done(int xact_id,
                     bamboo_get_res res)

application_enqueue

protected void application_enqueue(SinkIF sink,
                                   QueueElementIF item)

init

public void init(ConfigDataIF config)
          throws Exception
Specified by:
init in interface EventHandlerIF
Overrides:
init in class StandardStage
Throws:
Exception

try_next_gateway

protected void try_next_gateway()

handleEvent

public void handleEvent(QueueElementIF item)
Specified by:
handleEvent in interface EventHandlerIF
Overrides:
handleEvent in class StandardStage