[jboss-cvs] JBossAS SVN: r73822 - in trunk: profileservice/src/main/org/jboss/profileservice/management/upload/remoting and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu May 29 17:57:54 EDT 2008


Author: scott.stark at jboss.org
Date: 2008-05-29 17:57:54 -0400 (Thu, 29 May 2008)
New Revision: 73822

Modified:
   trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentManagerImpl.java
   trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentProgressImpl.java
   trunk/profileservice/src/main/org/jboss/profileservice/management/upload/SerializableDeploymentID.java
   trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/DeployHandler.java
   trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/StreamingDeploymentTarget.java
   trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentID.java
   trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentManager.java
   trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentStatus.java
   trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentTarget.java
   trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/profileservice/test/ClusteredDeployUnitTestCase.java
   trunk/testsuite/src/main/org/jboss/test/profileservice/test/DeployUnitTestCase.java
Log:
JBAS-5370, Add a prepare command and expand api to take multiple deployment names for commands that don't distribute content

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentManagerImpl.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentManagerImpl.java	2008-05-29 21:55:43 UTC (rev 73821)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentManagerImpl.java	2008-05-29 21:57:54 UTC (rev 73822)
@@ -126,7 +126,7 @@
    public DeploymentProgress distribute(String name, DeploymentPhase phase,
          URL contentURL)
    {
-      List<DeploymentTarget> targets = getDeploymentTargets(name);
+      List<DeploymentTarget> targets = getDeploymentTargets();
       SerializableDeploymentID deployment = new SerializableDeploymentID(name, phase, contentURL.toString());
       deployment.setContentURL(contentURL);
       DeploymentProgressImpl progressImpl = new DeploymentProgressImpl(targets, deployment, CommandType.DISTRIBUTE);
@@ -157,31 +157,43 @@
    public DeploymentProgress redeploy(String name, DeploymentPhase phase,
          URL contentURL)
    {
-      List<DeploymentTarget> targets = getDeploymentTargets(name);
+      List<DeploymentTarget> targets = getDeploymentTargets();
       SerializableDeploymentID deployment = new SerializableDeploymentID(name, phase, null);
       DeploymentProgressImpl progressImpl = new DeploymentProgressImpl(targets, deployment, CommandType.REDEPLOY);
       return progressImpl;
    }
 
-   public DeploymentProgress start(String name, DeploymentPhase phase) throws Exception
+   public DeploymentProgress prepare(DeploymentPhase phase, String... names)
+      throws Exception
    {
-      List<DeploymentTarget> targets = getDeploymentTargets(name);
-      SerializableDeploymentID deployment = new SerializableDeploymentID(name, phase, null);
+      List<DeploymentTarget> targets = getDeploymentTargets();
+      SerializableDeploymentID deployment = new SerializableDeploymentID(names, phase, null);
+      DeploymentProgressImpl progressImpl = new DeploymentProgressImpl(targets, deployment, CommandType.PREPARE);
+      return progressImpl;
+   }
+
+   public DeploymentProgress start(DeploymentPhase phase, String... names)
+      throws Exception
+   {
+      List<DeploymentTarget> targets = getDeploymentTargets();
+      SerializableDeploymentID deployment = new SerializableDeploymentID(names, phase, null);
       DeploymentProgressImpl progressImpl = new DeploymentProgressImpl(targets, deployment, CommandType.START);
       return progressImpl;
    }
 
-   public DeploymentProgress stop(String name, DeploymentPhase phase) throws Exception
+   public DeploymentProgress stop(DeploymentPhase phase, String... names)
+      throws Exception
    {
-      List<DeploymentTarget> targets = getDeploymentTargets(name);
-      SerializableDeploymentID deployment = new SerializableDeploymentID(name, phase, null);
+      List<DeploymentTarget> targets = getDeploymentTargets();
+      SerializableDeploymentID deployment = new SerializableDeploymentID(names, phase, null);
       DeploymentProgressImpl progressImpl = new DeploymentProgressImpl(targets, deployment, CommandType.STOP);
       return progressImpl;   }
 
-   public DeploymentProgress undeploy(String name, DeploymentPhase phase) throws Exception
+   public DeploymentProgress undeploy(DeploymentPhase phase, String... names)
+      throws Exception
    {
-      List<DeploymentTarget> targets = getDeploymentTargets(name);
-      SerializableDeploymentID deployment = new SerializableDeploymentID(name, phase, null);
+      List<DeploymentTarget> targets = getDeploymentTargets();
+      SerializableDeploymentID deployment = new SerializableDeploymentID(names, phase, null);
       DeploymentProgressImpl progressImpl = new DeploymentProgressImpl(targets, deployment, CommandType.UNDEPLOY);
       return progressImpl;
    }
@@ -191,10 +203,11 @@
     * @param name
     * @return
     */
-   protected List<DeploymentTarget> getDeploymentTargets(String name)
+   protected List<DeploymentTarget> getDeploymentTargets()
    {
+      String targetName = locator.getHost();
       List<DeploymentTarget> targets = new ArrayList<DeploymentTarget>();
-      StreamingDeploymentTarget hostTarget = new StreamingDeploymentTarget(locator, name, remotingSubsystem);
+      StreamingDeploymentTarget hostTarget = new StreamingDeploymentTarget(locator, targetName, remotingSubsystem);
       targets.add(hostTarget);
       return targets;
    }

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentProgressImpl.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentProgressImpl.java	2008-05-29 21:55:43 UTC (rev 73821)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentProgressImpl.java	2008-05-29 21:57:54 UTC (rev 73822)
@@ -85,10 +85,52 @@
          case DISTRIBUTE:
             doDistribute();
             break;
-            
+         case START:
+            start();
+            break;
+         default:
+            throw new IllegalStateException(command+" is not currently handled");
       }
    }
 
