com.limegroup.gnutella
Class UDPReplyHandler

java.lang.Object
  extended bycom.limegroup.gnutella.UDPReplyHandler
All Implemented Interfaces:
ReplyHandler

public final class UDPReplyHandler
extends java.lang.Object
implements ReplyHandler

This class is an implementation of ReplyHandler that is specialized for handling UDP messages.


Constructor Summary
UDPReplyHandler(java.net.InetAddress ip, int port)
          Constructor that sets the ip and port to reply to.
 
Method Summary
 boolean allowNewPings()
          Returns whether or not to allow new pings from this ReplyHandler.
 void countDroppedMessage()
           
 java.util.Set getDomains()
           
 java.net.InetAddress getInetAddress()
          Accessor for the InetAddress instance for this host.
 int getNumMessagesReceived()
           
 void handlePingReply(PingReply pong, ReplyHandler handler)
          Sends the PingReply via a UDP datagram to the IP and port for this handler.
 void handlePushRequest(PushRequest request, ReplyHandler handler)
          Sends the QueryRequest via a UDP datagram to the IP and port for this handler.
 void handleQueryReply(QueryReply hit, ReplyHandler handler)
          Sends the QueryReply via a UDP datagram to the IP and port for this handler.
 boolean isGoodLeaf()
          Returns false, as this node is not a "connection" in the first place, and so could never have sent the requisite headers.
 boolean isGoodUltrapeer()
          Returns false, as this node is not a "connection" in the first place, and so could never have sent the requisite headers.
 boolean isHighDegreeConnection()
          Returns whether or not this connection is a high-degree connection, meaning that it maintains a high number of intra-Ultrapeer connections.
 boolean isKillable()
          Returns whether or not this handler is killable by the handler watchdog.
 boolean isLeafConnection()
          Implements ReplyHandler interface.
 boolean isOpen()
          Returns true if the reply handler is still able to handle a reply.
 boolean isOutgoing()
           
 boolean isPersonalSpam(Message m)
           
 boolean isStable()
          Returns false to indicate that UDPReplyHandlers should never be considered stable, due to data loss over UDP and lack of knowledge as to whether the host is still alive.
 boolean isSupernodeClientConnection()
          Implements ReplyHandler.
 boolean isUltrapeerQueryRoutingConnection()
          Returns false since UDP reply handlers are not TCP connections in the first place.
 boolean supportsPongCaching()
          Returns false, since we don't know whether a host communicating via UDP supports pong caching or not.
 java.lang.String toString()
          Overrides toString to print out more detailed information about this UDPReplyHandler
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UDPReplyHandler

public UDPReplyHandler(java.net.InetAddress ip,
                       int port)
Constructor that sets the ip and port to reply to.

Parameters:
ip - the InetAddress to reply to
port - the port to reply to
Method Detail

handlePingReply

public void handlePingReply(PingReply pong,
                            ReplyHandler handler)
Sends the PingReply via a UDP datagram to the IP and port for this handler.

Implements ReplyHandler.

Specified by:
handlePingReply in interface ReplyHandler
Parameters:
handler - the ReplyHandler to use for sending the reply

handleQueryReply

public void handleQueryReply(QueryReply hit,
                             ReplyHandler handler)
Sends the QueryReply via a UDP datagram to the IP and port for this handler.

Implements ReplyHandler.

Specified by:
handleQueryReply in interface ReplyHandler
Parameters:
hit - the QueryReply to send
handler - the ReplyHandler to use for sending the reply

handlePushRequest

public void handlePushRequest(PushRequest request,
                              ReplyHandler handler)
Sends the QueryRequest via a UDP datagram to the IP and port for this handler.

Implements ReplyHandler.

Specified by:
handlePushRequest in interface ReplyHandler
Parameters:
request - the QueryRequest to send
handler - the ReplyHandler to use for sending the reply

countDroppedMessage

public void countDroppedMessage()
Specified by:
countDroppedMessage in interface ReplyHandler

getDomains

