Update of /cvsroot/freenet/freenet/src/freenet/node/states/request In directory sc8-pr-cvs1:/tmp/cvs-serv17951/src/freenet/node/states/request
Modified Files: DataPending.java FeedbackToken.java InsertPending.java Pending.java RequestDone.java RequestObject.java RequestSendCallback.java RequestState.java SendFinished.java TransferInsertPending.java Log Message: 6195: (mostly) asynchronous trailer writing, lots of logging improvements (most code supports selective logging now), bugfixes Index: DataPending.java =================================================================== RCS file: /cvsroot/freenet/freenet/src/freenet/node/states/request/DataPending.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- DataPending.java 4 Sep 2003 22:45:06 -0000 1.18 +++ DataPending.java 18 Sep 2003 17:48:11 -0000 1.19 @@ -61,7 +61,7 @@ if (this.ri == null || ri != this.ri) { throw new BadStateException("Not my request initiator: "+ri+" for "+this); } - if(Core.logger.shouldLog(Logger.DEBUG)) + if(Core.logger.shouldLog(Logger.DEBUG,this)) Core.logger.log(this, "Running "+ri+" at "+System.currentTimeMillis()+ " for "+this, ri.initException, Logger.DEBUG); try { Index: FeedbackToken.java =================================================================== RCS file: /cvsroot/freenet/freenet/src/freenet/node/states/request/FeedbackToken.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- FeedbackToken.java 4 Sep 2003 22:45:06 -0000 1.8 +++ FeedbackToken.java 18 Sep 2003 17:48:12 -0000 1.9 @@ -34,7 +34,7 @@ MessageSendCallback cb) throws CommunicationException; - OutputStream dataFound(Node n, Storables sto, long ctLength) + TrailerWriter dataFound(Node n, Storables sto, long ctLength) throws CommunicationException; /** Index: InsertPending.java =================================================================== RCS file: /cvsroot/freenet/freenet/src/freenet/node/states/request/InsertPending.java,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- InsertPending.java 4 Sep 2003 22:45:06 -0000 1.20 +++ InsertPending.java 18 Sep 2003 17:48:12 -0000 1.21 @@ -368,7 +368,7 @@ } void relayInsert(Node n, KeyInputStream doc) throws RequestAbortException { - OutputStream out; + TrailerWriter out; startedSendTime = System.currentTimeMillis(); try { receivedTime = -2; // receivedTime on the next message will be meaningless @@ -391,7 +391,7 @@ Logger.DEBUG); sendingData = new SendData(n.randSource.nextLong(), this.id, out, doc, doc.length(), - doc.getStorables().getPartSize()); + doc.getStorables().getPartSize(), n); sendingData.schedule(n); if(logDEBUG) n.logger.log(this, "Scheduled "+sendingData+" for "+this, Logger.DEBUG); Index: Pending.java =================================================================== RCS file: /cvsroot/freenet/freenet/src/freenet/node/states/request/Pending.java,v retrieving revision 1.60 retrieving revision 1.61 diff -u -r1.60 -r1.61 --- Pending.java 11 Sep 2003 15:32:42 -0000 1.60 +++ Pending.java 18 Sep 2003 17:48:12 -0000 1.61 @@ -741,20 +741,17 @@ if(logDEBUG) n.logger.log(this, "Sending data (,"+doc+") for "+this, Logger.DEBUG); Storables storables = doc.getStorables(); - OutputStream out = ft.dataFound(n, storables, doc.length()); - // this means the initiator is not interested in seeing the + 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) - if (out == null) out = new NullOutputStream(); - - // FIXME: don't waste resources piping data to the NullOutputStream SendData sd = new SendData(n.randSource.nextLong(), this.id, out, - doc, doc.length(), storables.getPartSize()); + doc, doc.length(), storables.getPartSize(), n); if(logDEBUG) n.logger.log(this, "Got SendData("+sd+") for "+this, Logger.DEBUG); return sd; } - + /** Attempts to retrieve the key from the cache and transition to * SendingReply. Will transition to null in the event of an * unrecoverable error. Does nothing if the key is not found. Index: RequestDone.java =================================================================== RCS file: /cvsroot/freenet/freenet/src/freenet/node/states/request/RequestDone.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- RequestDone.java 4 Sep 2003 22:45:06 -0000 1.3 +++ RequestDone.java 18 Sep 2003 17:48:12 -0000 1.4 @@ -32,7 +32,7 @@ // DataReply.. public State received(Node n, MessageObject mo) throws BadStateException { - logDEBUG = n.logger.shouldLog(Logger.DEBUG); + logDEBUG = n.logger.shouldLog(Logger.DEBUG,this); if (mo instanceof Accepted) { return this; } else if (mo instanceof DataInsert Index: RequestObject.java =================================================================== RCS file: /cvsroot/freenet/freenet/src/freenet/node/states/request/RequestObject.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -r1.1.1.1 -r1.2 --- RequestObject.java 13 Jan 2002 05:24:50 -0000 1.1.1.1 +++ RequestObject.java 18 Sep 2003 17:48:12 -0000 1.2 @@ -10,6 +10,11 @@ */ abstract class RequestObject extends EventMessageObject { + /** + * Create a RequestObject (states/request's version of EventMessageObject) + * @param id the chain ID + * @param external whether THE CHAIN is external + */ RequestObject(long id, boolean external) { super(id, external); } Index: RequestSendCallback.java =================================================================== RCS file: /cvsroot/freenet/freenet/src/freenet/node/states/request/RequestSendCallback.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- RequestSendCallback.java 8 Sep 2003 17:03:04 -0000 1.3 +++ RequestSendCallback.java 18 Sep 2003 17:48:12 -0000 1.4 @@ -20,7 +20,7 @@ public void setTrailerStream(OutputStream os) { }; public void succeeded() { - if(n.logger.shouldLog(Logger.DEBUG)) + if(n.logger.shouldLog(Logger.DEBUG,this)) n.logger.log(this, toString() + "succeeded sending "+m+ " for "+parent, Logger.DEBUG); } Index: RequestState.java =================================================================== RCS file: /cvsroot/freenet/freenet/src/freenet/node/states/request/RequestState.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- RequestState.java 4 Sep 2003 22:45:06 -0000 1.14 +++ RequestState.java 18 Sep 2003 17:48:12 -0000 1.15 @@ -57,7 +57,7 @@ origPeer = orig; this.ft = ft; this.ri = ri; - logDEBUG = Core.logger.shouldLog(Logger.DEBUG); + logDEBUG = Core.logger.shouldLog(Logger.DEBUG,this); } /** If one RequestState is derived from another, we must maintain @@ -75,7 +75,7 @@ unreachable = ancestor.unreachable; restarted = ancestor.restarted; rejected = ancestor.rejected; - logDEBUG = Core.logger.shouldLog(Logger.DEBUG); + logDEBUG = Core.logger.shouldLog(Logger.DEBUG,this); } Index: SendFinished.java =================================================================== RCS file: /cvsroot/freenet/freenet/src/freenet/node/states/request/SendFinished.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- SendFinished.java 9 Sep 2003 01:29:02 -0000 1.6 +++ SendFinished.java 18 Sep 2003 17:48:12 -0000 1.7 @@ -40,7 +40,7 @@ } public String toString() { - return getClass().getName()+"@ "+finishTime+":"+initTime+":"+succeeded+":"+ + return super.toString()+"@ "+finishTime+":"+initTime+":"+succeeded+":"+ finishException+":"+logMessage; } @@ -67,7 +67,7 @@ public void succeeded() { finishTime = System.currentTimeMillis(); succeeded = true; - if(n.logger.shouldLog(Logger.DEBUG)) + if(n.logger.shouldLog(Logger.DEBUG,this)) n.logger.log(this, toString() + " succeeded", Logger.DEBUG); n.schedule(this); @@ -87,5 +87,13 @@ this+": "+e, e, Logger.NORMAL); } n.schedule(this); + } + + public final State getInitialState() { + if(n.logger.shouldLog(Logger.DEBUG,this)) + n.logger.log(this, "getInitialState() called on "+this, + new Exception("debug"), + Logger.DEBUG); + return null; } } Index: TransferInsertPending.java =================================================================== RCS file: /cvsroot/freenet/freenet/src/freenet/node/states/request/TransferInsertPending.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- TransferInsertPending.java 4 Sep 2003 22:45:06 -0000 1.17 +++ TransferInsertPending.java 18 Sep 2003 17:48:12 -0000 1.18 @@ -31,7 +31,7 @@ TransferInsertPending(InsertPending ancestor, KeyInputStream doc) { this(ancestor); - if(Core.logger.shouldLog(Logger.DEBUG)) + if(Core.logger.shouldLog(Logger.DEBUG,this)) Core.logger.log(this, "Creating TransferInsertPending with stream " +"for "+searchKey, Logger.DEBUG); this.doc = doc; @@ -48,7 +48,7 @@ // these two cause the state to be recreated public State receivedMessage(Node n, QueryRejected qr) throws StateException { - if(Core.logger.shouldLog(Logger.DEBUG)) { + if(Core.logger.shouldLog(Logger.DEBUG,this)) { Core.logger.log(this, "TransferInsertPending ("+searchKey+ ") got QueryRejected", new Exception("debug"), Logger.DEBUG); @@ -59,14 +59,14 @@ try { super.receivedQueryRejected(n, qr); } catch (EndOfRouteException e) { - if(Core.logger.shouldLog(Logger.DEBUG)) + if(Core.logger.shouldLog(Logger.DEBUG,this)) Core.logger.log(this, "end of route exception "+searchKey, Logger.DEBUG); return endRoute(n); } catch (RequestAbortException rae) { // we are either going to SendingReply or RequestDone with no route found // So don't terminate()! - if(Core.logger.shouldLog(Logger.DEBUG)) + if(Core.logger.shouldLog(Logger.DEBUG,this)) Core.logger.log(this, "request abort exception "+searchKey, rae, Logger.DEBUG); if (receivingData.result() == -1) @@ -127,7 +127,7 @@ receivingData.cancel(); return rae.state; } catch (EndOfRouteException e) { - if(Core.logger.shouldLog(Logger.DEBUG)) + if(Core.logger.shouldLog(Logger.DEBUG,this)) Core.logger.log(this, "end of route exception "+searchKey, Logger.DEBUG); return endRoute(n); _______________________________________________ cvs mailing list [EMAIL PROTECTED] http://dodo.freenetproject.org/cgi-bin/mailman/listinfo/cvs