FileDocCategorySizeDatePackage
DHTTransportStatsImpl.javaAPI DocAzureus 3.0.3.49718Fri Mar 03 10:26:48 GMT 2006com.aelitis.azureus.core.dht.transport.util

DHTTransportStatsImpl

public abstract class DHTTransportStatsImpl extends Object implements com.aelitis.azureus.core.dht.transport.DHTTransportStats
author
parg

Fields Summary
private byte
protocol_version
private long[]
pings
private long[]
find_nodes
private long[]
find_values
private long[]
stores
private long[]
stats
private long[]
data
private long[]
key_blocks
private long[]
aliens
private long
incoming_requests
private long
outgoing_requests
private long
incoming_version_requests
private long[]
incoming_request_versions
private long
outgoing_version_requests
private long[]
outgoing_request_versions
Constructors Summary
protected DHTTransportStatsImpl(byte _protocol_version)

	
	
	
			 
	
		protocol_version	= _protocol_version;
		
		incoming_request_versions = new long[protocol_version+1];
		outgoing_request_versions = new long[protocol_version+1];
	
Methods Summary
public voidadd(com.aelitis.azureus.core.dht.transport.util.DHTTransportStatsImpl other)

		add( pings, other.pings );
		add( find_nodes, other.find_nodes );
		add( find_values, other.find_values );
		add( stores, other.stores );
		add( stats, other.stats );
		add( data, other.data );
		add( key_blocks, other.key_blocks );
		add( aliens, other.aliens );
		
		incoming_requests += other.incoming_requests;
		outgoing_requests += other.outgoing_requests;
	
protected voidadd(long[] a, long[] b)

		for (int i=0;i<a.length;i++){
			a[i]	+= b[i];
		}
	
public voiddataOK()

		data[STAT_OK]++;
	
public voiddataReceived()

		data[STAT_RECEIVED]++;
	
public voiddataSent(com.aelitis.azureus.core.dht.transport.udp.impl.DHTUDPPacketRequest request)

		data[STAT_SENT]++;
		
		outgoingRequestSent( request );
	
public voiddayaFailed()

		data[STAT_FAILED]++;
	
public voidfindNodeFailed()

		find_nodes[STAT_FAILED]++;
	
public voidfindNodeOK()

		find_nodes[STAT_OK]++;
	
public voidfindNodeReceived()

		find_nodes[STAT_RECEIVED]++;
	
public voidfindNodeSent(com.aelitis.azureus.core.dht.transport.udp.impl.DHTUDPPacketRequest request)

		find_nodes[STAT_SENT]++;
					
		outgoingRequestSent( request );
	
public voidfindValueFailed()

		find_values[STAT_FAILED]++;
	
public voidfindValueOK()

		find_values[STAT_OK]++;
	
public voidfindValueReceived()

		find_values[STAT_RECEIVED]++;
	
public voidfindValueSent(com.aelitis.azureus.core.dht.transport.udp.impl.DHTUDPPacketRequest request)

		find_values[STAT_SENT]++;
					
		outgoingRequestSent( request );
	
public long[]getAliens()

		return( aliens );
	
public long[]getData()

		return( data );
	
public long[]getFindNodes()

		return( find_nodes );
	
public long[]getFindValues()

		return( find_values );
	
public longgetIncomingRequests()

		return( incoming_requests );
	
public long[]getKeyBlocks()

		return( key_blocks );
	
public long[]getPings()

		return( pings );
	
protected bytegetProtocolVersion()

		return( protocol_version );
	
public long[]getStores()

		return( stores );
	
public java.lang.StringgetString()

		return( "ping:" + getString( pings ) + "," +
				"store:" + getString( stores ) + "," +
				"node:" + getString( find_nodes ) + "," +
				"value:" + getString( find_values ) + "," +
				"stats:" + getString( stats ) + "," +
				"data:" + getString( data ) + "," +
				"kb:" + getString( key_blocks ) + "," +
				"incoming:" + incoming_requests +"," +
				"alien:" + getString( aliens ));
	
protected java.lang.StringgetString(long[] x)

		String	str = "";
		
		for (int i=0;i<x.length;i++){
			
			str += (i==0?"":",") + x[i];
		}
				
		return( str );
	
