forked from I2P_Developers/i2p.i2p
2009-08-11 sponge
* Code Janitor time! Many fixes and documenting fixes that should be
done in the future. for the most part, this is a general code cleanup.
* On smaller/embedded systems, the "final" keyword cleanups will have
more of an impact than on larger systems.
* Document missing hashCode() methods.
* Unhide more variables to make code easier to read.
This commit is contained in:
@@ -20,12 +20,12 @@ import net.i2p.util.Log;
|
||||
public class BufferedStatLog implements StatLog {
|
||||
private I2PAppContext _context;
|
||||
private Log _log;
|
||||
private StatEvent _events[];
|
||||
private final StatEvent _events[];
|
||||
private int _eventNext;
|
||||
private int _lastWrite;
|
||||
/** flush stat events to disk after this many events (or 30s)*/
|
||||
private int _flushFrequency;
|
||||
private List _statFilters;
|
||||
private final List _statFilters;
|
||||
private String _lastFilters;
|
||||
private BufferedWriter _out;
|
||||
private String _outFile;
|
||||
@@ -125,7 +125,7 @@ public class BufferedStatLog implements StatLog {
|
||||
}
|
||||
|
||||
private class StatLogWriter implements Runnable {
|
||||
private SimpleDateFormat _fmt = new SimpleDateFormat("yyyyMMdd HH:mm:ss.SSS");
|
||||
private final SimpleDateFormat _fmt = new SimpleDateFormat("yyyyMMdd HH:mm:ss.SSS");
|
||||
public void run() {
|
||||
int writeStart = -1;
|
||||
int writeEnd = -1;
|
||||
|
||||
@@ -11,7 +11,7 @@ public class Frequency {
|
||||
private long _lastEvent;
|
||||
private long _start = now();
|
||||
private long _count = 0;
|
||||
private Object _lock = this; // new Object(); // in case we want to do fancy sync later
|
||||
private final Object _lock = this; // new Object(); // in case we want to do fancy sync later
|
||||
|
||||
public Frequency(long period) {
|
||||
setPeriod(period);
|
||||
|
||||
@@ -58,6 +58,8 @@ public class FrequencyStat {
|
||||
return null;
|
||||
}
|
||||
|
||||
/* FIXME missing equals() method FIXME */
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return _statName.hashCode();
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public class Rate {
|
||||
private long _period;
|
||||
|
||||
/** locked during coalesce and addData */
|
||||
private Object _lock = new Object();
|
||||
private final Object _lock = new Object();
|
||||
|
||||
/** in the current (partial) period, what is the total value acrued through all events? */
|
||||
public double getCurrentTotalValue() {
|
||||
@@ -452,6 +452,26 @@ public class Rate {
|
||||
&& _lifetimeTotalEventTime == r.getLifetimeTotalEventTime();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = 5;
|
||||
hash = 67 * hash + (int)(Double.doubleToLongBits(this._currentTotalValue) ^ (Double.doubleToLongBits(this._currentTotalValue) >>> 32));
|
||||
hash = 67 * hash + (int)(this._currentEventCount ^ (this._currentEventCount >>> 32));
|
||||
hash = 67 * hash + (int)(this._currentTotalEventTime ^ (this._currentTotalEventTime >>> 32));
|
||||
hash = 67 * hash + (int)(Double.doubleToLongBits(this._lastTotalValue) ^ (Double.doubleToLongBits(this._lastTotalValue) >>> 32));
|
||||
hash = 67 * hash + (int)(this._lastEventCount ^ (this._lastEventCount >>> 32));
|
||||
hash = 67 * hash + (int)(this._lastTotalEventTime ^ (this._lastTotalEventTime >>> 32));
|
||||
hash = 67 * hash + (int)(Double.doubleToLongBits(this._extremeTotalValue) ^ (Double.doubleToLongBits(this._extremeTotalValue) >>> 32));
|
||||
hash = 67 * hash + (int)(this._extremeEventCount ^ (this._extremeEventCount >>> 32));
|
||||
hash = 67 * hash + (int)(this._extremeTotalEventTime ^ (this._extremeTotalEventTime >>> 32));
|
||||
hash = 67 * hash + (int)(Double.doubleToLongBits(this._lifetimeTotalValue) ^ (Double.doubleToLongBits(this._lifetimeTotalValue) >>> 32));
|
||||
hash = 67 * hash + (int)(this._lifetimeEventCount ^ (this._lifetimeEventCount >>> 32));
|
||||
hash = 67 * hash + (int)(this._lifetimeTotalEventTime ^ (this._lifetimeTotalEventTime >>> 32));
|
||||
hash = 67 * hash + (int)(this._creationDate ^ (this._creationDate >>> 32));
|
||||
hash = 67 * hash + (int)(this._period ^ (this._period >>> 32));
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder buf = new StringBuilder(2048);
|
||||
|
||||
@@ -25,9 +25,9 @@ public class StatManager {
|
||||
private I2PAppContext _context;
|
||||
|
||||
/** stat name to FrequencyStat */
|
||||
private Map _frequencyStats;
|
||||
private final Map _frequencyStats;
|
||||
/** stat name to RateStat */
|
||||
private Map _rateStats;
|
||||
private final Map _rateStats;
|
||||
private StatLog _statLog;
|
||||
|
||||
public static final String PROP_STAT_FILTER = "stat.logFilters";
|
||||
|
||||
Reference in New Issue
Block a user