+   public void cancel()
+   {
+      isCancelled = true;
+   }
+
+   public DeploymentStatus getDeploymentStatus()
+   {
+      return currentStatus;
+   }
+
+   public DeploymentID getDeploymentID()
+   {
+      return deployment;
+   }
+
+   public List<DeploymentTarget> getDeploymentTargets()
+   {
+      return targets;
+   }
+
+   /**
+    * 
+    * @param event
+    */
+   protected void notify(ProgressEvent event)
+   {
+      for(ProgressListener listener : listeners)
+      {
+         try
+         {
+            listener.progressEvent(event);
+         }
+         catch(Throwable ignore)
+         {
+         }
+      }
+   }
+
    protected void doDistribute()
    {
       SerializableDeploymentStatus status = new SerializableDeploymentStatus(command, StateType.DEPLOYING);
@@ -151,41 +193,47 @@
       }
    }
 
-   public void cancel()
+   protected void start()
    {
-      isCancelled = true;
-   }
+      SerializableDeploymentStatus status = new SerializableDeploymentStatus(command, StateType.RUNNING);
+      status.setMessage("Running start to: "+targets);
+      currentStatus = status;
+      ProgressEvent event =  new ProgressEvent(deployment, currentStatus);
+      notify(event);
+      for(DeploymentTarget target : targets)
+      {
+         if(isCancelled)
+         {
+            status = new SerializableDeploymentStatus(command, StateType.CANCELLED);
+            status.setMessage("Start has been cancelled");
+            currentStatus = status;
+            event =  new ProgressEvent(deployment, currentStatus);
+            notify(event);
+            break;
+         }
 
-   public DeploymentStatus getDeploymentStatus()
-   {
-      return currentStatus;
-   }
-
-   public DeploymentID getDeploymentID()
-   {
-      return deployment;
-   }
-
-   public List<DeploymentTarget> getDeploymentTargets()
-   {
-      return targets;
-   }
-
-   /**
-    * 
-    * @param event
-    */
-   protected void notify(ProgressEvent event)
-   {
-      for(ProgressListener listener : listeners)
-      {
          try
          {
-            listener.progressEvent(event);
+            target.start(deployment);
+            status = new SerializableDeploymentStatus(command, StateType.COMPLETED);
+            status.setTarget(target);
+            status.setMessage("Completed start for target: "+target);
+            currentStatus = status;
+            event =  new ProgressEvent(deployment, currentStatus);
+            notify(event);
          }
-         catch(Throwable ignore)
+         catch(Exception e)
          {
+            status = new SerializableDeploymentStatus(command, StateType.FAILED);
+            status.setTarget(target);
+            status.setFailure(e);
+            status.setFailed(true);
+            currentStatus = status;
+            ProgressEvent error = new ProgressEvent(deployment, currentStatus);
+            notify(error);
+            break;
          }
       }
+  
    }
 }

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/SerializableDeploymentID.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/SerializableDeploymentID.java	2008-05-29 21:55:43 UTC (rev 73821)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/SerializableDeploymentID.java	2008-05-29 21:57:54 UTC (rev 73822)
@@ -39,23 +39,27 @@
 
    /** An InputStream to use to copy the contents */
    private transient InputStream contentIS;