public java.util.Set getDomains()
Specified by:
getDomains in interface ReplyHandler

isPersonalSpam

public boolean isPersonalSpam(Message m)
Specified by:
isPersonalSpam in interface ReplyHandler

isOpen

public boolean isOpen()
Description copied from interface: ReplyHandler
Returns true if the reply handler is still able to handle a reply.

Specified by:
isOpen in interface ReplyHandler

getNumMessagesReceived

public int getNumMessagesReceived()
Specified by:
getNumMessagesReceived in interface ReplyHandler

isOutgoing

public boolean isOutgoing()
Specified by:
isOutgoing in interface ReplyHandler

isKillable

public boolean isKillable()
Description copied from interface: ReplyHandler
Returns whether or not this handler is killable by the handler watchdog. In particular, this is used for old Clip2 indexing queries, which should not be killed.

Specified by:
isKillable in interface ReplyHandler
Returns:
true if the handler is 'killable', i.e. a clip2 indexing query, otherwise false

isSupernodeClientConnection

public boolean isSupernodeClientConnection()
Implements ReplyHandler. This always returns false for UDP reply handlers, as leaves are always connected via TCP.

Specified by:
isSupernodeClientConnection in interface ReplyHandler
Returns:
false, as all leaves are connected via TCP, so directly connected leaves will not have UDPReplyHandlers

isLeafConnection

public boolean isLeafConnection()
Implements ReplyHandler interface. Always returns false because leaves are connected via TCP, not UDP.

Specified by:
isLeafConnection in interface ReplyHandler
Returns:
false, since leaves never maintain their connections via UDP, only TCP

isHighDegreeConnection

public boolean isHighDegreeConnection()
Returns whether or not this connection is a high-degree connection, meaning that it maintains a high number of intra-Ultrapeer connections. In the case of UDP reply handlers, this always returns false.

Specified by:
isHighDegreeConnection in interface ReplyHandler
Returns:
false because, by definition, a UDP 'connection' is not a connection at all

isUltrapeerQueryRoutingConnection

public boolean isUltrapeerQueryRoutingConnection()
Returns false since UDP reply handlers are not TCP connections in the first place.

Specified by:
isUltrapeerQueryRoutingConnection in interface ReplyHandler
Returns:
false, since UDP handlers are not connections in the first place, and therefore cannot use Ultrapeer query routing

isGoodUltrapeer

public boolean isGoodUltrapeer()
Returns false, as this node is not a "connection" in the first place, and so could never have sent the requisite headers.

Specified by:
isGoodUltrapeer in interface ReplyHandler
Returns:
false, as this node is not a real connection

isGoodLeaf

public boolean isGoodLeaf()
Returns false, as this node is not a "connection" in the first place, and so could never have sent the requisite headers.

Specified by:
isGoodLeaf in interface ReplyHandler
Returns:
false, as this node is not a real connection

supportsPongCaching

public boolean supportsPongCaching()
Returns false, since we don't know whether a host communicating via UDP supports pong caching or not.

Specified by:
supportsPongCaching in interface ReplyHandler
Returns:
false since we don't know if this node supports pong caching or not

allowNewPings

public boolean allowNewPings()
Returns whether or not to allow new pings from this ReplyHandler. Since this ping is over UDP, we'll always allow it.

Specified by:
allowNewPings in interface ReplyHandler
Returns:
true since this ping is received over UDP

getInetAddress

public java.net.InetAddress getInetAddress()
Description copied from interface: ReplyHandler
Accessor for the InetAddress instance for this host.

Specified by:
getInetAddress in interface ReplyHandler
Returns:
the InetAddress instance for this host

isStable

public boolean isStable()
Returns false to indicate that UDPReplyHandlers should never be considered stable, due to data loss over UDP and lack of knowledge as to whether the host is still alive.

Specified by:
isStable in interface ReplyHandler
Returns:
false since UDP handler are never stable

toString

public java.lang.String toString()
Overrides toString to print out more detailed information about this UDPReplyHandler