org.gudy.azureus2.core3.peer
Interface PEPeer

All Superinterfaces:
Taggable
All Known Subinterfaces:
PEPeerTransport
All Known Implementing Classes:
PeerForeignDelegate, PEPeerTransportProtocol

public interface PEPeer
extends Taggable

Author:
Olivier, MjrTom 2005/Oct/08: lastPiece handling

Field Summary
static int CLOSING
           
static int CONNECTING
           
static int DISCONNECTED
           
static int HANDSHAKING
           
static int MESSAGING_AZMP
           
static int MESSAGING_BT_ONLY
           
static int MESSAGING_EXTERN
           
static int MESSAGING_LTEP
           
static String[] StateNames
           
static int TRANSFERING
           
 
Fields inherited from interface com.aelitis.azureus.core.tag.Taggable
TT_DOWNLOAD, TT_PEER
 
Method Summary
 void addListener(PEPeerListener listener)
          Add peer listener.
 void addRateLimiter(LimitedRateGroup limiter, boolean upload)
           
 void addReservedPieceNumber(int pieceNumber)
          adds the reserved piece for piece picking by this peer
 void clearRequestHint()
           
 InetAddress getAlternativeIPv6()
           
 BitFlags getAvailable()
           
 long getBytesRemaining()
           
 String getClient()
           
 String getClientNameFromExtensionHandshake()
           
 String getClientNameFromPeerID()
           
 int getConsecutiveNoRequestCount()
           
 Object getData(String key)
          To retreive arbitrary objects against a peer.
 int getDownloadRateLimitBytesPerSecond()
           
 String getEncryption()
          Returns name of encryption used by the peer
 byte[] getHandshakeReservedBytes()
           
 byte[] getId()
           
 int getIncomingRequestCount()
           
 int[] getIncomingRequestedPieceNumbers()
          get a list of piece numbers the peer has requested
 String getIp()
           
 String getIPHostName()
          Gets the host name for the IP, if possible, IP as string otherwise
 int getLastPiece()
           
 PEPeerManager getManager()
           
 int getMessagingMode()
           
 int getOutboundDataQueueSize()
          amount of data queued for delivery to peer
 int getOutgoingRequestCount()
           
 int[] getOutgoingRequestedPieceNumbers()
          get a list of piece numbers the we have requested from peer
 String getPeerSource()
           
 int getPeerState()
           
 int getPercentDoneInThousandNotation()
          Get the peer's torrent completion percentage in thousand-notation, i.e.
 int getPercentDoneOfCurrentIncomingRequest()
           
 int getPercentDoneOfCurrentOutgoingRequest()
           
 Connection getPluginConnection()
          Get the connection that backs this peer.
 int getPort()
          Get the peer's local TCP connection port.
 String getProtocol()
           
 String getProtocolQualifier()
           
 LimitedRateGroup[] getRateLimiters(boolean upload)
           
 int[] getRequestHint()
          Get current request hint for a given piece for this peer.
 int[] getReservedPieceNumbers()
          Get the reserved pieces for piece picking by this peer
 long getSnubbedTime()
           
 PEPeerStats getStats()
           
 Message[] getSupportedMessages()
          Get the list of messages that this peer and us both understand.
 int getTCPListenPort()
          Get the TCP port this peer is listening for incoming connections on.
 long getTimeSinceConnectionEstablished()
          Get the time since this connection was first established.
 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
 int getUniqueAnnounce()
           
 int getUploadHint()
           
 int getUploadRateLimitBytesPerSecond()
           
 Object getUserData(Object key)
           
 boolean hasReceivedBitField()
           
 boolean isChokedByMe()
          Am I choking the peer.
 boolean isChokingMe()
          Is the peer choking me.
 boolean isClosed()
           
 boolean isDownloadDisabled()
           
 boolean isDownloadPossible()
          checks several factors within the object so the caller wouldn't need to for convienience and speed.
 boolean isIncoming()
           
 boolean isInterested()
          Is the peer Interested in me.
 boolean isInteresting()
          Am I Interested in the peer.
 boolean isLANLocal()
           
 boolean isOptimisticUnchoke()
           
 boolean isPieceAvailable(int pieceNumber)
           
 boolean isPriorityConnection()
           
 boolean isRelativeSeed()
           
 boolean isSeed()
           
 boolean isSnubbed()
           
 boolean isUnchokeOverride()
           
 boolean isUploadDisabled()
           
 void removeListener(PEPeerListener listener)
          Remove peer listener.
 void removeRateLimiter(LimitedRateGroup limiter, boolean upload)
           
 void removeReservedPieceNumber(int pieceNumber)
           
 void sendChoke()
           
 void sendRejectRequest(DiskManagerReadRequest request)
           
 boolean sendRequestHint(int piece_number, int offset, int length, int life)
          Send a request hint to the peer.
 void sendStatsRequest(Map request)
           
 void sendUnChoke()
           
 void setConsecutiveNoRequestCount(int num)
           
 void setData(String key, Object value)
          To store arbitrary objects against a peer.
 void setDownloadDisabled(Object key, boolean disabled)
           
 void setDownloadRateLimitBytesPerSecond(int bytes)
           
 void setHaveAggregationEnabled(boolean enabled)
           
 void setLastPiece(int i)
           
 void setOptimisticUnchoke(boolean is_optimistic)
           
 void setPriorityConnection(boolean is_priority)
           
 void setSnubbed(boolean b)
           
 void setSuspendedLazyBitFieldEnabled(boolean enable)
          Enable suspended lazy bitfield for this peer - we will appear incomplete until this is disabled, at which point (well, fairly soon after) the bitfield will be completed
 void setUniqueAnnounce(int uniquePieceNumber)
           
 void setUploadDisabled(Object key, boolean disabled)
           
 void setUploadHint(int timeToSpread)
           
 void setUploadRateLimitBytesPerSecond(int bytes)
           
 void setUserData(Object key, Object value)
          To store arbitrary objects against a peer.
 boolean supportsMessaging()
          Whether or not this peer supports the advanced messaging API.
 boolean transferAvailable()
           
 void updateAutoUploadPriority(Object key, boolean inc)
           
 