-   private String deploymentName;
+   private String[] deploymentName;
    private DeploymentPhase phase;
    private String description;
    private URL contentURL;
 
    public SerializableDeploymentID(DeploymentID deployment)
    {
-      this(deployment.getName(), deployment.getPhase(), deployment.getDescription());
+      this(deployment.getNames(), deployment.getPhase(), deployment.getDescription());
    }
    public SerializableDeploymentID(String name, DeploymentPhase phase, String description)
    {
-      this.deploymentName = name;
+      this(new String[]{name}, phase, description);
+   }
+   public SerializableDeploymentID(String[] names, DeploymentPhase phase, String description)
+   {
+      this.deploymentName = names;
       this.phase = phase;
       this.description = description;
    }
 
-   public String getName()
+   public String[] getNames()
    {
       return deploymentName;
    }

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/DeployHandler.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/DeployHandler.java	2008-05-29 21:55:43 UTC (rev 73821)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/DeployHandler.java	2008-05-29 21:57:54 UTC (rev 73822)
@@ -29,6 +29,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URI;
+import java.util.Arrays;
 import java.util.Map;
 import java.util.zip.ZipInputStream;
 
@@ -36,6 +37,7 @@
 import javax.management.MBeanServerInvocationHandler;
 import javax.management.ObjectName;
 
+import org.jboss.aop.joinpoint.Invocation;
 import org.jboss.aop.joinpoint.InvocationResponse;
 import org.jboss.aspects.remoting.AOPRemotingInvocationHandler;
 import org.jboss.deployers.spi.management.deploy.DeploymentTarget;
@@ -90,7 +92,8 @@
       deploymentTarget.setContentIS(contentIS);
       DeploymentPhase phase = deploymentTarget.getPhase();
       //ZipInputStream zis = new ZipInputStream(contentIS);
-      deploymentRepository.addDeploymentContent(deploymentTarget.getName(), contentIS, phase);
+      String[] names = deploymentTarget.getNames();
+      deploymentRepository.addDeploymentContent(names[0], contentIS, phase);
 
       return new InvocationResponse(null);
    }
