bamboo.lss
Class Network

java.lang.Object
  extended by bamboo.util.StandardStage
      extended by bamboo.lss.Network
All Implemented Interfaces:
UdpCC.Serializer, UdpCC.Sink, EventHandlerIF, ProfilableIF, SingleThreadedEventHandlerIF

public class Network
extends StandardStage
implements EventHandlerIF, ProfilableIF, UdpCC.Serializer, UdpCC.Sink

Wraps bamboo.lss.UdpCC in the ostore.network.Network interface.

Version:
$Id: Network.java,v 1.28 2004/11/14 20:14:57 srhea Exp $
Author:
Sean C. Rhea

Nested Class Summary
static class Network.DuplicateTypeException
           
protected  class Network.MySendCB
           
 
Field Summary
protected  InetSocketAddress addr
           
protected static HashMap instances
           
protected  ASyncCore main_acore
           
protected  HashMap recv_cbs
           
protected  UdpCC udpcc
           
protected  ASyncCore udpcc_thread
           
 
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
Network(InetSocketAddress addr, ASyncCore ac)
           
 
Method Summary
 Object deserialize(ByteBuffer buf)
          Called to deserialize the given buf into the message it represents; the inverse of serialize.
protected  void enqueue_to_main_thread(SinkIF sink, QueueElementIF item)
           
protected  void handle_net_lat_req(ostore.network.NetworkLatencyReq req)
           
protected  void handle_outbound_msg(ostore.network.NetworkMessage msg)
           
 void handleEvent(QueueElementIF item)
           
 void init(ConfigDataIF config)
           
static Network instance(InetSocketAddress addr)
           
 int profileSize()
           
 void recv(Object o, InetSocketAddress src, InetSocketAddress l, int tries, long wait_ms, long est_rtt_ms)
          Called when a message is received.
 void reg_recv_cb(Class type, UdpCC.Sink cb)
           
 void send(Object msg, InetSocketAddress dst, long timeout_sec, UdpCC.SendCB cb)
           
 void send(Object msg, ostore.util.NodeId dst, long timeout_sec, UdpCC.SendCB cb)
           
 int serialize_size(Object msg)
          Called to determine the size of the byte array needed to serialize the given msg into.
 void serialize(Object msg, ByteBuffer buf)
          Called to serialize the given msg into the provided buf; the inverse of deserialize.
 
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
 
Methods inherited from interface seda.sandStorm.api.EventHandlerIF
destroy, handleEvents
 

Field Detail

instances

protected static HashMap instances

recv_cbs

protected HashMap recv_cbs

addr

protected InetSocketAddress addr

main_acore

protected ASyncCore main_acore

udpcc_thread

protected ASyncCore udpcc_thread

udpcc

protected UdpCC udpcc
Constructor Detail

Network

public Network(InetSocketAddress addr,
               ASyncCore ac)
        throws IOException
Throws:
IOException
Method Detail

instance

public static Network instance(InetSocketAddress addr)

reg_recv_cb

public void reg_recv_cb(Class type,
                        UdpCC.Sink cb)
                 throws Network.DuplicateTypeException
Throws:
Network.DuplicateTypeException

send

public void send(Object msg,
                 ostore.util.NodeId dst,
                 long timeout_sec,
                 UdpCC.SendCB cb)

send

public void send(Object msg,
                 InetSocketAddress dst,
                 long timeout_sec,
                 UdpCC.SendCB cb)

enqueue_to_main_thread

protected void enqueue_to_main_thread(SinkIF sink,
                                      QueueElementIF item)

serialize_size

public int serialize_size(Object msg)
Description copied from interface: UdpCC.Serializer
Called to determine the size of the byte array needed to serialize the given msg into.

Specified by:
serialize_size in interface UdpCC.Serializer

serialize

public void serialize(Object msg,
                      ByteBuffer buf)
Description copied from interface: UdpCC.Serializer
Called to serialize the given msg into the provided buf; the inverse of deserialize.

Specified by:
serialize in interface UdpCC.Serializer

deserialize

public Object deserialize(ByteBuffer buf)
                   throws Exception
Description copied from interface: UdpCC.Serializer
Called to deserialize the given buf into the message it represents; the inverse of serialize.

Specified by:
deserialize in interface UdpCC.Serializer
Throws:
Exception

recv

public void recv(Object o,
                 InetSocketAddress src,
                 InetSocketAddress l,
                 int tries,
                 long wait_ms,
                 long est_rtt_ms)
Description copied from interface: UdpCC.Sink
Called when a message is received.

Specified by:
recv in interface UdpCC.Sink
Parameters:
o - the message that was received
src - the host and port from which the message was sent. The source is not authenticated; this value is just what is read out of the IP packet header
l - the localhost and port on which the message was received
tries - the number of times the message has been sent, including this one, or -1 if that information is not available (for example, if the message was sent with UdpCC.send_nocc(java.lang.Object, java.net.InetSocketAddress))
wait_ms - the time in milliseconds that the message sat in the sender's outbound queue before being sent, presumably because it was waiting behind other messages, or -1 if that information is not available
est_rtt_ms - the sender's estimate of the round trip time in milliseconds between it and this host, or -1 if that information is not available

handleEvent

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

init

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

profileSize

public int profileSize()
Specified by:
profileSize in interface ProfilableIF

handle_outbound_msg

protected final void handle_outbound_msg(ostore.network.NetworkMessage msg)

handle_net_lat_req

protected void handle_net_lat_req(ostore.network.NetworkLatencyReq req)