[or-cvs] r11753: added method for HUP'ing directory nodes only (in puppetor/trunk/src/de/uniba/wiai/lspi/puppetor: . examples impl)

kloesing at seul.org kloesing at seul.org
Wed Oct 3 13:11:44 UTC 2007


Author: kloesing
Date: 2007-10-03 09:11:44 -0400 (Wed, 03 Oct 2007)
New Revision: 11753

Modified:
   puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/Network.java
   puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/examples/MergingRoutersWithLongRunningNetwork.java
   puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/NetworkImpl.java
Log:
added method for HUP'ing directory nodes only

Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/Network.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/Network.java	2007-10-03 10:55:25 UTC (rev 11752)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/Network.java	2007-10-03 13:11:44 UTC (rev 11753)
@@ -650,6 +650,22 @@
 			RemoteException;
 
 	/**
+	 * Sends a HUP signal to all directory nodes in the network once. This
+	 * operation can only be invoked, if all directory nodes in the network are
+	 * in state <code>NodeState.RUNNING</code>.
+	 * 
+	 * @throws IllegalStateException
+	 *             Thrown if at least one directory node is not in state
+	 *             <code>NodeState.RUNNING</code>.
+	 * @throws PuppeTorException
+	 *             Thrown if an I/O problem occurs while sending HUP signals.
+	 * @throws RemoteException
+	 *             Thrown if an error occurs when accessed remotely.
+	 */
+	public abstract void hupAllDirectories() throws PuppeTorException,
+			RemoteException;
+
+	/**
 	 * Attempts to shut down all running nodes. The method blocks until all
 	 * shutdown requests have been sent and either returns, or throws the first
 	 * exception that has been observed when shutting down nodes. The method can

Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/examples/MergingRoutersWithLongRunningNetwork.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/examples/MergingRoutersWithLongRunningNetwork.java	2007-10-03 10:55:25 UTC (rev 11752)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/examples/MergingRoutersWithLongRunningNetwork.java	2007-10-03 13:11:44 UTC (rev 11753)
@@ -97,9 +97,9 @@
 		network.configureAsInterconnectedPrivateNetwork(remoteNetwork);
 		System.out.println("Network configurations merged ...");
 
-		// write configurations and hup all nodes in the other network
+		// write configurations and hup all directory nodes in the other network
 		remoteNetwork.writeConfigurations();
-		remoteNetwork.hupAllNodes();
+		remoteNetwork.hupAllDirectories();
 
 		// write configuration of proxy node
 		network.writeConfigurations();

Modified: puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/NetworkImpl.java
===================================================================
--- puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/NetworkImpl.java	2007-10-03 10:55:25 UTC (rev 11752)
+++ puppetor/trunk/src/de/uniba/wiai/lspi/puppetor/impl/NetworkImpl.java	2007-10-03 13:11:44 UTC (rev 11753)
@@ -745,8 +745,8 @@
 				IllegalStateException e = new IllegalStateException(
 						"All nodes must be running before sending them HUP "
 								+ "commands!");
-				this.logger
-						.throwing(this.getClass().getName(), "hupUntilUp", e);
+				this.logger.throwing(this.getClass().getName(), "hupAllNodes",
+						e);
 				throw e;
 			}
 		}
@@ -763,6 +763,38 @@
 		this.logger.exiting(this.getClass().getName(), "hupAllNodes");
 	}
 
+	public void hupAllDirectories() throws PuppeTorException, RemoteException {
+
+		// log entering
+		this.logger.entering(this.getClass().getName(), "hupAllDirectories");
+
+		// check if all directory nodes are running
+		for (ProxyNode node : this.nodes.values()) {
+			if (node instanceof DirectoryNode
+					&& node.getNodeState() != NodeState.RUNNING) {
+				IllegalStateException e = new IllegalStateException(
+						"All directory nodes must be running before sending "
+								+ "them HUP commands!");
+				this.logger.throwing(this.getClass().getName(),
+						"hupAllDirectories", e);
+				throw e;
+			}
+		}
+
+		// send a HUP signal to all nodes
+		for (ProxyNode node : this.nodes.values()) {
+			if (node instanceof DirectoryNode) {
+				this.logger.log(Level.FINE, "Sending HUP to node "
+						+ node.toString());
+				node.hup();
+			}
+		}
+
+		// no retries left and not all nodes are up; log exiting and return
+		// failure
+		this.logger.exiting(this.getClass().getName(), "hupAllDirectories");
+	}
+
 	public void shutdownNodes() throws PuppeTorException, RemoteException {
 
 		// log entering
@@ -1072,7 +1104,7 @@
 
 		// iterate over existing template configuration strings and remove all
 		// configuration strings that have the given configuration key
-		List<String> configurationStringsToRemove = new ArrayList<String>(); 
+		List<String> configurationStringsToRemove = new ArrayList<String>();
 		for (String currentConfigurationString : templateConfig) {
 			String currentConfigurationKey = currentConfigurationString
 					.substring(0, currentConfigurationString.indexOf(" "));



More information about the tor-commits mailing list