@@ -105,32 +108,24 @@
     */
    public Object invoke(InvocationRequest request) throws Throwable
    {
-      InvocationResponse value = (InvocationResponse) super.invoke(request);
-      Map payload = request.getRequestPayload();
-      DeploymentID dtID = (DeploymentID) payload.get("DeploymentTargetID");
-      Object returnValue = value;
-      log.debug("invoke, dtID: "+dtID+", payload: "+payload);
-/*
-      if( name.equals("start") )
+      Object parameter = request.getParameter();
+      Object returnValue = null;
+
+      if(parameter instanceof Invocation)
       {
-         deployService.start(url);
+         InvocationResponse value = (InvocationResponse) super.invoke(request);
+         returnValue = value;
       }
-      else if( name.equals("stop") )
+      else
       {
-         deployService.stop(url);
-         
+         Map payload = request.getRequestPayload();
+         DeploymentID dtID = (DeploymentID) payload.get("DeploymentTargetID");
+         log.debug("invoke, dtID: "+dtID+", payload: "+payload);
+         if( parameter.equals("start") )
+         {
+            log.info("start, "+Arrays.asList(dtID.getNames()));
+         }
       }
-      else if( name.equals("undeploy") )
-      {
-         deployService.undeploy(url);         
-      }
-      else if( name.equals("getAvailableModules") )
-      {
-         Integer moduleType = (Integer) payload.get("moduleType");
-         SerializableTargetModuleID[] ids = deployService.getAvailableModules(moduleType);
-         returnValue = ids;
-      }
-      */
       return returnValue;
    }
 

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/StreamingDeploymentTarget.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/StreamingDeploymentTarget.java	2008-05-29 21:55:43 UTC (rev 73821)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/StreamingDeploymentTarget.java	2008-05-29 21:57:54 UTC (rev 73822)
@@ -31,6 +31,7 @@
 import org.jboss.logging.Logger;
 import org.jboss.profileservice.management.upload.SerializableDeploymentID;
 import org.jboss.remoting.Client;
+import org.jboss.remoting.InvocationRequest;
 import org.jboss.remoting.InvokerLocator;
 
 /**
@@ -95,9 +96,20 @@
       contentIS.close();
       client.disconnect();
    }
+   public void redeploy(DeploymentID deployment)
+      throws Exception
+   {
+      throw new IllegalStateException("redeploy is not yet implemented");
+   }
 
+   public void prepare(DeploymentID deployment)
+      throws Exception
+   {
+      throw new IllegalStateException("prepare is not yet implemented");
+   }
+
    /**
-    * Start a given module
+    * Start a given deployment(s)
     */
    public void start(DeploymentID dtID) throws Exception
    {

Modified: trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentID.java
===================================================================
--- trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentID.java	2008-05-29 21:55:43 UTC (rev 73821)
+++ trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentID.java	2008-05-29 21:57:54 UTC (rev 73822)
@@ -34,11 +34,11 @@
 public interface DeploymentID
 {
    /**
-    * Get the name of the deployment
+    * Get the names of the deployments 
     *
     * @return the deployment name
     */
-   String getName();
+   String[] getNames();
 
    /**
     * Get the phase the deployment is associated with
@@ -47,7 +47,7 @@
    DeploymentPhase getPhase();
 
    /**
-    * 
+    * An optional content URL used for distribute/redeploy operations.
     * @return
     */
    public URL getContentURL();

Modified: trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentManager.java
===================================================================
--- trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentManager.java	2008-05-29 21:55:43 UTC (rev 73821)
+++ trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentManager.java	2008-05-29 21:57:54 UTC (rev 73822)
@@ -68,16 +68,26 @@
          URL contentURL);
 
    /**
+    * Validate a set of deployments through their dependency analysis phase.
+    * @param phase
+    * @param names the unique names of the deployments within the phase to prepare
+    * @return a DeploymentProgress used to run and track the prepare progress.
+    * @throws Exception
+    */
+   public DeploymentProgress prepare(DeploymentPhase phase, String... names)
+      throws Exception;
+
+   /**
     * Start a previously distributed deployment
-    * @param name
     * @param phase
+    * @param names the unique names of the deployments within the phase to prepare
     * @return
     * @throws Exception
     */
-   public DeploymentProgress start(String name, DeploymentPhase phase)
+   public DeploymentProgress start(DeploymentPhase phase, String... names)
       throws Exception;
-   public DeploymentProgress stop(String name, DeploymentPhase phase)
+   public DeploymentProgress stop(DeploymentPhase phase, String... names)
       throws Exception;
-   public DeploymentProgress undeploy(String name, DeploymentPhase phase)
+   public DeploymentProgress undeploy(DeploymentPhase phase, String... names)
       throws Exception;
 }

