[or-cvs] r15614: cleanup (in puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi: . execute impl)

sebastian at seul.org sebastian at seul.org
Thu Jul 3 04:23:39 UTC 2008


Author: sebastian
Date: 2008-07-03 00:23:38 -0400 (Thu, 03 Jul 2008)
New Revision: 15614

Modified:
   puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/AbstractPuppeTorSlaveFactory.java
   puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/PuppeTorSlave.java
   puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/execute/PuppeTorSlaveProgram.java
   puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/impl/PuppeTorSlaveImpl.java
   puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/impl/PuppeTorSlaveImplFactory.java
Log:
cleanup

Modified: puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/AbstractPuppeTorSlaveFactory.java
===================================================================
--- puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/AbstractPuppeTorSlaveFactory.java	2008-07-03 04:12:01 UTC (rev 15613)
+++ puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/AbstractPuppeTorSlaveFactory.java	2008-07-03 04:23:38 UTC (rev 15614)
@@ -78,6 +78,7 @@
      *
      * @return The new <code>PuppeTorSlave</code> instance
      */
-    public abstract PuppeTorSlave createPuppeTorSlave(final String slaveName, final OS os, final String ip, final Set<Integer> ports)
+    public abstract PuppeTorSlave createPuppeTorSlave(final String slaveName,
+            final OS os, final String ip, final Set<Integer> ports)
             throws NullPointerException;
 }

