Update of /cvsroot/freenet/freenet/src/freenet/node/states/request
In directory sc8-pr-cvs1:/tmp/cvs-serv4928/src/freenet/node/states/request

Modified Files:
        Pending.java 
Log Message:
Indenting

Index: Pending.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/node/states/request/Pending.java,v
retrieving revision 1.86
retrieving revision 1.87
diff -u -w -r1.86 -r1.87
--- Pending.java        27 Nov 2003 02:05:57 -0000      1.86
+++ Pending.java        3 Dec 2003 11:18:10 -0000       1.87
@@ -135,16 +135,14 @@
                ignoreDS = false;
        }
        if(logDEBUG)
-           Core.logger.log(this, "Created new Pending: "+this+" from "+
-                           ancestor, new Exception("debug"), Logger.DEBUG);
+                       Core.logger.log(this, "Created new Pending: " + this +" from " 
+ ancestor, new Exception("debug"), Logger.DEBUG);
     }
     
     /** State implementation.
       */
     public void lost(Node n) {
         Core.diagnostics.occurrenceCounting("lostRequestState", 1);
-       Core.logger.log(this, "Lost a Pending state "+this+" !",
-                       new Exception("debug"), Logger.NORMAL);
+               Core.logger.log(this, "Lost a Pending state " + this +" !", new 
Exception("debug"), Logger.NORMAL);
        terminateRouting(false, false, false);
         fail(n, "Request state lost due to overflow for "+this);
     }
@@ -166,8 +164,7 @@
         storeData = sd;
     }
     
