Class PEPeerControlImpl.MyPeer
java.lang.Object
com.biglybt.core.peer.impl.control.PEPeerControlImpl.MyPeer
- Enclosing class:
PEPeerControlImpl
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int
private int[]
private long
private int
private int[]
private final PEPeerStats
Fields inherited from interface com.biglybt.core.peer.PEPeer
CLOSING, CONNECTING, DISCONNECTED, HANDSHAKING, MESSAGING_AZMP, MESSAGING_BT_ONLY, MESSAGING_EXTERN, MESSAGING_LTEP, StateNames, TRANSFERING
Fields inherited from interface com.biglybt.core.tag.Taggable
TT_DOWNLOAD, TT_NONE, TT_PEER
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
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
long
long
Get the time this connection was first established.int
int[]
int[]
To retreive arbitrary objects against a peer.int
Returns name of encryption used by the peerbyte[]
byte[]
getId()
int
int[]
get a list of piece numbers the peer has requestedgetIp()
Gets the host name for the IP, if possible, IP as string otherwiseint
int
int
int[]
get a list of piece numbers the we have requested from peerint
int
Get the peer's torrent completion percentage in thousand-notation, i.e.Get the connection that backs this peer.int
getPort()
Get the peer's local TCP connection port.getRateLimiters
(boolean upload) int[]
Get current request hint for a given piece for this peer.int[]
Get the reserved pieces for piece picking by this peerlong
getStats()
Message[]
Get the list of messages that this peer and us both understand.int
int
Get the TCP port this peer is listening for incoming connections on.int
Get the UDP port this peer is listening for incoming connections on.int
Get the UDP port this peer is listening on for non-data connectionsint
int
int
getUserData
(Object key) boolean
boolean
Am I choking the peer.boolean
Is the peer choking me.boolean
isClosed()
boolean
boolean
checks several factors within the object so the caller wouldn't need to for convenience and speed.boolean
boolean
Is the peer Interested in me.boolean
Am I Interested in the peer.boolean
boolean
isMyPeer()
Whether or not this is a 'dummy' peer that represents our presence in a swarmboolean
boolean
isPieceAvailable
(int pieceNumber) boolean
boolean
boolean
isSeed()
boolean
boolean
boolean
void
removeListener
(PEPeerListener listener) Remove peer listener.void
removeRateLimiter
(LimitedRateGroup limiter, boolean upload) void
removeReservedPieceNumber
(int pieceNumber) void
void
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
private void
void
setConsecutiveNoRequestCount
(int num) void
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 completedvoid
setTaggableTransientProperty
(String key, Object value) 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
Whether or not this peer supports the advanced messaging API.boolean
private void
update()
void
updateAutoUploadPriority
(Object key, boolean inc) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.biglybt.core.peer.PEPeer
getPercentDoneOfCurrentIncomingRequest, getPercentDoneOfCurrentOutgoingRequest, getRecentPiecesSent
-
Field Details
-
user_data
-
stats
-
last_active
private volatile long last_active -
incoming_request_count
private volatile int incoming_request_count -
outgoing_request_count
private volatile int outgoing_request_count -
incoming_requested_pieces
private volatile int[] incoming_requested_pieces -
outgoing_requested_pieces
private volatile int[] outgoing_requested_pieces
-
-
Constructor Details
-
MyPeer
private MyPeer()
-
-
Method Details
-
update
private void update() -
setActive
private void setActive() -
isMyPeer
public boolean isMyPeer()Description copied from interface:PEPeer
Whether or not this is a 'dummy' peer that represents our presence in a swarm -
addListener
Description copied from interface:PEPeer
Add peer listener.- Specified by:
addListener
in interfacePEPeer
- Parameters:
listener
-
-
removeListener
Description copied from interface:PEPeer
Remove peer listener.- Specified by:
removeListener
in interfacePEPeer
- Parameters:
listener
-
-
getPeerState
public int getPeerState()- Specified by:
getPeerState
in interfacePEPeer
-
getManager
- Specified by:
getManager
in interfacePEPeer
-
getPeerSource
- Specified by:
getPeerSource
in interfacePEPeer
-
getId
public byte[] getId() -
getIp
-
getAlternativeIPv6
- Specified by:
getAlternativeIPv6
in interfacePEPeer
- Returns:
- an ipv6 address under which the peer should be connectable if it announced one, null otherwise
-
getPort
public int getPort()Description copied from interface:PEPeer
Get the peer's local TCP connection port. -
getIPHostName
Description copied from interface:PEPeer
Gets the host name for the IP, if possible, IP as string otherwise- Specified by:
getIPHostName
in interfacePEPeer
- Returns:
- hostname or IP
-
getTCPListenPort
public int getTCPListenPort()Description copied from interface:PEPeer
Get the TCP port this peer is listening for incoming connections on.- Specified by:
getTCPListenPort
in interfacePEPeer
- Returns:
- TCP port, or 0 if port is unknown
-
getUDPListenPort
public int getUDPListenPort()Description copied from interface:PEPeer
Get the UDP port this peer is listening for incoming connections on.- Specified by:
getUDPListenPort
in interfacePEPeer
- Returns:
- UDP port, or 0 if port is unknown
-
getUDPNonDataListenPort
public int getUDPNonDataListenPort()Description copied from interface:PEPeer
Get the UDP port this peer is listening on for non-data connections- Specified by:
getUDPNonDataListenPort
in interfacePEPeer
- Returns:
-
getAvailable
- Specified by:
getAvailable
in interfacePEPeer
-
isPieceAvailable
public boolean isPieceAvailable(int pieceNumber) - Specified by:
isPieceAvailable
in interfacePEPeer
- Parameters:
pieceNumber
- int- Returns:
- true if this peers makes this piece available
-
transferAvailable
public boolean transferAvailable()- Specified by:
transferAvailable
in interfacePEPeer
-
setSnubbed
public void setSnubbed(boolean b) - Specified by:
setSnubbed
in interfacePEPeer
-
isChokingMe
public boolean isChokingMe()Description copied from interface:PEPeer
Is the peer choking me.- Specified by:
isChokingMe
in interfacePEPeer
- Returns:
- true if I am choked by the peer, false if not
-
isUnchokeOverride
public boolean isUnchokeOverride()- Specified by:
isUnchokeOverride
in interfacePEPeer
-
isChokedByMe
public boolean isChokedByMe()Description copied from interface:PEPeer
Am I choking the peer.- Specified by:
isChokedByMe
in interfacePEPeer
- Returns:
- true if the peer is choked, false if not
-
sendChoke
public void sendChoke() -
sendUnChoke
public void sendUnChoke()- Specified by:
sendUnChoke
in interfacePEPeer
-
isInteresting
public boolean isInteresting()Description copied from interface:PEPeer
Am I Interested in the peer.- Specified by:
isInteresting
in interfacePEPeer
- Returns:
- true if peer is interesting, false if not
-
isInterested
public boolean isInterested()Description copied from interface:PEPeer
Is the peer Interested in me.- Specified by:
isInterested
in interfacePEPeer
- Returns:
- true if the peer is interested in me, false if not
-
isDownloadPossible
public boolean isDownloadPossible()Description copied from interface:PEPeer
checks several factors within the object so the caller wouldn't need to for convenience and speed.- Specified by:
isDownloadPossible
in interfacePEPeer
- Returns:
- true if none of several criteria indicate a request can't be made of the peer
-
isSeed
public boolean isSeed() -
isRelativeSeed
public boolean isRelativeSeed()- Specified by:
isRelativeSeed
in interfacePEPeer
- 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
public boolean isSnubbed() -
getSnubbedTime
public long getSnubbedTime()- Specified by:
getSnubbedTime
in interfacePEPeer
-
getStats
-
isIncoming
public boolean isIncoming()- Specified by:
isIncoming
in interfacePEPeer
-
hasReceivedBitField
public boolean hasReceivedBitField()- Specified by:
hasReceivedBitField
in interfacePEPeer
-
getPercentDoneInThousandNotation
public int getPercentDoneInThousandNotation()Description copied from interface:PEPeer
Get the peer's torrent completion percentage in thousand-notation, i.e. 53.7% is returned as the value 0537.- Specified by:
getPercentDoneInThousandNotation
in interfacePEPeer
- Returns:
- the percentage the peer has complete
-
getClient
-
isOptimisticUnchoke
public boolean isOptimisticUnchoke()- Specified by:
isOptimisticUnchoke
in interfacePEPeer
-
setOptimisticUnchoke
public void setOptimisticUnchoke(boolean is_optimistic) - Specified by:
setOptimisticUnchoke
in interfacePEPeer
-
setUploadHint
public void setUploadHint(int timeToSpread) - Specified by:
setUploadHint
in interfacePEPeer
-
getUploadHint
public int getUploadHint()- Specified by:
getUploadHint
in interfacePEPeer
-
setUniqueAnnounce
public void setUniqueAnnounce(int uniquePieceNumber) - Specified by:
setUniqueAnnounce
in interfacePEPeer
-
getUniqueAnnounce
public int getUniqueAnnounce()- Specified by:
getUniqueAnnounce
in interfacePEPeer
-
getConsecutiveNoRequestCount
public int getConsecutiveNoRequestCount()- Specified by:
getConsecutiveNoRequestCount
in interfacePEPeer
-
setConsecutiveNoRequestCount
public void setConsecutiveNoRequestCount(int num) - Specified by:
setConsecutiveNoRequestCount
in interfacePEPeer
-
setUploadRateLimitBytesPerSecond
public void setUploadRateLimitBytesPerSecond(int bytes) - Specified by:
setUploadRateLimitBytesPerSecond
in interfacePEPeer
-
setDownloadRateLimitBytesPerSecond
public void setDownloadRateLimitBytesPerSecond(int bytes) - Specified by:
setDownloadRateLimitBytesPerSecond
in interfacePEPeer
-
getUploadRateLimitBytesPerSecond
public int getUploadRateLimitBytesPerSecond()- Specified by:
getUploadRateLimitBytesPerSecond
in interfacePEPeer
-
getDownloadRateLimitBytesPerSecond
public int getDownloadRateLimitBytesPerSecond()- Specified by:
getDownloadRateLimitBytesPerSecond
in interfacePEPeer
-
addRateLimiter
- Specified by:
addRateLimiter
in interfacePEPeer
-
getRateLimiters
- Specified by:
getRateLimiters
in interfacePEPeer
-
removeRateLimiter
- Specified by:
removeRateLimiter
in interfacePEPeer
-
setUploadDisabled
- Specified by:
setUploadDisabled
in interfacePEPeer
-
setDownloadDisabled
- Specified by:
setDownloadDisabled
in interfacePEPeer
-
isUploadDisabled
public boolean isUploadDisabled()- Specified by:
isUploadDisabled
in interfacePEPeer
-
isDownloadDisabled
public boolean isDownloadDisabled()- Specified by:
isDownloadDisabled
in interfacePEPeer
-
updateAutoUploadPriority
- Specified by:
updateAutoUploadPriority
in interfacePEPeer
-
getData
Description copied from interface:PEPeer
To retreive arbitrary objects against a peer. -
setData
Description copied from interface:PEPeer
To store arbitrary objects against a peer. -
getUserData
- Specified by:
getUserData
in interfacePEPeer
-
setUserData
Description copied from interface:PEPeer
To store arbitrary objects against a peer.- Specified by:
setUserData
in interfacePEPeer
-
getNetworkConnection
- Specified by:
getNetworkConnection
in interfacePEPeer
-
getPluginConnection
Description copied from interface:PEPeer
Get the connection that backs this peer.- Specified by:
getPluginConnection
in interfacePEPeer
- Returns:
- connection
-
supportsMessaging
public boolean supportsMessaging()Description copied from interface:PEPeer
Whether or not this peer supports the advanced messaging API.- Specified by:
supportsMessaging
in interfacePEPeer
- Returns:
- true if extended messaging is supported, false if not
-
getMessagingMode
public int getMessagingMode()- Specified by:
getMessagingMode
in interfacePEPeer
-
getEncryption
Description copied from interface:PEPeer
Returns name of encryption used by the peer- Specified by:
getEncryption
in interfacePEPeer
- Returns:
-
getProtocol
- Specified by:
getProtocol
in interfacePEPeer
-
getProtocolQualifier
- Specified by:
getProtocolQualifier
in interfacePEPeer
-
getSupportedMessages
Description copied from interface:PEPeer
Get the list of messages that this peer and us both understand.- Specified by:
getSupportedMessages
in interfacePEPeer
- Returns:
- messages available for use, or null of supported is yet unknown or unavailable
-
addReservedPieceNumber
public void addReservedPieceNumber(int pieceNumber) Description copied from interface:PEPeer
adds the reserved piece for piece picking by this peer- Specified by:
addReservedPieceNumber
in interfacePEPeer
-
removeReservedPieceNumber
public void removeReservedPieceNumber(int pieceNumber) - Specified by:
removeReservedPieceNumber
in interfacePEPeer
-
getReservedPieceNumbers
public int[] getReservedPieceNumbers()Description copied from interface:PEPeer
Get the reserved pieces for piece picking by this peer- Specified by:
getReservedPieceNumbers
in interfacePEPeer
-
getIncomingRequestCount
public int getIncomingRequestCount()- Specified by:
getIncomingRequestCount
in interfacePEPeer
-
getOutgoingRequestCount
public int getOutgoingRequestCount()- Specified by:
getOutgoingRequestCount
in interfacePEPeer
-
getIncomingRequestedPieceNumbers
public int[] getIncomingRequestedPieceNumbers()Description copied from interface:PEPeer
get a list of piece numbers the peer has requested- Specified by:
getIncomingRequestedPieceNumbers
in interfacePEPeer
- Returns:
- list of Long() representing the piece number requested, in order
-
getOutgoingRequestedPieceNumbers
public int[] getOutgoingRequestedPieceNumbers()Description copied from interface:PEPeer
get a list of piece numbers the we have requested from peer- Specified by:
getOutgoingRequestedPieceNumbers
in interfacePEPeer
- Returns:
- list of Long() representing the piece number requested, oldest to newest
-
getCurrentIncomingRequestProgress
public int[] getCurrentIncomingRequestProgress()- Specified by:
getCurrentIncomingRequestProgress
in interfacePEPeer
- Returns:
- null or { size, done }
-
getCurrentOutgoingRequestProgress
public int[] getCurrentOutgoingRequestProgress()- Specified by:
getCurrentOutgoingRequestProgress
in interfacePEPeer
-
getBytesRemaining
public long getBytesRemaining()- Specified by:
getBytesRemaining
in interfacePEPeer
-
setSuspendedLazyBitFieldEnabled
public void setSuspendedLazyBitFieldEnabled(boolean enable) Description copied from interface:PEPeer
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- Specified by:
setSuspendedLazyBitFieldEnabled
in interfacePEPeer
- Parameters:
enable
-
-
getConnectionEstablishedMonoTime
public long getConnectionEstablishedMonoTime()Description copied from interface:PEPeer
Get the time this connection was first established. NOTE: This method will always return -1 at any time before the underlying transport is fully connected, i.e. before handshaking begins.- Specified by:
getConnectionEstablishedMonoTime
in interfacePEPeer
- Returns:
- mono time in ms
-
setLastPiece
public void setLastPiece(int i) - Specified by:
setLastPiece
in interfacePEPeer
-
getLastPiece
public int getLastPiece()- Specified by:
getLastPiece
in interfacePEPeer
-
isLANLocal
public boolean isLANLocal()- Specified by:
isLANLocal
in interfacePEPeer
-
resetLANLocalStatus
public void resetLANLocalStatus()- Specified by:
resetLANLocalStatus
in interfacePEPeer
-
sendRequestHint
public boolean sendRequestHint(int piece_number, int offset, int length, int life) Description copied from interface:PEPeer
Send a request hint to the peer.- Specified by:
sendRequestHint
in interfacePEPeer
- Parameters:
piece_number
-offset
-length
-life
-- Returns:
- true if sent, false otherwise
-
getRequestHint
public int[] getRequestHint()Description copied from interface:PEPeer
Get current request hint for a given piece for this peer.- Specified by:
getRequestHint
in interfacePEPeer
- Returns:
- null if no hint int[]{ piece_number, offset, length } if hint found
-
clearRequestHint
public void clearRequestHint()- Specified by:
clearRequestHint
in interfacePEPeer
-
sendStatsRequest
- Specified by:
sendStatsRequest
in interfacePEPeer
-
sendRejectRequest
- Specified by:
sendRejectRequest
in interfacePEPeer
-
setHaveAggregationEnabled
public void setHaveAggregationEnabled(boolean enabled) - Specified by:
setHaveAggregationEnabled
in interfacePEPeer
-
getHandshakeReservedBytes
public byte[] getHandshakeReservedBytes()- Specified by:
getHandshakeReservedBytes
in interfacePEPeer
-
getClientNameFromPeerID
- Specified by:
getClientNameFromPeerID
in interfacePEPeer
-
getClientNameFromExtensionHandshake
- Specified by:
getClientNameFromExtensionHandshake
in interfacePEPeer
-
isPriorityConnection
public boolean isPriorityConnection()- Specified by:
isPriorityConnection
in interfacePEPeer
-
setPriorityConnection
public void setPriorityConnection(boolean is_priority) - Specified by:
setPriorityConnection
in interfacePEPeer
-
isClosed
public boolean isClosed() -
getTaggableType
public int getTaggableType()- Specified by:
getTaggableType
in interfaceTaggable
-
getTaggableID
- Specified by:
getTaggableID
in interfaceTaggable
-
getTaggableName
- Specified by:
getTaggableName
in interfaceTaggable
-
getTaggableResolver
- Specified by:
getTaggableResolver
in interfaceTaggable
-
getTaggableTransientProperty
- Specified by:
getTaggableTransientProperty
in interfaceTaggable
-
setTaggableTransientProperty
- Specified by:
setTaggableTransientProperty
in interfaceTaggable
-
getDescriptor
- Specified by:
getDescriptor
in interfacePEPeer
-