More information: http://www.cs.berkeley.edu/~mdw/proj/seda/

seda.sandStorm.lib.Gnutella
Class GnutellaConnection

java.lang.Object
  |
  +--seda.sandStorm.core.SimpleSink
        |
        +--seda.sandStorm.lib.Gnutella.GnutellaConnection
All Implemented Interfaces:
GnutellaConst, ProfilableIF, QueueElementIF, SinkIF

public class GnutellaConnection
extends SimpleSink
implements QueueElementIF, GnutellaConst

A GnutellaConnection represents a virtual connection to the Gnutella network. It may implement a single point-to-point connection between two peers, or a one-to-many connection to multiple peers.

Author:
Matt Welsh (mdw at cs dot berkeley dot edu)

Fields inherited from interface seda.sandStorm.lib.Gnutella.GnutellaConst
DEFAULT_DOWNLOAD_PORT, DEFAULT_GNUTELLA_PORT, DEFAULT_HOPS, DEFAULT_PING_INTERVAL, DEFAULT_SPEED, DEFAULT_TTL, GNUTELLA_CONNECT, GNUTELLA_FN_PING, GNUTELLA_FN_PONG, GNUTELLA_FN_PUSH, GNUTELLA_FN_QUERY, GNUTELLA_FN_QUERYHITS, GNUTELLA_OK, MAX_PAYLOAD_SIZE, PACKET_HEADER_SIZE, WRITE_CLOG_THRESHOLD
 
Constructor Summary
(package private) GnutellaConnection(GnutellaServer gs, ATcpConnection conn)
           
 
Method Summary
 void close(SinkIF compQ)
           
 void enqueue_abort(java.lang.Object key)
          Not supported; throws an IllegalArgumentException.
 void enqueue_commit(java.lang.Object key)
          Not supported; throws an IllegalArgumentException.
 boolean enqueue_lossy(QueueElementIF element)
          Calls enqueue() and returns false if SinkException occurs.
 void enqueue_many(QueueElementIF[] elements)
          Simply calls enqueue() on each item in the array.
 java.lang.Object enqueue_prepare(QueueElementIF[] enqueueMe)
          Not supported; throws an IllegalArgumentException.
 void enqueue(QueueElementIF element)
          Must be implemented by subclasses.
 void flush(SinkIF compQ)
           
 java.net.InetAddress getAddress()
          Return the InetAddress of the peer.
(package private)  ATcpConnection getConnection()
           
 int getPort()
          Return the port of the peer.
(package private)  GnutellaPacketReader getReader()
           
 void sendPing()
          Send a ping to this connection.
 void sendPing(int ttl)
          Send a ping to this connection with the given TTL.
 int size()
          Returns 0.
 java.lang.String toString()
           
 
Methods inherited from class seda.sandStorm.core.SimpleSink
getEnqueuePredicate, profileSize, setEnqueuePredicate
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GnutellaConnection

GnutellaConnection(GnutellaServer gs,
                   ATcpConnection conn)
Method Detail

getAddress

public java.net.InetAddress getAddress()
Return the InetAddress of the peer. Returns null if this is a 'virtual' connection.

getPort

public int getPort()
Return the port of the peer. Returns -1 if this is a 'virtual' connection.

sendPing

public void sendPing()
Send a ping to this connection.

sendPing

public void sendPing(int ttl)
Send a ping to this connection with the given TTL.

getConnection

ATcpConnection getConnection()

getReader

GnutellaPacketReader getReader()

enqueue

public void enqueue(QueueElementIF element)
             throws SinkException
Description copied from class: SimpleSink
Must be implemented by subclasses.
Overrides:
enqueue in class SimpleSink
Following copied from interface: seda.sandStorm.api.SinkIF
Parameters:
element - The QueueElementIF to enqueue
Throws:
SinkFullException - Indicates that the sink is temporarily full.
SinkClosedException - Indicates that the sink is no longer being serviced.

enqueue_lossy

public boolean enqueue_lossy(QueueElementIF element)
Description copied from class: SimpleSink
Calls enqueue() and returns false if SinkException occurs.
Overrides:
enqueue_lossy in class SimpleSink
Following copied from interface: seda.sandStorm.api.SinkIF
Parameters:
element - The QueueElementIF to enqueue
Returns:
true if the element was enqueued, false otherwise.

enqueue_many

public void enqueue_many(QueueElementIF[] elements)
                  throws SinkException
Description copied from class: SimpleSink
Simply calls enqueue() on each item in the array. Note that this behavior breaks the property that enqueue_many() should be an "all or nothing" operation, since enqueue() might reject some items but not others. Don't use SimpleSink if this is going to be a problem.
Overrides:
enqueue_many in class SimpleSink
Following copied from interface: seda.sandStorm.api.SinkIF
Parameters:
elements - The element array to enqueue
Throws:
SinkFullException - Indicates that the sink is temporarily full.
SinkClosedException - Indicates that the sink is no longer being serviced.

size

public int size()
Description copied from class: SimpleSink
Returns 0.
Overrides:
size in class SimpleSink

close

public void close(SinkIF compQ)
           throws SinkClosedException

flush

public void flush(SinkIF compQ)
           throws SinkClosedException

enqueue_prepare

public java.lang.Object enqueue_prepare(QueueElementIF[] enqueueMe)
                                 throws SinkException
Description copied from class: SimpleSink
Not supported; throws an IllegalArgumentException.
Overrides:
enqueue_prepare in class SimpleSink
Following copied from interface: seda.sandStorm.api.SinkIF
Parameters:
elements - The element array to provisionally enqueue
Returns:
A "transaction key" that may be used to commit or abort the provisional enqueue
Throws:
SinkFullException - Indicates that the sink is temporarily full and that the requested elements could not be provisionally enqueued.
SinkClosedException - Indicates that the sink is no longer being serviced.
See Also:
enqueue_commit, enqueue_abort

enqueue_commit

public void enqueue_commit(java.lang.Object key)
Description copied from class: SimpleSink
Not supported; throws an IllegalArgumentException.
Overrides:
enqueue_commit in class SimpleSink
Following copied from interface: seda.sandStorm.api.SinkIF
Parameters:
key - The enqueue key returned by a previous call to enqueue_prepare().
Throws:
java.lang.IllegalArgumentException - Thrown if an unknown enqueue key is provided.

enqueue_abort

public void enqueue_abort(java.lang.Object key)
Description copied from class: SimpleSink
Not supported; throws an IllegalArgumentException.
Overrides:
enqueue_abort in class SimpleSink
Following copied from interface: seda.sandStorm.api.SinkIF
Parameters:
key - The enqueue key returned by a previous call to enqueue_prepare().
Throws:
java.lang.IllegalArgumentException - Thrown if an unknown enqueue key is provided.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

More information: http://www.cs.berkeley.edu/~mdw/proj/seda/