org.gudy.azureus2.plugins.peers
Interface Peer

All Known Implementing Classes:
ExternalSeedPeer, PeerImpl

public interface Peer


Field Summary
static int CLOSING
           
static int CONNECTING
           
static int DISCONNECTED
           
static int HANDSHAKING
           
static java.lang.Object PR_PRIORITY_CONNECTION
           
static java.lang.Object PR_PROTOCOL
           
static java.lang.Object PR_PROTOCOL_QUALIFIER
           
static int TRANSFERING
           
 
Method Summary
 void addListener(PeerListener listener)
          Deprecated. use addListener( PeerListener2 )
 void addListener(PeerListener2 listener)
          Add peer listener.
 void addRateLimiter(RateLimiter limiter, boolean is_upload)
           
 boolean addRequest(PeerReadRequest request)
           
 void bindConnection(ConnectionStub stub)
           
 void cancelRequest(PeerReadRequest request)
           
 void close(java.lang.String reason, boolean closedOnError, boolean attemptReconnect)
           
 boolean[] getAvailable()
           
 java.lang.String getClient()
           
 Connection getConnection()
          Get the network connection that backs this peer.
 java.util.List getExpiredRequests()
           
 byte[] getHandshakeReservedBytes()
           
 byte[] getId()
           
 java.lang.String getIp()
          Get the peer's local TCP connection port.
 PeerManager getManager()
           
 int getMaximumNumberOfRequests()
           
 int getNumberOfRequests()
           
 int getOutgoingRequestCount()
           
 int[] getOutgoingRequestedPieceNumbers()
           
 int getPercentDone()
          Deprecated. This erroneously returns percent in 1000 (i.e. 100% = 1000 :) Therefore replaces with something more accurately named!
 int getPercentDoneInThousandNotation()
           
 int getPercentDoneOfCurrentIncomingRequest()
           
 int getPercentDoneOfCurrentOutgoingRequest()
           
 int getPort()
           
 int[] getPriorityOffsets()
           
 RateLimiter[] getRateLimiters(boolean is_upload)
           
 java.util.List getRequests()
           
 long getSnubbedTime()
           
 int getState()
           
 PeerStats getStats()
           
 Message[] getSupportedMessages()
          Get the list of messages that this peer and us mutually understand.
 int getTCPListenPort()
          Get the TCP port this peer is listening for incoming connections on.
 int getUDPListenPort()
          Get the UDP port this peer is listening for incoming connections on.
 int getUDPNonDataListenPort()
          Get the UDP port this peer is listening on for non-data connections
 java.lang.Object getUserData(java.lang.Object key)
           
 boolean isChoked()
           
 boolean isChoking()
           
 boolean isDownloadPossible()
          This is much list isTransferAvailable(), except is more comprehensive.
 boolean isIncoming()
           
 boolean isInterested()
           
 boolean isInteresting()
           
 boolean isLANLocal()
           
 boolean isOptimisticUnchoke()
           
 boolean isPieceAvailable(int pieceNumber)
           
 boolean isPriorityConnection()
           
 boolean isSeed()
           
 boolean isSnubbed()
           
 boolean isTransferAvailable()
           
 int readBytes(int max)
          Rate control - gives the maximum number of bytes that can be read from this connection at this time and returns the actual number read
 void removeListener(PeerListener listener)
          Deprecated. use removeListener( PeerListener2 )
 void removeListener(PeerListener2 listener)
          Remove peer listener.
 void removeRateLimiter(RateLimiter limiter, boolean is_upload)
           
 void requestAllocationComplete()
           
 boolean requestAllocationStarts(int[] base_priorities)
           
 void setOptimisticUnchoke(boolean is_optimistic)
           
 void setPriorityConnection(boolean is_priority)
           
 void setSnubbed(boolean b)
           
 void setUserData(java.lang.Object key, java.lang.Object value)
           
 boolean supportsMessaging()
          Whether or not this peer supports the advanced messaging API.
 int writeBytes(int max)
           
 

Field Detail

CONNECTING

static final int CONNECTING
See Also:
Constant Field Values

HANDSHAKING

static final int HANDSHAKING
See Also:
Constant Field Values

TRANSFERING

static final int TRANSFERING
See Also:
Constant Field Values

CLOSING

static final int CLOSING
See Also:
Constant Field Values

DISCONNECTED

static final int DISCONNECTED
See Also:
Constant Field Values

PR_PRIORITY_CONNECTION

static final java.lang.Object PR_PRIORITY_CONNECTION

PR_PROTOCOL

static final java.lang.Object PR_PROTOCOL

PR_PROTOCOL_QUALIFIER

static final java.lang.Object PR_PROTOCOL_QUALIFIER
Method Detail

bindConnection

void bindConnection(ConnectionStub stub)

getManager

PeerManager getManager()

getState

int getState()

getId

byte[] getId()

getIp

