[or-cvs] r11116: fixed some bugs in test application for proposal 114 (puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/examples)

kloesing at seul.org kloesing at seul.org
Wed Aug 15 14:48:59 UTC 2007


Author: kloesing
Date: 2007-08-15 10:48:59 -0400 (Wed, 15 Aug 2007)
New Revision: 11116

Modified:
   puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/examples/DistributedStorage.java
Log:
fixed some bugs in test application for proposal 114

Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/examples/DistributedStorage.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/examples/DistributedStorage.java	2007-08-15 13:37:33 UTC (rev 11115)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/examples/DistributedStorage.java	2007-08-15 14:48:59 UTC (rev 11116)
@@ -641,9 +641,7 @@
 				// a descriptor was published by any hidden service provider;
 				// check if this descriptor ID is novel
 
-				// parse desc id from the following message:
-				// "Sending publish request for v2 descriptor for service '.*'
-				// with descriptor ID '.*' with validity of .* seconds [...]"
+				// parse desc id from event message
 				String message = event.getMessage();
 				String prefixDescID = "with descriptor ID '";
 				String descID = message.substring(message.indexOf(prefixDescID)
@@ -876,16 +874,9 @@
 	}
 
 	/**
-	 * wartet 20 min nach hinzufügen eines hidserv, um ihn anschließend als
-	 * verfügbar zu markieren
-	 * 
-	 * @author karsten
-	 * 
-	 */
-	/**
-	 * Observes a descriptor for the first 20 minutes after starting it before
-	 * adding it to the list of available hidden services. When the node is
-	 * stopped (within or after the 20 minutes), the hidden service will be
+	 * Observes a hidden service for the first 20 minutes after starting it
+	 * before adding it to the list of available hidden services. When the node
+	 * is stopped (within or after the 20 minutes), the hidden service will be
 	 * removed from the list of available hidden services.
 	 */
 	private static class HiddenServiceObserver extends Thread implements
@@ -975,7 +966,7 @@
 			// stable state
 			// Thread.sleep(24 * 60 * 60 * 1000 + 90 * 60 * 1000);
 			try {
-				Thread.sleep(30 * 60 * 1000 + 90 * 60 * 1000);
+				Thread.sleep(30 * 60 * 1000 + 30 * 60 * 1000);
 			} catch (InterruptedException e) {
 			}
 
@@ -1074,17 +1065,12 @@
 			manager.addEventListener(providingNode, this);
 			manager.addEventListener(useAsProxy, this);
 
-			// parse onion address into address and port parts
-			String[] parts = onionAddress.split(":");
-			String address = parts[0];
-			int port = Integer.parseInt(parts[1]);
-
 			// determine socks port of proxy
 			int socksPort = useAsProxy.getSocksPort();
 
 			// create client application and register for events originating
 			// from it
-			this.clientApp = network.createClient("client", address, port,
+			this.clientApp = network.createClient("client", onionAddress, 80,
 					socksPort);
 			manager.addEventListener(this.clientApp, this);
 		}
@@ -1423,17 +1409,14 @@
 		long waitingTime = 0;
 
 		for (int i = 0; i < HOURS_TO_WAIT - 1; i++) {
-
-			// wait for 15 to 30 minutes (plus any remaining waiting time) now
-			waitingTime += 15 * 1000 + rnd.nextInt(15 * 1000);
+			// wait for 15 to 30 minutes
+			waitingTime = 15 * 60 * 1000 + rnd.nextInt(15 * 60 * 1000);
 			try {
-				Thread.sleep(1L * 60L * 60L * 1000L);
+				Thread.sleep(waitingTime);
 			} catch (InterruptedException e) {
 				// do nothing
 			}
-			// wait for the rest of the half hour later
-			waitingTime = 30 * 1000 - waitingTime;
-
+			
 			// shut down one node
 			int candidate = rnd.nextInt(runningRouters.size());
 			RouterNode removedRouter = runningRouters.remove(candidate);
@@ -1441,15 +1424,21 @@
 					+ removedRouter.getNodeName() + "...");
 			removedRouter.shutdown();
 
-			// wait for 15 to 30 minutes (plus any remaining waiting time) now
-			waitingTime += 15 * 1000 + rnd.nextInt(15 * 1000);
+			// wait for the rest of the half hour
+			waitingTime = 30 * 60 * 1000 - waitingTime;
 			try {
-				Thread.sleep(1L * 60L * 60L * 1000L);
+				Thread.sleep(waitingTime);
 			} catch (InterruptedException e) {
 				// do nothing
 			}
-			// wait for the rest of the half hour later
-			waitingTime = 30 * 1000 - waitingTime;
+			
+			// wait for 15 to 30 minutes
+			waitingTime = 15 * 60 * 1000 + rnd.nextInt(15 * 60 * 1000);
+			try {
+				Thread.sleep(waitingTime);
+			} catch (InterruptedException e) {
+				// do nothing
+			}
 
 			// start another node
 			RouterNode newRouter = network.createRouter("router"
@@ -1491,7 +1480,7 @@
 			// if a hidden service was started, start an observer for it
 			if (now >= hiddenServiceStableTime) {
 				new HiddenServiceObserver(newRouter, newRouter.getOnionAddress(
-						"hidServ" + routerCounter, 2));
+						"hidServ" + routerCounter, 2)).start();
 			}
 
 			// start observer for the new hidden service directory
@@ -1500,6 +1489,14 @@
 
 			routerCounter++;
 
+			// wait for the rest of the half hour
+			waitingTime = 30 * 60 * 1000 - waitingTime;
+			try {
+				Thread.sleep(waitingTime);
+			} catch (InterruptedException e) {
+				// do nothing
+			}
+			
 			System.out.println(new Date() + ": Waiting for another "
 					+ (HOURS_TO_WAIT - i - 1) + " hour"
 					+ (i == HOURS_TO_WAIT - 2 ? "" : "s") + " ...");



More information about the tor-commits mailing list