Class PEPeerControlImpl.MyPeer

java.lang.Object
com.biglybt.core.peer.impl.control.PEPeerControlImpl.MyPeer
All Implemented Interfaces:
PEPeer, Taggable, Taggable
Enclosing class:
PEPeerControlImpl

private class PEPeerControlImpl.MyPeer extends Object implements PEPeer
  • Field Details

    • user_data

      private final Map<Object,Object> user_data
    • stats

      private final PEPeerStats stats
    • last_active

      private volatile long last_active
    • incoming_request_count

      private volatile int incoming_request_count
    • outgoing_request_count

      private volatile int outgoing_request_count
    • incoming_requested_pieces

      private volatile int[] incoming_requested_pieces
    • outgoing_requested_pieces

      private volatile int[] outgoing_requested_pieces
  • Constructor Details

    • MyPeer

      private MyPeer()
  • Method Details

    • update

      private void update()
    • setActive

      private void setActive()
    • isMyPeer

      public boolean isMyPeer()
      Description copied from interface: PEPeer
      Whether or not this is a 'dummy' peer that represents our presence in a swarm
      Specified by:
      isMyPeer in interface PEPeer
      Returns:
    • addListener

      public void addListener(PEPeerListener listener)
      Description copied from interface: PEPeer
      Add peer listener.
      Specified by:
      addListener in interface PEPeer
      Parameters:
      listener -
    • removeListener

      public void removeListener(PEPeerListener listener)
      Description copied from interface: PEPeer
      Remove peer listener.
      Specified by:
      removeListener in interface PEPeer
      Parameters:
      listener -
    • getPeerState

      public int getPeerState()
      Specified by:
      getPeerState in interface PEPeer
    • getManager

      public PEPeerManager getManager()
      Specified by:
      getManager in interface PEPeer
    • getPeerSource

      public String getPeerSource()
      Specified by:
      getPeerSource in interface PEPeer
    • getId

      public byte[] getId()
      Specified by:
      getId in interface PEPeer
    • getIp

      public String getIp()
      Specified by:
      getIp in interface PEPeer
    • getAlternativeIPv6

      public InetAddress getAlternativeIPv6()
      Specified by:
      getAlternativeIPv6 in interface PEPeer
      Returns:
      an ipv6 address under which the peer should be connectable if it announced one, null otherwise
    • getPort

      public int getPort()
      Description copied from interface: PEPeer
      Get the peer's local TCP connection port.
      Specified by:
      getPort in interface PEPeer
      Returns:
      local port
    • getIPHostName

      public String getIPHostName()
      Description copied from interface: PEPeer
      Gets the host name for the IP, if possible, IP as string otherwise
      Specified by:
      getIPHostName in interface PEPeer
      Returns:
      hostname or IP
    • 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 interface PEPeer
      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 interface PEPeer
      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 interface PEPeer
      Returns:
    • getAvailable

      public BitFlags getAvailable()
      Specified by:
      getAvailable in interface PEPeer
    • isPieceAvailable

      public boolean isPieceAvailable(int pieceNumber)
      Specified by:
      isPieceAvailable in interface PEPeer
      Parameters:
      pieceNumber - int
      Returns:
      true if this peers makes this piece available
    • transferAvailable

      public boolean transferAvailable()
      Specified by:
      transferAvailable in interface PEPeer
    • setSnubbed

      public void setSnubbed(boolean b)
      Specified by:
      setSnubbed in interface PEPeer
    • isChokingMe

      public boolean isChokingMe()
      Description copied from interface: PEPeer
      Is the peer choking me.
      Specified by:
      isChokingMe in interface PEPeer
      Returns:
      true if I am choked by the peer, false if not
    • isUnchokeOverride

      public boolean isUnchokeOverride()
      Specified by:
      isUnchokeOverride in interface PEPeer
    • isChokedByMe

      public boolean isChokedByMe()
      Description copied from interface: PEPeer
      Am I choking the peer.
      Specified by:
      isChokedByMe in interface PEPeer
      Returns:
      true if the peer is choked, false if not
    • sendChoke

      public void sendChoke()
      Specified by:
      sendChoke in interface PEPeer
    • sendUnChoke

      public void sendUnChoke()
      Specified by:
      sendUnChoke in interface PEPeer
    • isInteresting

      public boolean isInteresting()
      Description copied from interface: PEPeer
      Am I Interested in the peer.
      Specified by:
      isInteresting in interface PEPeer
      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 interface PEPeer
      Returns:
      true if the peer is interested in me, false if not
    • isDownloadPossible

      public boolean isDownloadPossible()
      Description copied from interface: PEPeer
      checks several factors within the object so the caller wouldn't need to for convenience and speed.
      Specified by:
      isDownloadPossible in interface PEPeer
      Returns:
      true if none of several criteria indicate a request can't be made of the peer
    • isSeed

      public boolean isSeed()
      Specified by:
      isSeed in interface PEPeer
    • isRelativeSeed

      public boolean isRelativeSeed()
      Specified by:
      isRelativeSeed in interface PEPeer
      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)
    • isSnubbed

      public boolean isSnubbed()
      Specified by:
      isSnubbed in interface PEPeer
    • getSnubbedTime

      public long getSnubbedTime()
      Specified by:
      getSnubbedTime in interface PEPeer
    • getStats

      public PEPeerStats getStats()
      Specified by:
      getStats in interface PEPeer
    • isIncoming

      public boolean isIncoming()
      Specified by:
      isIncoming in interface PEPeer
    • hasReceivedBitField

      public boolean hasReceivedBitField()
      Specified by:
      hasReceivedBitField in interface PEPeer
    • 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 interface PEPeer
      Returns:
      the percentage the peer has complete
    • getClient

      public String getClient()
      Specified by:
      getClient in interface PEPeer
    • isOptimisticUnchoke

      public boolean isOptimisticUnchoke()
      Specified by:
      isOptimisticUnchoke in interface PEPeer
    • setOptimisticUnchoke

      public void setOptimisticUnchoke(boolean is_optimistic)
      Specified by:
      setOptimisticUnchoke in interface PEPeer
    • setUploadHint

      public void setUploadHint(int timeToSpread)
      Specified by:
      setUploadHint in interface PEPeer
    • getUploadHint

      public int getUploadHint()
      Specified by:
      getUploadHint in interface PEPeer
    • setUniqueAnnounce

      public void setUniqueAnnounce(int uniquePieceNumber)
      Specified by:
      setUniqueAnnounce in interface PEPeer
    • getUniqueAnnounce

      public int getUniqueAnnounce()
      Specified by:
      getUniqueAnnounce in interface PEPeer
    • getConsecutiveNoRequestCount

      public int getConsecutiveNoRequestCount()
      Specified by:
      getConsecutiveNoRequestCount in interface PEPeer
    • setConsecutiveNoRequestCount

      public void setConsecutiveNoRequestCount(int num)
      Specified by:
      setConsecutiveNoRequestCount in interface PEPeer
    • setUploadRateLimitBytesPerSecond

      public void setUploadRateLimitBytesPerSecond(int bytes)
      Specified by:
      setUploadRateLimitBytesPerSecond in interface PEPeer
    • setDownloadRateLimitBytesPerSecond

      public void setDownloadRateLimitBytesPerSecond(int bytes)
      Specified by:
      setDownloadRateLimitBytesPerSecond in interface PEPeer
    • getUploadRateLimitBytesPerSecond

      public int getUploadRateLimitBytesPerSecond()
      Specified by:
      getUploadRateLimitBytesPerSecond in interface PEPeer
    • getDownloadRateLimitBytesPerSecond

      public int getDownloadRateLimitBytesPerSecond()
      Specified by:
      getDownloadRateLimitBytesPerSecond in interface PEPeer
    • addRateLimiter

      public void addRateLimiter(LimitedRateGroup limiter, boolean upload)
      Specified by:
      addRateLimiter in interface PEPeer
    • getRateLimiters

      public LimitedRateGroup[] getRateLimiters(boolean upload)
      Specified by:
      getRateLimiters in interface PEPeer
    • removeRateLimiter

      public void removeRateLimiter(LimitedRateGroup limiter, boolean upload)
      Specified by:
      removeRateLimiter in interface PEPeer
    • setUploadDisabled

      public void setUploadDisabled(Object key, boolean disabled)
      Specified by:
      setUploadDisabled in interface PEPeer
    • setDownloadDisabled

      public void setDownloadDisabled(Object key, boolean disabled)
      Specified by:
      setDownloadDisabled in interface PEPeer
    • isUploadDisabled

      public boolean isUploadDisabled()
      Specified by:
      isUploadDisabled in interface PEPeer
    • isDownloadDisabled

      public boolean isDownloadDisabled()
      Specified by:
      isDownloadDisabled in interface PEPeer
    • updateAutoUploadPriority

      public void updateAutoUploadPriority(Object key, boolean inc)
      Specified by:
      updateAutoUploadPriority in interface PEPeer
    • getData

      public Object getData(String key)
      Description copied from interface: PEPeer
      To retreive arbitrary objects against a peer.
      Specified by:
      getData in interface PEPeer
    • setData

      public void setData(String key, Object value)
      Description copied from interface: PEPeer
      To store arbitrary objects against a peer.
      Specified by:
      setData in interface PEPeer
    • getUserData

      public Object getUserData(Object key)
      Specified by:
      getUserData in interface PEPeer
    • setUserData

      public void setUserData(Object key, Object value)
      Description copied from interface: PEPeer
      To store arbitrary objects against a peer.
      Specified by:
      setUserData in interface PEPeer
    • getNetworkConnection

      public NetworkConnectionBase getNetworkConnection()
      Specified by:
      getNetworkConnection in interface PEPeer
    • getPluginConnection

      public Connection getPluginConnection()
      Description copied from interface: PEPeer
      Get the connection that backs this peer.
      Specified by:
      getPluginConnection in interface PEPeer
      Returns:
      connection
    • supportsMessaging

      public boolean supportsMessaging()
      Description copied from interface: PEPeer
      Whether or not this peer supports the advanced messaging API.
      Specified by:
      supportsMessaging in interface PEPeer
      Returns:
      true if extended messaging is supported, false if not
    • getMessagingMode

      public int getMessagingMode()
      Specified by:
      getMessagingMode in interface PEPeer
    • getEncryption

      public String getEncryption()
      Description copied from interface: PEPeer
      Returns name of encryption used by the peer
      Specified by:
      getEncryption in interface PEPeer
      Returns:
    • getProtocol

      public String getProtocol()
      Specified by:
      getProtocol in interface PEPeer
    • getProtocolQualifier

      public String getProtocolQualifier()
      Specified by:
      getProtocolQualifier in interface PEPeer
    • 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 interface PEPeer
      Returns:
      messages available for use, or null of supported is yet unknown or unavailable
    • addReservedPieceNumber

      public void addReservedPieceNumber(int pieceNumber)
      Description copied from interface: PEPeer
      adds the reserved piece for piece picking by this peer
      Specified by:
      addReservedPieceNumber in interface PEPeer
    • removeReservedPieceNumber

      public void removeReservedPieceNumber(int pieceNumber)
      Specified by:
      removeReservedPieceNumber in interface PEPeer
    • getReservedPieceNumbers

      public int[] getReservedPieceNumbers()
      Description copied from interface: PEPeer
      Get the reserved pieces for piece picking by this peer
      Specified by:
      getReservedPieceNumbers in interface PEPeer
    • getIncomingRequestCount

      public int getIncomingRequestCount()
      Specified by:
      getIncomingRequestCount in interface PEPeer
    • getOutgoingRequestCount

      public int getOutgoingRequestCount()
      Specified by:
      getOutgoingRequestCount in interface PEPeer
    • getIncomingRequestedPieceNumbers

      public int[] getIncomingRequestedPieceNumbers()
      Description copied from interface: PEPeer
      get a list of piece numbers the peer has requested
      Specified by:
      getIncomingRequestedPieceNumbers in interface PEPeer
      Returns:
      list of Long() representing the piece number requested, in order
    • 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 interface PEPeer
      Returns:
      list of Long() representing the piece number requested, oldest to newest
    • getCurrentIncomingRequestProgress

      public int[] getCurrentIncomingRequestProgress()
      Specified by:
      getCurrentIncomingRequestProgress in interface PEPeer
      Returns:
      null or { size, done }
    • getCurrentOutgoingRequestProgress

      public int[] getCurrentOutgoingRequestProgress()
      Specified by:
      getCurrentOutgoingRequestProgress in interface PEPeer
    • getBytesRemaining

      public long getBytesRemaining()
      Specified by:
      getBytesRemaining in interface PEPeer
    • 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 interface PEPeer
      Parameters:
      enable -
    • getConnectionEstablishedMonoTime

      public long getConnectionEstablishedMonoTime()
      Description copied from interface: PEPeer
      Get the time this connection was first established. NOTE: This method will always return -1 at any time before the underlying transport is fully connected, i.e. before handshaking begins.
      Specified by:
      getConnectionEstablishedMonoTime in interface PEPeer
      Returns:
      mono time in ms
    • setLastPiece

      public void setLastPiece(int i)
      Specified by:
      setLastPiece in interface PEPeer
    • getLastPiece

      public int getLastPiece()
      Specified by:
      getLastPiece in interface PEPeer
    • isLANLocal

      public boolean isLANLocal()
      Specified by:
      isLANLocal in interface PEPeer
    • resetLANLocalStatus

      public void resetLANLocalStatus()
      Specified by:
      resetLANLocalStatus in interface PEPeer
    • 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 interface PEPeer
      Parameters:
      piece_number -
      offset -
      length -
      life -
      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 interface PEPeer
      Returns:
      null if no hint int[]{ piece_number, offset, length } if hint found
    • clearRequestHint

      public void clearRequestHint()
      Specified by:
      clearRequestHint in interface PEPeer
    • sendStatsRequest

      public void sendStatsRequest(Map request)
      Specified by:
      sendStatsRequest in interface PEPeer
    • sendRejectRequest

      public void sendRejectRequest(DiskManagerReadRequest request)
      Specified by:
      sendRejectRequest in interface PEPeer
    • setHaveAggregationEnabled

      public void setHaveAggregationEnabled(boolean enabled)
      Specified by:
      setHaveAggregationEnabled in interface PEPeer
    • getHandshakeReservedBytes

      public byte[] getHandshakeReservedBytes()
      Specified by:
      getHandshakeReservedBytes in interface PEPeer
    • getClientNameFromPeerID

      public String getClientNameFromPeerID()
      Specified by:
      getClientNameFromPeerID in interface PEPeer
    • getClientNameFromExtensionHandshake

      public String getClientNameFromExtensionHandshake()
      Specified by:
      getClientNameFromExtensionHandshake in interface PEPeer
    • isPriorityConnection

      public boolean isPriorityConnection()
      Specified by:
      isPriorityConnection in interface PEPeer
    • setPriorityConnection

      public void setPriorityConnection(boolean is_priority)
      Specified by:
      setPriorityConnection in interface PEPeer
    • isClosed

      public boolean isClosed()
      Specified by:
      isClosed in interface PEPeer
    • getTaggableType

      public int getTaggableType()
      Specified by:
      getTaggableType in interface Taggable
    • getTaggableID

      public String getTaggableID()
      Specified by:
      getTaggableID in interface Taggable
    • getTaggableName

      public String getTaggableName()
      Specified by:
      getTaggableName in interface Taggable
    • getTaggableResolver

      public TaggableResolver getTaggableResolver()
      Specified by:
      getTaggableResolver in interface Taggable
    • getTaggableTransientProperty

      public Object getTaggableTransientProperty(String key)
      Specified by:
      getTaggableTransientProperty in interface Taggable
    • setTaggableTransientProperty

      public void setTaggableTransientProperty(String key, Object value)
      Specified by:
      setTaggableTransientProperty in interface Taggable
    • getDescriptor

      public PeerDescriptor getDescriptor()
      Specified by:
      getDescriptor in interface PEPeer