Package com.biglybt.plugin.extseed
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 boolean
private boolean[]
private final ExternalSeedPeer.ESConnection
private Monitor
private ConnectionStub
private boolean
private Download
private boolean
private CopyOnWriteList<PeerListener2>
private Monitor
private PeerManager
private boolean
private byte[]
private ExternalSeedPlugin
private ExternalSeedReader
private List<PeerReadRequest>
private long
private int
private PeerStats
private Map
Fields inherited from interface com.biglybt.pif.peers.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
ConstructorsModifierConstructorDescriptionprotected
ExternalSeedPeer
(ExternalSeedPlugin _plugin, Download _download, ExternalSeedReader _reader) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(PeerListener2 listener) Add peer listener.protected void
addPeer()
void
addRateLimiter
(RateLimiter limiter, boolean is_upload) boolean
addRequest
(PeerReadRequest request) void
bindConnection
(ConnectionStub stub) void
cancelRequest
(PeerReadRequest request) protected boolean
void
protected void
final boolean[]
Get the network connection that backs this peer.int[]
int[]
protected Download
byte[]
byte[]
getId()
getIp()
Get the peer's local TCP connection port.int
getName()
int
int
int[]
int
int
getPort()
int[]
getRateLimiters
(boolean is_upload) protected ExternalSeedReader
long
int
getState()
getStats()
Message[]
Get the list of messages that this peer and us mutually understand.int
Get the TCP port this peer is listening for incoming connections on.int
Get the UDP port this peer is listening for incoming connections on.int
Get the UDP port this peer is listening on for non-data connectionsgetURL()
getUserData
(Object key) boolean
isChoked()
boolean
boolean
This is much list isTransferAvailable(), except is more comprehensive.boolean
boolean
boolean
boolean
boolean
isMyPeer()
boolean
final boolean
isPieceAvailable
(int pieceNumber) boolean
boolean
isSeed()
boolean
boolean
int
readBytes
(int max) Rate control - gives the maximum number of bytes that can be read from this connection at this time and returns the actual number readvoid
remove()
void
removeListener
(PeerListener2 listener) Remove peer listener.protected void
void
removeRateLimiter
(RateLimiter limiter, boolean is_upload) void
boolean
requestAllocationStarts
(int[] base_priorities) void
requestCancelled
(PeerReadRequest request) void
requestComplete
(PeerReadRequest request, PooledByteBuffer data) void
requestFailed
(PeerReadRequest request) void
protected boolean
sameAs
(ExternalSeedPeer other) protected void
setManager
(PeerManager _manager) void
setOptimisticUnchoke
(boolean _is_optimistic) void
setPriorityConnection
(boolean is_priority) void
setSnubbed
(boolean b) protected void
setState
(int newState) void
setUserData
(Object key, Object value) boolean
Whether or not this peer supports the advanced messaging API.int
writeBytes
(int 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:
getManager
in interfacePeer
-
getDownload
-
isMyPeer
public boolean isMyPeer() -
bindConnection
- Specified by:
bindConnection
in interfacePeer
-
getReader
-
setState
protected void setState(int newState) -
checkConnection
protected boolean checkConnection() -
addPeer
protected void addPeer() -
removePeer
protected void removePeer() -
requestComplete
- Specified by:
requestComplete
in interfaceExternalSeedReaderListener
-
requestCancelled
- Specified by:
requestCancelled
in interfaceExternalSeedReaderListener
-
requestFailed
- Specified by:
requestFailed
in interfaceExternalSeedReaderListener
-
getState
public int getState() -
getId
public byte[] getId() -
getURL
-
getIp
Description copied from interface:Peer
Get the peer's local TCP connection port. -
getTCPListenPort
public int getTCPListenPort()Description copied from interface:Peer
Get the TCP port this peer is listening for incoming connections on.- Specified by:
getTCPListenPort
in interfacePeer
- Returns:
- TCP port, or 0 if port is unknown
-
getUDPListenPort
public int getUDPListenPort()Description copied from interface:Peer
Get the UDP port this peer is listening for incoming connections on.- Specified by:
getUDPListenPort
in interfacePeer
- Returns:
- UDP port, or 0 if port is unknown
-
getUDPNonDataListenPort
public int getUDPNonDataListenPort()Description copied from interface:Peer
Get the UDP port this peer is listening on for non-data connections- Specified by:
getUDPNonDataListenPort
in interfacePeer
- Returns:
-
getPort
public int getPort() -
isLANLocal
public boolean isLANLocal()- Specified by:
isLANLocal
in interfacePeer
-
resetLANLocalStatus
public void resetLANLocalStatus()- Specified by:
resetLANLocalStatus
in interfacePeer
-
getAvailable
public final boolean[] getAvailable()- Specified by:
getAvailable
in interfacePeer
-
isPieceAvailable
public final boolean isPieceAvailable(int pieceNumber) - Specified by:
isPieceAvailable
in interfacePeer
- Parameters:
pieceNumber
- int- Returns:
- true if this peers makes this piece available
-
isTransferAvailable
public boolean isTransferAvailable()- Specified by:
isTransferAvailable
in interfacePeer
-
isDownloadPossible
public boolean isDownloadPossible()Description copied from interface:Peer
This 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:
isDownloadPossible
in interfacePeer
- Returns:
- true if several factors say downloading can be tried.
-
isChoked
public boolean isChoked() -
isChoking
public boolean isChoking() -
isInterested
public boolean isInterested()- Specified by:
isInterested
in interfacePeer
-
isInteresting
public boolean isInteresting()- Specified by:
isInteresting
in interfacePeer
-
isSeed
public boolean isSeed() -
isSnubbed
public boolean isSnubbed() -
getSnubbedTime
public long getSnubbedTime()- Specified by:
getSnubbedTime
in interfacePeer
-
setSnubbed
public void setSnubbed(boolean b) - Specified by:
setSnubbed
in interfacePeer
-
isOptimisticUnchoke
public boolean isOptimisticUnchoke()- Specified by:
isOptimisticUnchoke
in interfacePeer
-
setOptimisticUnchoke
public void setOptimisticUnchoke(boolean _is_optimistic) - Specified by:
setOptimisticUnchoke
in interfacePeer
-
getStats
-
isIncoming
public boolean isIncoming()- Specified by:
isIncoming
in interfacePeer
-
getPercentDoneInThousandNotation
public int getPercentDoneInThousandNotation()- Specified by:
getPercentDoneInThousandNotation
in interfacePeer
-
getClient
-
getExpiredRequests
- Specified by:
getExpiredRequests
in interfacePeer
-
getRequests
- Specified by:
getRequests
in interfacePeer
-
getMaximumNumberOfRequests
public int getMaximumNumberOfRequests()- Specified by:
getMaximumNumberOfRequests
in interfacePeer
-
getNumberOfRequests
public int getNumberOfRequests()- Specified by:
getNumberOfRequests
in interfacePeer
-
getPriorityOffsets
public int[] getPriorityOffsets()- Specified by:
getPriorityOffsets
in interfacePeer
-
requestAllocationStarts
public boolean requestAllocationStarts(int[] base_priorities) - Specified by:
requestAllocationStarts
in interfacePeer
-
requestAllocationComplete
public void requestAllocationComplete()- Specified by:
requestAllocationComplete
in interfacePeer
-
addRequest
- Specified by:
addRequest
in interfacePeer
-
cancelRequest
- Specified by:
cancelRequest
in interfacePeer
-
close
-
remove
public void remove() -
addListener
Description copied from interface:Peer
Add peer listener.- Specified by:
addListener
in interfacePeer
-
removeListener
Description copied from interface:Peer
Remove peer listener.- Specified by:
removeListener
in interfacePeer
-
fireEvent
-
getConnection
Description copied from interface:Peer
Get the network connection that backs this peer.- Specified by:
getConnection
in interfacePeer
- Returns:
- connection
-
supportsMessaging
public boolean supportsMessaging()Description copied from interface:Peer
Whether or not this peer supports the advanced messaging API.- Specified by:
supportsMessaging
in interfacePeer
- Returns:
- true if extended messaging is supported, false if not
-
getSupportedMessages
Description copied from interface:Peer
Get the list of messages that this peer and us mutually understand.- Specified by:
getSupportedMessages
in interfacePeer
- Returns:
- messages available for use, or null of supported is yet unknown
-
readBytes
public int readBytes(int max) Description copied from interface:Peer
Rate control - gives the maximum number of bytes that can be read from this connection at this time and returns the actual number read -
writeBytes
public int writeBytes(int max) - Specified by:
writeBytes
in interfacePeer
-
addRateLimiter
- Specified by:
addRateLimiter
in interfacePeer
- Parameters:
limiter
- create via ConnectionManageris_upload
- false -> download limit
-
removeRateLimiter
- Specified by:
removeRateLimiter
in interfacePeer
-
getRateLimiters
- Specified by:
getRateLimiters
in interfacePeer
-
getCurrentIncomingRequestProgress
public int[] getCurrentIncomingRequestProgress()- Specified by:
getCurrentIncomingRequestProgress
in interfacePeer
-
getOutgoingRequestedPieceNumbers
public int[] getOutgoingRequestedPieceNumbers()- Specified by:
getOutgoingRequestedPieceNumbers
in interfacePeer
-
getOutgoingRequestCount
public int getOutgoingRequestCount()- Specified by:
getOutgoingRequestCount
in interfacePeer
-
getCurrentOutgoingRequestProgress
public int[] getCurrentOutgoingRequestProgress()- Specified by:
getCurrentOutgoingRequestProgress
in interfacePeer
-
getProperties
-
getName
-
setUserData
- Specified by:
setUserData
in interfacePeer
-
getUserData
- Specified by:
getUserData
in interfacePeer
-
getHandshakeReservedBytes
public byte[] getHandshakeReservedBytes()- Specified by:
getHandshakeReservedBytes
in interfacePeer
-
isPriorityConnection
public boolean isPriorityConnection()- Specified by:
isPriorityConnection
in interfacePeer
-
setPriorityConnection
public void setPriorityConnection(boolean is_priority) - Specified by:
setPriorityConnection
in interfacePeer
-