Methods Summary |
---|
public void | addPeerConnection(NetworkConnectionBase connection)Add the given connection to the downloader.
try { connections_mon.enter();
//copy-on-write
ArrayList conn_new = new ArrayList( connections_cow.size() + 1 );
conn_new.addAll( connections_cow );
conn_new.add( connection );
connections_cow = conn_new;
}
finally{ connections_mon.exit(); }
|
public boolean | canProcess(EventWaiter waiter)
if( main_handler.getCurrentNumBytesAllowed() < 1/*NetworkManager.getTcpMssSize()*/ ) return false;
return true;
|
public boolean | doProcessing(EventWaiter waiter)
int num_bytes_allowed = main_handler.getCurrentNumBytesAllowed();
if( num_bytes_allowed < 1 ) return false;
ArrayList connections = connections_cow;
int num_checked = 0;
int num_bytes_remaining = num_bytes_allowed;
while( num_bytes_remaining > 0 && num_checked < connections.size() ) {
next_position = next_position >= connections.size() ? 0 : next_position; //make circular
NetworkConnectionBase connection = (NetworkConnectionBase)connections.get( next_position );
next_position++;
num_checked++;
if( connection.getTransportBase().isReadyForRead( waiter ) ) {
int mss = connection.getMssSize();
int allowed = num_bytes_remaining > mss ? mss : num_bytes_remaining;
int bytes_read = 0;
try {
bytes_read = connection.getIncomingMessageQueue().receiveFromTransport( allowed );
}
catch( Throwable e ) {
if( AEDiagnostics.TRACE_CONNECTION_DROPS ) {
if( e.getMessage() == null ) {
Debug.out( "null read exception message: ", e );
}
else {
if( e.getMessage().indexOf( "end of stream on socket read" ) == -1 &&
e.getMessage().indexOf( "An existing connection was forcibly closed by the remote host" ) == -1 &&
e.getMessage().indexOf( "Connection reset by peer" ) == -1 &&
e.getMessage().indexOf( "An established connection was aborted by the software in your host machine" ) == -1 ) {
System.out.println( "MP: read exception [" +connection.getTransportBase().getDescription()+ "]: " +e.getMessage() );
}
}
}
if (! (e instanceof IOException )){
Debug.printStackTrace(e);
}
connection.notifyOfException( e );
}
num_bytes_remaining -= bytes_read;
}
}
int total_bytes_read = num_bytes_allowed - num_bytes_remaining;
if( total_bytes_read > 0 ) {
main_handler.bytesProcessed( total_bytes_read );
return true;
}
return false; //zero bytes read
|
public long | getBytesReadyToWrite()
return( 0 );
|
public int | getConnectionCount()
return(connections_cow.size());
|
public int | getPriority() return RateControlledEntity.PRIORITY_HIGH;
|
public int | getReadyConnectionCount(EventWaiter waiter)
int res = 0;
for (Iterator it=connections_cow.iterator();it.hasNext();){
NetworkConnectionBase connection = (NetworkConnectionBase)it.next();
if ( connection.getTransportBase().isReadyForRead( waiter )){
res++;
}
}
return( res );
|
public java.lang.String | getString()
String str = "";
for (Iterator it=connections_cow.iterator();it.hasNext();){
NetworkConnectionBase connection = (NetworkConnectionBase)it.next();
str += (str.length()==0?"":",") + connection.getString();
}
return( "MPD: " + str );
|
public boolean | removePeerConnection(NetworkConnectionBase connection)Remove the given connection from the downloader.
try { connections_mon.enter();
//copy-on-write
ArrayList conn_new = new ArrayList( connections_cow );
boolean removed = conn_new.remove( connection );
if( !removed ) return false;
connections_cow = conn_new;
return true;
}
finally{ connections_mon.exit(); }
|