Author: toad
Date: 2008-04-11 17:57:03 +0000 (Fri, 11 Apr 2008)
New Revision: 19194
Modified:
trunk/freenet/src/freenet/node/UptimeEstimator.java
Log:
Make a constant PERIOD for 5*60*1000.
Modified: trunk/freenet/src/freenet/node/UptimeEstimator.java
===================================================================
--- trunk/freenet/src/freenet/node/UptimeEstimator.java 2008-04-11 17:55:25 UTC
(rev 19193)
+++ trunk/freenet/src/freenet/node/UptimeEstimator.java 2008-04-11 17:57:03 UTC
(rev 19194)
@@ -24,6 +24,8 @@
*/
public class UptimeEstimator implements Runnable {
+ static final int PERIOD = 5*60*1000;
+
Ticker ticker;
/** For each 5 minute slot in the last 48 hours, were we online? */
@@ -55,7 +57,7 @@
public void start() {
long now = System.currentTimeMillis();
- int fiveMinutesSinceEpoch = (int)(now / 5*60*1000);
+ int fiveMinutesSinceEpoch = (int)(now / PERIOD);
int base = fiveMinutesSinceEpoch - wasOnline.length;
// Read both files.
readData(prevFile, base);
@@ -103,7 +105,7 @@
}
FileOutputStream fos = null;
DataOutputStream dos = null;
- int fiveMinutesSinceEpoch = (int)(now / 5*60*1000);
+ int fiveMinutesSinceEpoch = (int)(now / PERIOD);
try {
fos = new FileOutputStream(logFile, true);
dos = new DataOutputStream(fos);
@@ -120,8 +122,8 @@
}
private void schedule(long now) {
- long nextTime = (((now / 5*60*1000)) * (5*60*1000)) +
timeOffset;
- if(nextTime < now) nextTime += 5*60*1000;
+ long nextTime = (((now / PERIOD)) * (PERIOD)) + timeOffset;
+ if(nextTime < now) nextTime += PERIOD;
ticker.queueTimedJob(this, System.currentTimeMillis() -
nextTime);
}