Author: toad
Date: 2007-06-11 19:48:25 +0000 (Mon, 11 Jun 2007)
New Revision: 13520

Added:
   trunk/freenet/src/freenet/node/updater/UpdateOverMandatoryManager.java
Modified:
   trunk/freenet/src/freenet/node/NodeDispatcher.java
   trunk/freenet/src/freenet/node/updater/NodeUpdateManager.java
   trunk/freenet/src/freenet/node/updater/RevocationChecker.java
Log:
Do something with incoming UOMAnnounce messages (so far just dump them to 
stderr!).

Modified: trunk/freenet/src/freenet/node/NodeDispatcher.java
===================================================================
--- trunk/freenet/src/freenet/node/NodeDispatcher.java  2007-06-11 19:32:39 UTC 
(rev 13519)
+++ trunk/freenet/src/freenet/node/NodeDispatcher.java  2007-06-11 19:48:25 UTC 
(rev 13520)
@@ -129,6 +129,8 @@
                        return handleProbeRejected(m, source);
                } else if(spec == DMT.FNPProbeTrace) {
                        return handleProbeTrace(m, source);
+               } else if(spec == DMT.UOMAnnounce) {
+                       return node.nodeUpdater.uom.handleAnnounce(m, source);
                }
                return false;
        }

Modified: trunk/freenet/src/freenet/node/updater/NodeUpdateManager.java
===================================================================
--- trunk/freenet/src/freenet/node/updater/NodeUpdateManager.java       
2007-06-11 19:32:39 UTC (rev 13519)
+++ trunk/freenet/src/freenet/node/updater/NodeUpdateManager.java       
2007-06-11 19:48:25 UTC (rev 13520)
@@ -78,6 +78,8 @@
        // Update alert
        private final UpdatedVersionAvailableUserAlert alert;

+       public final UpdateOverMandatoryManager uom;
+       
        private boolean logMINOR;

        public NodeUpdateManager(Node node, Config config) throws 
InvalidConfigValueException {
@@ -135,6 +137,7 @@

         this.revocationChecker = new RevocationChecker(this, new 
File(node.getNodeDir(), "revocation-key.fblob"));

+        this.uom = new UpdateOverMandatoryManager(this);
        }

        public void start() throws InvalidConfigValueException {
@@ -156,7 +159,7 @@
                return DMT.createUOMAnnounce(updateURI.toString(), 
extURI.toString(), revocationURI.toString(), hasBeenBlown, 
                                mainUpdater == null ? -1 : 
mainUpdater.getFetchedVersion(),
                                extUpdater == null ? -1 : 
extUpdater.getFetchedVersion(),
-                               revocationChecker.lastSucceeded(), 
revocationChecker.getRevocationDNFCounter(), 
+                               revocationChecker.lastSucceededDelta(), 
revocationChecker.getRevocationDNFCounter(), 
                                revocationChecker.getBlobSize(), 
                                mainUpdater == null ? -1 : 
mainUpdater.getBlobSize(),
                                extUpdater == null ? -1 : 
extUpdater.getBlobSize(), 

Modified: trunk/freenet/src/freenet/node/updater/RevocationChecker.java
===================================================================
--- trunk/freenet/src/freenet/node/updater/RevocationChecker.java       
2007-06-11 19:32:39 UTC (rev 13519)
+++ trunk/freenet/src/freenet/node/updater/RevocationChecker.java       
2007-06-11 19:48:25 UTC (rev 13520)
@@ -122,6 +122,11 @@
                return lastSucceeded;
        }

+       long lastSucceededDelta() {
+               if(lastSucceeded <= 0) return -1;
+               return System.currentTimeMillis() - lastSucceeded;
+       }
+       
        /** Called when the revocation URI changes. */
        public void onChangeRevocationURI() {
                kill();

Added: trunk/freenet/src/freenet/node/updater/UpdateOverMandatoryManager.java
===================================================================
--- trunk/freenet/src/freenet/node/updater/UpdateOverMandatoryManager.java      
                        (rev 0)
+++ trunk/freenet/src/freenet/node/updater/UpdateOverMandatoryManager.java      
2007-06-11 19:48:25 UTC (rev 13520)
@@ -0,0 +1,56 @@
+/* This code is part of Freenet. It is distributed under the GNU General
+ * Public License, version 2 (or at your option any later version). See
+ * http://www.gnu.org/ for further details of the GPL. */
+package freenet.node.updater;
+
+import freenet.io.comm.DMT;
+import freenet.io.comm.Message;
+import freenet.node.PeerNode;
+
+/**
+ * Co-ordinates update over mandatory. Update over mandatory = updating from 
your peers, even
+ * though they may be so much newer than you that you can't route requests 
through them.
+ * NodeDispatcher feeds UOMAnnounce's received from peers to this class, and 
it decides what to
+ * do about them.
+ * @author toad
+ */
+public class UpdateOverMandatoryManager {
+
+       final NodeUpdateManager updateManager;
+       
+       public UpdateOverMandatoryManager(NodeUpdateManager manager) {
+               this.updateManager = manager;
+       }
+
+       /** 
+        * Handle a UOMAnnounce message. A node has sent us a message offering 
us use of its update
+        * over mandatory facilities in some way.
+        * @param m The message to handle.
+        * @param source The PeerNode which sent the message.
+        * @return True unless we don't want the message (in this case, always 
true).
+        */
+       public boolean handleAnnounce(Message m, PeerNode source) {
+               String jarKey = m.getString(DMT.MAIN_JAR_KEY);
+               String extraJarKey = m.getString(DMT.EXTRA_JAR_KEY);
+               String revocationKey = m.getString(DMT.REVOCATION_KEY);
+               boolean haveRevocationKey = 
m.getBoolean(DMT.HAVE_REVOCATION_KEY);
+               long mainJarVersion = m.getLong(DMT.MAIN_JAR_VERSION);
+               long extraJarVersion = m.getLong(DMT.EXTRA_JAR_VERSION);
+               long revocationKeyLastTried = 
m.getLong(DMT.REVOCATION_KEY_TIME_LAST_TRIED);
+               int revocationKeyDNFs = m.getInt(DMT.REVOCATION_KEY_DNF_COUNT);
+               long revocationKeyFileLength = 
m.getLong(DMT.REVOCATION_KEY_FILE_LENGTH);
+               long mainJarFileLength = m.getLong(DMT.MAIN_JAR_FILE_LENGTH);
+               long extraJarFileLength = m.getLong(DMT.EXTRA_JAR_FILE_LENGTH);
+               int pingTime = m.getInt(DMT.PING_TIME);
+               int delayTime = m.getInt(DMT.BWLIMIT_DELAY_TIME);
+               System.err.println("Update Over Mandatory offer from node 
"+source.getPeer()+" : "+source.getName()+":");
+               System.err.println("Main jar key: "+jarKey+" 
version="+mainJarVersion+" length="+mainJarFileLength);
+               System.err.println("Extra jar key: "+extraJarKey+" 
version="+extraJarVersion+" length="+extraJarFileLength);
+               System.err.println("Revocation key: "+revocationKey+" 
found="+haveRevocationKey+" length="+revocationKeyFileLength+" last had 3 DNFs 
"+revocationKeyLastTried+" ms ago, "+revocationKeyDNFs+" DNFs so far");
+               System.err.println("Load stats: "+pingTime+"ms ping, 
"+delayTime+"ms bwlimit delay time");
+               return true;
+       }
+
+       
+       
+}


Reply via email to