[freenet-cvs] r17515 - trunk/freenet/src/freenet/node/simulator

toad at freenetproject.org toad at freenetproject.org
Mon Feb 4 22:26:34 UTC 2008


Author: toad
Date: 2008-02-04 22:26:34 +0000 (Mon, 04 Feb 2008)
New Revision: 17515

Modified:
   trunk/freenet/src/freenet/node/simulator/RealNodeULPRTest.java
Log:
More on ULPR testing.

Modified: trunk/freenet/src/freenet/node/simulator/RealNodeULPRTest.java
===================================================================
--- trunk/freenet/src/freenet/node/simulator/RealNodeULPRTest.java	2008-02-04 22:26:01 UTC (rev 17514)
+++ trunk/freenet/src/freenet/node/simulator/RealNodeULPRTest.java	2008-02-04 22:26:34 UTC (rev 17515)
@@ -124,6 +124,8 @@
         System.err.println("Created random test key "+testKey);
         System.err.println();
         
+        waitForAllConnected(nodes);
+        
         // Fetch the key from each node.
         
         for(int i=0;i<nodes.length;i++) {
@@ -166,6 +168,30 @@
 		}
         
     }
+    
+    // FIXME factor out to some simulator utility class.
+	private static void waitForAllConnected(Node[] nodes) throws InterruptedException {
+		while(true) {
+			int countFullyConnected = 0;
+			int totalPeers = 0;
+			int totalConnections = 0;
+			for(int i=0;i<nodes.length;i++) {
+				int countConnected = nodes[i].peers.countConnectedDarknetPeers();
+				int countTotal = nodes[i].peers.countValidPeers();
+				totalPeers += countTotal;
+				totalConnections += countConnected;
+				if(countConnected == countTotal)
+					countFullyConnected++;
+			}
+			if(countFullyConnected == nodes.length) {
+				System.err.println("All nodes fully connected");
+				return;
+			} else {
+				System.err.println("Waiting for nodes to be fully connected: "+countFullyConnected+" / "+nodes.length+" ("+totalConnections+" / "+totalPeers+" connections total)");
+				Thread.sleep(1000);
+			}
+		}
+	}
 
 
 }




More information about the cvs mailing list