FileDocCategorySizeDatePackage
PEPeerManagerStatsImpl.javaAPI DocAzureus 3.0.3.45042Tue Dec 26 13:36:28 GMT 2006org.gudy.azureus2.core3.peer.impl

PEPeerManagerStatsImpl

public class PEPeerManagerStatsImpl extends Object implements PEPeerManagerStats

Fields Summary
private PEPeerManagerAdapter
adapter
private long
total_data_bytes_received
private long
total_protocol_bytes_received
private long
total_data_bytes_sent
private long
total_protocol_bytes_sent
private long
totalDiscarded
private long
hash_fail_bytes
private int
last_data_received_seconds
private int
last_data_sent_seconds
private final Average
data_receive_speed
private final Average
protocol_receive_speed
private final Average
data_send_speed
private final Average
protocol_send_speed
private final Average
overallSpeed
Constructors Summary
public PEPeerManagerStatsImpl(org.gudy.azureus2.core3.peer.impl.control.PEPeerControlImpl _manager)

 //average over 100s, update every 5s



	 
	
			  
	
		adapter	= _manager.getAdapter();
	
Methods Summary
public voiddataBytesReceived(PEPeer peer, int length)

	  total_data_bytes_received += length;
	  data_receive_speed.addValue(length);
	  
	  if ( length > 0 ){
		  last_data_received_seconds = (int)(SystemTime.getCurrentTime()/1000);
	  }
	  
	  adapter.dataBytesReceived( peer, length );
	
public voiddataBytesSent(PEPeer peer, int length)

	  total_data_bytes_sent += length;
	  data_send_speed.addValue(length);  
	  
	  if ( length > 0 ){
		  last_data_sent_seconds = (int)(SystemTime.getCurrentTime()/1000);
	  }

	  adapter.dataBytesSent( peer, length );
	
public voiddiscarded(PEPeer peer, int length)

	  this.totalDiscarded += length;
	  
	  adapter.discarded( peer, length );
	
public longgetDataReceiveRate()

 
	  return( data_receive_speed.getAverage());
	
public longgetDataSendRate()

	  return( data_send_speed.getAverage());
	
public longgetProtocolReceiveRate()

    return protocol_receive_speed.getAverage();
  
public longgetProtocolSendRate()

    return protocol_send_speed.getAverage();
  
public intgetTimeSinceLastDataReceivedInSeconds()

 
		if ( last_data_received_seconds == 0 ){
			
			return( -1 );
		}
		
		int	now = (int)(SystemTime.getCurrentTime()/1000);
		
		if ( now < last_data_received_seconds ){
			
			last_data_received_seconds	= now;
		}
		
		return( now - last_data_received_seconds );
	
public intgetTimeSinceLastDataSentInSeconds()

 
		if ( last_data_sent_seconds == 0 ){
			
			return( -1 );
		}
		
		int	now = (int)(SystemTime.getCurrentTime()/1000);
		
		if ( now < last_data_sent_seconds ){
			
			last_data_sent_seconds	= now;
		}
		
		return( now - last_data_sent_seconds );
	
public longgetTotalAverage()

	  return( overallSpeed.getAverage() + getDataReceiveRate() );
	
public longgetTotalDataBytesReceived()

	  return total_data_bytes_received;
	
public longgetTotalDataBytesSent()

	  return total_data_bytes_sent;
	
public longgetTotalDiscarded()

	  return( totalDiscarded );
	
public longgetTotalHashFailBytes()

		return( hash_fail_bytes );
	
public longgetTotalProtocolBytesReceived()

    return total_protocol_bytes_received;
  
public longgetTotalProtocolBytesSent()

    return total_protocol_bytes_sent;
  
public voidhashFailed(int length)

		hash_fail_bytes += length;
	
public voidhaveNewPiece(int pieceLength)

	  overallSpeed.addValue(pieceLength);
	
public voidprotocolBytesReceived(PEPeer peer, int length)

    total_protocol_bytes_received += length;
    protocol_receive_speed.addValue(length);
    
    adapter.protocolBytesReceived( peer, length );
  
public voidprotocolBytesSent(PEPeer peer, int length)

    total_protocol_bytes_sent += length;
    protocol_send_speed.addValue(length);
    
 	adapter.protocolBytesSent( peer, length );
  
public voidsetTotalDiscarded(long total)

	  this.totalDiscarded = total;