public voidincomingRequestReceived(com.aelitis.azureus.core.dht.transport.udp.impl.DHTUDPPacketRequest request, boolean alien)

		incoming_requests++;
		
		if ( alien ){
			
			int	type = request.getAction();
			
			if ( type == DHTUDPPacketHelper.ACT_REQUEST_FIND_NODE ){
				
				aliens[AT_FIND_NODE]++;
			
			}else if ( type == DHTUDPPacketHelper.ACT_REQUEST_FIND_VALUE ){
				
				aliens[AT_FIND_VALUE]++;
				
			}else if ( type == DHTUDPPacketHelper.ACT_REQUEST_PING ){
				
				aliens[AT_PING]++;
				
			}else if ( type == DHTUDPPacketHelper.ACT_REQUEST_STATS ){
				
				aliens[AT_STATS]++;
				
			}else if ( type == DHTUDPPacketHelper.ACT_REQUEST_STORE ){
				
				aliens[AT_STORE]++;
				
			}else if ( type == DHTUDPPacketHelper.ACT_REQUEST_KEY_BLOCK ){
				
				aliens[AT_KEY_BLOCK]++;
			}
		}
		
		if ( DHTLog.TRACE_VERSIONS ){
			
			byte protocol_version = request.getProtocolVersion();
			
			if ( protocol_version >= 0 && protocol_version < incoming_request_versions.length ){
				
				incoming_request_versions[ protocol_version ]++;
				
				incoming_version_requests++;
				
				if ( incoming_version_requests%100 == 0 ){
					
					String	str= "";
					
					for (int i=0;i<incoming_request_versions.length;i++){
						
						long	count = incoming_request_versions[i];
						
						if ( count > 0 ){
							
							str += (str.length()==0?"":", ") + i + "=" +  count + "[" +
										((incoming_request_versions[i]*100)/incoming_version_requests) + "]";
						}
					}
					
					System.out.println( "net " + request.getTransport().getNetwork() + ": Incoming versions: tot = " + incoming_requests +"/" + incoming_version_requests + ": " + str );
				}
				
				if ( incoming_version_requests%1000 == 0 ){
					
					for (int i=0;i<incoming_request_versions.length;i++){
						
						incoming_request_versions[i] = 0;
					}
	
					incoming_version_requests	= 0;
				}
			}
		}
	
public voidkeyBlockFailed()

		key_blocks[STAT_FAILED]++;
	
public voidkeyBlockOK()

		key_blocks[STAT_OK]++;
	
public voidkeyBlockReceived()

		key_blocks[STAT_RECEIVED]++;
	
public voidkeyBlockSent(com.aelitis.azureus.core.dht.transport.udp.impl.DHTUDPPacketRequest request)

		key_blocks[STAT_SENT]++;
					
		outgoingRequestSent( request );
	
protected voidoutgoingRequestSent(com.aelitis.azureus.core.dht.transport.udp.impl.DHTUDPPacketRequest request)

		outgoing_requests++;		

		if ( DHTLog.TRACE_VERSIONS ){
			
			byte protocol_version = request.getProtocolVersion();
			
			if ( protocol_version >= 0 && protocol_version < outgoing_request_versions.length ){
				
				outgoing_request_versions[ protocol_version ]++;
				
				outgoing_version_requests++;
				
				if ( outgoing_version_requests%100 == 0 ){
					
					String	str= "";
					
					for (int i=0;i<outgoing_request_versions.length;i++){
						
						long	count = outgoing_request_versions[i];
						
						if ( count > 0 ){
							
							str += (str.length()==0?"":", ") + i + "=" +  count + "[" +
										((outgoing_request_versions[i]*100)/outgoing_version_requests) + "]";
						}
					}
					
					System.out.println( "net " + request.getTransport().getNetwork() + ": Outgoing versions: tot = " + outgoing_requests +"/" + outgoing_version_requests + ": " + str );
				}
				
				if ( outgoing_version_requests%1000 == 0 ){
					
					for (int i=0;i<outgoing_request_versions.length;i++){
						
						outgoing_request_versions[i] = 0;
					}
	
					outgoing_version_requests	= 0;
				}
			}
		}
	
public voidpingFailed()

		pings[STAT_FAILED]++;
	
public voidpingOK()

		pings[STAT_OK]++;
	
public voidpingReceived()

		pings[STAT_RECEIVED]++;
	
public voidpingSent(com.aelitis.azureus.core.dht.transport.udp.impl.DHTUDPPacketRequest request)

		pings[STAT_SENT]++;
					
		outgoingRequestSent( request );
	
protected voidsnapshotSupport(com.aelitis.azureus.core.dht.transport.util.DHTTransportStatsImpl clone)

		clone.pings			= (long[])pings.clone();
		clone.find_nodes	= (long[])find_nodes.clone();
		clone.find_values	= (long[])find_values.clone();
		clone.stores		= (long[])stores.clone();
		clone.data			= (long[])data.clone();
		clone.key_blocks	= (long[])key_blocks.clone();
		clone.aliens		= (long[])aliens.clone();
		
		clone.incoming_requests	= incoming_requests;
		clone.outgoing_requests	= outgoing_requests;
	
public voidstatsFailed()

		stats[STAT_FAILED]++;
	
public voidstatsOK()

		stats[STAT_OK]++;
	
public voidstatsReceived()

		stats[STAT_RECEIVED]++;
	
public voidstatsSent(com.aelitis.azureus.core.dht.transport.udp.impl.DHTUDPPacketRequest request)

		stats[STAT_SENT]++;
		
		outgoingRequestSent( request );
	
public voidstoreFailed()

		stores[STAT_FAILED]++;
	
public voidstoreOK()

		stores[STAT_OK]++;
	
public voidstoreReceived()

		stores[STAT_RECEIVED]++;
	
public voidstoreSent(com.aelitis.azureus.core.dht.transport.udp.impl.DHTUDPPacketRequest request)

		stores[STAT_SENT]++;
		
		outgoingRequestSent( request );