Package com.biglybt.core.peer
Interface PEPeer
-
- All Known Subinterfaces:
PEPeerTransport
- All Known Implementing Classes:
PeerForeignDelegate
,PEPeerControlImpl.MyPeer
,PEPeerTransportProtocol
public interface PEPeer extends Taggable
-
-
Field Summary
Fields Modifier and Type Field Description 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 java.lang.String[]
StateNames
static int
TRANSFERING
-
Fields inherited from interface com.biglybt.core.tag.Taggable
TT_DOWNLOAD, TT_PEER
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description 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 peervoid
clearRequestHint()
java.net.InetAddress
getAlternativeIPv6()
BitFlags
getAvailable()
long
getBytesRemaining()
java.lang.String
getClient()
java.lang.String
getClientNameFromExtensionHandshake()
java.lang.String
getClientNameFromPeerID()
int
getConsecutiveNoRequestCount()
java.lang.Object
getData(java.lang.String key)
To retreive arbitrary objects against a peer.int
getDownloadRateLimitBytesPerSecond()
java.lang.String
getEncryption()
Returns name of encryption used by the peerbyte[]
getHandshakeReservedBytes()
byte[]
getId()
int
getIncomingRequestCount()
int[]
getIncomingRequestedPieceNumbers()
get a list of piece numbers the peer has requestedjava.lang.String
getIp()
java.lang.String
getIPHostName()
Gets the host name for the IP, if possible, IP as string otherwiseint
getLastPiece()
PEPeerManager
getManager()
int
getMessagingMode()
NetworkConnectionBase
getNetworkConnection()
int
getOutgoingRequestCount()
int[]
getOutgoingRequestedPieceNumbers()
get a list of piece numbers the we have requested from peerjava.lang.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.java.lang.String
getProtocol()
java.lang.String
getProtocolQualifier()
LimitedRateGroup[]
getRateLimiters(boolean upload)
default DiskManagerReadRequest[]
getRecentPiecesSent()
int[]
getRequestHint()
Get current request hint for a given piece for this peer.int[]
getReservedPieceNumbers()
Get the reserved pieces for piece picking by this peerlong
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 connectionsint
getUniqueAnnounce()
int
getUploadHint()
int
getUploadRateLimitBytesPerSecond()
java.lang.Object
getUserData(java.lang.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
isMyPeer()
Whether or not this is a 'dummy' peer that represents our presence in a swarmboolean
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
resetLANLocalStatus()
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(java.util.Map request)
void
sendUnChoke()
void
setConsecutiveNoRequestCount(int num)
void
setData(java.lang.String key, java.lang.Object value)
To store arbitrary objects against a peer.void
setDownloadDisabled(java.lang.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 completedvoid
setUniqueAnnounce(int uniquePieceNumber)
void
setUploadDisabled(java.lang.Object key, boolean disabled)
void
setUploadHint(int timeToSpread)
void
setUploadRateLimitBytesPerSecond(int bytes)
void
setUserData(java.lang.Object key, java.lang.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(java.lang.Object key, boolean inc)
-
Methods inherited from interface com.biglybt.core.tag.Taggable
getTaggableID, getTaggableName, 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 java.lang.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
java.lang.String getPeerSource()
-
isMyPeer
boolean isMyPeer()
Whether or not this is a 'dummy' peer that represents our presence in a swarm- Returns:
-
getId
byte[] getId()
-
getIp
java.lang.String getIp()
-
getAlternativeIPv6
java.net.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
java.lang.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
java.lang.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(java.lang.Object key, boolean disabled)
-
setDownloadDisabled
void setDownloadDisabled(java.lang.Object key, boolean disabled)
-
isUploadDisabled
boolean isUploadDisabled()
-
isDownloadDisabled
boolean isDownloadDisabled()
-
updateAutoUploadPriority
void updateAutoUploadPriority(java.lang.Object key, boolean inc)
-
getData
java.lang.Object getData(java.lang.String key)
To retreive arbitrary objects against a peer.
-
setData
void setData(java.lang.String key, java.lang.Object value)
To store arbitrary objects against a peer.
-
getUserData
java.lang.Object getUserData(java.lang.Object key)
-
setUserData
void setUserData(java.lang.Object key, java.lang.Object value)
To store arbitrary objects against a peer.
-
getNetworkConnection
NetworkConnectionBase getNetworkConnection()
-
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
java.lang.String getEncryption()
Returns name of encryption used by the peer- Returns:
-
getProtocol
java.lang.String getProtocol()
-
getProtocolQualifier
java.lang.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()
-
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
-
getRecentPiecesSent
default DiskManagerReadRequest[] getRecentPiecesSent()
-
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()
-
resetLANLocalStatus
void resetLANLocalStatus()
-
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(java.util.Map request)
-
sendRejectRequest
void sendRejectRequest(DiskManagerReadRequest request)
-
setHaveAggregationEnabled
void setHaveAggregationEnabled(boolean enabled)
-
getHandshakeReservedBytes
byte[] getHandshakeReservedBytes()
-
getClientNameFromPeerID
java.lang.String getClientNameFromPeerID()
-
getClientNameFromExtensionHandshake
java.lang.String getClientNameFromExtensionHandshake()
-
isPriorityConnection
boolean isPriorityConnection()
-
setPriorityConnection
void setPriorityConnection(boolean is_priority)
-
isClosed
boolean isClosed()
-
-