[jboss-cvs] JBossAS SVN: r73618 - in trunk: system/src/main/org/jboss/deployers/spi/management/deploy and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri May 23 10:09:50 EDT 2008
Author: scott.stark at jboss.org
Date: 2008-05-23 10:09:49 -0400 (Fri, 23 May 2008)
New Revision: 73618
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/SerializableDeploymentStatus.java
trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentManager.java
trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentProgress.java
trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentStatus.java
trunk/testsuite/src/main/org/jboss/test/profileservice/test/DeployUnitTestCase.java
Log:
JBAS-5370, update content deployment api to return a DeploymentProgress for the start/stop/undeploy ops
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-23 13:14:18 UTC (rev 73617)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentManagerImpl.java 2008-05-23 14:09:49 UTC (rev 73618)
@@ -21,7 +21,6 @@
*/
package org.jboss.profileservice.management.upload;
-import java.net.URI;
import java.net.URL;
import java.text.MessageFormat;
import java.util.ArrayList;
@@ -32,7 +31,7 @@
import org.jboss.deployers.spi.management.deploy.DeploymentManager;
import org.jboss.deployers.spi.management.deploy.DeploymentProgress;
import org.jboss.deployers.spi.management.deploy.DeploymentTarget;
-import org.jboss.deployers.spi.management.deploy.DeploymentID;
+import org.jboss.deployers.spi.management.deploy.DeploymentStatus.CommandType;
import org.jboss.logging.Logger;
import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
import org.jboss.profileservice.management.upload.remoting.DeployHandler;
@@ -46,8 +45,9 @@
import org.jboss.remoting.InvokerLocator;
/**
+ * The remoting base DeploymentManager implementation
* @author Scott.Stark at jboss.org
- * @version $Revision:$
+ * @version $Revision$
*/
public class DeploymentManagerImpl
implements DeploymentManager
@@ -126,16 +126,14 @@
public DeploymentProgress distribute(String name, DeploymentPhase phase,
URL contentURL)
{
- // TODO, the targets need to be externalized
- List<DeploymentTarget> targets = new ArrayList<DeploymentTarget>();
- StreamingDeploymentTarget hostTarget = new StreamingDeploymentTarget(locator, name, remotingSubsystem);
- targets.add(hostTarget);
+ List<DeploymentTarget> targets = getDeploymentTargets(name);
SerializableDeploymentID deployment = new SerializableDeploymentID(name, phase, contentURL.toString());
deployment.setContentURL(contentURL);
- DeploymentProgressImpl progressImpl = new DeploymentProgressImpl(targets, deployment);
+ DeploymentProgressImpl progressImpl = new DeploymentProgressImpl(targets, deployment, CommandType.DISTRIBUTE);
return progressImpl;
}
+
public boolean isRedeploySupported()
{
return true;
@@ -159,25 +157,46 @@
public DeploymentProgress redeploy(String name, DeploymentPhase phase,
URL contentURL)
{
- // TODO Auto-generated method stub
- return null;
+ List<DeploymentTarget> targets = getDeploymentTargets(name);
+ SerializableDeploymentID deployment = new SerializableDeploymentID(name, phase, null);
+ DeploymentProgressImpl progressImpl = new DeploymentProgressImpl(targets, deployment, CommandType.REDEPLOY);
+ return progressImpl;
}
- public void start(String name, DeploymentPhase phase) throws Exception
+ public DeploymentProgress start(String name, DeploymentPhase phase) throws Exception
{
- // TODO Auto-generated method stub
-
+ List<DeploymentTarget> targets = getDeploymentTargets(name);
+ SerializableDeploymentID deployment = new SerializableDeploymentID(name, phase, null);
+ DeploymentProgressImpl progressImpl = new DeploymentProgressImpl(targets, deployment, CommandType.START);
+ return progressImpl;
}
- public void stop(String name, DeploymentPhase phase) throws Exception
+ public DeploymentProgress stop(String name, DeploymentPhase phase) throws Exception
{
- // TODO Auto-generated method stub
-
+ List<DeploymentTarget> targets = getDeploymentTargets(name);
+ SerializableDeploymentID deployment = new SerializableDeploymentID(name, phase, null);
+ DeploymentProgressImpl progressImpl = new DeploymentProgressImpl(targets, deployment, CommandType.STOP);
+ return progressImpl; }
+
+ public DeploymentProgress undeploy(String name, DeploymentPhase phase) throws Exception
+ {
+ List<DeploymentTarget> targets = getDeploymentTargets(name);
+ SerializableDeploymentID deployment = new SerializableDeploymentID(name, phase, null);
+ DeploymentProgressImpl progressImpl = new DeploymentProgressImpl(targets, deployment, CommandType.UNDEPLOY);
+ return progressImpl;
}
- public void undeploy(String name, DeploymentPhase phase) throws Exception
+ /**
+ * TODO: should the targets include cluster info
+ * @param name
+ * @return
+ */
+ protected List<DeploymentTarget> getDeploymentTargets(String name)
{
- // TODO Auto-generated method stub
-
+ List<DeploymentTarget> targets = new ArrayList<DeploymentTarget>();
+ StreamingDeploymentTarget hostTarget = new StreamingDeploymentTarget(locator, name, remotingSubsystem);
+ targets.add(hostTarget);
+ return targets;
}
+
}
Property changes on: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentManagerImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
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-23 13:14:18 UTC (rev 73617)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentProgressImpl.java 2008-05-23 14:09:49 UTC (rev 73618)
@@ -54,11 +54,14 @@
private List<DeploymentTarget> targets;
/** The deployment being distributed */
private DeploymentID deployment;
+ private CommandType command;
- public DeploymentProgressImpl(List<DeploymentTarget> targets, DeploymentID deployment)
+ public DeploymentProgressImpl(List<DeploymentTarget> targets, DeploymentID deployment,
+ CommandType command)
{
this.targets = targets;
this.deployment = deployment;
+ this.command = command;
}
public synchronized void addProgressListener(ProgressListener listener)
@@ -73,19 +76,33 @@
}
/**
- * Begins the deployment distribution process
+ * Begins the deployment command process
*/
public void run()
{
- CommandType command = CommandType.DISTRIBUTE;
- currentStatus = new SerializableDeploymentStatus(command, StateType.DEPLOYING);
+ switch(command)
+ {
+ case DISTRIBUTE:
+ doDistribute();
+ break;
+
+ }
+ }
+
+ protected void doDistribute()
+ {
+ SerializableDeploymentStatus status = new SerializableDeploymentStatus(command, StateType.DEPLOYING);
+ status.setMessage("Running distribute to: "+targets);
+ currentStatus = status;
ProgressEvent event = new ProgressEvent(deployment, currentStatus);
notify(event);
for(DeploymentTarget target : targets)
{
if(isCancelled)
{
- currentStatus = new SerializableDeploymentStatus(command, StateType.CANCELLED);
+ status = new SerializableDeploymentStatus(command, StateType.CANCELLED);
+ status.setMessage("Distribute has been cancelled");
+ currentStatus = status;
event = new ProgressEvent(deployment, currentStatus);
notify(event);
break;
@@ -93,21 +110,45 @@
try
{
+ // TODO, percent complete info in upload and overall distribute
+ status = new SerializableDeploymentStatus(command, StateType.UPLOADING);
+ status.setTarget(target);
+ status.setMessage("Begining distribute to target: "+target);
+ currentStatus = status;
+ event = new ProgressEvent(deployment, currentStatus);
+ notify(event);
+
+ // TODO, cancellation of in progress distribution
target.distribute(deployment);
- currentStatus = new SerializableDeploymentStatus(command, StateType.COMPLETED);
+ status = new SerializableDeploymentStatus(command, StateType.DEPLOYING);
+ status.setTarget(target);
+ status.setMessage("Completed distribute to target: "+target);
+ currentStatus = status;
event = new ProgressEvent(deployment, currentStatus);
notify(event);
}
catch(Exception e)
{
- SerializableDeploymentStatus status = new SerializableDeploymentStatus(command, StateType.FAILED);
+ 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;
}
}
+
+ if(currentStatus.isFailed() == false)
+ {
+ status = new SerializableDeploymentStatus(command, StateType.COMPLETED);
+ status.setMessage("Completed distribute to all targets");
+ status.setCompleted(true);
+ currentStatus = status;
+ event = new ProgressEvent(deployment, currentStatus);
+ notify(event);
+ }
}
public void cancel()
@@ -119,10 +160,6 @@
{
return currentStatus;
}
- public void setDeploymentStatus(DeploymentStatus currentStatus)
- {
- this.currentStatus = currentStatus;
- }
public DeploymentID getDeploymentID()
{
@@ -134,6 +171,10 @@
return targets;
}
+ /**
+ *
+ * @param event
+ */
protected void notify(ProgressEvent event)
{
for(ProgressListener listener : listeners)
Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/upload/SerializableDeploymentStatus.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/upload/SerializableDeploymentStatus.java 2008-05-23 13:14:18 UTC (rev 73617)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/upload/SerializableDeploymentStatus.java 2008-05-23 14:09:49 UTC (rev 73618)
@@ -26,6 +26,7 @@
import java.io.StringWriter;
import org.jboss.deployers.spi.management.deploy.DeploymentStatus;
+import org.jboss.deployers.spi.management.deploy.DeploymentTarget;
/**
* Simple javabean impl of DeploymentStatus
@@ -42,6 +43,7 @@
private Exception failure;
private String message;
private StateType state;
+ private DeploymentTarget target;
private boolean isCompleted;
private boolean isFailed;
private boolean isRunning;
@@ -60,6 +62,16 @@
{
this.command = command;
}
+
+ public DeploymentTarget getTarget()
+ {
+ return target;
+ }
+ public void setTarget(DeploymentTarget target)
+ {
+ this.target = target;
+ }
+
public Exception getFailure()
{
return failure;
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-23 13:14:18 UTC (rev 73617)
+++ trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentManager.java 2008-05-23 14:09:49 UTC (rev 73618)
@@ -57,13 +57,27 @@
URL contentURL);
public boolean isRedeploySupported();
+ /**
+ *
+ * @param name
+ * @param phase
+ * @param contentURL
+ * @return
+ */
public DeploymentProgress redeploy(String name, DeploymentPhase phase,
URL contentURL);
- public void start(String name, DeploymentPhase phase)
+ /**
+ * Start a previously distributed deployment
+ * @param name
+ * @param phase
+ * @return
+ * @throws Exception
+ */
+ public DeploymentProgress start(String name, DeploymentPhase phase)
throws Exception;
- public void stop(String name, DeploymentPhase phase)
+ public DeploymentProgress stop(String name, DeploymentPhase phase)
throws Exception;
- public void undeploy(String name, DeploymentPhase phase)
+ public DeploymentProgress undeploy(String name, DeploymentPhase phase)
throws Exception;
}
Modified: trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentProgress.java
===================================================================
--- trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentProgress.java 2008-05-23 13:14:18 UTC (rev 73617)
+++ trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentProgress.java 2008-05-23 14:09:49 UTC (rev 73618)
@@ -39,6 +39,10 @@
*/
DeploymentStatus getDeploymentStatus();
+ /**
+ * Get the identifier for the deployment the progress applies to
+ * @return
+ */
DeploymentID getDeploymentID();
/**
@@ -49,7 +53,7 @@
List<DeploymentTarget> getDeploymentTargets();
/**
- * Begins the deployment distribution process
+ * Begins the deployment command
*/
void run();
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-23 13:14:18 UTC (rev 73617)
+++ trunk/system/src/main/org/jboss/deployers/spi/management/deploy/DeploymentStatus.java 2008-05-23 14:09:49 UTC (rev 73618)
@@ -53,6 +53,12 @@
CommandType getCommand();
/**
+ * The target the status applies to
+ * @return
+ */
+ DeploymentTarget getTarget();
+
+ /**
* Get the current status message
*
* @return the message
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-23 13:14:18 UTC (rev 73617)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/test/DeployUnitTestCase.java 2008-05-23 14:09:49 UTC (rev 73618)
@@ -21,11 +21,8 @@
*/
package org.jboss.test.profileservice.test;
-import java.io.InputStream;
import java.net.URL;
-import java.util.zip.ZipInputStream;
-import org.jboss.deployers.spi.management.ManagementView;
import org.jboss.deployers.spi.management.deploy.DeploymentManager;
import org.jboss.deployers.spi.management.deploy.DeploymentProgress;
import org.jboss.deployers.spi.management.deploy.DeploymentStatus;
@@ -34,6 +31,7 @@
import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
/**
+ * Profile service DeploymentManager tests
* @author Scott.Stark at jboss.org
* @version $Revision:$
*/
@@ -79,27 +77,26 @@
throws Exception
{
URL contentURL = super.getDeployURL("testMCBeansDeployment.beans");
- /*
- assertNotNull(contentURL);
- InputStream is = contentURL.openStream();
- byte[] tmp = new byte[4096];
- int totalRead = 0, read = 0;
- while((read = is.read(tmp)) > 0)
- {
- totalRead += read;
- }
- is.close();
- getLog().info(contentURL+", bytes: "+totalRead);
- */
+ // Distribute the content
DeploymentManager mgtView = getDeploymentManager();
DeploymentProgress progress = mgtView.distribute("testMCBeansDeployment.beans", DeploymentPhase.APPLICATION, contentURL);
progress.addProgressListener(this);
progress.run();
DeploymentStatus status = progress.getDeploymentStatus();
assertTrue("DeploymentStatus.isCompleted", status.isCompleted());
- assertTrue("DeploymentStatus.isRunning", status.isRunning());
+ // It should not be running yet
+ assertFalse("DeploymentStatus.isRunning", status.isRunning());
assertFalse("DeploymentStatus.isFailed", status.isFailed());
+
+ // Now start the deployment
+ progress = mgtView.start("testMCBeansDeployment.beans", DeploymentPhase.APPLICATION);
+ progress.addProgressListener(this);
+ progress.run();
+ status = progress.getDeploymentStatus();
+ assertTrue("DeploymentStatus.isCompleted", status.isCompleted());
+ assertTrue("DeploymentStatus.isRunning", status.isRunning());
+ assertFalse("DeploymentStatus.isFailed", status.isFailed());
}
public void testSarDeployment()
throws Exception
More information about the jboss-cvs-commits
mailing list