Class PeerImpl
java.lang.Object
com.biglybt.core.logging.LogRelation
com.biglybt.pifimpl.local.peers.PeerImpl
- All Implemented Interfaces:
Peer
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprotected PEPeerprotected PeerManagerImplprivate HashMap<PeerListener2, PEPeerListener> Fields inherited from interface Peer
CLOSING, CONNECTING, DISCONNECTED, HANDSHAKING, PR_FORCE_CONNECTION, PR_PEER_SOURCE, PR_PREFER_UTP, PR_PRIORITY_CONNECTION, PR_PROTOCOL, PR_PROTOCOL_QUALIFIER, TRANSFERING -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd peer listener.voidaddRateLimiter(RateLimiter limiter, boolean is_upload) booleanaddRequest(PeerReadRequest request) voidbindConnection(ConnectionStub stub) voidcancelRequest(PeerReadRequest request) voidprotected voidclosed()private voidbooleanfinal boolean[]Get the network connection that backs this peer.int[]int[]byte[]byte[]getId()getIp()Get the peer's local TCP connection port.intintintint[]Core use only.intintgetPort()int[]Object[]Query this class for a reference to another class that it may holdgetRateLimiters(boolean is_upload) A short description of what your class holds that can be printed by the loggerlongintgetState()getStats()Message[]Get the list of messages that this peer and us mutually understand.intGet 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 connectionsgetUserData(Object key) inthashCode()voidbooleanisChoked()booleanbooleanThis is much list isTransferAvailable(), except is more comprehensive.booleanbooleanbooleanbooleanbooleanisMyPeer()booleanbooleanisPieceAvailable(int pieceNumber) booleanbooleanisSeed()booleanbooleanlongreadBytes(long max) Rate control - gives the maximum number of bytes that can be read from this connection at this time and returns the actual number readvoidRemove peer listener.voidremoveRateLimiter(RateLimiter limiter, boolean is_upload) voidbooleanrequestAllocationStarts(int[] base_priorities) voidvoidsetOptimisticUnchoke(boolean is_optimistic) voidsetPriorityConnection(boolean is_priority) voidsetSnubbed(boolean b) voidsetUserData(Object key, Object value) booleanWhether or not this peer supports the advanced messaging API.longwriteBytes(long max) Methods inherited from class LogRelation
propogatedRelationText, queryForClass
-
Field Details
-
manager
-
delegate
-
peer_listeners
-
up_rg_listener
-
down_rg_listener
-
closed
private volatile boolean closed
-
-
Constructor Details
-
PeerImpl
don't use me, use PeerManagerImpl.getPeerForPEPeer- Parameters:
_delegate-
-
-
Method Details
-
bindConnection
- Specified by:
bindConnectionin interfacePeer
-
getManager
- Specified by:
getManagerin interfacePeer
-
getDelegate
-
getConnection
Description copied from interface:PeerGet the network connection that backs this peer.- Specified by:
getConnectionin interfacePeer- Returns:
- connection
-
supportsMessaging
public boolean supportsMessaging()Description copied from interface:PeerWhether or not this peer supports the advanced messaging API.- Specified by:
supportsMessagingin interfacePeer- Returns:
- true if extended messaging is supported, false if not
-
getSupportedMessages
Description copied from interface:PeerGet the list of messages that this peer and us mutually understand.- Specified by:
getSupportedMessagesin interfacePeer- Returns:
- messages available for use, or null of supported is yet unknown
-
getState
-
isMyPeer
-
getId
-
getIp
-
getPort
-
getTCPListenPort
public int getTCPListenPort()Description copied from interface:PeerGet the TCP port this peer is listening for incoming connections on.- Specified by:
getTCPListenPortin interfacePeer- Returns:
- TCP port, or 0 if port is unknown
-
getUDPListenPort
public int getUDPListenPort()Description copied from interface:PeerGet the UDP port this peer is listening for incoming connections on.- Specified by:
getUDPListenPortin interfacePeer- Returns:
- UDP port, or 0 if port is unknown
-
getUDPNonDataListenPort
public int getUDPNonDataListenPort()Description copied from interface:PeerGet the UDP port this peer is listening on for non-data connections- Specified by:
getUDPNonDataListenPortin interfacePeer- Returns:
-
isLANLocal
public boolean isLANLocal()- Specified by:
isLANLocalin interfacePeer
-
resetLANLocalStatus
public void resetLANLocalStatus()- Specified by:
resetLANLocalStatusin interfacePeer
-
getAvailable
public final boolean[] getAvailable()- Specified by:
getAvailablein interfacePeer
-
isPieceAvailable
public boolean isPieceAvailable(int pieceNumber) - Specified by:
isPieceAvailablein interfacePeer- Parameters:
pieceNumber- int- Returns:
- true if this peers makes this piece available
-
isTransferAvailable
public boolean isTransferAvailable()- Specified by:
isTransferAvailablein interfacePeer
-
isDownloadPossible
public boolean isDownloadPossible()Description copied from interface:PeerThis is much list isTransferAvailable(), except is more comprehensive. That is; it checks a few more factors, within the object for speed, so that a more timely status is considered and the caller doesn't need to try to check each thing on it's own.- Specified by:
isDownloadPossiblein interfacePeer- Returns:
- true if several factors say downloading can be tried.
-
isChoked
-
isChoking
-
isInterested
public boolean isInterested()- Specified by:
isInterestedin interfacePeer
-
isInteresting
public boolean isInteresting()- Specified by:
isInterestingin interfacePeer
-
isSeed
-
isSnubbed
-
getSnubbedTime
public long getSnubbedTime()- Specified by:
getSnubbedTimein interfacePeer
-
setSnubbed
public void setSnubbed(boolean b) - Specified by:
setSnubbedin interfacePeer
-
getStats
-
isIncoming
public boolean isIncoming()- Specified by:
isIncomingin interfacePeer
-
getOutgoingRequestCount
public int getOutgoingRequestCount()- Specified by:
getOutgoingRequestCountin interfacePeer
-
getOutgoingRequestedPieceNumbers
public int[] getOutgoingRequestedPieceNumbers()- Specified by:
getOutgoingRequestedPieceNumbersin interfacePeer
-
getPercentDoneInThousandNotation
public int getPercentDoneInThousandNotation()- Specified by:
getPercentDoneInThousandNotationin interfacePeer
-
getClient
-
isOptimisticUnchoke
public boolean isOptimisticUnchoke()- Specified by:
isOptimisticUnchokein interfacePeer
-
setOptimisticUnchoke
public void setOptimisticUnchoke(boolean is_optimistic) - Specified by:
setOptimisticUnchokein interfacePeer
-
initialize
public void initialize() -
getExpiredRequests
- Specified by:
getExpiredRequestsin interfacePeer
-
getRequests
- Specified by:
getRequestsin interfacePeer
-
getNumberOfRequests
public int getNumberOfRequests()- Specified by:
getNumberOfRequestsin interfacePeer
-
getMaximumNumberOfRequests
public int getMaximumNumberOfRequests()- Specified by:
getMaximumNumberOfRequestsin interfacePeer
-
getPriorityOffsets
public int[] getPriorityOffsets()- Specified by:
getPriorityOffsetsin interfacePeer
-
requestAllocationStarts
public boolean requestAllocationStarts(int[] base_priorities) - Specified by:
requestAllocationStartsin interfacePeer
-
requestAllocationComplete
public void requestAllocationComplete()- Specified by:
requestAllocationCompletein interfacePeer
-
cancelRequest
- Specified by:
cancelRequestin interfacePeer
-
addRequest
- Specified by:
addRequestin interfacePeer
-
createRGListeners
private void createRGListeners() -
addRateLimiter
- Specified by:
addRateLimiterin interfacePeer- Parameters:
limiter- create via ConnectionManageris_upload- false -> download limit
-
removeRateLimiter
- Specified by:
removeRateLimiterin interfacePeer
-
getRateLimiters
- Specified by:
getRateLimitersin interfacePeer
-
close
-
readBytes
-
writeBytes
public long writeBytes(long max) - Specified by:
writeBytesin interfacePeer
-
closed
protected void closed() -
getCurrentIncomingRequestProgress
public int[] getCurrentIncomingRequestProgress()- Specified by:
getCurrentIncomingRequestProgressin interfacePeer
-
getCurrentOutgoingRequestProgress
public int[] getCurrentOutgoingRequestProgress()- Specified by:
getCurrentOutgoingRequestProgressin interfacePeer
-
addListener
Description copied from interface:PeerAdd peer listener.- Specified by:
addListenerin interfacePeer- Parameters:
l-
-
removeListener
Description copied from interface:PeerRemove peer listener.- Specified by:
removeListenerin interfacePeer- Parameters:
l-
-
isPriorityConnection
public boolean isPriorityConnection()- Specified by:
isPriorityConnectionin interfacePeer
-
setPriorityConnection
public void setPriorityConnection(boolean is_priority) - Specified by:
setPriorityConnectionin interfacePeer
-
setUserData
- Specified by:
setUserDatain interfacePeer
-
getUserData
- Specified by:
getUserDatain interfacePeer
-
equals
-
hashCode
-
getPEPeer
Core use only. This is not propogated to the plugin interface- Returns:
- PEPeer object associated with the plugin Peer object
-
getRelationText
Description copied from class:LogRelationA short description of what your class holds that can be printed by the logger- Overrides:
getRelationTextin classLogRelation- Returns:
-
getQueryableInterfaces
Description copied from class:LogRelationQuery this class for a reference to another class that it may hold- Overrides:
getQueryableInterfacesin classLogRelation- Returns:
- If found, the class desired. Otherwise, null.
-
getHandshakeReservedBytes
public byte[] getHandshakeReservedBytes()- Specified by:
getHandshakeReservedBytesin interfacePeer
-
getDescriptor
- Specified by:
getDescriptorin interfacePeer
-