[or-cvs] r15590: Make the basic test work again. Fix quite a few bugs, too. (in puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi: . execute impl)

sebastian at seul.org sebastian at seul.org
Wed Jul 2 09:18:59 UTC 2008


Author: sebastian
Date: 2008-07-02 05:18:58 -0400 (Wed, 02 Jul 2008)
New Revision: 15590

Modified:
   puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/AbstractPuppeTorSlaveFactory.java
   puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/AbstractRemotePuppeTorFactory.java
   puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/MasterConnector.java
   puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/PuppeTorSlave.java
   puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/PuppeTorTest.java
   puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/PuppeTorTestResult.java
   puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/RemotePuppeTor.java
   puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/execute/PuppeTorMasterProgram.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/RemotePuppeTorImpl.java
   puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/impl/RemotePuppeTorImplFactory.java
Log:
Make the basic test work again. Fix quite a few bugs, too.

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 08:52:16 UTC (rev 15589)
+++ puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/AbstractPuppeTorSlaveFactory.java	2008-07-02 09:18:58 UTC (rev 15590)
@@ -44,13 +44,14 @@
 
     /**
      * Hold the concrete RemotePuppeTorFactory that will be used to create
-     * <code>RemotePuppeTor</code> instances.
+     * <code>RemotePuppeTor</code> instances. Uses
+     * AbstractPuppeTorSlaveFactory.class for locking.
      */
     volatile private static AbstractPuppeTorSlaveFactory factory;
 
     /**
      * @return a new concrete
-     *     <code>AbstractRemotePuppeTorFactory<code>subclass as
+     *         <code>AbstractPuppeTorSlaveFactory<code>subclass as
      *     specified by the initialization
      */
     final public static AbstractPuppeTorSlaveFactory getInstance() {
@@ -59,18 +60,21 @@
 
     /**
      * @param factory
-     *            save this as the factory if this hasn't been called before.
+     *         save this as the factory if this hasn't been called before.
+     * XXX - We could throw an exception here, too. I will think about that.-SH   
      */
-    final public static void initialize(final AbstractPuppeTorSlaveFactory factory) {
-        if (AbstractPuppeTorSlaveFactory.factory != null) {
+    final public static void initialize(
+            final AbstractPuppeTorSlaveFactory factory) {
+        if (AbstractPuppeTorSlaveFactory.factory == null) {
             AbstractPuppeTorSlaveFactory.factory = factory;
         }
     }
-    
+
     /**
-     * Override this to create a subclass of <code>RemotePuppeTor</code>
-     * @return
-     *     <code>The new RemotePuppeTor</code> instance
+     * Override this to create a subclass of <code>PuppeTorSlave</code>
+     *
+     * @return The new <code>PuppeTorSlave</code> instance
      */
-    public abstract PuppeTorSlave createPuppeTorSlave() throws RemoteException;
+    public abstract PuppeTorSlave createPuppeTorSlave(final String slaveName)
+            throws RemoteException;
 }

Modified: puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/AbstractRemotePuppeTorFactory.java
===================================================================
--- puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/AbstractRemotePuppeTorFactory.java	2008-07-02 08:52:16 UTC (rev 15589)
+++ puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/AbstractRemotePuppeTorFactory.java	2008-07-02 09:18:58 UTC (rev 15590)
@@ -50,7 +50,7 @@
 
     /**
      * @return a new concrete
-     *     <code>AbstractRemotePuppeTorFactory<code>subclass as
+     *         <code>AbstractRemotePuppeTorFactory<code>subclass as
      *     specified by the initialization
      */
     final public static AbstractRemotePuppeTorFactory getInstance() {
@@ -61,19 +61,20 @@
      * @param factory
      *            save this as the factory if this hasn't been called before.
      */
-    final public static void initialize(final AbstractRemotePuppeTorFactory factory) {
-        if (AbstractRemotePuppeTorFactory.factory != null) {
+    final public static void initialize(
+            final AbstractRemotePuppeTorFactory factory) {
+        if (AbstractRemotePuppeTorFactory.factory == null) {
             AbstractRemotePuppeTorFactory.factory = factory;
         }
     }
-    
+
     /**
      * Override this to create a subclass of <code>RemotePuppeTor</code>
+     *
      * @param slave
-     *     Create the server represantation for this connected slave
-     * @return
-     *     <code>The new RemotePuppeTor</code> instance
+     *            Create the server represantation for this connected slave
+     * @return The new <code>RemotePuppeTor</code> instance
      */
     public abstract RemotePuppeTor createRemotePuppeTor(PuppeTorSlave slave)
-        throws RemoteException;
+            throws RemoteException;
 }

Modified: puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/MasterConnector.java
===================================================================
--- puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/MasterConnector.java	2008-07-02 08:52:16 UTC (rev 15589)
+++ puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/MasterConnector.java	2008-07-02 09:18:58 UTC (rev 15590)
@@ -31,6 +31,7 @@
  */
 package de.uniba.wiai.lspi.puppetor.rmi;
 
+import java.rmi.Remote;
 import java.rmi.RemoteException;
 
 /**
@@ -40,7 +41,7 @@
  * 
  * @author Sebastian Hahn
  */
-public interface MasterConnector {
+public interface MasterConnector extends Remote {
 	
 	/**
 	 * Called once by every connecting client so that the master knows about it

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 08:52:16 UTC (rev 15589)
+++ puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/PuppeTorSlave.java	2008-07-02 09:18:58 UTC (rev 15590)
@@ -38,7 +38,7 @@
  * It carries information about the testing capabilities of a given slave. A
  * slave may not provide information except for its name, which is always
  * mandatory. The slave will not be used for non-client traffic, though.
- * 
+ *
  * @author Sebastian Hahn
  */
 public interface PuppeTorSlave extends Serializable {

Modified: puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/PuppeTorTest.java
===================================================================
--- puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/PuppeTorTest.java	2008-07-02 08:52:16 UTC (rev 15589)
+++ puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/PuppeTorTest.java	2008-07-02 09:18:58 UTC (rev 15590)
@@ -38,16 +38,17 @@
 
 /**
  * <code>PuppeTorTest</code> describes a test and the kind of slave it can run
- * on, as well as other network settings that are required for the test to
- * work. A test should be able to tell whether it was successfully run or not
- * when passed a PuppeTorTestResult.
- * 
+ * on, as well as other network settings that are required for the test to work.
+ * A test should be able to tell whether it was successfully run or not when
+ * passed a PuppeTorTestResult.
+ *
  * @author Sebastian Hahn
  */
 public interface PuppeTorTest extends Serializable {
     /**
      * XXX this goes away. I just put it in to see whether a remote test would
      * actually execut on a slave.
+     *
      * @return
      * @throws RemoteException
      * @throws PuppeTorException

Modified: puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/PuppeTorTestResult.java
===================================================================
--- puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/PuppeTorTestResult.java	2008-07-02 08:52:16 UTC (rev 15589)
+++ puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/PuppeTorTestResult.java	2008-07-02 09:18:58 UTC (rev 15590)
@@ -34,9 +34,9 @@
 import java.io.Serializable;
 
 /**
- * XXX unused for now. this will hold the result of a 
- * /<code>PuppeTorTest</code> -SH
-*/
+ * XXX unused for now. this will hold the result of a /<code>PuppeTorTest</code>
+ * -SH
+ */
 public interface PuppeTorTestResult extends Serializable {
     public PuppeTorTest getJob();
 }

Modified: puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/RemotePuppeTor.java
===================================================================
--- puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/RemotePuppeTor.java	2008-07-02 08:52:16 UTC (rev 15589)
+++ puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/RemotePuppeTor.java	2008-07-02 09:18:58 UTC (rev 15590)
@@ -33,40 +33,39 @@
 
 import java.rmi.Remote;
 import java.rmi.RemoteException;
-import java.rmi.server.Unreferenced;
 
 /**
- * <code>RemotePuppeTor</code> is the main interface that drives the 
+ * <code>RemotePuppeTor</code> is the main interface that drives the
  * interaction between the interconnected master and its slave instances. It is
  * published by the master's instance, and represents the view of the master a
- * slave has.
- * It provides ways for the slave to register a <code>PuppeTorSlave</code>
- * to provide information about its capabilities, as well as a way for the
- * slave to poll the master for new work and then report back results.
- * XXX We will need a way to allow the master to access this, as well as a way
- * for clients with open ports to register for callback support instead of
- * polling for new tasks =SH
- * 
+ * slave has. It provides ways for the slave to register a
+ * <code>PuppeTorSlave</code> to provide information about its capabilities,
+ * as well as a way for the slave to poll the master for new work and then
+ * report back results. XXX We will need a way to allow the master to access
+ * this, as well as a way for clients with open ports to register for callback
+ * support instead of polling for new tasks =SH
+ *
  * @author Sebastian Hahn
  */
-public interface RemotePuppeTor extends Remote, Unreferenced{
+public interface RemotePuppeTor extends Remote {
 
     /**
-     * Slaves that must poll because they are not reachable can use this
-     * method to ask the master for new work.
-     * 
+     * Slaves that must poll because they are not reachable can use this method
+     * to ask the master for new work.
+     *
      * @throws RemoteException
-     *     RMI...
+     *             RMI...
      */
     public PuppeTorTest getNewJob() throws RemoteException;
 
     /**
      * XXX We want the slaves to report back when they have an update for the
      * master-SH
+     *
      * @param jobResult
      * @throws RemoteException
-     
-    public void reportResults(PuppeTorTestResult testResult)
-            throws RemoteException;
-            */
+     *
+     * public void reportResults(PuppeTorTestResult testResult) throws
+     * RemoteException;
+     */
 }

Modified: puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/execute/PuppeTorMasterProgram.java
===================================================================
--- puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/execute/PuppeTorMasterProgram.java	2008-07-02 08:52:16 UTC (rev 15589)
+++ puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/execute/PuppeTorMasterProgram.java	2008-07-02 09:18:58 UTC (rev 15590)
@@ -59,7 +59,7 @@
     /**
      * The login object for clients
      */
-    final private UnicastRemoteObject master;
+    final private PuppeTorMasterProgram.InnerMasterConnector master;
     
     /**
      * The port the server is supposed to listen on. This port must not be
@@ -105,27 +105,12 @@
         AbstractRemotePuppeTorFactory.initialize(
                 new RemotePuppeTorImplFactory());
         
-        class InnerMasterConnector extends UnicastRemoteObject implements MasterConnector {
-        	/**
-             * Required for serialization. Needs to change for new released versions.
-             */
-			private static final long serialVersionUID = 1L;
-
-			public RemotePuppeTor registerClient
-		        ( final PuppeTorSlave slave ) throws RemoteException {
-			    AbstractRemotePuppeTorFactory fact = 
-	                AbstractRemotePuppeTorFactory.getInstance();
-			    return fact.createRemotePuppeTor(slave);
-		    }
-        }
-        
         try {
             master = new InnerMasterConnector();
         } catch (RemoteException e) {
             //We cannot do much better here. This is supposed to just work.
-            System.out.println("Couldn't create remote object. Dying.");
             e.printStackTrace();
-            System.exit(1);
+            throw new RuntimeException("Couldn't create remote object. Dying.");
         }
     }
 
@@ -150,4 +135,25 @@
             System.exit(1);
         }
     }
+    
+    class InnerMasterConnector extends UnicastRemoteObject implements MasterConnector {
+        /**
+         * Required for serialization. Needs to change for new released versions.
+         */
+        private static final long serialVersionUID = 1L;
+
+        /**
+         * empty default constructor necessary for the Exception
+         * @throws RemoteException
+         *     RMI
+         */
+        public InnerMasterConnector() throws RemoteException { }
+        
+        public RemotePuppeTor registerClient
+            ( final PuppeTorSlave slave ) throws RemoteException {
+            AbstractRemotePuppeTorFactory fact = 
+                AbstractRemotePuppeTorFactory.getInstance();
+            return fact.createRemotePuppeTor(slave);
+        }
+    }
 }

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 08:52:16 UTC (rev 15589)
+++ puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/execute/PuppeTorSlaveProgram.java	2008-07-02 09:18:58 UTC (rev 15590)
@@ -39,11 +39,12 @@
 import javax.rmi.ssl.SslRMIClientSocketFactory;
 
 import de.uniba.wiai.lspi.puppetor.PuppeTorException;
+import de.uniba.wiai.lspi.puppetor.rmi.AbstractPuppeTorSlaveFactory;
 import de.uniba.wiai.lspi.puppetor.rmi.MasterConnector;
 import de.uniba.wiai.lspi.puppetor.rmi.PuppeTorSlave;
 import de.uniba.wiai.lspi.puppetor.rmi.PuppeTorTest;
 import de.uniba.wiai.lspi.puppetor.rmi.RemotePuppeTor;
-import de.uniba.wiai.lspi.puppetor.rmi.impl.PuppeTorSlaveImpl;
+import de.uniba.wiai.lspi.puppetor.rmi.impl.PuppeTorSlaveImplFactory;
 
 /**
  * The <code>PuppeTorSlaveProgram</code> contains the main method for the
@@ -138,12 +139,23 @@
          * Set the location of the truststore which contains the exported
          * certificates of your slaves
          */
-        System.setProperty("javax.net.ssl.trustStore", "res/truststore");
+        System.setProperty("javax.net.ssl.trustStore", "res/truststore");        
+        //Set up the factories we want to use
+        AbstractPuppeTorSlaveFactory.initialize(
+                new PuppeTorSlaveImplFactory());
+        AbstractPuppeTorSlaveFactory fac = AbstractPuppeTorSlaveFactory.getInstance();
+        
         /*
          * Create a new slave with the properties that are relevant for the
          * computer and networking environment it runs on.
          */
-        this.slave = new PuppeTorSlaveImpl(slaveName);
+        try {
+            
+            this.slave = fac.createPuppeTorSlave(slaveName);
+        } catch (RemoteException e) {
+            e.printStackTrace();
+            throw new RuntimeException("Couldn't creat slave object. Dying.");
+        }
         
     }
 
@@ -161,7 +173,7 @@
                     LocateRegistry.getRegistry(serveraddress, serverport,
                             new SslRMIClientSocketFactory());
 
-            ((MasterConnector)registry.lookup("Master")).registerClient(
+            master = ((MasterConnector)registry.lookup("Master")).registerClient(
             		this.slave);
         } catch (final NotBoundException e) {
             e.printStackTrace();

Modified: puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/impl/RemotePuppeTorImpl.java
===================================================================
--- puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/impl/RemotePuppeTorImpl.java	2008-07-02 08:52:16 UTC (rev 15589)
+++ puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/impl/RemotePuppeTorImpl.java	2008-07-02 09:18:58 UTC (rev 15590)
@@ -33,6 +33,7 @@
 
 import java.rmi.RemoteException;
 import java.rmi.server.UnicastRemoteObject;
+import java.rmi.server.Unreferenced;
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.ConcurrentHashMap;
 
@@ -48,7 +49,7 @@
  * @author Sebastian Hahn
  */
 public class RemotePuppeTorImpl extends UnicastRemoteObject implements
-        RemotePuppeTor {
+        RemotePuppeTor, Unreferenced {
 
     /**
      * Required for serialization. Needs to change for new released versions.

Modified: puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/impl/RemotePuppeTorImplFactory.java
===================================================================
--- puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/impl/RemotePuppeTorImplFactory.java	2008-07-02 08:52:16 UTC (rev 15589)
+++ puppetor/branches/gsoc2008/src/de/uniba/wiai/lspi/puppetor/rmi/impl/RemotePuppeTorImplFactory.java	2008-07-02 09:18:58 UTC (rev 15590)
@@ -33,22 +33,23 @@
 
 import java.rmi.RemoteException;
 import de.uniba.wiai.lspi.puppetor.rmi.AbstractRemotePuppeTorFactory;
+import de.uniba.wiai.lspi.puppetor.rmi.PuppeTorSlave;
 import de.uniba.wiai.lspi.puppetor.rmi.RemotePuppeTor;
 
 /**
  * Create <code>RemotePuppeTorImpl</code> instances
- * 
+ *
  * @author Sebastian Hahn
  */
 public class RemotePuppeTorImplFactory extends AbstractRemotePuppeTorFactory {
 
     /**
-     * @return
-     *     a new <code>RemotePuppeTorImpl</code> instance.
+     * @return a new <code>RemotePuppeTorImpl</code> instance.
      */
     @Override
-    public RemotePuppeTor createRemotePuppeTor() throws RemoteException{
-        return new RemotePuppeTorImpl();
+    public RemotePuppeTor createRemotePuppeTor(final PuppeTorSlave slave)
+            throws RemoteException {
+        return new RemotePuppeTorImpl(slave);
     }
 
 }



More information about the tor-commits mailing list