Modified: puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/PuppeTorSlave.java
===================================================================
--- puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/PuppeTorSlave.java	2008-07-03 04:12:01 UTC (rev 15613)
+++ puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/PuppeTorSlave.java	2008-07-03 04:23:38 UTC (rev 15614)
@@ -45,25 +45,27 @@
  */
 public interface PuppeTorSlave extends Serializable {
 
-	public enum OS {
-		UNDEFINED, LINUX_I86_32, LINUX_I86_64, MAC_OSX_PPC, MAC_OSX_I86, WINDOWS_XP_32, WINDOWS_XP_64, WINDOWS_VISTA_32, WINDOWS_VISTA_64
-	}
-	
+    public enum OS {
+        UNDEFINED, LINUX_I86_32, LINUX_I86_64, MAC_OSX_PPC, MAC_OSX_I86,
+        WINDOWS_XP_32, WINDOWS_XP_64, WINDOWS_VISTA_32, WINDOWS_VISTA_64
+    }
+
     /**
      * @return the slave's name.
      */
     public String getName();
-    
+
     /**
-     * @return the slave's operating system as defined in <code>PuppeTorSlave.OS</code>.
+     * @return the slave's operating system as defined in
+     *         <code>PuppeTorSlave.OS</code>.
      */
     public OS getOS();
-    
+
     /**
      * @return the slave's IP address. XXX Test this with IPv6-SH
      */
     public InetAddress getIP();
-    
+
     /**
      * @return the ports this slave can open
      */

Modified: puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/execute/PuppeTorSlaveProgram.java
===================================================================
--- puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/execute/PuppeTorSlaveProgram.java	2008-07-03 04:12:01 UTC (rev 15613)
+++ puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/execute/PuppeTorSlaveProgram.java	2008-07-03 04:23:38 UTC (rev 15614)
@@ -150,12 +150,13 @@
          * Create a new slave with the properties that are relevant for the
          * computer and networking environment it runs on.
          */
-        Set<Integer> ports = new HashSet<Integer>();
-        for(int i = 10025; i < 20000; i++) {
+        final Set<Integer> ports = new HashSet<Integer>();
+        for (int i = 10025; i < 20000; i++) {
             ports.add(i);
         }
-        slave = fac.createPuppeTorSlave(slaveName, PuppeTorSlave.OS.UNDEFINED, "127.0.0.1", ports );
-        
+        slave =
+                fac.createPuppeTorSlave(slaveName, PuppeTorSlave.OS.UNDEFINED,
+                        "127.0.0.1", ports);
 
     }
 
@@ -181,7 +182,7 @@
                     + "exported the Master Object yet." + e);
             return false;
         } catch (final RemoteException e) {
-         // XXX remove the next two lines once this stabilizes-SH
+            // XXX remove the next two lines once this stabilizes-SH
             e.printStackTrace();
             System.out.println("Server down " + e);
             return false;

Modified: puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/impl/PuppeTorSlaveImpl.java
===================================================================
--- puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/impl/PuppeTorSlaveImpl.java	2008-07-03 04:12:01 UTC (rev 15613)
+++ puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/impl/PuppeTorSlaveImpl.java	2008-07-03 04:23:38 UTC (rev 15614)
@@ -58,81 +58,88 @@
      * The slave's name
      */
     protected final String name;
-    
+
     /**
      * The slave's ip address
      */
     protected final InetAddress ip;
-    
+
     /**
      * The operating system of the slave. See <code>PuppeTorSlave.OS</code>.
      */
     protected final OS os;
-    
+
     /**
      * The ports this slave can open. Currently, we choose to use 256 as a
      * maximum that "should be" enough so we don't transfer so much data when
-     * serializing. See the constructor.
+     * serializing. See the constructor. Make sure this is immutable.
      */
     protected final Set<Integer> ports;
-    
+
     /**
      * Create a new <code>PuppeTorSlave</code> with the metrics we currently
      * use, meaning it's operating system, it's IP, and the ports it can open.
      * We may in the future include other things like Tor executable version
-     * numbers and the ability to run certain extra scripts. 
+     * numbers and the ability to run certain extra scripts.
+     *
      * @param slaveName
-     *     the slave's name. Each slave must have it's own unique name in a
-     *     given PuppeTor network.
+     *            the slave's name. Each slave must have it's own unique name in
+     *            a given PuppeTor network.
      * @param os
-     *     the slave's operating system.
+     *            the slave's operating system.
      * @param ip
-     *     A String representation of the slave's IP (v4 or v6).
+     *            A String representation of the slave's IP (v4 or v6).
      * @param ports
-     *     All the ports this slave can open. Currently, we pick 256 out of
-     *     those at random.
+     *            All the ports this slave can open. Currently, we pick 256 out
+     *            of those at random.
      * @throws NullPointerException
-     *     if the slavename is null
+     *             if the slavename is null
      */
-    public PuppeTorSlaveImpl(final String slaveName, final OS os, final String ip, final Set<Integer> ports ) throws NullPointerException {
+    public PuppeTorSlaveImpl(final String slaveName, final OS os,
+            final String ip, final Set<Integer> ports)
+            throws NullPointerException {
         if (slaveName == null) {
             throw new NullPointerException("slaveName must not be null");
         }
         name = slaveName;
         this.os = os;
         try {
-			this.ip = InetAddress.getByName(ip);
-		} catch (UnknownHostException e) {	
-			e.printStackTrace();
-			throw new RuntimeException("You specified an invalid IP address!");
-		}
-		
-		if(ports.size() > 256) {
-		    final Set<Integer> tmp = new CopyOnWriteArraySet<Integer>();
-		    int i = 0;
-		    for(Integer j : tmp) {
-		        if(i++==256)
-		            break;
-		        tmp.add(j);
-		    }
-		    this.ports = Collections.unmodifiableSet(tmp);
-		} else {
-		    this.ports = Collections.unmodifiableSet(new CopyOnWriteArraySet<Integer>(ports));
-		}
+            this.ip = InetAddress.getByName(ip);
+        } catch (final UnknownHostException e) {
+            e.printStackTrace();
+            throw new RuntimeException("You specified an invalid IP address!");
+        }
+
+        if (ports.size() > 256) {
+            final Set<Integer> tmp = new CopyOnWriteArraySet<Integer>();
+            int i = 0;
+            for (final Integer j : tmp) {
+                if (i++ == 256) {
+                    break;
+                }
+                tmp.add(j);
+            }
+            this.ports = Collections.unmodifiableSet(tmp);
+        } else {
+            this.ports =
+                    Collections
+                            .unmodifiableSet(new CopyOnWriteArraySet<Integer>(
+                                    ports));
+        }
     }
 
     public String getName() {
         return name;
     }
-    
+
     public OS getOS() {
-    	return os;
+        return os;
     }
-    
+
     public InetAddress getIP() {
-    	return ip;
+        return ip;
     }
-    
+
     public Set<Integer> openablePorts() {
         return ports;
     }

Modified: puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/impl/PuppeTorSlaveImplFactory.java
===================================================================
--- puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/impl/PuppeTorSlaveImplFactory.java	2008-07-03 04:12:01 UTC (rev 15613)
+++ puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/impl/PuppeTorSlaveImplFactory.java	2008-07-03 04:23:38 UTC (rev 15614)
@@ -48,7 +48,9 @@
      * @return a new <code>RemotePuppeTorImpl</code> instance.
      */
     @Override
-    public PuppeTorSlave createPuppeTorSlave(final String slaveName, final OS os, final String ip, final Set<Integer> ports) throws NullPointerException {
+    public PuppeTorSlave createPuppeTorSlave(final String slaveName,
+            final OS os, final String ip, final Set<Integer> ports)
+            throws NullPointerException {
         System.out.println(slaveName);
         return new PuppeTorSlaveImpl(slaveName, os, ip, ports);
     }



More information about the tor-commits mailing list