Methods Summary |
---|
public void | destroyInitiated()
updateStats( true );
|
public int | getAverageDownloadSpeed()
if(totalUptime > 1) {
return (int)(totalDownloaded / totalUptime);
}
return 0;
|
public int | getAverageUploadSpeed()
if(totalUptime > 1) {
return (int)(totalUploaded / totalUptime);
}
return 0;
|
public long | getDownloadedBytes()
return totalDownloaded;
|
protected long | getLong(java.util.Map map, java.lang.String name)
if ( map == null ){
return( 0 );
}
Object obj = map.get(name);
if (!(obj instanceof Long )){
return(0);
}
return(((Long)obj).longValue());
|
public long | getSessionUpTime()
return (SystemTime.getCurrentTime() - session_start_time) / 1000;
|
public long | getTotalUpTime()
return totalUptime;
|
public long | getUploadedBytes()
return totalUploaded;
|
private java.util.Map | load(java.lang.String filename)
return( FileUtil.readResilientConfigFile( filename ));
|
private java.util.Map | load()
return( load("azureus.statistics"));
|
private void | save(java.lang.String filename, java.util.Map map)
try{
this_mon.enter();
FileUtil.writeResilientConfigFile( filename, map );
}finally{
this_mon.exit();
}
|
private void | save(java.util.Map map)
save("azureus.statistics", map);
|
private void | updateStats(boolean force)
try{
this_mon.enter();
long current_time = SystemTime.getCurrentTime() / 1000;
if ( current_time < lastUptime ) { //time went backwards
lastUptime = current_time;
return;
}
GlobalManagerStats stats = core.getGlobalManager().getStats();
long current_total_received = stats.getTotalDataBytesReceived() + stats.getTotalProtocolBytesReceived();
long current_total_sent = stats.getTotalDataBytesSent() + stats.getTotalProtocolBytesSent();
totalDownloaded += current_total_received - lastDownloaded;
lastDownloaded = current_total_received;
if( totalDownloaded < 0 ) totalDownloaded = 0;
totalUploaded += current_total_sent - lastUploaded;
lastUploaded = current_total_sent;
if( totalUploaded < 0 ) totalUploaded = 0;
long delta = current_time - lastUptime;
if( delta > 100 || delta < 0 ) { //make sure the time diff isn't borked
lastUptime = current_time;
return;
}
if( totalUptime > TEN_YEARS ) { //total uptime > 10years is an error, reset
totalUptime = 0;
}
if( totalUptime < 0 ) totalUptime = 0;
totalUptime += delta;
lastUptime = current_time;
tick_count++;
HashMap overallMap = new HashMap();
overallMap.put("downloaded",new Long(totalDownloaded));
overallMap.put("uploaded",new Long(totalUploaded));
overallMap.put("uptime",new Long(totalUptime));
Map map = new HashMap();
map.put( "all", overallMap );
save( map );
}finally{
this_mon.exit();
}
|
private void | validateAndLoadValues(java.util.Map statisticsMap)
lastUptime = SystemTime.getCurrentTime() / 1000;
Map overallMap = (Map) statisticsMap.get("all");
totalDownloaded = getLong( overallMap, "downloaded" );
totalUploaded = getLong( overallMap, "uploaded" );
totalUptime = getLong( overallMap, "uptime" );
|