Package com.biglybt.pifimpl.local.peers
Class PeerForeignDelegate
- java.lang.Object
-
- com.biglybt.pifimpl.local.peers.PeerForeignDelegate
-
- All Implemented Interfaces:
PEPeerTransport
,PEPeer
,Taggable
,Taggable
public class PeerForeignDelegate extends java.lang.Object implements PEPeerTransport
-
-
Field Summary
Fields Modifier and Type Field Description protected int
_lastPiece
private BitFlags
bit_flags
private boolean
closed
private int
consecutive_no_requests
private long
create_time
private java.util.Map
data
private java.util.Set<java.lang.Object>
download_disabled_set
private Peer
foreign
private boolean
is_download_disabled
private long
last_data_message_received_time
private long
last_data_received_time
private PeerManagerImpl
manager
private NetworkConnectionBase
network_connection
private java.util.HashMap<PEPeerListener,PeerListener2>
peer_listeners
private boolean
priority_connection
private int[]
reserved_pieces
protected AEMonitor
this_mon
-
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.peer.impl.PEPeerTransport
CONNECTION_CONNECTING, CONNECTION_FULLY_ESTABLISHED, CONNECTION_PENDING, CONNECTION_WAITING_FOR_HANDSHAKE, CP_CONNECT_FAILED, CP_CONNECT_OK, CP_CONNECTING, CP_RECEIVED_DATA, CP_UNKNOWN
-
Fields inherited from interface com.biglybt.core.tag.Taggable
TT_DOWNLOAD, TT_PEER
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
PeerForeignDelegate(PeerManagerImpl _manager, Peer _foreign)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addListener(PEPeerListener l)
Add peer listener.void
addRateLimiter(LimitedRateGroup limiter, boolean upload)
void
addReservedPieceNumber(int piece_number)
adds the reserved piece for piece picking by this peervoid
checkInterested()
Nothing to do if calledvoid
clearAvailabilityAdded()
Nothing to do if calledvoid
clearRequestHint()
void
closeConnection(java.lang.String reason)
Close the peer connectionprotected void
dataReceived()
void
doKeepAliveCheck()
Check if we need to send a keep-alive message.void
doPerformanceTuningCheck()
Perform checks related to performance optimizations, i.e.boolean
doTimeoutChecks()
Check for possible connection timeouts.boolean
equals(java.lang.Object other)
void
generateEvidence(IndentWriter writer)
java.net.InetAddress
getAlternativeIPv6()
BitFlags
getAvailable()
long
getBytesRemaining()
java.lang.String
getClient()
java.lang.String
getClientNameFromExtensionHandshake()
java.lang.String
getClientNameFromPeerID()
int
getConnectionState()
Get the specific peer connection state.int
getConsecutiveNoRequestCount()
PEPeerControl
getControl()
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 peerjava.util.List
getExpiredRequests()
byte[]
getHandshakeReservedBytes()
byte[]
getId()
int
getIncomingRequestCount()
int
getIncomingRequestedPieceNumberCount()
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 otherwiselong
getLastMessageSentTime()
int
getLastPiece()
long
getLatency()
PEPeerManager
getManager()
int
getMaxNbRequests()
peer-specific request max.int
getMessagingMode()
int
getNbRequests()
java.lang.String
getNetwork()
NetworkConnectionBase
getNetworkConnection()
int
getOutboundConnectionProgress()
int
getOutgoingRequestCount()
int[]
getOutgoingRequestedPieceNumbers()
get a list of piece numbers the we have requested from peerPeerItem
getPeerItemIdentity()
Get the peer's address + port identification item.java.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.int[]
getPriorityOffsets()
Any priority offsets this peer has, or null if nonejava.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
getRequestIndex(DiskManagerReadRequest request)
Returns the index of this request in the peer's queue or -1 if not foundint[]
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.long
getTimeSinceGoodDataReceived()
Get the time since the most-recent data that was actually written to disk was received.long
getTimeSinceLastDataMessageReceived()
Get the time since the last (most-recent) data (payload) message was received.long
getTimeSinceLastDataMessageSent()
Get the time since the last (most-recent) data (payload) message was sent.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 connectionslong
getUnchokedForMillis()
int
getUniqueAnnounce()
int
getUploadHint()
int
getUploadRateLimitBytesPerSecond()
java.lang.Object
getUserData(java.lang.Object key)
To retreive arbitrary objects against a peer.int
hashCode()
boolean
hasReceivedBitField()
boolean
isAvailabilityAdded()
Apaprently nothing significant to do if calledboolean
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()
Is the connection within the local LAN network.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
isSafeForReconnect()
This method is called to check if it is safe to reconnect to a peer, i.e.boolean
isSeed()
boolean
isSnubbed()
boolean
isStalledPendingLoad()
is peer waiting for a disk read with no network writes queuedboolean
isTCP()
boolean
isUnchokeOverride()
boolean
isUploadDisabled()
PEPeerTransport
reconnect(boolean tryUDP, boolean tryIPv6)
Attempts to reconnect to the same peervoid
removeListener(PEPeerListener l)
Remove peer listener.void
removeRateLimiter(LimitedRateGroup limiter, boolean upload)
void
removeReservedPieceNumber(int piece_number)
DiskManagerReadRequest
request(int pieceNumber, int pieceOffset, int pieceLength, boolean return_duplicates)
void
requestAllocationComplete()
boolean
requestAllocationStarts(int[] base_priorities)
Two methods that allow a peer to aggregate the individual requests generated during an allocation cycle if so desiredvoid
resetLANLocalStatus()
void
sendBadPiece(int piece_number)
void
sendCancel(DiskManagerReadRequest request)
void
sendChoke()
Should never be calledvoid
sendHashRequest(TOTorrentFileHashTree.HashRequest req)
void
sendHave(int piece)
Nothing to do if calledvoid
sendRejectRequest(DiskManagerReadRequest request)
boolean
sendRequestHint(int piece_number, int offset, int length, int life)
Send a request hint to the peer.void
sendStatsReply(java.util.Map reply)
void
sendStatsRequest(java.util.Map request)
void
sendUnChoke()
Should never be calledvoid
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 pieceNumber)
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.void
start()
Start message processing for the peerprotected void
stop()
boolean
supportsMessaging()
Whether or not this peer supports the advanced messaging API.boolean
transferAvailable()
void
updateAutoUploadPriority(java.lang.Object key, boolean inc)
void
updatePeerExchange()
Do any peer exchange processing/updating.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.biglybt.core.peer.PEPeer
getRecentPiecesSent
-
-
-
-
Field Detail
-
_lastPiece
protected volatile int _lastPiece
-
manager
private PeerManagerImpl manager
-
foreign
private Peer foreign
-
network_connection
private NetworkConnectionBase network_connection
-
create_time
private long create_time
-
last_data_received_time
private long last_data_received_time
-
last_data_message_received_time
private long last_data_message_received_time
-
reserved_pieces
private int[] reserved_pieces
-
consecutive_no_requests
private int consecutive_no_requests
-
bit_flags
private BitFlags bit_flags
-
priority_connection
private boolean priority_connection
-
data
private java.util.Map data
-
peer_listeners
private java.util.HashMap<PEPeerListener,PeerListener2> peer_listeners
-
this_mon
protected AEMonitor this_mon
-
download_disabled_set
private java.util.Set<java.lang.Object> download_disabled_set
-
is_download_disabled
private boolean is_download_disabled
-
closed
private volatile boolean closed
-
-
Constructor Detail
-
PeerForeignDelegate
protected PeerForeignDelegate(PeerManagerImpl _manager, Peer _foreign)
-
-
Method Detail
-
isMyPeer
public boolean isMyPeer()
Description copied from interface:PEPeer
Whether or not this is a 'dummy' peer that represents our presence in a swarm
-
getOutboundConnectionProgress
public int getOutboundConnectionProgress()
- Specified by:
getOutboundConnectionProgress
in interfacePEPeerTransport
-
start
public void start()
Description copied from interface:PEPeerTransport
Start message processing for the peer- Specified by:
start
in interfacePEPeerTransport
-
stop
protected void stop()
-
sendChoke
public void sendChoke()
Should never be called- Specified by:
sendChoke
in interfacePEPeer
- Specified by:
sendChoke
in interfacePEPeerTransport
-
sendHave
public void sendHave(int piece)
Nothing to do if called- Specified by:
sendHave
in interfacePEPeerTransport
-
sendUnChoke
public void sendUnChoke()
Should never be called- Specified by:
sendUnChoke
in interfacePEPeer
- Specified by:
sendUnChoke
in interfacePEPeerTransport
-
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
-
transferAvailable
public boolean transferAvailable()
- Specified by:
transferAvailable
in interfacePEPeer
- Specified by:
transferAvailable
in interfacePEPeerTransport
-
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
-
sendCancel
public void sendCancel(DiskManagerReadRequest request)
- Specified by:
sendCancel
in interfacePEPeerTransport
-
request
public DiskManagerReadRequest request(int pieceNumber, int pieceOffset, int pieceLength, boolean return_duplicates)
- Specified by:
request
in interfacePEPeerTransport
- Parameters:
pieceNumber
-pieceOffset
-pieceLength
-return_duplicates
- - if true and request already exists it will be returned, if false -> null- Returns:
- true is the piece is really requested
-
getRequestIndex
public int getRequestIndex(DiskManagerReadRequest request)
Description copied from interface:PEPeerTransport
Returns the index of this request in the peer's queue or -1 if not found- Specified by:
getRequestIndex
in interfacePEPeerTransport
- Returns:
-
dataReceived
protected void dataReceived()
-
closeConnection
public void closeConnection(java.lang.String reason)
Description copied from interface:PEPeerTransport
Close the peer connection- Specified by:
closeConnection
in interfacePEPeerTransport
- Parameters:
reason
- for closure
-
getExpiredRequests
public java.util.List getExpiredRequests()
- Specified by:
getExpiredRequests
in interfacePEPeerTransport
-
getLastMessageSentTime
public long getLastMessageSentTime()
- Specified by:
getLastMessageSentTime
in interfacePEPeerTransport
-
getMaxNbRequests
public int getMaxNbRequests()
Description copied from interface:PEPeerTransport
peer-specific request max. return -1 to use the default piece-picker allocation method- Specified by:
getMaxNbRequests
in interfacePEPeerTransport
- Returns:
-
getNbRequests
public int getNbRequests()
- Specified by:
getNbRequests
in interfacePEPeerTransport
-
getPriorityOffsets
public int[] getPriorityOffsets()
Description copied from interface:PEPeerTransport
Any priority offsets this peer has, or null if none- Specified by:
getPriorityOffsets
in interfacePEPeerTransport
- Returns:
-
requestAllocationStarts
public boolean requestAllocationStarts(int[] base_priorities)
Description copied from interface:PEPeerTransport
Two methods that allow a peer to aggregate the individual requests generated during an allocation cycle if so desired- Specified by:
requestAllocationStarts
in interfacePEPeerTransport
- Returns:
- true if the peer is managing request priorities and doesn't want end-game random allocation behaviour
-
requestAllocationComplete
public void requestAllocationComplete()
- Specified by:
requestAllocationComplete
in interfacePEPeerTransport
-
getControl
public PEPeerControl getControl()
- Specified by:
getControl
in interfacePEPeerTransport
-
updatePeerExchange
public void updatePeerExchange()
Description copied from interface:PEPeerTransport
Do any peer exchange processing/updating.- Specified by:
updatePeerExchange
in interfacePEPeerTransport
-
getPeerItemIdentity
public PeerItem getPeerItemIdentity()
Description copied from interface:PEPeerTransport
Get the peer's address + port identification item.- Specified by:
getPeerItemIdentity
in interfacePEPeerTransport
- Returns:
- id
-
getConnectionState
public int getConnectionState()
Description copied from interface:PEPeerTransport
Get the specific peer connection state.- Specified by:
getConnectionState
in interfacePEPeerTransport
- Returns:
- connection state
-
doKeepAliveCheck
public void doKeepAliveCheck()
Description copied from interface:PEPeerTransport
Check if we need to send a keep-alive message. A keep-alive is sent if no other message has been sent within the last 2min.- Specified by:
doKeepAliveCheck
in interfacePEPeerTransport
-
doTimeoutChecks
public boolean doTimeoutChecks()
Description copied from interface:PEPeerTransport
Check for possible connection timeouts.- Specified by:
doTimeoutChecks
in interfacePEPeerTransport
- Returns:
- true if the connection has been timed-out, false if not
-
doPerformanceTuningCheck
public void doPerformanceTuningCheck()
Description copied from interface:PEPeerTransport
Perform checks related to performance optimizations, i.e. tune buffering related to send/receive speed.- Specified by:
doPerformanceTuningCheck
in interfacePEPeerTransport
-
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
-
getTimeSinceLastDataMessageReceived
public long getTimeSinceLastDataMessageReceived()
Description copied from interface:PEPeerTransport
Get the time since the last (most-recent) data (payload) message was received.- Specified by:
getTimeSinceLastDataMessageReceived
in interfacePEPeerTransport
- Returns:
- time count in ms, or -1 if we've never received a data message from them
-
getTimeSinceGoodDataReceived
public long getTimeSinceGoodDataReceived()
Description copied from interface:PEPeerTransport
Get the time since the most-recent data that was actually written to disk was received.- Specified by:
getTimeSinceGoodDataReceived
in interfacePEPeerTransport
- Returns:
- time count in ms, or -1 if we've never received usefull data from them
-
getTimeSinceLastDataMessageSent
public long getTimeSinceLastDataMessageSent()
Description copied from interface:PEPeerTransport
Get the time since the last (most-recent) data (payload) message was sent.- Specified by:
getTimeSinceLastDataMessageSent
in interfacePEPeerTransport
- Returns:
- time count in ms, or -1 if we've never sent them a data message
-
getUnchokedForMillis
public long getUnchokedForMillis()
- Specified by:
getUnchokedForMillis
in interfacePEPeerTransport
-
getLatency
public long getLatency()
- Specified by:
getLatency
in interfacePEPeerTransport
-
getConsecutiveNoRequestCount
public int getConsecutiveNoRequestCount()
- Specified by:
getConsecutiveNoRequestCount
in interfacePEPeer
-
setConsecutiveNoRequestCount
public void setConsecutiveNoRequestCount(int num)
- Specified by:
setConsecutiveNoRequestCount
in interfacePEPeer
-
getManager
public PEPeerManager getManager()
- Specified by:
getManager
in interfacePEPeer
-
getPeerSource
public java.lang.String getPeerSource()
- Specified by:
getPeerSource
in interfacePEPeer
-
getPeerState
public int getPeerState()
- Specified by:
getPeerState
in interfacePEPeer
-
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
-
getPort
public int getPort()
Description copied from interface:PEPeer
Get the peer's local TCP connection port.
-
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
-
hasReceivedBitField
public boolean hasReceivedBitField()
- Specified by:
hasReceivedBitField
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
-
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
-
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
-
isUnchokeOverride
public boolean isUnchokeOverride()
- Specified by:
isUnchokeOverride
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
-
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
-
isLANLocal
public boolean isLANLocal()
Description copied from interface:PEPeerTransport
Is the connection within the local LAN network.- Specified by:
isLANLocal
in interfacePEPeer
- Specified by:
isLANLocal
in interfacePEPeerTransport
- Returns:
- true if within LAN, false of outside the LAN segment
-
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
-
sendRejectRequest
public void sendRejectRequest(DiskManagerReadRequest request)
- Specified by:
sendRejectRequest
in interfacePEPeer
-
sendBadPiece
public void sendBadPiece(int piece_number)
- Specified by:
sendBadPiece
in interfacePEPeerTransport
-
sendStatsRequest
public void sendStatsRequest(java.util.Map request)
- Specified by:
sendStatsRequest
in interfacePEPeer
- Specified by:
sendStatsRequest
in interfacePEPeerTransport
-
sendStatsReply
public void sendStatsReply(java.util.Map reply)
- Specified by:
sendStatsReply
in interfacePEPeerTransport
-
sendHashRequest
public void sendHashRequest(TOTorrentFileHashTree.HashRequest req)
- Specified by:
sendHashRequest
in interfacePEPeerTransport
-
isTCP
public boolean isTCP()
- Specified by:
isTCP
in interfacePEPeerTransport
-
getNetwork
public java.lang.String getNetwork()
- Specified by:
getNetwork
in interfacePEPeerTransport
-
getStats
public PEPeerStats getStats()
-
isIncoming
public boolean isIncoming()
- Specified by:
isIncoming
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
-
getBytesRemaining
public long getBytesRemaining()
- Specified by:
getBytesRemaining
in interfacePEPeer
-
getHandshakeReservedBytes
public byte[] getHandshakeReservedBytes()
- Specified by:
getHandshakeReservedBytes
in interfacePEPeer
-
isOptimisticUnchoke
public boolean isOptimisticUnchoke()
- Specified by:
isOptimisticUnchoke
in interfacePEPeer
-
setOptimisticUnchoke
public void setOptimisticUnchoke(boolean is_optimistic)
- Specified by:
setOptimisticUnchoke
in interfacePEPeer
-
getUniqueAnnounce
public int getUniqueAnnounce()
- Specified by:
getUniqueAnnounce
in interfacePEPeer
-
getUploadHint
public int getUploadHint()
- Specified by:
getUploadHint
in interfacePEPeer
-
setUniqueAnnounce
public void setUniqueAnnounce(int uniquePieceNumber)
- Specified by:
setUniqueAnnounce
in interfacePEPeer
-
setUploadHint
public void setUploadHint(int timeToSpread)
- Specified by:
setUploadHint
in interfacePEPeer
-
isStalledPendingLoad
public boolean isStalledPendingLoad()
Description copied from interface:PEPeerTransport
is peer waiting for a disk read with no network writes queued- Specified by:
isStalledPendingLoad
in interfacePEPeerTransport
- Returns:
-
addListener
public void addListener(PEPeerListener l)
Description copied from interface:PEPeer
Add peer listener.- Specified by:
addListener
in interfacePEPeer
-
removeListener
public void removeListener(PEPeerListener l)
Description copied from interface:PEPeer
Remove peer listener.- Specified by:
removeListener
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
-
getPercentDoneOfCurrentIncomingRequest
public int getPercentDoneOfCurrentIncomingRequest()
- Specified by:
getPercentDoneOfCurrentIncomingRequest
in interfacePEPeer
-
getPercentDoneOfCurrentOutgoingRequest
public int getPercentDoneOfCurrentOutgoingRequest()
- Specified by:
getPercentDoneOfCurrentOutgoingRequest
in interfacePEPeer
-
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
-
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)
To retreive arbitrary objects against a peer.- Specified by:
getUserData
in interfacePEPeer
-
setUserData
public void setUserData(java.lang.Object key, java.lang.Object value)
To store arbitrary objects against a peer.- Specified by:
setUserData
in interfacePEPeer
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
getReservedPieceNumbers
public int[] getReservedPieceNumbers()
Description copied from interface:PEPeer
Get the reserved pieces for piece picking by this peer- Specified by:
getReservedPieceNumbers
in interfacePEPeer
-
addReservedPieceNumber
public void addReservedPieceNumber(int piece_number)
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 piece_number)
- Specified by:
removeReservedPieceNumber
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
-
getIncomingRequestedPieceNumberCount
public int getIncomingRequestedPieceNumberCount()
- Specified by:
getIncomingRequestedPieceNumberCount
in interfacePEPeerTransport
-
getIncomingRequestCount
public int getIncomingRequestCount()
- Specified by:
getIncomingRequestCount
in interfacePEPeer
-
getOutgoingRequestCount
public int getOutgoingRequestCount()
- Specified by:
getOutgoingRequestCount
in interfacePEPeer
-
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
-
getLastPiece
public int getLastPiece()
- Specified by:
getLastPiece
in interfacePEPeer
-
setLastPiece
public void setLastPiece(int pieceNumber)
- Specified by:
setLastPiece
in interfacePEPeer
-
checkInterested
public void checkInterested()
Nothing to do if called- Specified by:
checkInterested
in interfacePEPeerTransport
-
isAvailabilityAdded
public boolean isAvailabilityAdded()
Apaprently nothing significant to do if called
-
clearAvailabilityAdded
public void clearAvailabilityAdded()
Nothing to do if called
-
reconnect
public PEPeerTransport reconnect(boolean tryUDP, boolean tryIPv6)
Description copied from interface:PEPeerTransport
Attempts to reconnect to the same peer- Specified by:
reconnect
in interfacePEPeerTransport
- Parameters:
tryUDP
- try to initate a UDP connection if true, just reestablish the previous state otherwisetryIPv6
- TODO- Returns:
- null if reconnect not possible, reconnected peer otherwise
-
isSafeForReconnect
public boolean isSafeForReconnect()
Description copied from interface:PEPeerTransport
This method is called to check if it is safe to reconnect to a peer, i.e. avoid hammering exchanging data with a peer should work as it takes time to setup the connection and negotiate things before that happens- Specified by:
isSafeForReconnect
in interfacePEPeerTransport
- Returns:
- true if we exchanged payload data with the peer during the current connection
-
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
-
updateAutoUploadPriority
public void updateAutoUploadPriority(java.lang.Object key, boolean inc)
- Specified by:
updateAutoUploadPriority
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
-
setHaveAggregationEnabled
public void setHaveAggregationEnabled(boolean enabled)
- Specified by:
setHaveAggregationEnabled
in interfacePEPeer
-
setPriorityConnection
public void setPriorityConnection(boolean is_priority)
- Specified by:
setPriorityConnection
in interfacePEPeer
-
isPriorityConnection
public boolean isPriorityConnection()
- Specified by:
isPriorityConnection
in interfacePEPeer
-
generateEvidence
public void generateEvidence(IndentWriter writer)
- Specified by:
generateEvidence
in interfacePEPeerTransport
-
getClientNameFromExtensionHandshake
public java.lang.String getClientNameFromExtensionHandshake()
- Specified by:
getClientNameFromExtensionHandshake
in interfacePEPeer
-
getClientNameFromPeerID
public java.lang.String getClientNameFromPeerID()
- Specified by:
getClientNameFromPeerID
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
-
-