forked from I2P_Developers/i2p.i2p
* Profiles:
- Nicer profile dump - More efficient profile lookup for display - Fix dumpprofile NPE - Change file suffix from .dat to .txt.gz
This commit is contained in:
@ -1,10 +1,16 @@
|
||||
package net.i2p.stat;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Properties;
|
||||
|
||||
import net.i2p.data.DataHelper;
|
||||
import net.i2p.util.Log;
|
||||
|
||||
/** object orientation gives you hairy palms. */
|
||||
/**
|
||||
* Output rate data.
|
||||
* This is used via ProfilePersistenceHelper and the output
|
||||
* must be compatible.
|
||||
*/
|
||||
class PersistenceHelper {
|
||||
private final static Log _log = new Log(PersistenceHelper.class);
|
||||
private final static String NL = System.getProperty("line.separator");
|
||||
@ -15,6 +21,18 @@ class PersistenceHelper {
|
||||
buf.append(prefix).append(name).append('=').append(value).append(NL).append(NL);
|
||||
}
|
||||
|
||||
/** @since 0.8.5 */
|
||||
public final static void addDate(StringBuilder buf, String prefix, String name, String description, long value) {
|
||||
String when = value > 0 ? (new Date(value)).toString() : "Never";
|
||||
add(buf, prefix, name, description + ' ' + when, value);
|
||||
}
|
||||
|
||||
/** @since 0.8.5 */
|
||||
public final static void addTime(StringBuilder buf, String prefix, String name, String description, long value) {
|
||||
String when = DataHelper.formatDuration(value);
|
||||
add(buf, prefix, name, description + ' ' + when, value);
|
||||
}
|
||||
|
||||
public final static void add(StringBuilder buf, String prefix, String name, String description, long value) {
|
||||
buf.append("# ").append(prefix).append(name).append(NL);
|
||||
buf.append("# ").append(description).append(NL);
|
||||
@ -48,4 +66,4 @@ class PersistenceHelper {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -400,42 +400,41 @@ public class Rate {
|
||||
}
|
||||
|
||||
public void store(String prefix, StringBuilder buf) throws IOException {
|
||||
PersistenceHelper.add(buf, prefix, ".period", "Number of milliseconds in the period", _period);
|
||||
PersistenceHelper.add(buf, prefix, ".creationDate",
|
||||
"When was this rate created? (milliseconds since the epoch, GMT)", _creationDate);
|
||||
PersistenceHelper.add(buf, prefix, ".lastCoalesceDate",
|
||||
"When did we last coalesce this rate? (milliseconds since the epoch, GMT)",
|
||||
PersistenceHelper.addTime(buf, prefix, ".period", "Length of the period:", _period);
|
||||
PersistenceHelper.addDate(buf, prefix, ".creationDate",
|
||||
"When was this rate created?", _creationDate);
|
||||
PersistenceHelper.addDate(buf, prefix, ".lastCoalesceDate",
|
||||
"When did we last coalesce this rate?",
|
||||
_lastCoalesceDate);
|
||||
PersistenceHelper.add(buf, prefix, ".currentDate",
|
||||
"When did this data get written? (milliseconds since the epoch, GMT)", now());
|
||||
PersistenceHelper.addDate(buf, prefix, ".currentDate",
|
||||
"When was this data written?", now());
|
||||
PersistenceHelper.add(buf, prefix, ".currentTotalValue",
|
||||
"Total value of data points in the current (uncoalesced) period", _currentTotalValue);
|
||||
PersistenceHelper
|
||||
.add(buf, prefix, ".currentEventCount",
|
||||
PersistenceHelper.add(buf, prefix, ".currentEventCount",
|
||||
"How many events have occurred in the current (uncoalesced) period?", _currentEventCount);
|
||||
PersistenceHelper.add(buf, prefix, ".currentTotalEventTime",
|
||||
"How many milliseconds have the events in the current (uncoalesced) period consumed?",
|
||||
PersistenceHelper.addTime(buf, prefix, ".currentTotalEventTime",
|
||||
"How much time have the events in the current (uncoalesced) period consumed?",
|
||||
_currentTotalEventTime);
|
||||
PersistenceHelper.add(buf, prefix, ".lastTotalValue",
|
||||
"Total value of data points in the most recent (coalesced) period", _lastTotalValue);
|
||||
PersistenceHelper.add(buf, prefix, ".lastEventCount",
|
||||
"How many events have occurred in the most recent (coalesced) period?", _lastEventCount);
|
||||
PersistenceHelper.add(buf, prefix, ".lastTotalEventTime",
|
||||
"How many milliseconds have the events in the most recent (coalesced) period consumed?",
|
||||
PersistenceHelper.addTime(buf, prefix, ".lastTotalEventTime",
|
||||
"How much time have the events in the most recent (coalesced) period consumed?",
|
||||
_lastTotalEventTime);
|
||||
PersistenceHelper.add(buf, prefix, ".extremeTotalValue",
|
||||
"Total value of data points in the most extreme period", _extremeTotalValue);
|
||||
PersistenceHelper.add(buf, prefix, ".extremeEventCount",
|
||||
"How many events have occurred in the most extreme period?", _extremeEventCount);
|
||||
PersistenceHelper.add(buf, prefix, ".extremeTotalEventTime",
|
||||
"How many milliseconds have the events in the most extreme period consumed?",
|
||||
PersistenceHelper.addTime(buf, prefix, ".extremeTotalEventTime",
|
||||
"How much time have the events in the most extreme period consumed?",
|
||||
_extremeTotalEventTime);
|
||||
PersistenceHelper.add(buf, prefix, ".lifetimeTotalValue",
|
||||
"Total value of data points since this stat was created", _lifetimeTotalValue);
|
||||
PersistenceHelper.add(buf, prefix, ".lifetimeEventCount",
|
||||
"How many events have occurred since this stat was created?", _lifetimeEventCount);
|
||||
PersistenceHelper.add(buf, prefix, ".lifetimeTotalEventTime",
|
||||
"How many milliseconds have the events since this stat was created consumed?",
|
||||
PersistenceHelper.addTime(buf, prefix, ".lifetimeTotalEventTime",
|
||||
"How much total time was consumed by the events since this stat was created?",
|
||||
_lifetimeTotalEventTime);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user