Modified: trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentStatus.java
===================================================================
--- trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentStatus.java	2008-05-29 21:55:43 UTC (rev 73821)
+++ trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentStatus.java	2008-05-29 21:57:54 UTC (rev 73822)
@@ -21,13 +21,14 @@
  */
 package org.jboss.deployers.spi.management.deploy;
 
-import org.jboss.deployers.spi.management.ManagementView;
 
 /**
- * A deployment progress interface used to notify a caller of
- * {@linkplain ManagementView#addDeployment(String, org.jboss.managed.api.ManagedDeployment.DeploymentPhase, java.net.URL)}
+ * A deployment status interface used to provide information about a
+ * DeploymentProgress event associated with a {@linkplain DeploymentManager}
+ * command.
+ * 
  * @author Scott.Stark at jboss.org
- * @version $Revision:$
+ * @version $Revision$
  */
 public interface DeploymentStatus
 {
@@ -35,7 +36,7 @@
       UPLOADING, DEPLOYING, RUNNING, COMPLETED, FAILED, CANCELLED
    }
    public enum CommandType {
-      DISTRIBUTE, START, STOP, UNDEPLOY, REDEPLOY 
+      DISTRIBUTE, PREPARE, START, STOP, UNDEPLOY, REDEPLOY 
    }
 
    /**


Property changes on: trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentStatus.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision

Modified: trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentTarget.java
===================================================================
--- trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentTarget.java	2008-05-29 21:55:43 UTC (rev 73821)
+++ trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentTarget.java	2008-05-29 21:57:54 UTC (rev 73822)
@@ -37,9 +37,20 @@
     * @return the name
     */
    String getName();
+
    
    void distribute(DeploymentID deployment)
       throws Exception;
+   void redeploy(DeploymentID deployment)
+      throws Exception;
+   void prepare(DeploymentID deployment)
+      throws Exception;
+   void start(DeploymentID deployment)
+      throws Exception;
+   void stop(DeploymentID deployment)
+   throws Exception;
+   void undeploy(DeploymentID deployment)
+      throws Exception;
 
    /**
     * Get the target description

Modified: trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/profileservice/test/ClusteredDeployUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/profileservice/test/ClusteredDeployUnitTestCase.java	2008-05-29 21:55:43 UTC (rev 73821)
+++ trunk/testsuite/src/main/org/jboss/test/cluster/defaultcfg/profileservice/test/ClusteredDeployUnitTestCase.java	2008-05-29 21:57:54 UTC (rev 73822)
@@ -95,7 +95,8 @@
       assertFalse("DeploymentStatus.isFailed", status.isFailed());
 
       // Now start the deployment
-      progress = mgtView.start("testMCBeansDeployment.beans", DeploymentPhase.APPLICATION_CLUSTERED);
+      String[] names = {"testMCBeansDeployment.beans"};
+      progress = mgtView.start(DeploymentPhase.APPLICATION, names);
       assertEquals("DeploymentProgress.getDeploymentTargets", 2, progress.getDeploymentTargets().size());
       progress.addProgressListener(this);
       progress.run();

Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/test/DeployUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/test/DeployUnitTestCase.java	2008-05-29 21:55:43 UTC (rev 73821)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/test/DeployUnitTestCase.java	2008-05-29 21:57:54 UTC (rev 73822)
@@ -90,7 +90,8 @@
       assertFalse("DeploymentStatus.isFailed", status.isFailed());
 
       // Now start the deployment
-      progress = mgtView.start("testMCBeansDeployment.beans", DeploymentPhase.APPLICATION);
+      String[] names = {"testMCBeansDeployment.beans"};
+      progress = mgtView.start(DeploymentPhase.APPLICATION, names);
       progress.addProgressListener(this);
       progress.run();
       status = progress.getDeploymentStatus();




More information about the jboss-cvs-commits mailing list