[or-cvs] r15613: A slave can now tell its IP address, the ports it can open, (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:12:02 UTC 2008
Author: sebastian
Date: 2008-07-03 00:12:01 -0400 (Thu, 03 Jul 2008)
New Revision: 15613
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:
A slave can now tell its IP address, the ports it can open, and what OS it is running.
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-02 23:00:54 UTC (rev 15612)
+++ puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/AbstractPuppeTorSlaveFactory.java 2008-07-03 04:12:01 UTC (rev 15613)
@@ -31,8 +31,10 @@
*/
package de.uniba.wiai.lspi.puppetor.rmi;
-import java.rmi.RemoteException;
+import java.util.Set;
+import de.uniba.wiai.lspi.puppetor.rmi.PuppeTorSlave.OS;
+
/**
* Create a new representation of the server. Initialize this once with a
* concrete subclass of itself to create the actual <code>RemotePuppeTor</code>
@@ -76,6 +78,6 @@
*
* @return The new <code>PuppeTorSlave</code> instance
*/
- public abstract PuppeTorSlave createPuppeTorSlave(final String slaveName)
- throws RemoteException;
+ 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-02 23:00:54 UTC (rev 15612)
+++ puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/PuppeTorSlave.java 2008-07-03 04:12:01 UTC (rev 15613)
@@ -32,6 +32,8 @@
package de.uniba.wiai.lspi.puppetor.rmi;
import java.io.Serializable;
+import java.net.InetAddress;
+import java.util.Set;
/**
* A <code>PuppeTorSlave</code> represents a slave instance ready for tests.
@@ -43,8 +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
+ }
+
/**
- * @return The slave's name.
+ * @return the slave's name.
*/
public String getName();
+
+ /**
+ * @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
+ */
+ public Set<Integer> openablePorts();
}
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-02 23:00:54 UTC (rev 15612)
+++ puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/execute/PuppeTorSlaveProgram.java 2008-07-03 04:12:01 UTC (rev 15613)
@@ -35,6 +35,8 @@
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
+import java.util.HashSet;
+import java.util.Set;
import javax.rmi.ssl.SslRMIClientSocketFactory;
@@ -148,13 +150,12 @@
* Create a new slave with the properties that are relevant for the
* computer and networking environment it runs on.
*/
- try {
-
- slave = fac.createPuppeTorSlave(slaveName);
- } catch (final RemoteException e) {
- e.printStackTrace();
- throw new RuntimeException("Couldn't creat slave object. Dying.");
+ 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 );
+
}
@@ -180,8 +181,8 @@
+ "exported the Master Object yet." + e);
return false;
} catch (final RemoteException e) {
+ // XXX remove the next two lines once this stabilizes-SH
e.printStackTrace();
- // XXX remove the next line once this stabilizes-SH
System.out.println("Server down " + e);
return false;
} catch (final IllegalArgumentException e) {
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-02 23:00:54 UTC (rev 15612)
+++ puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/impl/PuppeTorSlaveImpl.java 2008-07-03 04:12:01 UTC (rev 15613)
@@ -31,6 +31,12 @@
*/
package de.uniba.wiai.lspi.puppetor.rmi.impl;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.Collections;
+import java.util.Set;
+import java.util.concurrent.CopyOnWriteArraySet;
+
import de.uniba.wiai.lspi.puppetor.rmi.PuppeTorSlave;
/**
@@ -52,28 +58,83 @@
* The slave's name
*/
protected final String name;
-
+
/**
- * This constructor is useful for slaves only, and only if they don't want
- * to provide any OS-specific or otherwise capability-telling information.
- *
+ * 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.
+ */
+ 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.
* @param slaveName
- * The slave's name
+ * 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.
+ * @param ip
+ * 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.
* @throws NullPointerException
+ * if the slavename is null
*/
- public PuppeTorSlaveImpl(final String slaveName)
- 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));
+ }
}
- /**
- * @return The slave's name
- */
public String getName() {
return name;
}
+
+ public OS getOS() {
+ return os;
+ }
+
+ public InetAddress getIP() {
+ 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-02 23:00:54 UTC (rev 15612)
+++ puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/impl/PuppeTorSlaveImplFactory.java 2008-07-03 04:12:01 UTC (rev 15613)
@@ -31,9 +31,11 @@
*/
package de.uniba.wiai.lspi.puppetor.rmi.impl;
-import java.rmi.RemoteException;
+import java.util.Set;
+
import de.uniba.wiai.lspi.puppetor.rmi.AbstractPuppeTorSlaveFactory;
import de.uniba.wiai.lspi.puppetor.rmi.PuppeTorSlave;
+import de.uniba.wiai.lspi.puppetor.rmi.PuppeTorSlave.OS;
/**
* Create <code>RemotePuppeTorImpl</code> instances
@@ -46,10 +48,9 @@
* @return a new <code>RemotePuppeTorImpl</code> instance.
*/
@Override
- public PuppeTorSlave createPuppeTorSlave(final String slaveName)
- throws RemoteException {
+ 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);
+ return new PuppeTorSlaveImpl(slaveName, os, ip, ports);
}
}
More information about the tor-commits
mailing list