Class ExternalSeedPeer
java.lang.Object
com.biglybt.plugin.extseed.ExternalSeedPeer
- All Implemented Interfaces:
Peer, ExternalSeedReaderListener
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate boolean[]private final ExternalSeedPeer.ESConnectionprivate Monitorprivate ConnectionStubprivate booleanprivate Downloadprivate booleanprivate CopyOnWriteList<PeerListener2> private Monitorprivate PeerManagerprivate booleanprivate byte[]private ExternalSeedPluginprivate ExternalSeedReaderprivate List<PeerReadRequest> private longprivate intprivate PeerStatsprivate MapFields 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
ConstructorsModifierConstructorDescriptionprotectedExternalSeedPeer(ExternalSeedPlugin _plugin, Download _download, ExternalSeedReader _reader) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(PeerListener2 listener) Add peer listener.protected voidaddPeer()voidaddRateLimiter(RateLimiter limiter, boolean is_upload) booleanaddRequest(PeerReadRequest request) voidbindConnection(ConnectionStub stub) voidcancelRequest(PeerReadRequest request) protected booleanvoidprotected voidfinal boolean[]Get the network connection that backs this peer.int[]int[]protected Downloadbyte[]byte[]getId()getIp()Get the peer's local TCP connection port.intgetName()intintint[]intintgetPort()int[]getRateLimiters(boolean is_upload) protected ExternalSeedReaderlongintgetState()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 connectionsgetURL()getUserData(Object key) booleanisChoked()booleanbooleanThis is much list isTransferAvailable(), except is more comprehensive.booleanbooleanbooleanbooleanbooleanisMyPeer()booleanfinal booleanisPieceAvailable(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()voidremoveListener(PeerListener2 listener) Remove peer listener.protected voidvoidremoveRateLimiter(RateLimiter limiter, boolean is_upload) voidbooleanrequestAllocationStarts(int[] base_priorities) voidrequestCancelled(PeerReadRequest request) voidrequestComplete(PeerReadRequest request, PooledByteBuffer data) voidrequestFailed(PeerReadRequest request) voidprotected booleansameAs(ExternalSeedPeer other) protected voidsetManager(PeerManager _manager) voidsetOptimisticUnchoke(boolean _is_optimistic) voidsetPriorityConnection(boolean is_priority) voidsetSnubbed(boolean b) protected voidsetState(int newState) voidsetUserData(Object key, Object value) booleanWhether or not this peer supports the advanced messaging API.longwriteBytes(long max)
-
Field Details
-
plugin
-
download
-
manager
-
connection_stub
-
stats
-
user_data
-
reader
-
state
private int state -
peer_id
private byte[] peer_id -
available
private boolean[] available -
availabilityAdded
private boolean availabilityAdded -
snubbed
private long snubbed -
is_optimistic
private boolean is_optimistic -
connection_mon
-
peer_added
private boolean peer_added -
request_list
-
listeners
-
listeners_mon
-
doing_allocations
private boolean doing_allocations -
connection
-
-
Constructor Details
-
ExternalSeedPeer
protected ExternalSeedPeer(ExternalSeedPlugin _plugin, Download _download, ExternalSeedReader _reader)
-
-
Method Details
-
sameAs
-
setManager
-
getManager
- Specified by:
getManagerin interfacePeer
-
getDownload
-
isMyPeer
-
bindConnection
- Specified by:
bindConnectionin interfacePeer
-
getReader
-
setState
protected void setState(int newState) -
checkConnection
protected boolean checkConnection() -
addPeer
protected void addPeer() -
removePeer
protected void removePeer() -
requestComplete
- Specified by:
requestCompletein interfaceExternalSeedReaderListener
-
requestCancelled
- Specified by:
requestCancelledin interfaceExternalSeedReaderListener
-
requestFailed
- Specified by:
requestFailedin interfaceExternalSeedReaderListener
-
getState
-
getId
-
getURL
-
getIp
-
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:
-
getPort
-
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 final 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
-
isOptimisticUnchoke
public boolean isOptimisticUnchoke()- Specified by:
isOptimisticUnchokein interfacePeer
-
setOptimisticUnchoke
public void setOptimisticUnchoke(boolean _is_optimistic) - Specified by:
setOptimisticUnchokein interfacePeer
-
getStats
-
isIncoming
public boolean isIncoming()- Specified by:
isIncomingin interfacePeer
-
getPercentDoneInThousandNotation
public int getPercentDoneInThousandNotation()- Specified by:
getPercentDoneInThousandNotationin interfacePeer
-
getClient
-
getExpiredRequests
- Specified by:
getExpiredRequestsin interfacePeer
-
getRequests
- Specified by:
getRequestsin interfacePeer
-
getMaximumNumberOfRequests
public int getMaximumNumberOfRequests()- Specified by:
getMaximumNumberOfRequestsin interfacePeer
-
getNumberOfRequests
public int getNumberOfRequests()- Specified by:
getNumberOfRequestsin 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
-
addRequest
- Specified by:
addRequestin interfacePeer
-
cancelRequest
- Specified by:
cancelRequestin interfacePeer
-
close
-
remove
public void remove() -
addListener
Description copied from interface:PeerAdd peer listener.- Specified by:
addListenerin interfacePeer- Parameters:
listener-
-
removeListener
Description copied from interface:PeerRemove peer listener.- Specified by:
removeListenerin interfacePeer- Parameters:
listener-
-
fireEvent
-
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
-
readBytes
-
writeBytes
public long writeBytes(long max) - Specified by:
writeBytesin interfacePeer
-
addRateLimiter
- Specified by:
addRateLimiterin interfacePeer- Parameters:
limiter- create via ConnectionManageris_upload- false -> download limit
-
removeRateLimiter
- Specified by:
removeRateLimiterin interfacePeer
-
getRateLimiters
- Specified by:
getRateLimitersin interfacePeer
-
getCurrentIncomingRequestProgress
public int[] getCurrentIncomingRequestProgress()- Specified by:
getCurrentIncomingRequestProgressin interfacePeer
-
getOutgoingRequestedPieceNumbers
public int[] getOutgoingRequestedPieceNumbers()- Specified by:
getOutgoingRequestedPieceNumbersin interfacePeer
-
getOutgoingRequestCount
public int getOutgoingRequestCount()- Specified by:
getOutgoingRequestCountin interfacePeer
-
getCurrentOutgoingRequestProgress
public int[] getCurrentOutgoingRequestProgress()- Specified by:
getCurrentOutgoingRequestProgressin interfacePeer
-
getProperties
-
getName
-
getDescriptor
- Specified by:
getDescriptorin interfacePeer
-
setUserData
- Specified by:
setUserDatain interfacePeer
-
getUserData
- Specified by:
getUserDatain interfacePeer
-
getHandshakeReservedBytes
public byte[] getHandshakeReservedBytes()- Specified by:
getHandshakeReservedBytesin interfacePeer
-
isPriorityConnection
public boolean isPriorityConnection()- Specified by:
isPriorityConnectionin interfacePeer
-
setPriorityConnection
public void setPriorityConnection(boolean is_priority) - Specified by:
setPriorityConnectionin interfacePeer
-