Methods Summary |
---|
public void | addListener(PeerListener listener)
try{
listenerListMon.enter();
listenerList.add(listener);
}finally{
listenerListMon.exit();
}
|
public void | addListener(PeerListener2 listener)
try{
listenerListMon.enter();
listenerList.add(listener);
}finally{
listenerListMon.exit();
}
|
protected void | addPeer()
setState(Peer.HANDSHAKING);
manager.addPeer( this );
// we can get synchronously disconnected - e.g. IP filter rules
if ( peer_added ){
setState(Peer.TRANSFERING);
try{
listenerListMon.enter();
if ( availabilityAdded ){
Debug.out( "availabililty already added" );
}else{
availabilityAdded = true;
fireEvent( PeerEvent.ET_ADD_AVAILABILITY, getAvailable());
}
}finally{
listenerListMon.exit();
}
}
|
public boolean | addRequest(PeerReadRequest request)
if ( !doing_allocations ){
Debug.out( "request added when not in allocation phase" );
}
request_list.add( request );
snubbed = 0;
return( true );
|
public void | cancelRequest(PeerReadRequest request)
reader.cancelRequest( request );
|
protected boolean | checkConnection()
boolean state_changed = false;
try{
connection_mon.enter();
boolean active = reader.checkActivation( manager, this );
if ( manager != null && active != peer_added ){
state_changed = true;
boolean peer_was_added = peer_added;
peer_added = active;
if ( active ){
addPeer();
}else{
if ( peer_was_added ){
removePeer();
}
}
}
}finally{
connection_mon.exit();
}
return( state_changed );
|
public void | close(java.lang.String reason, boolean closedOnError, boolean attemptReconnect)
boolean peer_was_added;
try{
connection_mon.enter();
peer_was_added = peer_added;
reader.cancelAllRequests();
reader.deactivate( reason );
peer_added = false;
try{
listenerListMon.enter();
if ( availabilityAdded ){
availabilityAdded = false;
fireEvent( PeerEvent.ET_REMOVE_AVAILABILITY, getAvailable());
}
}finally{
listenerListMon.exit();
}
}finally{
connection_mon.exit();
}
if ( peer_was_added ){
manager.removePeer( this );
}
setState( Peer.DISCONNECTED );
if ( reader.isTransient()){
plugin.removePeer( this );
}
|
protected void | fireEvent(int type, java.lang.Object data)
try{
listenerListMon.enter();
for (int i =0; i <listenerList.size(); i++){
try{
Object _listener = listenerList.get(i);
if ( _listener instanceof PeerListener ){
PeerListener listener = (PeerListener)_listener;
if ( type == PeerEvent.ET_STATE_CHANGED ){
listener.stateChanged(((Integer)data).intValue());
}else if ( type == PeerEvent.ET_BAD_CHUNK ){
Integer[] d = (Integer[])data;
listener.sentBadChunk(d[0].intValue(),d[1].intValue());
}
}else{
PeerListener2 listener = (PeerListener2)_listener;
listener.eventOccurred(
new PeerEvent()
{
public int
getType()
{
return( type );
}
public Object
getData()
{
return( data );
}
});
}
}catch( Throwable e ){
e.printStackTrace();
}
}
}finally{
listenerListMon.exit();
}
|
public final boolean[] | getAvailable()
return( available );
|
public java.lang.String | getClient()
return( reader.getName());
|
public org.gudy.azureus2.plugins.network.Connection | getConnection()
return( null );
|
protected org.gudy.azureus2.plugins.download.Download | getDownload()
return( download );
|
public java.util.List | getExpiredRequests()
return( reader.getExpiredRequests());
|
public byte[] | getHandshakeReservedBytes()
return null;
|
public byte[] | getId()
return( peer_id );
|
public java.lang.String | getIp()
return( reader.getIP());
|
public PeerManager | getManager()
return( manager );
|
public int | getMaximumNumberOfRequests()
return( reader.getMaximumNumberOfRequests());
|
public java.lang.String | getName()
return( reader.getName());
|
public int | getNumberOfRequests()
return( reader.getRequestCount() + request_list.size());
|
public int | getPercentDone()
return( 1000 );
|
public int | getPercentDoneInThousandNotation()
return( 1000 );
|
public int | getPercentDoneOfCurrentIncomingRequest()
return( reader.getPercentDoneOfCurrentIncomingRequest());
|
public int | getPercentDoneOfCurrentOutgoingRequest()
return( 0 );
|
public int | getPort()
return( reader.getPort());
|
public int[] | getPriorityOffsets()
return( reader.getPriorityOffsets());
|
public java.util.Map | getProperties()
return( new HashMap());
|
public java.util.List | getRequests()
return( reader.getRequests());
|
public long | getSnubbedTime()
if ( !isSnubbed()){
return 0;
}
final long now = plugin.getPluginInterface().getUtilities().getCurrentSystemTime();
if ( now < snubbed ){
snubbed = now - 26; // odds are ...
}
return now - snubbed;
|
public int | getState()
return state;
|
public PeerStats | getStats()
return( stats );
|
public org.gudy.azureus2.plugins.messaging.Message[] | getSupportedMessages()
return( new Message[0] );
|
public int | getTCPListenPort()
return( 0 );
|
public int | getUDPListenPort()
return( 0 );
|
public int | getUDPNonDataListenPort()
return( 0 );
|
public java.lang.Object | getUserData(java.lang.Object key)
if ( user_data == null ){
return( null );
}
return( user_data.get( key ));
|
public boolean | isChoked()
return( false );
|
public boolean | isChoking()
return( false );
|
public boolean | isDownloadPossible()
return peer_added &&reader.isActive();
|
public boolean | isIncoming()
return( false );
|
public boolean | isInterested()
return( false );
|
public boolean | isInteresting()
return( true );
|
public boolean | isOptimisticUnchoke()
return( is_optimistic );
|
public final boolean | isPieceAvailable(int pieceNumber)
return( true );
|
public boolean | isSeed()
return( true );
|
public boolean | isSnubbed()
if ( snubbed != 0 ){
// mindless snubbing control - if we have no outstanding requests then we
// drop the snubbed status :)
if ( reader.getRequestCount() == 0 ){
snubbed = 0;
}
}
return( snubbed != 0 );
|
public boolean | isTransferAvailable()
return( reader.isActive());
|
public int | readBytes(int max)
int res = reader.readBytes( max );
if ( res > 0 ){
stats.received( res );
}
return( res );
|
public void | removeListener(PeerListener listener)
try{
listenerListMon.enter();
listenerList.remove(listener);
}finally{
listenerListMon.exit();
}
|
public void | removeListener(PeerListener2 listener)
try{
listenerListMon.enter();
listenerList.remove(listener);
}finally{
listenerListMon.exit();
}
|
protected void | removePeer()
setState(Peer.CLOSING);
try{
listenerListMon.enter();
if ( availabilityAdded ){
availabilityAdded = false;
fireEvent( PeerEvent.ET_REMOVE_AVAILABILITY, getAvailable());
}
}finally{
listenerListMon.exit();
}
manager.removePeer( this );
setState( Peer.DISCONNECTED );
|
public void | requestAllocationComplete()
reader.addRequests( request_list );
request_list.clear();
doing_allocations = false;
|
public boolean | requestAllocationStarts(int[] base_priorities)
if ( doing_allocations ){
Debug.out( "recursive allocations" );
}
doing_allocations = true;
if ( request_list.size() != 0 ){
Debug.out( "req list must be empty" );
}
PeerManager pm = manager;
if ( pm != null ){
reader.calculatePriorityOffsets( pm, base_priorities );
}
return( true );
|
public void | requestCancelled(PeerReadRequest request)
PeerManager man = manager;
if ( man != null ){
man.requestCancelled( request, this );
}
|
public void | requestComplete(PeerReadRequest request, PooledByteBuffer data)
PeerManager man = manager;
if ( request.isCancelled() || man == null ){
data.returnToPool();
}else{
try{
man.requestComplete( request, data, this );
// moved to the rate-limiting code for more accurate stats
// stats.received( request.getLength());
}catch( Throwable e ){
data.returnToPool();
e.printStackTrace();
}
}
|
public void | requestFailed(PeerReadRequest request)
PeerManager man = manager;
if ( man != null ){
man.requestCancelled( request, this );
try{
connection_mon.enter();
if ( peer_added ){
plugin.log( reader.getName() + " failed - " + reader.getStatus() + ", permanent = " + reader.isPermanentlyUnavailable());
peer_added = false;
removePeer();
}
}finally{
connection_mon.exit();
}
if ( reader.isTransient() && reader.isPermanentlyUnavailable()){
plugin.removePeer( this );
}
}
|
protected boolean | sameAs(com.aelitis.azureus.plugins.extseed.ExternalSeedPeer other)
return( reader.sameAs( other.reader ));
|
protected void | setManager(PeerManager _manager)
setState(Peer.CONNECTING);
try{
connection_mon.enter();
manager = _manager;
if ( manager != null ){
stats = manager.createPeerStats( this );
}
checkConnection();
}finally{
connection_mon.exit();
}
|
public void | setOptimisticUnchoke(boolean _is_optimistic)
is_optimistic = _is_optimistic;
|
public void | setSnubbed(boolean b)
if (!b){
snubbed = 0;
}else if ( snubbed == 0 ){
snubbed = plugin.getPluginInterface().getUtilities().getCurrentSystemTime();
}
|
protected void | setState(int newState)
state = newState;
fireEvent( PeerEvent.ET_STATE_CHANGED, new Integer( newState ));
|
public void | setUserData(java.lang.Object key, java.lang.Object value)
if ( user_data == null ){
user_data = new HashMap();
}
user_data.put( key, value );
|
public boolean | supportsMessaging()
return( false );
|
public int | writeBytes(int max)
throw( new RuntimeException( "Not supported" ));
|