Class PEPeerControlImpl.MyPeer
java.lang.Object
com.biglybt.core.peer.impl.control.PEPeerControlImpl.MyPeer
- Enclosing class:
PEPeerControlImpl
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intprivate int[]private longprivate intprivate int[]private final PEPeerStatsprivate AtomicLongFields inherited from interface PEPeer
CLOSING, CONNECTING, DISCONNECTED, HANDSHAKING, MESSAGING_AZMP, MESSAGING_BT_ONLY, MESSAGING_EXTERN, MESSAGING_LTEP, StateNames, TRANSFERINGFields inherited from interface Taggable
TT_DOWNLOAD, TT_NONE, TT_PEER -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(PEPeerListener listener) Add peer listener.voidaddRateLimiter(LimitedRateGroup limiter, boolean upload) voidaddReservedPieceNumber(int pieceNumber) adds the reserved piece for piece picking by this peervoidlonglongGet the time this connection was first established.intint[]int[]To retreive arbitrary objects against a peer.intReturns name of encryption used by the peerbyte[]byte[]getId()intint[]get a list of piece numbers the peer has requestedgetIp()Gets the host name for the IP, if possible, IP as string otherwiseintintintint[]get a list of piece numbers the we have requested from peerintintGet the peer's torrent completion percentage in thousand-notation, i.e.Get the connection that backs this peer.intgetPort()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 peerlonggetStats()Message[]Get the list of messages that this peer and us both understand.intlongintGet the TCP port this peer is listening for incoming connections on.intGet the UDP port this peer is listening for incoming connections on.intGet the UDP port this peer is listening on for non-data connectionsintintintgetUserData(Object key) booleanbooleanAm I choking the peer.booleanIs the peer choking me.booleanisClosed()booleanbooleanchecks several factors within the object so the caller wouldn't need to for convenience and speed.booleanbooleanIs the peer Interested in me.booleanAm I Interested in the peer.booleanbooleanisMyPeer()Whether or not this is a 'dummy' peer that represents our presence in a swarmbooleanbooleanisPieceAvailable(int pieceNumber) booleanbooleanbooleanisSeed()booleanbooleanbooleanvoidremoveListener(PEPeerListener listener) Remove peer listener.voidremoveRateLimiter(LimitedRateGroup limiter, boolean upload) voidremoveReservedPieceNumber(int pieceNumber) voidvoidvoidsendRejectRequest(DiskManagerReadRequest request) booleansendRequestHint(int piece_number, int offset, int length, int life) Send a request hint to the peer.voidsendStatsRequest(Map request) voidprivate voidvoidsetConsecutiveNoRequestCount(int num) voidTo store arbitrary objects against a peer.voidsetDownloadDisabled(Object key, boolean disabled) voidsetDownloadRateLimitBytesPerSecond(int bytes) voidsetHaveAggregationEnabled(boolean enabled) voidsetLastPiece(int i) voidsetOptimisticUnchoke(boolean is_optimistic) voidsetPriorityConnection(boolean is_priority) voidsetSnubbed(boolean b) voidsetSuspendedLazyBitFieldEnabled(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 completedvoidsetTaggableTransientProperty(String key, Object value) voidsetUniqueAnnounce(int uniquePieceNumber) voidsetUploadDisabled(Object key, boolean disabled) voidsetUploadHint(int timeToSpread) voidsetUploadRateLimitBytesPerSecond(int bytes) voidsetUserData(Object key, Object value) To store arbitrary objects against a peer.booleanWhether or not this peer supports the advanced messaging API.booleanprivate voidupdate()voidupdateAutoUploadPriority(Object key, boolean inc) voidMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface 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 -
tagMutationCounter
-
-
Constructor Details
-
MyPeer
private MyPeer()
-
-
Method Details
-
update
private void update() -
setActive
private void setActive() -
isMyPeer
-
addListener
Description copied from interface:PEPeerAdd peer listener.- Specified by:
addListenerin interfacePEPeer- Parameters:
listener-
-
removeListener
Description copied from interface:PEPeerRemove peer listener.- Specified by:
removeListenerin interfacePEPeer- Parameters:
listener-
-
getPeerState
public int getPeerState()- Specified by:
getPeerStatein interfacePEPeer
-
getManager
- Specified by:
getManagerin interfacePEPeer
-
getPeerSource
- Specified by:
getPeerSourcein interfacePEPeer
-
getId
-
getIp
-
getAlternativeIPv6
- Specified by:
getAlternativeIPv6in interfacePEPeer- Returns:
- an ipv6 address under which the peer should be connectable if it announced one, null otherwise
-
getPort
-
getIPHostName
Description copied from interface:PEPeerGets the host name for the IP, if possible, IP as string otherwise- Specified by:
getIPHostNamein interfacePEPeer- Returns:
- hostname or IP
-
getTCPListenPort
public int getTCPListenPort()Description copied from interface:PEPeerGet the TCP port this peer is listening for incoming connections on.- Specified by:
getTCPListenPortin interfacePEPeer- Returns:
- TCP port, or 0 if port is unknown
-
getUDPListenPort
public int getUDPListenPort()Description copied from interface:PEPeerGet the UDP port this peer is listening for incoming connections on.- Specified by:
getUDPListenPortin interfacePEPeer- Returns:
- UDP port, or 0 if port is unknown
-
getUDPNonDataListenPort
public int getUDPNonDataListenPort()Description copied from interface:PEPeerGet the UDP port this peer is listening on for non-data connections- Specified by:
getUDPNonDataListenPortin interfacePEPeer- Returns:
-
getAvailable
- Specified by:
getAvailablein interfacePEPeer
-
isPieceAvailable
public boolean isPieceAvailable(int pieceNumber) - Specified by:
isPieceAvailablein interfacePEPeer- Parameters:
pieceNumber- int- Returns:
- true if this peers makes this piece available
-
transferAvailable
public boolean transferAvailable()- Specified by:
transferAvailablein interfacePEPeer
-
setSnubbed
public void setSnubbed(boolean b) - Specified by:
setSnubbedin interfacePEPeer
-
isChokingMe
public boolean isChokingMe()Description copied from interface:PEPeerIs the peer choking me.- Specified by:
isChokingMein interfacePEPeer- Returns:
- true if I am choked by the peer, false if not
-
isUnchokeOverride
public boolean isUnchokeOverride()- Specified by:
isUnchokeOverridein interfacePEPeer
-
isChokedByMe
public boolean isChokedByMe()Description copied from interface:PEPeerAm I choking the peer.- Specified by:
isChokedByMein interfacePEPeer- Returns:
- true if the peer is choked, false if not
-
sendChoke
-
sendUnChoke
public void sendUnChoke()- Specified by:
sendUnChokein interfacePEPeer
-
isInteresting
public boolean isInteresting()Description copied from interface:PEPeerAm I Interested in the peer.- Specified by:
isInterestingin interfacePEPeer- Returns:
- true if peer is interesting, false if not
-
isInterested
public boolean isInterested()Description copied from interface:PEPeerIs the peer Interested in me.- Specified by:
isInterestedin interfacePEPeer- Returns:
- true if the peer is interested in me, false if not
-
isDownloadPossible
public boolean isDownloadPossible()Description copied from interface:PEPeerchecks several factors within the object so the caller wouldn't need to for convenience and speed.- Specified by:
isDownloadPossiblein interfacePEPeer- Returns:
- true if none of several criteria indicate a request can't be made of the peer
-
isSeed
-
isRelativeSeed
public boolean isRelativeSeed()- Specified by:
isRelativeSeedin 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
-
getSnubbedTime
public long getSnubbedTime()- Specified by:
getSnubbedTimein interfacePEPeer
-
getStats
-
isIncoming
public boolean isIncoming()- Specified by:
isIncomingin interfacePEPeer
-
hasReceivedBitField
public boolean hasReceivedBitField()- Specified by:
hasReceivedBitFieldin interfacePEPeer
-
getPercentDoneInThousandNotation
public int getPercentDoneInThousandNotation()Description copied from interface:PEPeerGet the peer's torrent completion percentage in thousand-notation, i.e. 53.7% is returned as the value 0537.- Specified by:
getPercentDoneInThousandNotationin interfacePEPeer- Returns:
- the percentage the peer has complete
-
getClient
-
isOptimisticUnchoke
public boolean isOptimisticUnchoke()- Specified by:
isOptimisticUnchokein interfacePEPeer
-
setOptimisticUnchoke
public void setOptimisticUnchoke(boolean is_optimistic) - Specified by:
setOptimisticUnchokein interfacePEPeer
-
setUploadHint
public void setUploadHint(int timeToSpread) - Specified by:
setUploadHintin interfacePEPeer
-
getUploadHint
public int getUploadHint()- Specified by:
getUploadHintin interfacePEPeer
-
setUniqueAnnounce
public void setUniqueAnnounce(int uniquePieceNumber) - Specified by:
setUniqueAnnouncein interfacePEPeer
-
getUniqueAnnounce
public int getUniqueAnnounce()- Specified by:
getUniqueAnnouncein interfacePEPeer
-
getConsecutiveNoRequestCount
public int getConsecutiveNoRequestCount()- Specified by:
getConsecutiveNoRequestCountin interfacePEPeer
-
setConsecutiveNoRequestCount
public void setConsecutiveNoRequestCount(int num) - Specified by:
setConsecutiveNoRequestCountin interfacePEPeer
-
setUploadRateLimitBytesPerSecond
public void setUploadRateLimitBytesPerSecond(int bytes) - Specified by:
setUploadRateLimitBytesPerSecondin interfacePEPeer
-
setDownloadRateLimitBytesPerSecond
public void setDownloadRateLimitBytesPerSecond(int bytes) - Specified by:
setDownloadRateLimitBytesPerSecondin interfacePEPeer
-
getUploadRateLimitBytesPerSecond
public int getUploadRateLimitBytesPerSecond()- Specified by:
getUploadRateLimitBytesPerSecondin interfacePEPeer
-
getDownloadRateLimitBytesPerSecond
public int getDownloadRateLimitBytesPerSecond()- Specified by:
getDownloadRateLimitBytesPerSecondin interfacePEPeer
-
addRateLimiter
- Specified by:
addRateLimiterin interfacePEPeer
-
getRateLimiters
- Specified by:
getRateLimitersin interfacePEPeer
-
removeRateLimiter
- Specified by:
removeRateLimiterin interfacePEPeer
-
setUploadDisabled
- Specified by:
setUploadDisabledin interfacePEPeer
-
setDownloadDisabled
- Specified by:
setDownloadDisabledin interfacePEPeer
-
isUploadDisabled
public boolean isUploadDisabled()- Specified by:
isUploadDisabledin interfacePEPeer
-
isDownloadDisabled
public boolean isDownloadDisabled()- Specified by:
isDownloadDisabledin interfacePEPeer
-
updateAutoUploadPriority
- Specified by:
updateAutoUploadPriorityin interfacePEPeer
-
getData
-
setData
-
getUserData
- Specified by:
getUserDatain interfacePEPeer
-
setUserData
Description copied from interface:PEPeerTo store arbitrary objects against a peer.- Specified by:
setUserDatain interfacePEPeer
-
getNetworkConnection
- Specified by:
getNetworkConnectionin interfacePEPeer
-
getPluginConnection
Description copied from interface:PEPeerGet the connection that backs this peer.- Specified by:
getPluginConnectionin interfacePEPeer- Returns:
- connection
-
supportsMessaging
public boolean supportsMessaging()Description copied from interface:PEPeerWhether or not this peer supports the advanced messaging API.- Specified by:
supportsMessagingin interfacePEPeer- Returns:
- true if extended messaging is supported, false if not
-
getMessagingMode
public int getMessagingMode()- Specified by:
getMessagingModein interfacePEPeer
-
getEncryption
Description copied from interface:PEPeerReturns name of encryption used by the peer- Specified by:
getEncryptionin interfacePEPeer- Returns:
-
getProtocol
- Specified by:
getProtocolin interfacePEPeer
-
getProtocolQualifier
- Specified by:
getProtocolQualifierin interfacePEPeer
-
getSupportedMessages
Description copied from interface:PEPeerGet the list of messages that this peer and us both understand.- Specified by:
getSupportedMessagesin 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:PEPeeradds the reserved piece for piece picking by this peer- Specified by:
addReservedPieceNumberin interfacePEPeer
-
removeReservedPieceNumber
public void removeReservedPieceNumber(int pieceNumber) - Specified by:
removeReservedPieceNumberin interfacePEPeer
-
getReservedPieceNumbers
public int[] getReservedPieceNumbers()Description copied from interface:PEPeerGet the reserved pieces for piece picking by this peer- Specified by:
getReservedPieceNumbersin interfacePEPeer
-
getIncomingRequestCount
public int getIncomingRequestCount()- Specified by:
getIncomingRequestCountin interfacePEPeer
-
getOutgoingRequestCount
public int getOutgoingRequestCount()- Specified by:
getOutgoingRequestCountin interfacePEPeer
-
getIncomingRequestedPieceNumbers
public int[] getIncomingRequestedPieceNumbers()Description copied from interface:PEPeerget a list of piece numbers the peer has requested- Specified by:
getIncomingRequestedPieceNumbersin interfacePEPeer- Returns:
- list of Long() representing the piece number requested, in order
-
getOutgoingRequestedPieceNumbers
public int[] getOutgoingRequestedPieceNumbers()Description copied from interface:PEPeerget a list of piece numbers the we have requested from peer- Specified by:
getOutgoingRequestedPieceNumbersin interfacePEPeer- Returns:
- list of Long() representing the piece number requested, oldest to newest
-
getCurrentIncomingRequestProgress
public int[] getCurrentIncomingRequestProgress()- Specified by:
getCurrentIncomingRequestProgressin interfacePEPeer- Returns:
- null or { size, done }
-
getCurrentOutgoingRequestProgress
public int[] getCurrentOutgoingRequestProgress()- Specified by:
getCurrentOutgoingRequestProgressin interfacePEPeer
-
getBytesRemaining
public long getBytesRemaining()- Specified by:
getBytesRemainingin interfacePEPeer
-
setSuspendedLazyBitFieldEnabled
public void setSuspendedLazyBitFieldEnabled(boolean enable) Description copied from interface:PEPeerEnable 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:
setSuspendedLazyBitFieldEnabledin interfacePEPeer- Parameters:
enable-
-
getConnectionEstablishedMonoTime
public long getConnectionEstablishedMonoTime()Description copied from interface:PEPeerGet 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:
getConnectionEstablishedMonoTimein interfacePEPeer- Returns:
- mono time in ms
-
setLastPiece
public void setLastPiece(int i) - Specified by:
setLastPiecein interfacePEPeer
-
getLastPiece
public int getLastPiece()- Specified by:
getLastPiecein interfacePEPeer
-
isLANLocal
public boolean isLANLocal()- Specified by:
isLANLocalin interfacePEPeer
-
resetLANLocalStatus
public void resetLANLocalStatus()- Specified by:
resetLANLocalStatusin interfacePEPeer
-
sendRequestHint
public boolean sendRequestHint(int piece_number, int offset, int length, int life) Description copied from interface:PEPeerSend a request hint to the peer.- Specified by:
sendRequestHintin interfacePEPeer- Parameters:
piece_number-offset-length-life-- Returns:
- true if sent, false otherwise
-
getRequestHint
public int[] getRequestHint()Description copied from interface:PEPeerGet current request hint for a given piece for this peer.- Specified by:
getRequestHintin interfacePEPeer- Returns:
- null if no hint int[]{ piece_number, offset, length } if hint found
-
clearRequestHint
public void clearRequestHint()- Specified by:
clearRequestHintin interfacePEPeer
-
sendStatsRequest
- Specified by:
sendStatsRequestin interfacePEPeer
-
sendRejectRequest
- Specified by:
sendRejectRequestin interfacePEPeer
-
setHaveAggregationEnabled
public void setHaveAggregationEnabled(boolean enabled) - Specified by:
setHaveAggregationEnabledin interfacePEPeer
-
getHandshakeReservedBytes
public byte[] getHandshakeReservedBytes()- Specified by:
getHandshakeReservedBytesin interfacePEPeer
-
getClientNameFromPeerID
- Specified by:
getClientNameFromPeerIDin interfacePEPeer
-
getClientNameFromExtensionHandshake
- Specified by:
getClientNameFromExtensionHandshakein interfacePEPeer
-
isPriorityConnection
public boolean isPriorityConnection()- Specified by:
isPriorityConnectionin interfacePEPeer
-
setPriorityConnection
public void setPriorityConnection(boolean is_priority) - Specified by:
setPriorityConnectionin interfacePEPeer
-
isClosed
-
getTaggableType
public int getTaggableType()- Specified by:
getTaggableTypein interfaceTaggable
-
getTaggableID
- Specified by:
getTaggableIDin interfaceTaggable
-
getTaggableName
- Specified by:
getTaggableNamein interfaceTaggable
-
getTaggableResolver
- Specified by:
getTaggableResolverin interfaceTaggable
-
getTagMutationCount
public long getTagMutationCount()- Specified by:
getTagMutationCountin interfaceTaggable
-
updateTagMutationCount
public void updateTagMutationCount()- Specified by:
updateTagMutationCountin interfaceTaggable
-
getTaggableTransientProperty
- Specified by:
getTaggableTransientPropertyin interfaceTaggable
-
setTaggableTransientProperty
- Specified by:
setTaggableTransientPropertyin interfaceTaggable
-
getDescriptor
- Specified by:
getDescriptorin interfacePEPeer
-