java.lang.String getIp()
Get the peer's local TCP connection port.

Returns:
local port

getTCPListenPort

int getTCPListenPort()
Get the TCP port this peer is listening for incoming connections on.

Returns:
TCP port, or 0 if port is unknown

getUDPListenPort

int getUDPListenPort()
Get the UDP port this peer is listening for incoming connections on.

Returns:
UDP port, or 0 if port is unknown

getUDPNonDataListenPort

int getUDPNonDataListenPort()
Get the UDP port this peer is listening on for non-data connections

Returns:

getPort

int getPort()

isLANLocal

boolean isLANLocal()

getAvailable

boolean[] getAvailable()

isPieceAvailable

boolean isPieceAvailable(int pieceNumber)
Parameters:
pieceNumber - int
Returns:
true if this peers makes this piece available

isTransferAvailable

boolean isTransferAvailable()

readBytes

int readBytes(int max)
Rate control - gives the maximum number of bytes that can be read from this connection at this time and returns the actual number read

Parameters:
max -
Returns:

writeBytes

int writeBytes(int max)

isDownloadPossible

boolean isDownloadPossible()
This is much list isTransferAvailable(), except is more comprehensive. That is; it checks a few more factors, within the object for speed, so that a more timely status is considered and the caller doesn't need to try to check each thing on it's own.

Returns:
true if several factors say downloading can be tried.

isChoked

boolean isChoked()

isChoking

boolean isChoking()

isInterested

boolean isInterested()

isInteresting

boolean isInteresting()

isSeed

boolean isSeed()

isSnubbed

boolean isSnubbed()

getSnubbedTime

long getSnubbedTime()

setSnubbed

void setSnubbed(boolean b)

getStats

PeerStats getStats()

isIncoming

boolean isIncoming()

getPercentDone

int getPercentDone()
Deprecated. This erroneously returns percent in 1000 (i.e. 100% = 1000 :) Therefore replaces with something more accurately named!

Returns:

getPercentDoneInThousandNotation

int getPercentDoneInThousandNotation()

getClient

java.lang.String getClient()

isOptimisticUnchoke

boolean isOptimisticUnchoke()

setOptimisticUnchoke

void setOptimisticUnchoke(boolean is_optimistic)

getExpiredRequests

java.util.List getExpiredRequests()

getRequests

java.util.List getRequests()

getMaximumNumberOfRequests

int getMaximumNumberOfRequests()

getNumberOfRequests

int getNumberOfRequests()

cancelRequest

void cancelRequest(PeerReadRequest request)

requestAllocationStarts

boolean requestAllocationStarts(int[] base_priorities)

getPriorityOffsets

int[] getPriorityOffsets()

requestAllocationComplete

void requestAllocationComplete()

addRequest

boolean addRequest(PeerReadRequest request)

close

void close(java.lang.String reason,
           boolean closedOnError,
           boolean attemptReconnect)

getPercentDoneOfCurrentIncomingRequest

int getPercentDoneOfCurrentIncomingRequest()

getOutgoingRequestedPieceNumbers

int[] getOutgoingRequestedPieceNumbers()

getOutgoingRequestCount

int getOutgoingRequestCount()

getPercentDoneOfCurrentOutgoingRequest

int getPercentDoneOfCurrentOutgoingRequest()

addListener

void addListener(PeerListener listener)
Deprecated. use addListener( PeerListener2 )

Add peer listener.

Parameters:
listener -

removeListener

void removeListener(PeerListener listener)
Deprecated. use removeListener( PeerListener2 )

Remove peer listener.

Parameters:
listener -

addListener

void addListener(PeerListener2 listener)
Add peer listener.

Parameters:
listener -

removeListener

void removeListener(PeerListener2 listener)
Remove peer listener.

Parameters:
listener -

getConnection

Connection getConnection()
Get the network connection that backs this peer.

Returns:
connection

supportsMessaging

boolean supportsMessaging()
Whether or not this peer supports the advanced messaging API.

Returns:
true if extended messaging is supported, false if not

getSupportedMessages

Message[] getSupportedMessages()
Get the list of messages that this peer and us mutually understand.

Returns:
messages available for use, or null of supported is yet unknown

setUserData

void setUserData(java.lang.Object key,
                 java.lang.Object value)

getUserData

java.lang.Object getUserData(java.lang.Object key)

getHandshakeReservedBytes

byte[] getHandshakeReservedBytes()

isPriorityConnection

boolean isPriorityConnection()

setPriorityConnection

void setPriorityConnection(boolean is_priority)

addRateLimiter

void addRateLimiter(RateLimiter limiter,
                    boolean is_upload)
Parameters:
limiter - create via ConnectionManager
is_upload - false -> download limit
Since:
4.7.0.3

removeRateLimiter

void removeRateLimiter(RateLimiter limiter,
                       boolean is_upload)

getRateLimiters

RateLimiter[] getRateLimiters(boolean is_upload)