Class PEPeerControlImpl.MyPeer
- java.lang.Object
-
- com.biglybt.core.peer.impl.control.PEPeerControlImpl.MyPeer
-
- Enclosing class:
- PEPeerControlImpl
private class PEPeerControlImpl.MyPeer extends java.lang.Object implements PEPeer
-
-
Field Summary
Fields Modifier and Type Field Description private int
incoming_request_count
private int[]
incoming_requested_pieces
private long
last_active
private int
outgoing_request_count
private int[]
outgoing_requested_pieces
private PEPeerStats
stats
private java.util.Map<java.lang.Object,java.lang.Object>
user_data
-
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_PEER
-
-
Constructor Summary
Constructors Modifier Constructor Description private
MyPeer()
-
Method Summary
All Methods Instance Methods Concrete 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)
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.java.lang.String
getTaggableID()
java.lang.String
getTaggableName()
TaggableResolver
getTaggableResolver()
java.lang.Object
getTaggableTransientProperty(java.lang.String key)
int
getTaggableType()
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()
private void
setActive()
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
setTaggableTransientProperty(java.lang.String key, java.lang.Object value)
void
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()
private void
update()
void
updateAutoUploadPriority(java.lang.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
getRecentPiecesSent
-
-
-
-
Field Detail
-
user_data
private final java.util.Map<java.lang.Object,java.lang.Object> user_data
-
stats
private final PEPeerStats 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
-
-
Method Detail
-
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
public void addListener(PEPeerListener listener)
Description copied from interface:PEPeer
Add peer listener.- Specified by:
addListener
in interfacePEPeer
-
removeListener
public void removeListener(PEPeerListener listener)
Description copied from interface:PEPeer
Remove peer listener.- Specified by:
removeListener
in interfacePEPeer
-
getPeerState
public int getPeerState()
- Specified by:
getPeerState
in interfacePEPeer
-
getManager
public PEPeerManager getManager()
- Specified by:
getManager
in interfacePEPeer
-
getPeerSource
public java.lang.String getPeerSource()
- Specified by:
getPeerSource
in interfacePEPeer
-
getAlternativeIPv6
public java.net.InetAddress 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
public java.lang.String 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
public BitFlags 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
-
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 convienience and speed.- Specified by:
isDownloadPossible
in interfacePEPeer
- Returns:
- true if none of several criteria indicate a request can't be made of the peer
-
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)
-
getSnubbedTime
public long getSnubbedTime()
- Specified by:
getSnubbedTime
in interfacePEPeer
-
getStats
public PEPeerStats 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
-
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
public void addRateLimiter(LimitedRateGroup limiter, boolean upload)
- Specified by:
addRateLimiter
in interfacePEPeer
-
getRateLimiters
public LimitedRateGroup[] getRateLimiters(boolean upload)
- Specified by:
getRateLimiters
in interfacePEPeer
-
removeRateLimiter
public void removeRateLimiter(LimitedRateGroup limiter, boolean upload)
- Specified by:
removeRateLimiter
in interfacePEPeer
-
setUploadDisabled
public void setUploadDisabled(java.lang.Object key, boolean disabled)
- Specified by:
setUploadDisabled
in interfacePEPeer
-
setDownloadDisabled
public void setDownloadDisabled(java.lang.Object key, boolean disabled)
- Specified by:
setDownloadDisabled
in interfacePEPeer
-
isUploadDisabled
public boolean isUploadDisabled()
- Specified by:
isUploadDisabled
in interfacePEPeer
-
isDownloadDisabled
public boolean isDownloadDisabled()
- Specified by:
isDownloadDisabled
in interfacePEPeer
-
updateAutoUploadPriority
public void updateAutoUploadPriority(java.lang.Object key, boolean inc)
- Specified by:
updateAutoUploadPriority
in interfacePEPeer
-
getData
public java.lang.Object getData(java.lang.String key)
Description copied from interface:PEPeer
To retreive arbitrary objects against a peer.
-
setData
public void setData(java.lang.String key, java.lang.Object value)
Description copied from interface:PEPeer
To store arbitrary objects against a peer.
-
getUserData
public java.lang.Object getUserData(java.lang.Object key)
- Specified by:
getUserData
in interfacePEPeer
-
setUserData
public void setUserData(java.lang.Object key, java.lang.Object value)
Description copied from interface:PEPeer
To store arbitrary objects against a peer.- Specified by:
setUserData
in interfacePEPeer
-
getNetworkConnection
public NetworkConnectionBase getNetworkConnection()
- Specified by:
getNetworkConnection
in interfacePEPeer
-
getPluginConnection
public Connection 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
public java.lang.String getEncryption()
Description copied from interface:PEPeer
Returns name of encryption used by the peer- Specified by:
getEncryption
in interfacePEPeer
- Returns:
-
getProtocol
public java.lang.String getProtocol()
- Specified by:
getProtocol
in interfacePEPeer
-
getProtocolQualifier
public java.lang.String getProtocolQualifier()
- Specified by:
getProtocolQualifier
in interfacePEPeer
-
getSupportedMessages
public Message[] 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
-
getPercentDoneOfCurrentIncomingRequest
public int getPercentDoneOfCurrentIncomingRequest()
- Specified by:
getPercentDoneOfCurrentIncomingRequest
in interfacePEPeer
-
getPercentDoneOfCurrentOutgoingRequest
public int getPercentDoneOfCurrentOutgoingRequest()
- Specified by:
getPercentDoneOfCurrentOutgoingRequest
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
-
getTimeSinceConnectionEstablished
public long getTimeSinceConnectionEstablished()
Description copied from interface:PEPeer
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.- Specified by:
getTimeSinceConnectionEstablished
in interfacePEPeer
- Returns:
- time count 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
- 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
public void sendStatsRequest(java.util.Map request)
- Specified by:
sendStatsRequest
in interfacePEPeer
-
sendRejectRequest
public void sendRejectRequest(DiskManagerReadRequest request)
- 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
public java.lang.String getClientNameFromPeerID()
- Specified by:
getClientNameFromPeerID
in interfacePEPeer
-
getClientNameFromExtensionHandshake
public java.lang.String 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
-
getTaggableType
public int getTaggableType()
- Specified by:
getTaggableType
in interfaceTaggable
-
getTaggableID
public java.lang.String getTaggableID()
- Specified by:
getTaggableID
in interfaceTaggable
-
getTaggableName
public java.lang.String getTaggableName()
- Specified by:
getTaggableName
in interfaceTaggable
-
getTaggableResolver
public TaggableResolver getTaggableResolver()
- Specified by:
getTaggableResolver
in interfaceTaggable
-
getTaggableTransientProperty
public java.lang.Object getTaggableTransientProperty(java.lang.String key)
- Specified by:
getTaggableTransientProperty
in interfaceTaggable
-
setTaggableTransientProperty
public void setTaggableTransientProperty(java.lang.String key, java.lang.Object value)
- Specified by:
setTaggableTransientProperty
in interfaceTaggable
-
-