-    void receivedQueryRestarted(Node n, QueryRestarted qr) throws BadStateException,
-                                                                  
RequestAbortException {
+    void receivedQueryRestarted(Node n, QueryRestarted qr) throws BadStateException, 
RequestAbortException {
         if (!fromLastPeer(qr)) {
             throw new BadStateException("QueryRestarted from the wrong peer!");
         }
@@ -185,9 +182,7 @@
      * Must be called by subclass as part of the implementation
      * for receivedMessage(Node n, QueryRejected qr)
      */
-    void receivedQueryRejected(Node n, QueryRejected qr) throws BadStateException,
-                                                                RequestAbortException,
-                                                                EndOfRouteException {
+    void receivedQueryRejected(Node n, QueryRejected qr) throws BadStateException, 
RequestAbortException, EndOfRouteException {
         if (!fromLastPeer(qr)) {
             throw new BadStateException("QueryRejected from the wrong peer!");
         }
@@ -195,20 +190,16 @@
        gotTime = System.currentTimeMillis();
        if(receivedTime >= -1) {
            receivedTime = qr.getReceivedTime(); // measure routing time again
-           if(logDEBUG) Core.logger.log(this, "Remeasured receivedTime: 
"+receivedTime+
-                                     " for "+this, Logger.DEBUG);
+                       if (logDEBUG)
+                               Core.logger.log(this, "Remeasured receivedTime: " + 
receivedTime + " for " + this, Logger.DEBUG);
        }
        if (receivedTime <= last20thCenturyMillisecond) {
            if(logDEBUG && receivedTime > -1)
-               Core.logger.log(this, "qr.getReceivedTime() returned a 20th century 
time "+
-                            receivedTime + ") for " +
-                            this, Logger.DEBUG);
+                               Core.logger.log(this, "qr.getReceivedTime() returned a 
20th century time " + receivedTime + ") for " + this, Logger.DEBUG);
            receivedTime = 0;
        } else {
            if(logDEBUG)
-               Core.logger.log(this, "QueryRejected gotTime-recievedTime: "+
-                            (gotTime-receivedTime)+" for "+this,
-                            new Exception("debug"), Logger.DEBUG);
+                               Core.logger.log(this, "QueryRejected 
gotTime-recievedTime: " + (gotTime - receivedTime) + " for " + this, new 
Exception("debug"), Logger.DEBUG);
        }
        
 //     logFailure(n, gotTime);
@@ -219,20 +210,16 @@
         hopsToLive--;
         
        if(logDEBUG)
-           Core.logger.log(this, "Rejected count: "+rejected+
-                        ", current hopsToLive: "+
-                        hopsToLive+" for "+this, Logger.DEBUG);
+                       Core.logger.log(this, "Rejected count: " + rejected + ", 
current hopsToLive: " + hopsToLive + " for " + this, Logger.DEBUG);
        
        if(routes == null) {
-           Core.logger.log(this, "Already terminated in "+this+
-                        ".receivedQueryRejected!", Logger.NORMAL);
+                       Core.logger.log(this, "Already terminated in " + this 
+".receivedQueryRejected!", Logger.NORMAL);
        } else {
            routes.queryRejected(qr.source.isCached(), qr.attenuation);
        }
        long toldRTTime = System.currentTimeMillis();
        if(logDEBUG)
-           Core.logger.log(this, "Time to inform RT: "+toldRTTime+" for "+
-                        this, Logger.DEBUG);
+                       Core.logger.log(this, "Time to inform RT: " + toldRTTime + " 
for " + this, Logger.DEBUG);
        
         // FIXME - do we want to do a QueryRestarted if the sanity check fails?
         
@@ -241,14 +228,11 @@
                         // a parallel request succeeding
        long preGotRouteTime = System.currentTimeMillis();
        if(logDEBUG)
-           Core.logger.log(this, "Time to cancel restart and search data "+
-                        "(unsuccessfully): "+(preGotRouteTime - toldRTTime)+
-                        " for "+this, Logger.DEBUG);
+                       Core.logger.log(this, "Time to cancel restart and search data 
" + "(unsuccessfully): " + (preGotRouteTime - toldRTTime) + " for " + this, 
Logger.DEBUG);
        Request newReq = createRequest(qr.otherFields, n.myRef);
        gotRouteTime = System.currentTimeMillis();
        if(logDEBUG)
-           Core.logger.log(this, "Got request in "+(gotRouteTime-preGotRouteTime)+
-                        " for "+this, Logger.DEBUG);
+                       Core.logger.log(this, "Got request in " + (gotRouteTime - 
preGotRouteTime) + " for " + this, Logger.DEBUG);
         sendOn(n, newReq, false);
     }
     
@@ -385,16 +369,11 @@
        if(logDEBUG)
            Core.logger.log(this, "Backtracking", Logger.DEBUG);
         try {
-           Message m = new QueryRejected(id, hopsToLive, "Looped request", 
-                       n.requestInterval, r.otherFields);
-           RequestSendCallback cb = 
-               new RequestSendCallback("QueryRejected (looped "+
-                                       "request) for "+this, n, this);
-           n.sendMessageAsync(m, r.getSource(), Core.hopTime(1),
-                              cb);
+                       Message m = new QueryRejected(id, hopsToLive, "Looped 
request", n.requestInterval, r.otherFields);
+                       RequestSendCallback cb = new 
RequestSendCallback("QueryRejected (looped " + "request) for " + this, n, this);
+                       n.sendMessageAsync(m, r.getSource(), Core.hopTime(1), cb);
         } catch (CommunicationException e) {
-            Core.logger.log(this, "Failed to send backtrack reply: "+e+" for "+this,
-                        Logger.MINOR);
+                       Core.logger.log(this, "Failed to send backtrack reply: " + e + 
" for " + this, Logger.MINOR);
         }
        receivedTime = -2;
         r.drop(n);
@@ -406,17 +385,14 @@
         }
         if (!accepted) {
            if(logDEBUG)
-               Core.logger.log(this, "Got Accepted in Pending, chain "+
-                            this, new Exception("debug"), 
-                            Logger.DEBUG);
+                               Core.logger.log(this, "Got Accepted in Pending, chain 
" + this, new Exception("debug"), Logger.DEBUG);
             scheduleRestart(n, Core.hopTime(hopsToLive));
             acceptedTime = System.currentTimeMillis();
             accepted = true;
             routes.routeAccepted();
            if(outwardSender != null) {
-               Core.logger.log(this, "Got Accepted before got SendFinished "+
-                            outwardSender+" on "+this, 
-                            Logger.DEBUG /* FIXME */);
+                               Core.logger.log(this, "Got Accepted before got 
SendFinished " + outwardSender + " on " + this, Logger.DEBUG /* FIXME */
+                               );
                outwardSender.mustHaveSucceeded();
                outwardSender.cancel();
                outwardSender = null;
@@ -537,8 +513,7 @@
     
     //=== support methods ======================================================
     
-    private void sendOn(Node n, Request r, boolean isFirst)
-       throws EndOfRouteException, RequestAbortException {
+    private void sendOn(Node n, Request r, boolean isFirst) throws 
EndOfRouteException, RequestAbortException {
 
        loggedResult = false;
        
@@ -547,8 +522,7 @@
             throw new EndOfRouteException("Reached last node in route");
         }
        
-        if (routeToNewestNodes &&
-                       routedTime > 0) {
+               if (routeToNewestNodes && routedTime > 0) {
                terminateRouting(false, false, false);
                throw new EndOfRouteException("Only routing to one node as requested");
         }
@@ -559,47 +533,38 @@
         int attemptCount = 0;
        while (true) { // until the send doesn't fail
            if(logDEBUG)
-               Core.logger.log(this, "Still trying to route "+searchKey+"("+
-                            this+"), attempt "+attemptCount, Logger.DEBUG);
+                               Core.logger.log(this, "Still trying to route " + 
searchKey + "(" + this +"), attempt " + attemptCount, Logger.DEBUG);
            if(routes == null) {
                nr = null; // terminated
                Core.logger.log(this, "Already terminated but trying to route!: 
"+this,Logger.NORMAL);
            } else
                nr = routes.getNextRoute();
-           if(logDEBUG) Core.logger.log(this, "Got next route for "+this,
-                                     Logger.DEBUG);
+                       if (logDEBUG)
+                               Core.logger.log(this, "Got next route for " + this, 
Logger.DEBUG);
            long stillInSendOnTime = System.currentTimeMillis();
            if(isFirst && attemptCount == 0) {
-               Core.diagnostics.occurrenceContinuous("stillInSendOnTime", 
-                                                  stillInSendOnTime - 
-                                                  gotRouteTime);
-               if(logDEBUG) Core.logger.log(this, "stillInSendOnTime="+
-                                         (stillInSendOnTime - gotRouteTime)+
-                                         " for "+this, Logger.DEBUG);
+                               
Core.diagnostics.occurrenceContinuous("stillInSendOnTime", stillInSendOnTime - 
gotRouteTime);
+                               if (logDEBUG)
+                                       Core.logger.log(this, "stillInSendOnTime=" + 
(stillInSendOnTime - gotRouteTime) + " for " + this, Logger.DEBUG);
            }
             if (nr == null) {
                if(logDEBUG)
-                   Core.logger.log(this, "Ran out of routes for "+this+" after "+
-                                attemptCount+" tries.", Logger.DEBUG);
+                                       Core.logger.log(this, "Ran out of routes for " 
+ this +" after " + attemptCount + " tries.", Logger.DEBUG);
                fail(n, "No route found", r.otherFields);
                if(logDEBUG)
-                   Core.logger.log(this, "rt exhaused for "+this, 
-                                Logger.DEBUG);
+                                       Core.logger.log(this, "rt exhaused for " + 
this, Logger.DEBUG);
                terminateRouting(false, origHopsToLive>0, true);
                throw new RequestAbortException(new RequestDone(this));
            } else {
                if(logDEBUG)
-                   Core.logger.log(this, "Got a route for "+this,
-                                Logger.DEBUG);
+                                       Core.logger.log(this, "Got a route for " + 
this, Logger.DEBUG);
            }
            addr = n.getPeer(nr);
-           if(logDEBUG) Core.logger.log(this, "Got peer "+addr+" for "+this,
-                                     Logger.DEBUG);
+                       if (logDEBUG)
+                               Core.logger.log(this, "Got peer " + addr + " for " + 
this, Logger.DEBUG);
            long stillStillInSendOnTime = System.currentTimeMillis();
            if(isFirst && attemptCount == 0) {
-               Core.diagnostics.occurrenceContinuous("stillStillInSendOnTime", 
-                                                  stillStillInSendOnTime - 
-                                                  stillInSendOnTime);
+                               
Core.diagnostics.occurrenceContinuous("stillStillInSendOnTime", stillStillInSendOnTime 
- stillInSendOnTime);
            }
            if (addr == null) {  // bad node ref
                // or, one we just don't have a transport for?
@@ -608,8 +573,7 @@
                //    Logger.MINOR);
                //n.rt.dereference(nr.getIdentity());
                if(logDEBUG)
-                   Core.logger.log(this, this+": Route address is NULL!", 
-                                Logger.DEBUG);
+                                       Core.logger.log(this, this +": Route address 
is NULL!", Logger.DEBUG);
                routes.ignoreRoute();
                continue;
            }
@@ -617,56 +581,45 @@
                // funnily enough, this happens quite often
                // and results in some pretty dumb "loops"
                if(logDEBUG)
-                   Core.logger.log(this, this+": Route is self",
-                                Logger.DEBUG);
+                                       Core.logger.log(this, this +": Route is self", 
Logger.DEBUG);
                routes.ignoreRoute();
                continue;
            }
-           if(logDEBUG) Core.logger.log(this, "Still here after origPeer checks: "+
-                                     this, Logger.DEBUG);
+                       if (logDEBUG)
+                               Core.logger.log(this, "Still here after origPeer 
checks: " + this, Logger.DEBUG);
            routedTime = System.currentTimeMillis();
            if(logDEBUG)
-               Core.logger.log(this, "Forwarding query "+this+" to "+
-                            addr+" at "+routedTime, Logger.DEBUG);
+                               Core.logger.log(this, "Forwarding query " + this +" to 
" + addr + " at " + routedTime, Logger.DEBUG);
            try {
-               if (attemptCount == 0 && receivedTime > 0 &&
-                   receivedTime < routedTime) { // sanity
+                               if (attemptCount == 0 && receivedTime > 0 && 
receivedTime < routedTime) { // sanity
                    long rt = routedTime - receivedTime;
                    Core.diagnostics.occurrenceContinuous("routingTime", rt);
                    if(rt > 1000 && logDEBUG)
-                       Core.logger.log(this, "routingTime "+rt+" for "+
-                                    this, new Exception("debug"), 
-                                    Logger.DEBUG);
-                   Core.diagnostics.occurrenceContinuous("subRoutingTime",
-                                                      routedTime - 
-                                                      stillStillInSendOnTime);
+                                               Core.logger.log(this, "routingTime " + 
rt + " for " + this, new Exception("debug"), Logger.DEBUG);
+                                       
Core.diagnostics.occurrenceContinuous("subRoutingTime", routedTime - 
stillStillInSendOnTime);
                    if(searchDataRoutingTime > 0)
-                       Core.diagnostics.occurrenceContinuous("searchDataRoutingTime", 
-                                                          searchDataRoutingTime);
+                                               
Core.diagnostics.occurrenceContinuous("searchDataRoutingTime", searchDataRoutingTime);
                    receivedTime = -2; // make sure we aren't called twice
                }
                attemptCount++;
                
                outwardIdentityLastUsed = nr.getIdentity();
                outwardSender = new SendFinished(n, id, r.toString());
-               if(logDEBUG) Core.logger.log(this, "Sending message "+r+" on "
-                                            +nr+" for "+this+": "+outwardSender,
-                                            Logger.DEBUG);
+                               if (logDEBUG)
+                                       Core.logger.log(this, "Sending message " + r + 
" on " + nr + " for " + this +": " + outwardSender, Logger.DEBUG);
                n.sendMessageAsync(r, nr, Core.hopTime(1), outwardSender);
                
                // We only wait 1 hop time for accepted. Sending should take much less 
time.
                n.schedule(Core.hopTime(1), outwardSender);
-               if(logDEBUG) Core.logger.log(this, "Sent message "+r+" on "+
-                                            nr+" for "+this, Logger.DEBUG);
+                               if (logDEBUG)
+                                       Core.logger.log(this, "Sent message " + r + " 
on " + nr + " for " + this, Logger.DEBUG);
                break;
            } catch (CommunicationException e) {
                ++unreachable;
                // don't care if it's terminal or nonterminal
                // because routing is too time-critical
                if(logDEBUG)
-                   Core.logger.log(this, "Routing ("+this+") failure to: "
-                                +e.peerAddress() + " -- " + e, e, 
-                                Logger.DEBUG);
+                                       Core.logger.log(this, "Routing (" + this +") 
failure to: " + e.peerAddress() + " -- " + e, e, Logger.DEBUG);
                if (e instanceof AuthenticationFailedException) {
                    routes.authFailed();
                } else {
@@ -694,10 +647,13 @@
     public boolean canRunFast(Node n, MessageObject mo) {
        if(mo instanceof SendFinished) {
            SendFinished sf = (SendFinished)mo;
-           if(sf == feedbackSender) return true;
+                       if (sf == feedbackSender)
+                               return true;
            if(sf == outwardSender) {
-               if(sf.getSuccess()) return true;
-               else return false;
+                               if (sf.getSuccess())
+                                       return true;
+                               else
+                                       return false;
            }
            return true;
        }
@@ -806,18 +762,14 @@
        }
     }
     
-    private final void relayRestarted(Node n, long timeout,
-                                     boolean sendAsync) throws RequestAbortException {
+    private final void relayRestarted(Node n, long timeout, boolean sendAsync) throws 
RequestAbortException {
        if(sendAsync)
            feedbackSender = new SendFinished(n, id, "Restarted");
        // We don't care if it takes forever, nothing is waiting for it
         try {
-            ft.restarted(n, timeout, 
-                        sendAsync ? feedbackSender : null);
+                       ft.restarted(n, timeout, sendAsync ? feedbackSender : null);
         } catch (CommunicationException e) {
-            Core.logger.log(this,
-                         "Couldn't restart because relaying QueryRestarted failed: "+
-                        e+" for "+this, Logger.MINOR);
+                       Core.logger.log(this, "Couldn't restart because relaying 
QueryRestarted failed: " + e + " for " + this, Logger.MINOR);
            terminateRouting(false, false, false);
             throw new RequestAbortException(new RequestDone(this));
         }
@@ -827,17 +779,16 @@
      * transfer the data back to the requester. 
      */
     SendData sendData(Node n, KeyInputStream doc) throws CommunicationException {
-       if(logDEBUG) Core.logger.log(this, "Sending data (,"+doc+") for "+this,
-                                 Logger.DEBUG);
+               if (logDEBUG)
+                       Core.logger.log(this, "Sending data (," + doc + ") for " + 
this, Logger.DEBUG);
         Storables storables = doc.getStorables();
         TrailerWriter out = ft.dataFound(n, storables, doc.length());
         // null means the initiator is not interested in seeing the 
         // data (e.g., KeyCollision response in FCP)
         
-       SendData sd = new SendData(Core.getRandSource().nextLong(), this.id, out,
-                                  doc, doc.length(), storables.getPartSize(), n);
-       if(logDEBUG) Core.logger.log(this, "Got SendData("+sd+") for "+this,
-                                 Logger.DEBUG);
+               SendData sd = new SendData(Core.getRandSource().nextLong(), this.id, 
out, doc, doc.length(), storables.getPartSize(), n);
+               if (logDEBUG)
+                       Core.logger.log(this, "Got SendData(" + sd + ") for " + this, 
Logger.DEBUG);
        return sd;
     }
     

_______________________________________________
cvs mailing list
[EMAIL PROTECTED]
http://dodo.freenetproject.org/cgi-bin/mailman/listinfo/cvs

Reply via email to