Package com.biglybt.core.peer.impl
Interface PEPeerTransport
-
- All Known Implementing Classes:
PeerForeignDelegate
,PEPeerTransportProtocol
public interface PEPeerTransport extends PEPeer
-
-
Field Summary
Fields Modifier and Type Field Description static int
CONNECTION_CONNECTING
static int
CONNECTION_FULLY_ESTABLISHED
static int
CONNECTION_PENDING
static int
CONNECTION_WAITING_FOR_HANDSHAKE
static int
CP_CONNECT_FAILED
static int
CP_CONNECT_OK
static int
CP_CONNECTING
static int
CP_RECEIVED_DATA
static int
CP_UNKNOWN
-
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
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
checkInterested()
if it doesn't go as expected when trying to find a piece to ask a peer for, need to double check if we're still interested in them, and get the BT protocol sycnhedvoid
closeConnection(java.lang.String reason)
Close the peer connectionvoid
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.void
generateEvidence(IndentWriter writer)
int
getConnectionState()
Get the specific peer connection state.PEPeerControl
getControl()
java.util.List
getExpiredRequests()
int
getIncomingRequestedPieceNumberCount()
long
getLastMessageSentTime()
long
getLatency()
int
getMaxNbRequests()
peer-specific request max.int
getNbRequests()
java.lang.String
getNetwork()
int
getOutboundConnectionProgress()
PeerItem
getPeerItemIdentity()
Get the peer's address + port identification item.int[]
getPriorityOffsets()
Any priority offsets this peer has, or null if noneint
getRequestIndex(DiskManagerReadRequest request)
Returns the index of this request in the peer's queue or -1 if not foundlong
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.long
getUnchokedForMillis()
boolean
isLANLocal()
Is the connection within the local LAN network.boolean
isSafeForReconnect()
This method is called to check if it is safe to reconnect to a peer, i.e.boolean
isStalledPendingLoad()
is peer waiting for a disk read with no network writes queuedboolean
isTCP()
PEPeerTransport
reconnect(boolean tryUDP, boolean tryIPv6)
Attempts to reconnect to the same peerDiskManagerReadRequest
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
sendBadPiece(int piece_number)
void
sendCancel(DiskManagerReadRequest request)
void
sendChoke()
void
sendHashRequest(TOTorrentFileHashTree.HashRequest req)
void
sendHave(int piece)
void
sendStatsReply(java.util.Map reply)
void
sendStatsRequest(java.util.Map request)
void
sendUnChoke()
void
start()
Start message processing for the peerboolean
transferAvailable()
void
updatePeerExchange()
Do any peer exchange processing/updating.-
Methods inherited from interface com.biglybt.core.peer.PEPeer
addListener, addRateLimiter, addReservedPieceNumber, clearRequestHint, getAlternativeIPv6, getAvailable, getBytesRemaining, getClient, getClientNameFromExtensionHandshake, getClientNameFromPeerID, getConsecutiveNoRequestCount, getData, getDownloadRateLimitBytesPerSecond, getEncryption, getHandshakeReservedBytes, getId, getIncomingRequestCount, getIncomingRequestedPieceNumbers, getIp, getIPHostName, getLastPiece, getManager, getMessagingMode, getNetworkConnection, getOutgoingRequestCount, getOutgoingRequestedPieceNumbers, getPeerSource, getPeerState, getPercentDoneInThousandNotation, getPercentDoneOfCurrentIncomingRequest, getPercentDoneOfCurrentOutgoingRequest, getPluginConnection, getPort, getProtocol, getProtocolQualifier, getRateLimiters, getRecentPiecesSent, getRequestHint, getReservedPieceNumbers, getSnubbedTime, getStats, getSupportedMessages, getTCPListenPort, getTimeSinceConnectionEstablished, getUDPListenPort, getUDPNonDataListenPort, getUniqueAnnounce, getUploadHint, getUploadRateLimitBytesPerSecond, getUserData, hasReceivedBitField, isChokedByMe, isChokingMe, isClosed, isDownloadDisabled, isDownloadPossible, isIncoming, isInterested, isInteresting, isMyPeer, isOptimisticUnchoke, isPieceAvailable, isPriorityConnection, isRelativeSeed, isSeed, isSnubbed, isUnchokeOverride, isUploadDisabled, removeListener, removeRateLimiter, removeReservedPieceNumber, resetLANLocalStatus, sendRejectRequest, sendRequestHint, setConsecutiveNoRequestCount, setData, setDownloadDisabled, setDownloadRateLimitBytesPerSecond, setHaveAggregationEnabled, setLastPiece, setOptimisticUnchoke, setPriorityConnection, setSnubbed, setSuspendedLazyBitFieldEnabled, setUniqueAnnounce, setUploadDisabled, setUploadHint, setUploadRateLimitBytesPerSecond, setUserData, supportsMessaging, updateAutoUploadPriority
-
Methods inherited from interface com.biglybt.core.tag.Taggable
getTaggableID, getTaggableName, getTaggableResolver, getTaggableTransientProperty, getTaggableType, setTaggableTransientProperty
-
-
-
-
Field Detail
-
CONNECTION_PENDING
static final int CONNECTION_PENDING
- See Also:
- Constant Field Values
-
CONNECTION_CONNECTING
static final int CONNECTION_CONNECTING
- See Also:
- Constant Field Values
-
CONNECTION_WAITING_FOR_HANDSHAKE
static final int CONNECTION_WAITING_FOR_HANDSHAKE
- See Also:
- Constant Field Values
-
CONNECTION_FULLY_ESTABLISHED
static final int CONNECTION_FULLY_ESTABLISHED
- See Also:
- Constant Field Values
-
CP_UNKNOWN
static final int CP_UNKNOWN
- See Also:
- Constant Field Values
-
CP_CONNECTING
static final int CP_CONNECTING
- See Also:
- Constant Field Values
-
CP_CONNECT_OK
static final int CP_CONNECT_OK
- See Also:
- Constant Field Values
-
CP_CONNECT_FAILED
static final int CP_CONNECT_FAILED
- See Also:
- Constant Field Values
-
CP_RECEIVED_DATA
static final int CP_RECEIVED_DATA
- See Also:
- Constant Field Values
-
-
Method Detail
-
getOutboundConnectionProgress
int getOutboundConnectionProgress()
-
start
void start()
Start message processing for the peer
-
sendUnChoke
void sendUnChoke()
- Specified by:
sendUnChoke
in interfacePEPeer
-
sendHave
void sendHave(int piece)
-
sendCancel
void sendCancel(DiskManagerReadRequest request)
-
sendBadPiece
void sendBadPiece(int piece_number)
-
sendStatsRequest
void sendStatsRequest(java.util.Map request)
- Specified by:
sendStatsRequest
in interfacePEPeer
-
sendStatsReply
void sendStatsReply(java.util.Map reply)
-
requestAllocationStarts
boolean requestAllocationStarts(int[] base_priorities)
Two methods that allow a peer to aggregate the individual requests generated during an allocation cycle if so desired- Returns:
- true if the peer is managing request priorities and doesn't want end-game random allocation behaviour
-
requestAllocationComplete
void requestAllocationComplete()
-
request
DiskManagerReadRequest request(int pieceNumber, int pieceOffset, int pieceLength, boolean return_duplicates)
- Parameters:
pieceNumber
-pieceOffset
-pieceLength
-return_duplicates
- - if true and request already exists it will be returned, if false -> null- Returns:
- request if actually requested, null otherwise
-
getRequestIndex
int getRequestIndex(DiskManagerReadRequest request)
Returns the index of this request in the peer's queue or -1 if not found- Returns:
-
closeConnection
void closeConnection(java.lang.String reason)
Close the peer connection- Parameters:
reason
- for closure
-
transferAvailable
boolean transferAvailable()
- Specified by:
transferAvailable
in interfacePEPeer
-
getLastMessageSentTime
long getLastMessageSentTime()
-
getExpiredRequests
java.util.List getExpiredRequests()
-
getMaxNbRequests
int getMaxNbRequests()
peer-specific request max. return -1 to use the default piece-picker allocation method- Returns:
-
getNbRequests
int getNbRequests()
-
getControl
PEPeerControl getControl()
-
getPriorityOffsets
int[] getPriorityOffsets()
Any priority offsets this peer has, or null if none- Returns:
-
doKeepAliveCheck
void doKeepAliveCheck()
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.
-
doTimeoutChecks
boolean doTimeoutChecks()
Check for possible connection timeouts.- Returns:
- true if the connection has been timed-out, false if not
-
doPerformanceTuningCheck
void doPerformanceTuningCheck()
Perform checks related to performance optimizations, i.e. tune buffering related to send/receive speed.
-
getConnectionState
int getConnectionState()
Get the specific peer connection state.- Returns:
- connection state
-
getTimeSinceLastDataMessageReceived
long getTimeSinceLastDataMessageReceived()
Get the time since the last (most-recent) data (payload) message was received.- Returns:
- time count in ms, or -1 if we've never received a data message from them
-
getTimeSinceGoodDataReceived
long getTimeSinceGoodDataReceived()
Get the time since the most-recent data that was actually written to disk was received.- Returns:
- time count in ms, or -1 if we've never received usefull data from them
-
getTimeSinceLastDataMessageSent
long getTimeSinceLastDataMessageSent()
Get the time since the last (most-recent) data (payload) message was sent.- Returns:
- time count in ms, or -1 if we've never sent them a data message
-
getUnchokedForMillis
long getUnchokedForMillis()
-
getLatency
long getLatency()
-
updatePeerExchange
void updatePeerExchange()
Do any peer exchange processing/updating.
-
getPeerItemIdentity
PeerItem getPeerItemIdentity()
Get the peer's address + port identification item.- Returns:
- id
-
isStalledPendingLoad
boolean isStalledPendingLoad()
is peer waiting for a disk read with no network writes queued- Returns:
-
isLANLocal
boolean isLANLocal()
Is the connection within the local LAN network.- Specified by:
isLANLocal
in interfacePEPeer
- Returns:
- true if within LAN, false of outside the LAN segment
-
isTCP
boolean isTCP()
-
checkInterested
void checkInterested()
if it doesn't go as expected when trying to find a piece to ask a peer for, need to double check if we're still interested in them, and get the BT protocol sycnhed
-
reconnect
PEPeerTransport reconnect(boolean tryUDP, boolean tryIPv6)
Attempts to reconnect to the same peer- 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
-
getIncomingRequestedPieceNumberCount
int getIncomingRequestedPieceNumberCount()
-
isSafeForReconnect
boolean isSafeForReconnect()
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- Returns:
- true if we exchanged payload data with the peer during the current connection
-
getNetwork
java.lang.String getNetwork()
-
sendHashRequest
void sendHashRequest(TOTorrentFileHashTree.HashRequest req)
-
generateEvidence
void generateEvidence(IndentWriter writer)
-
-