rice.pastry.socket
Class SocketNodeHandle

java.lang.Object
  |
  +--java.util.Observable
        |
        +--rice.pastry.NodeHandle
              |
              +--rice.pastry.dist.DistNodeHandle
                    |
                    +--rice.pastry.socket.SocketNodeHandle
All Implemented Interfaces:
rice.pastry.LocalNodeI, rice.pastry.messaging.MessageReceiver, rice.p2p.commonapi.NodeHandle, java.util.Observer, java.io.Serializable, TransportListener

public class SocketNodeHandle
extends rice.pastry.dist.DistNodeHandle
implements TransportListener

A direct mimic of WireNodeHandle class. Class which represents a node handle in the socket-based pastry protocol. Initially, all of the messages are sent over UDP. If a message is too large to be sent over the UDP protocol (as determined by the MAX_UDP_MESSAGE_SIZE), then a socket connection is opened to the remote node.

Version:
$Id: SocketNodeHandle.java,v 1.4 2003/10/05 18:50:53 glchen Exp $
Author:
Guanling Chen, Alan Mislove
See Also:
Serialized Form

Field Summary
protected  java.util.List _attr
           
protected  EventFactory _factory
           
protected  boolean _greeted
           
protected  java.lang.Object _lock
           
protected  int _protocol
           
protected  long lastpingtime
           
static int PING_THROTTLE
           
 
Fields inherited from class rice.pastry.dist.DistNodeHandle
address, alive, isInPool, isLocal, nodeId
 
Fields inherited from class rice.pastry.NodeHandle
DECLARED_DEAD, DECLARED_LIVE, PROXIMITY_CHANGED
 
Fields inherited from class java.util.Observable
 
Fields inherited from interface rice.pastry.LocalNodeI
pending
 
Constructor Summary
SocketNodeHandle(int proto, java.net.InetSocketAddress address, rice.pastry.NodeId nid)
           
SocketNodeHandle(int proto, java.net.InetSocketAddress address, rice.pastry.NodeId nid, rice.pastry.PastryNode pn)
           
 
Method Summary
 void connectionClosed(Address peer)
          Called when an connection closed.
 void connectionOpened(Address peer)
          Called when an connection opened.
 void dataReceived(Adu adu, Header header)
          Called when new data is received.
 boolean pingImpl()
           
 void receiveMessageImpl(rice.pastry.messaging.Message msg)
          Called to send a message to the node corresponding to this handle.
 void receiveSocketMessage(rice.pastry.wire.messaging.socket.SocketCommandMessage message)
          Method which is called when a SocketCommandMessage comes across an open socket for this node handle.
 java.lang.String toStringImpl()
           
 
Methods inherited from class rice.pastry.dist.DistNodeHandle
addObserver, afterSetLocalNode, clearChanged, countObservers, debug, deleteObserver, deleteObservers, equals, getAddress, getIsInPool, getNodeId, hasChanged, hashCode, isAlive, markAlive, markDead, notifyObservers, notifyObservers, ping, proximity, receiveMessage, setChanged, setIsInPool, setProximity, toString, update
 
Methods inherited from class rice.pastry.NodeHandle
assertLocalNode, getId, getLocalNode, setLocalNode
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

PING_THROTTLE

public static int PING_THROTTLE

lastpingtime

protected transient long lastpingtime

_protocol

protected transient int _protocol

_factory

protected transient EventFactory _factory

_greeted

protected transient boolean _greeted

_lock

protected transient java.lang.Object _lock

_attr

protected transient java.util.List _attr
Constructor Detail

SocketNodeHandle

public SocketNodeHandle(int proto,
                        java.net.InetSocketAddress address,
                        rice.pastry.NodeId nid)

SocketNodeHandle

public SocketNodeHandle(int proto,
                        java.net.InetSocketAddress address,
                        rice.pastry.NodeId nid,
                        rice.pastry.PastryNode pn)
Method Detail

dataReceived

public void dataReceived(Adu adu,
                         Header header)
Description copied from interface: TransportListener
Called when new data is received.

Specified by:
dataReceived in interface TransportListener

connectionOpened

public void connectionOpened(Address peer)
Description copied from interface: TransportListener
Called when an connection opened.

Specified by:
connectionOpened in interface TransportListener

connectionClosed

public void connectionClosed(Address peer)
Description copied from interface: TransportListener
Called when an connection closed.

Specified by:
connectionClosed in interface TransportListener

receiveSocketMessage

public void receiveSocketMessage(rice.pastry.wire.messaging.socket.SocketCommandMessage message)
Method which is called when a SocketCommandMessage comes across an open socket for this node handle.

Parameters:
message - The message coming across the wire.

receiveMessageImpl

public void receiveMessageImpl(rice.pastry.messaging.Message msg)
Called to send a message to the node corresponding to this handle.

Specified by:
receiveMessageImpl in class rice.pastry.dist.DistNodeHandle
Parameters:
msg - Message to be delivered, may or may not be routeMessage.

pingImpl

public boolean pingImpl()
Specified by:
pingImpl in class rice.pastry.dist.DistNodeHandle

toStringImpl

public java.lang.String toStringImpl()
Specified by:
toStringImpl in class rice.pastry.dist.DistNodeHandle