Methods inherited from interface com.aelitis.azureus.core.tag.Taggable
getTaggableID, getTaggableResolver, getTaggableTransientProperty, getTaggableType, setTaggableTransientProperty
 

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

StateNames

static final String[] StateNames

MESSAGING_BT_ONLY

static final int MESSAGING_BT_ONLY
See Also:
Constant Field Values

MESSAGING_AZMP

static final int MESSAGING_AZMP
See Also:
Constant Field Values

MESSAGING_LTEP

static final int MESSAGING_LTEP
See Also:
Constant Field Values

MESSAGING_EXTERN

static final int MESSAGING_EXTERN
See Also:
Constant Field Values
Method Detail

addListener

void addListener(PEPeerListener listener)
Add peer listener.

Parameters:
listener -

removeListener

void removeListener(PEPeerListener listener)
Remove peer listener.

Parameters:
listener -

getPeerState

int getPeerState()

getManager

PEPeerManager getManager()

getPeerSource

String getPeerSource()

getId

byte[] getId()

getIp

String getIp()

getAlternativeIPv6

InetAddress getAlternativeIPv6()
Returns:
an ipv6 address under which the peer should be connectable if it announced one, null otherwise

getPort

int getPort()
Get the peer's local TCP connection port.

Returns:
local port

getIPHostName

String getIPHostName()
Gets the host name for the IP, if possible, IP as string otherwise

Returns:
hostname or IP

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:

getAvailable

BitFlags getAvailable()

isPieceAvailable

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

transferAvailable

boolean transferAvailable()

setSnubbed

void setSnubbed(boolean b)

isChokingMe

boolean isChokingMe()
Is the peer choking me.

Returns:
true if I am choked by the peer, false if not

isUnchokeOverride

boolean isUnchokeOverride()

isChokedByMe

boolean isChokedByMe()
Am I choking the peer.

Returns:
true if the peer is choked, false if not

sendChoke

void sendChoke()

sendUnChoke

void sendUnChoke()

isInteresting

boolean isInteresting()
Am I Interested in the peer.

Returns:
true if peer is interesting, false if not

isInterested

boolean isInterested()
Is the peer Interested in me.

Returns:
true if the peer is interested in me, false if not

isDownloadPossible

boolean isDownloadPossible()
checks several factors within the object so the caller wouldn't need to for convienience and speed.

Returns:
true if none of several criteria indicate a request can't be made of the peer

isSeed

boolean isSeed()

isRelativeSeed

boolean isRelativeSeed()
Returns:
true if the peer is only uploading and can't use the data we have to offer (we're seeding) or we can't use the data he has to offer (we're downloading)

isSnubbed

boolean isSnubbed()

getSnubbedTime

long getSnubbedTime()

getStats

PEPeerStats getStats()

isIncoming

boolean isIncoming()

hasReceivedBitField

boolean hasReceivedBitField()

getPercentDoneInThousandNotation

int getPercentDoneInThousandNotation()
Get the peer's torrent completion percentage in thousand-notation, i.e. 53.7% is returned as the value 0537.

Returns:
the percentage the peer has complete

getClient

String getClient()

isOptimisticUnchoke

boolean isOptimisticUnchoke()

setOptimisticUnchoke

void setOptimisticUnchoke(boolean is_optimistic)

setUploadHint

void setUploadHint(int timeToSpread)

getUploadHint

int getUploadHint()

setUniqueAnnounce

void setUniqueAnnounce(int uniquePieceNumber)

getUniqueAnnounce

int getUniqueAnnounce()

