Author: toad
Date: 2005-11-25 00:56:19 +0000 (Fri, 25 Nov 2005)
New Revision: 7592
Modified:
trunk/freenet/src/freenet/client/RetryTracker.java
trunk/freenet/src/freenet/client/Segment.java
trunk/freenet/src/freenet/client/SplitInserter.java
trunk/freenet/src/freenet/client/events/SplitfileProgressEvent.java
trunk/freenet/src/freenet/node/Version.java
Log:
Minor improvements to progress monitor.
Modified: trunk/freenet/src/freenet/client/RetryTracker.java
===================================================================
--- trunk/freenet/src/freenet/client/RetryTracker.java 2005-11-25 00:50:05 UTC
(rev 7591)
+++ trunk/freenet/src/freenet/client/RetryTracker.java 2005-11-25 00:56:19 UTC
(rev 7592)
@@ -71,6 +71,7 @@
private boolean killed;
private boolean finishOnEmpty;
private final RetryTrackerCallback callback;
+ private boolean callOnProgress = false;
/**
* Create a RetryTracker.
@@ -173,6 +174,8 @@
* we have run out of retries.
*/
public synchronized void nonfatalError(SplitfileBlock block, int
reasonCode) {
+ if(!callOnProgress)
+ callback.onProgress();
nonfatalErrors.inc(reasonCode);
runningBlocks.remove(block);
int levelNumber = block.getRetryCount();
@@ -194,6 +197,8 @@
* @param reasonCode A client-specific code indicating the type of
failure.
*/
public synchronized void fatalError(SplitfileBlock block, int
reasonCode) {
+ if(!callOnProgress)
+ callback.onProgress();
fatalErrors.inc(reasonCode);
runningBlocks.remove(block);
failedBlocksFatalErrors.add(block);
@@ -205,7 +210,6 @@
* Otherwise if we are finished, call the callback's finish method.
*/
public synchronized void maybeStart(boolean cantCallFinished) {
- callback.onProgress();
if(killed) return;
Logger.minor(this, "succeeded: "+succeededBlocks.size()+",
target: "+targetSuccesses+
", failed:
"+failedBlocksTooManyRetries.size()+", fatal: "+failedBlocksFatalErrors.size()+
@@ -245,12 +249,18 @@
}
public synchronized void success(SplitfileBlock block) {
+ if(!callOnProgress)
+ callback.onProgress();
if(killed) return;
runningBlocks.remove(block);
succeededBlocks.add(block);
maybeStart(false);
}
+ public synchronized void callOnProgress() {
+ callOnProgress = true;
+ }
+
/**
* Get the next block to try. This is a randomly selected block from the
* lowest priority currently available. Move it into the running list.
Modified: trunk/freenet/src/freenet/client/Segment.java
===================================================================
--- trunk/freenet/src/freenet/client/Segment.java 2005-11-25 00:50:05 UTC
(rev 7591)
+++ trunk/freenet/src/freenet/client/Segment.java 2005-11-25 00:56:19 UTC
(rev 7592)
@@ -160,6 +160,7 @@
for(int i=0;i<checkBlockStatus.length;i++) {
tracker.addBlock(checkBlockStatus[i]);
}
+ tracker.callOnProgress();
tracker.setFinishOnEmpty();
}
Modified: trunk/freenet/src/freenet/client/SplitInserter.java
===================================================================
--- trunk/freenet/src/freenet/client/SplitInserter.java 2005-11-25 00:50:05 UTC
(rev 7591)
+++ trunk/freenet/src/freenet/client/SplitInserter.java 2005-11-25 00:56:19 UTC
(rev 7592)
@@ -197,6 +197,7 @@
private void startInsertingDataBlocks() {
for(int i=0;i<origDataBlocks.length;i++)
tracker.addBlock(origDataBlocks[i]);
+ tracker.callOnProgress();
}
/**
Modified: trunk/freenet/src/freenet/client/events/SplitfileProgressEvent.java
===================================================================
--- trunk/freenet/src/freenet/client/events/SplitfileProgressEvent.java
2005-11-25 00:50:05 UTC (rev 7591)
+++ trunk/freenet/src/freenet/client/events/SplitfileProgressEvent.java
2005-11-25 00:56:19 UTC (rev 7592)
@@ -20,7 +20,7 @@
}
public String getDescription() {
- return "Completed "+fetchedBlocks+"/"+totalBlocks+" (failed
"+failedBlocks+", fatally "+fatallyFailedBlocks+", running "+runningBlocks+")";
+ return "Completed
"+(100*(fetchedBlocks+failedBlocks+fatallyFailedBlocks)/totalBlocks)+"%
"+fetchedBlocks+"/"+totalBlocks+" (failed "+failedBlocks+", fatally
"+fatallyFailedBlocks+", running "+runningBlocks+")";
}
public int getCode() {
Modified: trunk/freenet/src/freenet/node/Version.java
===================================================================
--- trunk/freenet/src/freenet/node/Version.java 2005-11-25 00:50:05 UTC (rev
7591)
+++ trunk/freenet/src/freenet/node/Version.java 2005-11-25 00:56:19 UTC (rev
7592)
@@ -20,7 +20,7 @@
public static final String protocolVersion = "1.0";
/** The build number of the current revision */
- public static final int buildNumber = 211;
+ public static final int buildNumber = 212;
/** Oldest build of Fred we will talk to */
public static final int lastGoodBuild = 211;