[jboss-cvs] JBossAS SVN: r86103 - in branches/Branch_5_x: profileservice/src/main/org/jboss/profileservice/management/upload/remoting and 5 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Mar 19 11:30:02 EDT 2009
Author: emuckenhuber
Date: 2009-03-19 11:30:01 -0400 (Thu, 19 Mar 2009)
New Revision: 86103
Added:
branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/DeploymentManagerUnitTestCase.java
branches/Branch_5_x/testsuite/src/resources/deployers/failed/
branches/Branch_5_x/testsuite/src/resources/deployers/failed/empty-jboss-beans.xml
branches/Branch_5_x/testsuite/src/resources/deployers/failed/failing-jboss-beans.xml
Modified:
branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentProgressImpl.java
branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/AbstractDeployHandler.java
branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/DeployHandler.java
branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/StreamingDeploymentTarget.java
branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/MainDeployerAdapter.java
branches/Branch_5_x/testsuite/imports/sections/profileservice.xml
Log:
[JBAS-5993] DeploymentManager.redeploy() and failed deployments test
Modified: branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentProgressImpl.java
===================================================================
--- branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentProgressImpl.java 2009-03-19 14:50:35 UTC (rev 86102)
+++ branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/upload/DeploymentProgressImpl.java 2009-03-19 15:30:01 UTC (rev 86103)
@@ -90,6 +90,9 @@
case REMOVE:
remove();
break;
+ case REDEPLOY:
+ redeploy();
+ break;
default:
throw new IllegalStateException(command+" is not currently handled");
}
@@ -332,4 +335,49 @@
}
}
}
+
+ protected void redeploy()
+ {
+ SerializableDeploymentStatus status = new SerializableDeploymentStatus(command, StateType.RUNNING);
+ status.setMessage("Running redeploy 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("Redeploy has been cancelled");
+ currentStatus = status;
+ event = new ProgressEvent(deployment, currentStatus);
+ notify(event);
+ break;
+ }
+
+ try
+ {
+ target.redeploy(deployment);
+ status = new SerializableDeploymentStatus(command, StateType.COMPLETED);
+ status.setTarget(target);
+ status.setMessage("Completed redeploy for target: "+target);
+ status.setCompleted(true);
+ status.setRunning(true);
+ currentStatus = status;
+ event = new ProgressEvent(deployment, currentStatus);
+ notify(event);
+ }
+ 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: branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/AbstractDeployHandler.java
===================================================================
--- branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/AbstractDeployHandler.java 2009-03-19 14:50:35 UTC (rev 86102)
+++ branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/AbstractDeployHandler.java 2009-03-19 15:30:01 UTC (rev 86103)
@@ -22,7 +22,9 @@
package org.jboss.profileservice.management.upload.remoting;
import java.io.InputStream;
+import java.util.ArrayList;
import java.util.Arrays;
+import java.util.List;
import java.util.Map;
import javax.management.MBeanServer;
@@ -30,9 +32,7 @@
import org.jboss.aop.joinpoint.Invocation;
import org.jboss.aop.joinpoint.InvocationResponse;
import org.jboss.aspects.remoting.AOPRemotingInvocationHandler;
-import org.jboss.deployers.spi.DeploymentException;
import org.jboss.deployers.spi.management.deploy.DeploymentID;
-import org.jboss.deployers.spi.management.deploy.DeploymentManager;
import org.jboss.logging.Logger;
import org.jboss.profileservice.management.upload.SerializableDeploymentID;
import org.jboss.profileservice.spi.DeploymentRepository;
@@ -151,6 +151,9 @@
{
Map<?, ?> payload = request.getRequestPayload();
DeploymentID dtID = (DeploymentID) payload.get("DeploymentTargetID");
+ if(dtID == null)
+ throw new IllegalStateException("Null deployment target ID.");
+
log.debug("invoke, payload: "+payload+", parameter: "+parameter);
try
{
@@ -180,7 +183,11 @@
else if( parameter.equals("undeploy") )
{
remove(dtID);
- }
+ }
+ else if (parameter.equals("redeploy"))
+ {
+ redeploy(dtID);
+ }
}
catch(Exception e)
{
@@ -198,7 +205,7 @@
/**
* Handle a DeploymentManager distribute invocation for copyContent == true
*
- * @see DeploymentManager#distribute(String, DeploymentPhase, java.net.URL)
+ * @see DeploymentManager#distribute(String, java.net.URL, true)
* @param request - the remoting invocation
*/
public Object handleStream(InputStream contentIS, InvocationRequest request) throws Throwable
@@ -231,34 +238,41 @@
DeploymentRepository deploymentRepository = getDeploymentRepository(dtID);
log.info("Begin start, "+Arrays.asList(names));
+ List<String> deployments = new ArrayList<String>();
for(String name : names)
{
// Schedule start for the deployment
- scheduleStart(name, deploymentRepository);
+ deployments.add(scheduleStart(name, deploymentRepository));
}
+ // Process
+ deployer.process();
// CheckComplete
- processCheckComplete();
- log.info("End start, "+Arrays.asList(names));
+ deployer.checkComplete(
+ deployments.toArray(new String[deployments.size()]));
+
+ log.info("End start, "+ deployments);
}
- protected void scheduleStart(String name, DeploymentRepository deploymentRepository) throws Exception
+ protected String scheduleStart(String name, DeploymentRepository deploymentRepository) throws Exception
{
VirtualFile vf = deploymentRepository.getDeploymentContent(name);
- scheduleStart(vf, deploymentRepository);
+ return scheduleStart(vf, deploymentRepository);
}
- protected void scheduleStart(VirtualFile vf, DeploymentRepository repository) throws Exception
+ protected String scheduleStart(VirtualFile vf, DeploymentRepository repository) throws Exception
{
// Create profile deployment
ProfileDeployment profileDeployment = createDeployment(vf);
+ String deploymentName = profileDeployment.getName();
// Add deployment to profile
- repository.addDeployment(profileDeployment.getName(), profileDeployment);
+ repository.addDeployment(deploymentName, profileDeployment);
// Add deployment
deployer.addDeployment(profileDeployment);
// Unlock the contents
- repository.unlockDeploymentContent(profileDeployment.getName());
+ repository.unlockDeploymentContent(deploymentName);
log.debug("Scheduling start for: "+ profileDeployment);
+ return deploymentName;
}
/**
@@ -273,16 +287,19 @@
DeploymentRepository deploymentRepository = getDeploymentRepository(dtID);
log.info("Stop, "+Arrays.asList(names));
+ List<String> deployments = new ArrayList<String>();
for(String name : names)
{
// Schedule stop
- scheduleStop(name, deploymentRepository);
+ deployments.add(scheduleStop(name, deploymentRepository));
}
// CheckComplete
- processCheckComplete();
+ deployer.process();
+ // TODO check if there is still a deploymentContext ?
+ log.info("End stop, "+ deployments);
}
- protected void scheduleStop(String name, DeploymentRepository repository) throws Exception
+ protected String scheduleStop(String name, DeploymentRepository repository) throws Exception
{
// Obtain the deployment
ProfileDeployment vfsd = repository.getDeployment(name);
@@ -292,6 +309,7 @@
deployer.removeDeployment(vfsd);
log.debug("Scheduling stop for: "+ vfsd);
+ return vfsd.getName();
}
/**
@@ -318,18 +336,21 @@
{
// Remove the deployment
ProfileDeployment deployment = repository.removeDeployment(name);
- // Reset to an unlocked deployment
- if(deployment != null)
- repository.unlockDeploymentContent(deployment.getName());
- log.debug("Removed: "+name);
+ log.debug("Removed: "+deployment);
}
-
- protected void processCheckComplete() throws DeploymentException
+
+ /**
+ * Redeploy a deployment.
+ *
+ * @param dtID the deployment id
+ * @throws Exception for any error
+ */
+ protected void redeploy(DeploymentID dtID) throws Exception
{
- // Process
- deployer.process();
- // And checkComplete
- deployer.checkComplete();
+ // Stop
+ stop(dtID);
+ // Start
+ start(dtID);
}
/**
Modified: branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/DeployHandler.java
===================================================================
--- branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/DeployHandler.java 2009-03-19 14:50:35 UTC (rev 86102)
+++ branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/DeployHandler.java 2009-03-19 15:30:01 UTC (rev 86103)
@@ -128,31 +128,31 @@
}
@Override
- protected void scheduleStart(String name, DeploymentRepository deploymentRepository) throws Exception
+ protected String scheduleStart(String name, DeploymentRepository deploymentRepository) throws Exception
{
String deploymentName = resolveDeploymentName(name);
if(deploymentName != null)
{
- VirtualFile vf = this.transientDeployments.get(name);
- super.scheduleStart(vf, this.transientDeploymentRepository);
+ VirtualFile vf = this.transientDeployments.get(deploymentName);
+ return super.scheduleStart(vf, this.transientDeploymentRepository);
}
else
{
- super.scheduleStart(name, deploymentRepository);
+ return super.scheduleStart(name, deploymentRepository);
}
}
@Override
- protected void scheduleStop(String name, DeploymentRepository deploymentRepository) throws Exception
+ protected String scheduleStop(String name, DeploymentRepository deploymentRepository) throws Exception
{
String deploymentName = resolveDeploymentName(name);
if(deploymentName != null)
{
- super.scheduleStop(name, this.transientDeploymentRepository);
+ return super.scheduleStop(name, this.transientDeploymentRepository);
}
else
{
- super.scheduleStop(name, deploymentRepository);
+ return super.scheduleStop(name, deploymentRepository);
}
}
Modified: branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/StreamingDeploymentTarget.java
===================================================================
--- branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/StreamingDeploymentTarget.java 2009-03-19 14:50:35 UTC (rev 86102)
+++ branches/Branch_5_x/profileservice/src/main/org/jboss/profileservice/management/upload/remoting/StreamingDeploymentTarget.java 2009-03-19 15:30:01 UTC (rev 86103)
@@ -137,9 +137,19 @@
}
}
- public void redeploy(DeploymentID deployment) throws Exception
+ public void redeploy(DeploymentID dtID) throws Exception
{
- throw new IllegalStateException("redeploy is not yet implemented");
+ Client client = getClient();
+ try
+ {
+ log.debug("Begin redeploy: " + dtID);
+ invoke(client, "redeploy", createArgs(dtID));
+ log.debug("End redeploy: "+dtID);
+ }
+ finally
+ {
+ client.disconnect();
+ }
}
public void prepare(DeploymentID deployment) throws Exception
@@ -205,9 +215,9 @@
Client client = getClient();
try
{
- log.debug("Begin undeploy: " + dtID);
- invoke(client, "undeploy", createArgs(dtID));
- log.debug("End undeploy");
+ log.debug("Begin remove: " + dtID);
+ invoke(client, "remove", createArgs(dtID));
+ log.debug("End remove");
}
finally
{
Modified: branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/MainDeployerAdapter.java
===================================================================
--- branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/MainDeployerAdapter.java 2009-03-19 14:50:35 UTC (rev 86102)
+++ branches/Branch_5_x/system/src/main/org/jboss/system/server/profileservice/repository/MainDeployerAdapter.java 2009-03-19 15:30:01 UTC (rev 86103)
@@ -118,6 +118,17 @@
}
/**
+ * Check complete
+ *
+ * @param names the deployment names
+ * @throws DeploymentExcetion
+ */
+ public void checkComplete(String... names) throws DeploymentException
+ {
+ this.mainDeployer.checkComplete(names);
+ }
+
+ /**
* CheckComplete
*
* @throws DeploymentException
Modified: branches/Branch_5_x/testsuite/imports/sections/profileservice.xml
===================================================================
--- branches/Branch_5_x/testsuite/imports/sections/profileservice.xml 2009-03-19 14:50:35 UTC (rev 86102)
+++ branches/Branch_5_x/testsuite/imports/sections/profileservice.xml 2009-03-19 15:30:01 UTC (rev 86103)
@@ -56,6 +56,11 @@
<include name="testEarDeployment-application.xml"/>
</zipfileset>
</jar>
+
+ <copy tofile="${build.lib}/deployers-empty-jboss-beans.xml"
+ file="${build.resources}/deployers/failed/empty-jboss-beans.xml"/>
+ <copy tofile="${build.lib}/deployers-failing-jboss-beans.xml"
+ file="${build.resources}/deployers/failed/failing-jboss-beans.xml"/>
<copy tofile="${build.lib}/profileservice-remove-ds.xml"
file="${build.resources}/profileservice/override/profileservice-remove-ds.xml"/>
Added: branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/DeploymentManagerUnitTestCase.java
===================================================================
--- branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/DeploymentManagerUnitTestCase.java (rev 0)
+++ branches/Branch_5_x/testsuite/src/main/org/jboss/test/deployers/DeploymentManagerUnitTestCase.java 2009-03-19 15:30:01 UTC (rev 86103)
@@ -0,0 +1,186 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.deployers;
+
+import javax.naming.InitialContext;
+
+import org.jboss.deployers.spi.management.deploy.DeploymentManager;
+import org.jboss.deployers.spi.management.deploy.DeploymentProgress;
+import org.jboss.profileservice.spi.ProfileService;
+import org.jboss.test.JBossTestCase;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class DeploymentManagerUnitTestCase extends JBossTestCase
+{
+
+ final static String FAILING_DEPLOYMENT = "deployers-failing-jboss-beans.xml";
+ final static String EMTPY_DEPLOYMENT = "deployers-empty-jboss-beans.xml";
+
+ /** The deployment manager. */
+ DeploymentManager deployMgr;
+
+ public DeploymentManagerUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ }
+
+ public void testCopyContent() throws Exception
+ {
+ try
+ {
+ // failed
+ deployFailed(true);
+ // complete
+ deployEmpty(true);
+ // Test redeploy
+ redeployCheckComplete(EMTPY_DEPLOYMENT);
+ }
+ finally
+ {
+ stopAndRemove(new String[]
+ { FAILING_DEPLOYMENT, EMTPY_DEPLOYMENT } );
+ }
+ }
+
+ public void testNoCopyContent() throws Exception
+ {
+ try
+ {
+ // failed
+ deployFailed(false);
+ // complete
+ deployEmpty(false);
+ // test redeploy
+ redeployCheckComplete(EMTPY_DEPLOYMENT);
+ }
+ finally
+ {
+ stopAndRemove(new String[]
+ { FAILING_DEPLOYMENT, EMTPY_DEPLOYMENT } );
+ }
+ }
+
+ void deployFailed(boolean isCopyContent) throws Exception
+ {
+ DeploymentProgress start = distributeAndStart(FAILING_DEPLOYMENT, isCopyContent);
+ assertFailed(start);
+ }
+
+ void deployEmpty(boolean isCopyContent) throws Exception
+ {
+ DeploymentProgress start = distributeAndStart(EMTPY_DEPLOYMENT, isCopyContent);
+ assertComplete(start);
+ }
+
+ DeploymentProgress distributeAndStart(String deploymentName, boolean copyContent) throws Exception
+ {
+ // The deployment manager
+ DeploymentManager deployMgr = getDeploymentManager();
+
+ // Distribute
+ DeploymentProgress distribute = deployMgr.distribute(deploymentName,
+ getDeployURL(deploymentName), copyContent);
+ distribute.run();
+ // Distribute always have to work
+ assertComplete(distribute);
+
+ // Get the repository names
+ String[] uploadedNames = distribute.getDeploymentID().getRepositoryNames();
+ assertNotNull(uploadedNames);
+
+ // Start
+ DeploymentProgress start = deployMgr.start(uploadedNames);
+ start.run();
+ // Return the start deployment progress
+ return start;
+ }
+
+ void redeployCheckComplete(String name) throws Exception
+ {
+ // The deployment manager
+ DeploymentManager deployMgr = getDeploymentManager();
+
+ // Redeploy
+ DeploymentProgress redeploy = deployMgr.redeploy(name);
+ redeploy.run();
+ assertComplete(redeploy);
+ }
+
+ void stopAndRemove(String[] names) throws Exception
+ {
+ // The deployment manager
+ DeploymentManager deployMgr = getDeploymentManager();
+
+ try
+ {
+ DeploymentProgress stop = deployMgr.stop(names);
+ stop.run();
+ assertComplete(stop);
+ }
+ finally
+ {
+ DeploymentProgress remove = deployMgr.remove(names);
+ remove.run();
+ assertComplete(remove);
+ }
+ }
+
+ void assertFailed(DeploymentProgress progress) throws Exception
+ {
+ assertFalse(progress.getDeploymentStatus().isCompleted());
+ assertTrue(progress.getDeploymentStatus().isFailed());
+ }
+
+ void assertComplete(DeploymentProgress progress) throws Exception
+ {
+ if(progress.getDeploymentStatus().isFailed())
+ {
+ throw new RuntimeException("deployment failed.", progress.getDeploymentStatus().getFailure());
+ }
+ //
+ assertTrue(progress.getDeploymentStatus().isCompleted());
+ }
+
+ DeploymentManager getDeploymentManager() throws Exception
+ {
+ if(this.deployMgr == null)
+ {
+ this.deployMgr = getProfileService().getDeploymentManager();
+ }
+ return deployMgr;
+ }
+
+ ProfileService getProfileService() throws Exception
+ {
+ InitialContext ctx = getInitialContext();
+ return (ProfileService) ctx.lookup("ProfileService");
+ }
+
+}
Added: branches/Branch_5_x/testsuite/src/resources/deployers/failed/empty-jboss-beans.xml
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/deployers/failed/empty-jboss-beans.xml (rev 0)
+++ branches/Branch_5_x/testsuite/src/resources/deployers/failed/empty-jboss-beans.xml 2009-03-19 15:30:01 UTC (rev 86103)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <!-- Emtpy -->
+
+</deployment>
\ No newline at end of file
Added: branches/Branch_5_x/testsuite/src/resources/deployers/failed/failing-jboss-beans.xml
===================================================================
--- branches/Branch_5_x/testsuite/src/resources/deployers/failed/failing-jboss-beans.xml (rev 0)
+++ branches/Branch_5_x/testsuite/src/resources/deployers/failed/failing-jboss-beans.xml 2009-03-19 15:30:01 UTC (rev 86103)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <bean name="FailingBean" class="org.jboss.test.no.such.class.NoSuchClassTest" />
+
+</deployment>
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list