getConsecutiveNoRequestCount

int getConsecutiveNoRequestCount()

setConsecutiveNoRequestCount

void setConsecutiveNoRequestCount(int num)

setUploadRateLimitBytesPerSecond

void setUploadRateLimitBytesPerSecond(int bytes)

setDownloadRateLimitBytesPerSecond

void setDownloadRateLimitBytesPerSecond(int bytes)

getUploadRateLimitBytesPerSecond

int getUploadRateLimitBytesPerSecond()

getDownloadRateLimitBytesPerSecond

int getDownloadRateLimitBytesPerSecond()

addRateLimiter

void addRateLimiter(LimitedRateGroup limiter,
                    boolean upload)

getRateLimiters

LimitedRateGroup[] getRateLimiters(boolean upload)

removeRateLimiter

void removeRateLimiter(LimitedRateGroup limiter,
                       boolean upload)

setUploadDisabled

void setUploadDisabled(Object key,
                       boolean disabled)

setDownloadDisabled

void setDownloadDisabled(Object key,
                         boolean disabled)

isUploadDisabled

boolean isUploadDisabled()

isDownloadDisabled

boolean isDownloadDisabled()

updateAutoUploadPriority

void updateAutoUploadPriority(Object key,
                              boolean inc)

getData

Object getData(String key)
To retreive arbitrary objects against a peer.


setData

void setData(String key,
             Object value)
To store arbitrary objects against a peer.


getUserData

Object getUserData(Object key)

setUserData

void setUserData(Object key,
                 Object value)
To store arbitrary objects against a peer.


getPluginConnection

Connection getPluginConnection()
Get the 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

getMessagingMode

int getMessagingMode()

getEncryption

String getEncryption()
Returns name of encryption used by the peer

Returns:

getProtocol

String getProtocol()

getProtocolQualifier

String getProtocolQualifier()

getSupportedMessages

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

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

addReservedPieceNumber

void addReservedPieceNumber(int pieceNumber)
adds the reserved piece for piece picking by this peer


removeReservedPieceNumber

void removeReservedPieceNumber(int pieceNumber)

getReservedPieceNumbers

int[] getReservedPieceNumbers()
Get the reserved pieces for piece picking by this peer


getIncomingRequestCount

int getIncomingRequestCount()

getOutgoingRequestCount

int getOutgoingRequestCount()

getOutboundDataQueueSize

int getOutboundDataQueueSize()
amount of data queued for delivery to peer

Returns:

getIncomingRequestedPieceNumbers

int[] getIncomingRequestedPieceNumbers()
get a list of piece numbers the peer has requested

Returns:
list of Long() representing the piece number requested, in order

getOutgoingRequestedPieceNumbers

int[] getOutgoingRequestedPieceNumbers()
get a list of piece numbers the we have requested from peer

Returns:
list of Long() representing the piece number requested, oldest to newest

getPercentDoneOfCurrentIncomingRequest

int getPercentDoneOfCurrentIncomingRequest()

getPercentDoneOfCurrentOutgoingRequest

int getPercentDoneOfCurrentOutgoingRequest()

getBytesRemaining

long getBytesRemaining()

setSuspendedLazyBitFieldEnabled

void setSuspendedLazyBitFieldEnabled(boolean enable)
Enable suspended lazy bitfield for this peer - we will appear incomplete until this is disabled, at which point (well, fairly soon after) the bitfield will be completed

Parameters:
enable -

getTimeSinceConnectionEstablished

long getTimeSinceConnectionEstablished()
Get the time since this connection was first established. NOTE: This method will always return 0 at any time before the underlying transport is fully connected, i.e. before handshaking begins.

Returns:
time count in ms

setLastPiece

void setLastPiece(int i)

getLastPiece

int getLastPiece()

isLANLocal

boolean isLANLocal()

sendRequestHint

boolean sendRequestHint(int piece_number,
                        int offset,
                        int length,
                        int life)
Send a request hint to the peer.

Parameters:
piece_number -
offset -
length -
life -
Returns:
true if sent, false otherwise

getRequestHint

int[] getRequestHint()
Get current request hint for a given piece for this peer.

Returns:
null if no hint int[]{ piece_number, offset, length } if hint found

clearRequestHint

void clearRequestHint()

sendStatsRequest

void sendStatsRequest(Map request)

sendRejectRequest

void sendRejectRequest(DiskManagerReadRequest request)

setHaveAggregationEnabled

void setHaveAggregationEnabled(boolean enabled)

getHandshakeReservedBytes

byte[] getHandshakeReservedBytes()

getClientNameFromPeerID

String getClientNameFromPeerID()

getClientNameFromExtensionHandshake

String getClientNameFromExtensionHandshake()

isPriorityConnection

boolean isPriorityConnection()

setPriorityConnection

void setPriorityConnection(boolean is_priority)

isClosed

boolean isClosed()