Index: trunk/WikiWord/WikiWordBuilder/src/main/java/de/brightbyte/wikiword/processor/ChunkedProgressRateTracker.java |
— | — | @@ -9,12 +9,14 @@ |
10 | 10 | import de.brightbyte.job.ProgressRateTracker; |
11 | 11 | |
12 | 12 | public class ChunkedProgressRateTracker extends ProgressRateTracker { |
13 | | - protected long counter = 0; |
14 | | - protected long timestamp = 0; |
| 13 | + protected long counter; |
| 14 | + protected long timestamp; |
15 | 15 | protected String name; |
16 | 16 | |
17 | 17 | public ChunkedProgressRateTracker(String name) { |
18 | 18 | this.name = name; |
| 19 | + this.timestamp = System.currentTimeMillis(); |
| 20 | + this.counter = 0; |
19 | 21 | } |
20 | 22 | |
21 | 23 | public void step() { |
— | — | @@ -34,8 +36,10 @@ |
35 | 37 | } |
36 | 38 | |
37 | 39 | public boolean chunkIf(long counter, int sec) { |
| 40 | + if (sec>0 && this.timestamp<=0) this.timestamp = System.currentTimeMillis(); |
| 41 | + long d = System.currentTimeMillis() - this.timestamp; |
38 | 42 | if ((counter>0 && this.counter>=0 && this.counter >= counter) |
39 | | - || (sec>0 && this.timestamp>0 && (System.currentTimeMillis() - this.timestamp)>sec*1000)) { |
| 43 | + || (sec>0 && this.timestamp>0 && d>sec*1000)) { |
40 | 44 | chunk(); |
41 | 45 | return true; |
42 | 46 | } else { |