Author: toad
Date: 2008-01-16 15:06:02 +0000 (Wed, 16 Jan 2008)
New Revision: 17068

Modified:
   trunk/freenet/src/freenet/client/async/SingleBlockInserter.java
   trunk/freenet/src/freenet/node/SendableInsert.java
   trunk/freenet/src/freenet/node/SimpleSendableInsert.java
Log:
The last commit started migrating SendableInsert to the with-keyNum API (which 
supports one SendableRequest including multiple keys e.g. with 
SplitFileFetcherSubSegment).
Finish migrating the API.
At some point we will create SplitFileInserterSubSegment, and use it properly.

Modified: trunk/freenet/src/freenet/client/async/SingleBlockInserter.java
===================================================================
--- trunk/freenet/src/freenet/client/async/SingleBlockInserter.java     
2008-01-16 15:02:20 UTC (rev 17067)
+++ trunk/freenet/src/freenet/client/async/SingleBlockInserter.java     
2008-01-16 15:06:02 UTC (rev 17068)
@@ -136,7 +136,7 @@
                return retries;
        }

-       public void onFailure(LowLevelPutException e) {
+       public void onFailure(LowLevelPutException e, int keyNum) {
                if(parent.isCancelled()) {
                        fail(new InsertException(InsertException.CANCELLED));
                        return;
@@ -167,7 +167,7 @@
                        if(logMINOR) Logger.minor(this, "Consecutive RNFs: 
"+consecutiveRNFs+" / "+ctx.consecutiveRNFsCountAsSuccess);
                        if(consecutiveRNFs == 
ctx.consecutiveRNFsCountAsSuccess) {
                                if(logMINOR) Logger.minor(this, "Consecutive 
RNFs: "+consecutiveRNFs+" - counting as success");
-                               onSuccess();
+                               onSuccess(keyNum);
                                return;
                        }
                } else
@@ -253,7 +253,7 @@
                return resultingURI;
        }

-       public void onSuccess() {
+       public void onSuccess(int keyNum) {
                if(logMINOR) Logger.minor(this, "Succeeded ("+this+"): "+token);
                if(parent.isCancelled()) {
                        fail(new InsertException(InsertException.CANCELLED));
@@ -298,12 +298,12 @@
                                return false;
                        }
                } catch (LowLevelPutException e) {
-                       onFailure(e);
+                       onFailure(e, keyNum);
                        if(logMINOR) Logger.minor(this, "Request failed: 
"+this+" for "+e);
                        return true;
                }
                if(logMINOR) Logger.minor(this, "Request succeeded: "+this);
-               onSuccess();
+               onSuccess(keyNum);
                return true;
        }


Modified: trunk/freenet/src/freenet/node/SendableInsert.java
===================================================================
--- trunk/freenet/src/freenet/node/SendableInsert.java  2008-01-16 15:02:20 UTC 
(rev 17067)
+++ trunk/freenet/src/freenet/node/SendableInsert.java  2008-01-16 15:06:02 UTC 
(rev 17068)
@@ -12,13 +12,13 @@
 public abstract class SendableInsert extends SendableRequest {

        /** Called when we successfully insert the data */
-       public abstract void onSuccess();
+       public abstract void onSuccess(int keyNum);

        /** Called when we don't! */
-       public abstract void onFailure(LowLevelPutException e);
+       public abstract void onFailure(LowLevelPutException e, int keyNum);

        public void internalError(int keyNum, Throwable t) {
-               onFailure(new 
LowLevelPutException(LowLevelPutException.INTERNAL_ERROR, t.getMessage(), t));
+               onFailure(new 
LowLevelPutException(LowLevelPutException.INTERNAL_ERROR, t.getMessage(), t), 
keyNum);
        }

 }

Modified: trunk/freenet/src/freenet/node/SimpleSendableInsert.java
===================================================================
--- trunk/freenet/src/freenet/node/SimpleSendableInsert.java    2008-01-16 
15:02:20 UTC (rev 17067)
+++ trunk/freenet/src/freenet/node/SimpleSendableInsert.java    2008-01-16 
15:06:02 UTC (rev 17068)
@@ -42,13 +42,13 @@
                this.scheduler = scheduler;
        }

-       public void onSuccess() {
+       public void onSuccess(int keyNum) {
                // Yay!
                if(Logger.shouldLog(Logger.MINOR, this))
                        Logger.minor(this, "Finished insert of "+block);
        }

-       public void onFailure(LowLevelPutException e) {
+       public void onFailure(LowLevelPutException e, int keyNum) {
                if(Logger.shouldLog(Logger.MINOR, this))
                        Logger.minor(this, "Failed insert of "+block+": "+e);
        }
@@ -69,14 +69,14 @@
                        if(logMINOR) Logger.minor(this, "Starting request: 
"+this);
                        core.realPut(block, shouldCache());
                } catch (LowLevelPutException e) {
-                       onFailure(e);
+                       onFailure(e, keyNum);
                        if(logMINOR) Logger.minor(this, "Request failed: 
"+this+" for "+e);
                        return true;
                } finally {
                        finished = true;
                }
                if(logMINOR) Logger.minor(this, "Request succeeded: "+this);
-               onSuccess();
+               onSuccess(keyNum);
                return true;
        }



Reply via email to