Author: toad
Date: 2009-04-22 12:22:09 +0000 (Wed, 22 Apr 2009)
New Revision: 27211

Modified:
   trunk/freenet/src/freenet/clients/http/FProxyFetchInProgress.java
   trunk/freenet/src/freenet/clients/http/FProxyFetchResult.java
   trunk/freenet/src/freenet/clients/http/FProxyFetchTracker.java
   trunk/freenet/src/freenet/clients/http/FProxyFetchWaiter.java
   trunk/freenet/src/freenet/clients/http/FProxyToadlet.java
Log:
Fix some performance regressions, don't wait for 2 seconds on coalescing, don't 
re-run the request, do rerun the request if we coalesced with a request which 
failed non-fatally, but if it failed fatally (e.g. too big) then tell the user


Modified: trunk/freenet/src/freenet/clients/http/FProxyFetchInProgress.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/FProxyFetchInProgress.java   
2009-04-22 12:13:53 UTC (rev 27210)
+++ trunk/freenet/src/freenet/clients/http/FProxyFetchInProgress.java   
2009-04-22 12:22:09 UTC (rev 27211)
@@ -109,14 +109,14 @@
                return waiter;
        }
 
-       synchronized FProxyFetchResult innerGetResult() {
+       synchronized FProxyFetchResult innerGetResult(boolean hasWaited) {
                lastTouched = System.currentTimeMillis();
                FProxyFetchResult res;
                if(data != null)
-                       res = new FProxyFetchResult(this, data, mimeType, 
timeStarted, goneToNetwork, getETA());
+                       res = new FProxyFetchResult(this, data, mimeType, 
timeStarted, goneToNetwork, getETA(), hasWaited);
                else
                        res = new FProxyFetchResult(this, mimeType, size, 
timeStarted, goneToNetwork,
-                                       totalBlocks, requiredBlocks, 
fetchedBlocks, failedBlocks, fatallyFailedBlocks, finalizedBlocks, failed, 
getETA());
+                                       totalBlocks, requiredBlocks, 
fetchedBlocks, failedBlocks, fatallyFailedBlocks, finalizedBlocks, failed, 
getETA(), hasWaited);
                results.add(res);
                return res;
        }
@@ -283,4 +283,10 @@
                if(fetchedBlocks - fetchedBlocksPreNetwork < 5) return -1;
                return (System.currentTimeMillis() - timeStarted) * 
((requiredBlocks - fetchedBlocksPreNetwork) / (fetchedBlocks - 
fetchedBlocksPreNetwork));
        }
+
+       public synchronized boolean notFinishedOrFatallyFinished() {
+               if(data == null && failed == null) return true;
+               if(failed != null && failed.isFatal()) return true;
+               return false;
+       }
 }

Modified: trunk/freenet/src/freenet/clients/http/FProxyFetchResult.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/FProxyFetchResult.java       
2009-04-22 12:13:53 UTC (rev 27210)
+++ trunk/freenet/src/freenet/clients/http/FProxyFetchResult.java       
2009-04-22 12:22:09 UTC (rev 27211)
@@ -36,15 +36,17 @@
        /** Finalized blocks? */
        final boolean finalizedBlocks;
        
+       
        /** Failed */
        final FetchException failed;
        
        final FProxyFetchInProgress progress;
+       final boolean hasWaited;
 
        final long eta;
 
        /** Constructor when we are returning the data */
-       FProxyFetchResult(FProxyFetchInProgress parent, Bucket data, String 
mimeType, long timeStarted, boolean goneToNetwork, long eta) {
+       FProxyFetchResult(FProxyFetchInProgress parent, Bucket data, String 
mimeType, long timeStarted, boolean goneToNetwork, long eta, boolean hasWaited) 
{
                this.data = data;
                this.mimeType = mimeType;
                this.size = data.size();
@@ -55,10 +57,11 @@
                failed = null;
                this.progress = parent;
                this.eta = eta;
+               this.hasWaited = hasWaited;
        }
 
        /** 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, long eta) {
+       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, boolean hasWaited) {
                this.data = null;
                this.mimeType = mimeType;
                this.size = size;
@@ -73,6 +76,7 @@
                this.failed = failed;
                this.progress = parent;
                this.eta = eta;
+               this.hasWaited = hasWaited;
        }
        
        /** Must be called when fproxy has finished with the data */
@@ -83,5 +87,9 @@
        public boolean hasData() {
                return data != null;
        }
+
+       public boolean hasWaited() {
+               return hasWaited;
+       }
        
 }

Modified: trunk/freenet/src/freenet/clients/http/FProxyFetchTracker.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/FProxyFetchTracker.java      
2009-04-22 12:13:53 UTC (rev 27210)
+++ trunk/freenet/src/freenet/clients/http/FProxyFetchTracker.java      
2009-04-22 12:22:09 UTC (rev 27211)
@@ -53,7 +53,7 @@
                                Object[] check = fetchers.getArray(key);
                                for(int i=0;i<check.length;i++) {
                                        progress = (FProxyFetchInProgress) 
check[i];
-                                       if(progress.maxSize == maxSize 
+                                       if((progress.maxSize == maxSize && 
progress.notFinishedOrFatallyFinished())
                                                        || progress.hasData()) 
return progress.getWaiter();
                                }
                        }

Modified: trunk/freenet/src/freenet/clients/http/FProxyFetchWaiter.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/FProxyFetchWaiter.java       
2009-04-22 12:13:53 UTC (rev 27210)
+++ trunk/freenet/src/freenet/clients/http/FProxyFetchWaiter.java       
2009-04-22 12:22:09 UTC (rev 27211)
@@ -15,6 +15,7 @@
        private boolean awoken;
        
        public FProxyFetchResult getResult() {
+               boolean waited;
                synchronized(this) {
                        if(!(finished || hasWaited || awoken)) {
                                awoken = false;
@@ -23,9 +24,11 @@
                                } catch (InterruptedException e) { 
                                        // Not likely
                                };
+                               hasWaited = true;
                        }
+                       waited = hasWaited;
                }
-               return progress.innerGetResult();
+               return progress.innerGetResult(waited);
        }
 
        public void close() {

Modified: trunk/freenet/src/freenet/clients/http/FProxyToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/FProxyToadlet.java   2009-04-22 
12:13:53 UTC (rev 27210)
+++ trunk/freenet/src/freenet/clients/http/FProxyToadlet.java   2009-04-22 
12:22:09 UTC (rev 27211)
@@ -599,7 +599,7 @@
                try {
                        if(Logger.shouldLog(Logger.MINOR, this))
                                Logger.minor(this, "FProxy fetching "+key+" 
("+maxSize+ ')');
-                       if(data == null && fe == null) {
+                       if((data == null && fe == null) || fr.hasWaited()) {
                        FetchResult result = fetch(key, maxSize, new 
RequestClient() {
                                public boolean persistent() {
                                        return false;

_______________________________________________
cvs mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs

Reply via email to