Author: toad
Date: 2009-04-21 18:58:13 +0000 (Tue, 21 Apr 2009)
New Revision: 27166
Modified:
trunk/freenet/src/freenet/clients/http/FProxyFetchInProgress.java
trunk/freenet/src/freenet/clients/http/FProxyFetchResult.java
trunk/freenet/src/freenet/clients/http/FProxyToadlet.java
Log:
Show an ETA
Modified: trunk/freenet/src/freenet/clients/http/FProxyFetchInProgress.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/FProxyFetchInProgress.java
2009-04-21 18:45:52 UTC (rev 27165)
+++ trunk/freenet/src/freenet/clients/http/FProxyFetchInProgress.java
2009-04-21 18:58:13 UTC (rev 27166)
@@ -76,6 +76,7 @@
private int failedBlocks;
/** Fatally failed blocks */
private int fatallyFailedBlocks;
+ private int fetchedBlocksPreNetwork;
/** Finalized the block set? */
private boolean finalizedBlocks;
/** Fetch failed */
@@ -110,10 +111,10 @@
lastTouched = System.currentTimeMillis();
FProxyFetchResult res;
if(data != null)
- res = new FProxyFetchResult(this, data, mimeType,
timeStarted, goneToNetwork);
+ res = new FProxyFetchResult(this, data, mimeType,
timeStarted, goneToNetwork, getETA());
else
res = new FProxyFetchResult(this, mimeType, size,
timeStarted, goneToNetwork,
- totalBlocks, requiredBlocks,
fetchedBlocks, failedBlocks, fatallyFailedBlocks, finalizedBlocks, failed);
+ totalBlocks, requiredBlocks,
fetchedBlocks, failedBlocks, fatallyFailedBlocks, finalizedBlocks, failed,
getETA());
results.add(res);
return res;
}
@@ -151,6 +152,7 @@
synchronized(this) {
if(goneToNetwork) return;
goneToNetwork = true;
+ fetchedBlocksPreNetwork = fetchedBlocks;
}
} else return;
wakeWaiters(false);
@@ -263,4 +265,12 @@
}
tracker.queueCancel(this);
}
+
+ public synchronized long getETA() {
+ if(!goneToNetwork) return -1;
+ if(requiredBlocks <= 0) return -1;
+ if(fetchedBlocks >= requiredBlocks) return -1;
+ if(fetchedBlocks - fetchedBlocksPreNetwork < 5) return -1;
+ return (System.currentTimeMillis() - timeStarted) *
((requiredBlocks - fetchedBlocksPreNetwork) / (fetchedBlocks -
fetchedBlocksPreNetwork));
+ }
}
Modified: trunk/freenet/src/freenet/clients/http/FProxyFetchResult.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/FProxyFetchResult.java
2009-04-21 18:45:52 UTC (rev 27165)
+++ trunk/freenet/src/freenet/clients/http/FProxyFetchResult.java
2009-04-21 18:58:13 UTC (rev 27166)
@@ -41,8 +41,10 @@
final FProxyFetchInProgress progress;
+ final long eta;
+
/** Constructor when we are returning the data */
- FProxyFetchResult(FProxyFetchInProgress parent, Bucket data, String
mimeType, long timeStarted, boolean goneToNetwork) {
+ FProxyFetchResult(FProxyFetchInProgress parent, Bucket data, String
mimeType, long timeStarted, boolean goneToNetwork, long eta) {
this.data = data;
this.mimeType = mimeType;
this.size = data.size();
@@ -52,10 +54,11 @@
finalizedBlocks = true;
failed = null;
this.progress = parent;
+ this.eta = eta;
}
/** Constructor when we are not returning the data, because it is still
running or it failed */
- FProxyFetchResult(FProxyFetchInProgress parent, String mimeType, long
size, long timeStarted, boolean goneToNetwork, int totalBlocks, int
requiredBlocks, int fetchedBlocks, int failedBlocks, int fatallyFailedBlocks,
boolean finalizedBlocks, FetchException failed) {
+ FProxyFetchResult(FProxyFetchInProgress parent, String mimeType, long
size, long timeStarted, boolean goneToNetwork, int totalBlocks, int
requiredBlocks, int fetchedBlocks, int failedBlocks, int fatallyFailedBlocks,
boolean finalizedBlocks, FetchException failed, long eta) {
this.data = null;
this.mimeType = mimeType;
this.size = size;
@@ -69,6 +72,7 @@
this.finalizedBlocks = finalizedBlocks;
this.failed = failed;
this.progress = parent;
+ this.eta = eta;
}
/** Must be called when fproxy has finished with the data */
Modified: trunk/freenet/src/freenet/clients/http/FProxyToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/FProxyToadlet.java 2009-04-21
18:45:52 UTC (rev 27165)
+++ trunk/freenet/src/freenet/clients/http/FProxyToadlet.java 2009-04-21
18:58:13 UTC (rev 27166)
@@ -527,6 +527,9 @@
infoboxContent.addChild("p", "Fatally blocks:
"+fr.fatallyFailedBlocks);
infoboxContent.addChild("p", "Finalized:
"+fr.finalizedBlocks);
infoboxContent.addChild("p", "Time elapsed:
"+TimeUtil.formatTime(System.currentTimeMillis() - fr.timeStarted));
+ long eta = fr.eta;
+ if(eta > 0)
+ infoboxContent.addChild("p", "ETA:
"+TimeUtil.formatTime(eta));
if(fr.goneToNetwork)
infoboxContent.addChild("p", "Your node
is downloading this file from Freenet. This could take seconds or minutes
depending on how big the file is and how popular.");
else
_______________________________________________
cvs mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs