Update of /cvsroot/freenet/freenet/src/freenet/node/rt
In directory sc8-pr-cvs1:/tmp/cvs-serv11455/src/freenet/node/rt

Modified Files:
        NGRoutingTable.java 
Log Message:
Make global estimator serialization rotate through serialization filenames and, on 
windows, make it work. Remember.. windows is very reluctant to allow fs-level 
modifications to open files as well as renaming files to filenames which already are 
occupied by another file.

Index: NGRoutingTable.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/node/rt/NGRoutingTable.java,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -w -r1.27 -r1.28
--- NGRoutingTable.java 4 Nov 2003 20:29:18 -0000       1.27
+++ NGRoutingTable.java 4 Nov 2003 23:00:43 -0000       1.28
@@ -46,6 +46,7 @@
        File[] globalFiles = 
        { new File(Node.routingDir, "ngrt_global_a"),
          new File(Node.routingDir, "ngrt_global_b") };
+       int nextGlobalEstimatorFile = 0; //Which file should we use next. Index into 
the array above.
        public NGRoutingTable(RoutingStore routingStore, int maxNodes,
                                                  NodeEstimatorFactory factory,
                                                  TimeEstimatorFactory tf,
@@ -503,16 +504,23 @@
        }
        
        public void checkpoint() {
-               File f = globalFiles[1];
+               File f = globalFiles[nextGlobalEstimatorFile];
                try {
+                       if(f.exists())
+                               f.delete();
+                       if(f.exists())
+                               throw new IOException("Failed to delete old global 
estimator file");
                        FileOutputStream fo = new FileOutputStream(f);
                        DataOutputStream dos = new DataOutputStream(fo);
                        globalEstimator.writeTo(dos);
                        dos.close();
-                       globalFiles[1].renameTo(globalFiles[0]);
+                       fo.close();
+                       nextGlobalEstimatorFile++;//When we safely has written to one 
of the files defined.. use next one next
+                       if(nextGlobalEstimatorFile>globalFiles.length-1) //and if we 
have used all files.. then start from the beginning again
+                               nextGlobalEstimatorFile =0;
                } catch (IOException e) {
                        Core.logger.log(this, "Couldn't write global estimator out!: 
"+e,
-                                                       e, Logger.NORMAL);
+                                                       e, Logger.ERROR);
                }
        }
 }

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

Reply via email to