FileDocCategorySizeDatePackage
DHTControlStatsImpl.javaAPI DocAzureus 3.0.3.46283Sat Aug 19 07:14:00 BST 2006com.aelitis.azureus.core.dht.control.impl

DHTControlStatsImpl

public class DHTControlStatsImpl extends Object implements DHTTransportFullStats, com.aelitis.azureus.core.dht.control.DHTControlStats
author
parg

Fields Summary
private static final int
UPDATE_INTERVAL
private static final int
UPDATE_PERIOD
private DHTControlImpl
control
private Average
packets_in_average
private Average
packets_out_average
private Average
bytes_in_average
private Average
bytes_out_average
private DHTTransportStats
transport_snapshot
private long[]
router_snapshot
Constructors Summary
protected DHTControlStatsImpl(DHTControlImpl _control)

		
	
	
				 
	
		control	= _control;
		
		transport_snapshot	= control.getTransport().getStats().snapshot();
		
		router_snapshot		= control.getRouter().getStats().getStats();
		
		SimpleTimer.addPeriodicEvent(
			"DHTCS:update",
			UPDATE_INTERVAL,
			new TimerEventPerformer()
			{
				public void
				perform(
					TimerEvent	event )
				{
					update();
				
					control.poke();
				}
			});
	
Methods Summary
public longgetAverageBytesReceived()

		return( bytes_in_average.getAverage());
	
public longgetAverageBytesSent()

		return( bytes_out_average.getAverage());	
	
public longgetAveragePacketsReceived()

		return( packets_in_average.getAverage());
	
public longgetAveragePacketsSent()

		return( packets_out_average.getAverage());
	
public longgetDBKeysBlocked()

		return( control.getDataBase().getStats().getKeyBlockCount());
	
public longgetDBValuesStored()

		return( control.getDataBase().getStats().getValueDetails()[ DHTDBStats.VD_VALUE_COUNT ]);
	
public longgetEstimatedDHTSize()

		return( control.getEstimatedDHTSize());
	
public longgetIncomingRequests()

		return( transport_snapshot.getIncomingRequests());
	
public longgetRouterContacts()

		return( router_snapshot[DHTRouterStats.ST_CONTACTS]);
	
public intgetRouterCount()

		return( control.getRouterCount());
	
public longgetRouterLeaves()

		return( router_snapshot[DHTRouterStats.ST_LEAVES]);
	
public longgetRouterNodes()

		return( router_snapshot[DHTRouterStats.ST_NODES]);
	
public longgetRouterUptime()

		return( control.getRouterUptime());
	
public java.lang.StringgetString()

		return(	"transport:" + 
				getTotalBytesReceived() + "," +
				getTotalBytesSent() + "," +
				getTotalPacketsReceived() + "," +
				getTotalPacketsSent() + "," +
				getTotalPingsReceived() + "," +
				getTotalFindNodesReceived() + "," +
				getTotalFindValuesReceived() + "," +
				getTotalStoresReceived() + "," +
				getTotalKeyBlocksReceived() + "," +
				getAverageBytesReceived() + "," +
				getAverageBytesSent() + "," +
				getAveragePacketsReceived() + "," +
				getAveragePacketsSent() + "," +
				getIncomingRequests() + 
				",router:" +
				getRouterNodes() + "," +
				getRouterLeaves() + "," +
				getRouterContacts() + 
				",database:" +
				getDBValuesStored()+ ","+
				getDBKeysBlocked()+
				",version:" + getVersion()+","+
				getRouterUptime() + ","+
				getRouterCount());
	
public longgetTotalBytesReceived()

		return( transport_snapshot.getBytesReceived());
	
public longgetTotalBytesSent()

		return( transport_snapshot.getBytesSent());
	
public longgetTotalFindNodesReceived()

		return( transport_snapshot.getFindNodes()[DHTTransportStats.STAT_RECEIVED]);
	
public longgetTotalFindValuesReceived()

		return( transport_snapshot.getFindValues()[DHTTransportStats.STAT_RECEIVED]);
	
public longgetTotalKeyBlocksReceived()

		return( transport_snapshot.getKeyBlocks()[DHTTransportStats.STAT_RECEIVED]);
	
public longgetTotalPacketsReceived()

		return( transport_snapshot.getPacketsReceived());
	
public longgetTotalPacketsSent()

		return( transport_snapshot.getPacketsSent());
		
	
public longgetTotalPingsReceived()

		return( transport_snapshot.getPings()[DHTTransportStats.STAT_RECEIVED]);
	
public longgetTotalStoresReceived()

		return( transport_snapshot.getStores()[DHTTransportStats.STAT_RECEIVED]);
	
public java.lang.StringgetVersion()

		return( Constants.AZUREUS_VERSION );
	
protected voidupdate()

		DHTTransport	transport 	= control.getTransport();
		
		DHTTransportStats	t_stats = transport.getStats().snapshot();
					
		packets_in_average.addValue( 
				t_stats.getPacketsReceived() - transport_snapshot.getPacketsReceived());
			
		packets_out_average.addValue( 
				t_stats.getPacketsSent() - transport_snapshot.getPacketsSent());
			
		bytes_in_average.addValue( 
				t_stats.getBytesReceived() - transport_snapshot.getBytesReceived());
			
		bytes_out_average.addValue( 
				t_stats.getBytesSent() - transport_snapshot.getBytesSent());
		
		transport_snapshot	= t_stats;
		
		router_snapshot	= control.getRouter().getStats().getStats();