Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Gorovoy2011-03-04 21:54:15 -0500
committerMichael Gorovoy2011-03-04 21:54:15 -0500
commit266195cc0bedea21d256d57d9b9745243e64230a (patch)
treed85839fe7e8ad3af1b68cf9333a921c324e2deb7 /jetty-deploy
parentdb438ca86fc065b0c7634ade95c37b01345603da (diff)
downloadorg.eclipse.jetty.project-266195cc0bedea21d256d57d9b9745243e64230a.tar.gz
org.eclipse.jetty.project-266195cc0bedea21d256d57d9b9745243e64230a.tar.xz
org.eclipse.jetty.project-266195cc0bedea21d256d57d9b9745243e64230a.zip
338819: Externally control Deployment Manager application lifecycle
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@2856 7e9141cc-0065-0410-87d8-b60c137991c4
Diffstat (limited to 'jetty-deploy')
-rw-r--r--jetty-deploy/pom.xml1
-rw-r--r--jetty-deploy/src/main/java/org/eclipse/jetty/deploy/DeploymentManager.java23
-rw-r--r--jetty-deploy/src/main/java/org/eclipse/jetty/deploy/jmx/DeploymentManagerMBean.java22
-rw-r--r--jetty-deploy/src/main/resources/org/eclipse/jetty/deploy/jmx/DeploymentManager-mbean.properties12
-rw-r--r--jetty-deploy/src/main/resources/org/eclipse/jetty/deploy/jmx/WebAppDeployer-mbean.properties2
-rw-r--r--jetty-deploy/src/test/java/org/eclipse/jetty/deploy/DeploymentManagerLifeCyclePathTest.java54
6 files changed, 105 insertions, 9 deletions
diff --git a/jetty-deploy/pom.xml b/jetty-deploy/pom.xml
index 79ef070474..e0822b9724 100644
--- a/jetty-deploy/pom.xml
+++ b/jetty-deploy/pom.xml
@@ -95,6 +95,7 @@
<dependency>
<groupId>org.eclipse.jetty.toolchain</groupId>
<artifactId>jetty-test-helper</artifactId>
+ <version>1.3-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
diff --git a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/DeploymentManager.java b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/DeploymentManager.java
index 1e2c0acfb4..5e83a08364 100644
--- a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/DeploymentManager.java
+++ b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/DeploymentManager.java
@@ -35,7 +35,6 @@ import org.eclipse.jetty.deploy.graph.Path;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
import org.eclipse.jetty.util.AttributesMap;
-import org.eclipse.jetty.util.component.AbstractLifeCycle;
import org.eclipse.jetty.util.component.AggregateLifeCycle;
import org.eclipse.jetty.util.log.Log;
@@ -435,10 +434,10 @@ public class DeploymentManager extends AggregateLifeCycle
public void requestAppGoal(App app, String nodeName)
{
AppEntry appentry = findAppByOriginId(app.getOriginId());
- if (appentry == null)
- {
- throw new IllegalStateException("App not being tracked by Deployment Manager: " + app);
- }
+ if (appentry == null)
+ {
+ throw new IllegalStateException("App not being tracked by Deployment Manager: " + app);
+ }
requestAppGoal(appentry,nodeName);
}
@@ -455,6 +454,10 @@ public class DeploymentManager extends AggregateLifeCycle
private void requestAppGoal(AppEntry appentry, String nodeName)
{
Node destinationNode = _lifecycle.getNodeByName(nodeName);
+ if (destinationNode == null)
+ {
+ throw new IllegalStateException("Node not present in Deployment Manager: " + nodeName);
+ }
// Compute lifecycle steps
Path path = _lifecycle.getPath(appentry.lifecyleNode,destinationNode);
if (path.isEmpty())
@@ -563,4 +566,14 @@ public class DeploymentManager extends AggregateLifeCycle
{
this._useStandardBindings = useStandardBindings;
}
+
+ public Collection<Node> getNodes()
+ {
+ return _lifecycle.getNodes();
+ }
+
+ public Collection<App> getApps(String nodeName)
+ {
+ return getApps(_lifecycle.getNodeByName(nodeName));
+ }
}
diff --git a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/jmx/DeploymentManagerMBean.java b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/jmx/DeploymentManagerMBean.java
index 3a219215f6..3bd5362494 100644
--- a/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/jmx/DeploymentManagerMBean.java
+++ b/jetty-deploy/src/main/java/org/eclipse/jetty/deploy/jmx/DeploymentManagerMBean.java
@@ -7,6 +7,7 @@ import java.util.List;
import org.eclipse.jetty.deploy.App;
import org.eclipse.jetty.deploy.AppProvider;
import org.eclipse.jetty.deploy.DeploymentManager;
+import org.eclipse.jetty.deploy.graph.Node;
import org.eclipse.jetty.jmx.ObjectMBean;
import org.eclipse.jetty.server.handler.ContextHandler;
@@ -20,6 +21,14 @@ public class DeploymentManagerMBean extends ObjectMBean
_manager=(DeploymentManager)managedObject;
}
+ public Collection<String> getNodes()
+ {
+ List<String> nodes = new ArrayList<String>();
+ for (Node node: _manager.getNodes())
+ nodes.add(node.getName());
+ return nodes;
+ }
+
public Collection<String> getApps()
{
List<String> apps=new ArrayList<String>();
@@ -28,6 +37,14 @@ public class DeploymentManagerMBean extends ObjectMBean
return apps;
}
+ public Collection<String> getApps(String nodeName)
+ {
+ List<String> apps=new ArrayList<String>();
+ for (App app: _manager.getApps(nodeName))
+ apps.add(app.getOriginId());
+ return apps;
+ }
+
public Collection<ContextHandler> getContexts() throws Exception
{
List<ContextHandler> apps=new ArrayList<ContextHandler>();
@@ -40,4 +57,9 @@ public class DeploymentManagerMBean extends ObjectMBean
{
return _manager.getAppProviders();
}
+
+ public void requestAppGoal(String appId, String nodeName)
+ {
+ _manager.requestAppGoal(appId, nodeName);
+ }
}
diff --git a/jetty-deploy/src/main/resources/org/eclipse/jetty/deploy/jmx/DeploymentManager-mbean.properties b/jetty-deploy/src/main/resources/org/eclipse/jetty/deploy/jmx/DeploymentManager-mbean.properties
index 726c236b1a..4149820d53 100644
--- a/jetty-deploy/src/main/resources/org/eclipse/jetty/deploy/jmx/DeploymentManager-mbean.properties
+++ b/jetty-deploy/src/main/resources/org/eclipse/jetty/deploy/jmx/DeploymentManager-mbean.properties
@@ -1,4 +1,10 @@
DeploymentManager: Deployment Manager
-apps:MBean:Deployed Apps
-contexts:MMBean:Deployed Contexts
-appProviders:MMBean:Application Providers \ No newline at end of file
+nodes:MBean: App LifeCycle Nodes
+apps:MBean: Deployed Apps
+contexts:MMBean: Deployed Contexts
+appProviders:MMBean: Application Providers
+getApps(java.lang.String):MBean:ACTION: List apps that are located at specified App LifeCycle node
+getApps(java.lang.String)[0]:nodeName: Name of the App LifeCycle node
+requestAppGoal(java.lang.String,java.lang.String) ACTION: Request the app to be moved to the specified App LifeCycle node
+requestAppGoal(java.lang.String,java.lang.String)[0]:appId:App identifier
+requestAppGoal(java.lang.String,java.lang.String)[1]:nodeName:Name of the App LifeCycle node \ No newline at end of file
diff --git a/jetty-deploy/src/main/resources/org/eclipse/jetty/deploy/jmx/WebAppDeployer-mbean.properties b/jetty-deploy/src/main/resources/org/eclipse/jetty/deploy/jmx/WebAppDeployer-mbean.properties
index a1304e1e7a..2815ae6ee4 100644
--- a/jetty-deploy/src/main/resources/org/eclipse/jetty/deploy/jmx/WebAppDeployer-mbean.properties
+++ b/jetty-deploy/src/main/resources/org/eclipse/jetty/deploy/jmx/WebAppDeployer-mbean.properties
@@ -1,6 +1,6 @@
WebAppDeployer: Deployer for startup deployment of webapps
contexts: MObject: The ContextHandlerCollection to which the deployer deploys
-allowDuplicates: Object:R0: Whether or not duplicate deployments are allowed
+allowDuplicates: Object:RO: Whether or not duplicate deployments are allowed
setAllowDuplicates(boolean):ACTION: Whether or not duplicate deployments are allowed
setAllowDuplicates(boolean)[0]:allowDuplicates: True allows duplicate webapps to be deployed while false does not
defaultsDescriptor: Object: The webdefault.xml descriptor to use for all webapps deployed by the deployer
diff --git a/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/DeploymentManagerLifeCyclePathTest.java b/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/DeploymentManagerLifeCyclePathTest.java
index b15bdc5f4b..a239502513 100644
--- a/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/DeploymentManagerLifeCyclePathTest.java
+++ b/jetty-deploy/src/test/java/org/eclipse/jetty/deploy/DeploymentManagerLifeCyclePathTest.java
@@ -15,10 +15,16 @@
// ========================================================================
package org.eclipse.jetty.deploy;
+import java.lang.management.ManagementFactory;
import java.util.ArrayList;
import java.util.List;
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+
+import org.eclipse.jetty.jmx.MBeanContainer;
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
+import org.eclipse.jetty.toolchain.jmx.JmxServiceConnection;
import org.junit.Test;
public class DeploymentManagerLifeCyclePathTest
@@ -79,4 +85,52 @@ public class DeploymentManagerLifeCyclePathTest
pathtracker.assertExpected("Test StateTransition / New only",expected);
}
+
+ @Test
+ public void testStateTransition_DeployedToUndeployed() throws Exception
+ {
+ DeploymentManager depman = new DeploymentManager();
+ depman.setDefaultLifeCycleGoal(null); // no default
+ AppLifeCyclePathCollector pathtracker = new AppLifeCyclePathCollector();
+ MockAppProvider mockProvider = new MockAppProvider();
+
+ // Setup JMX
+ MBeanContainer mbContainer=new MBeanContainer(ManagementFactory.getPlatformMBeanServer());
+ mbContainer.start();
+ mbContainer.addBean(depman);
+
+ depman.addLifeCycleBinding(pathtracker);
+ depman.addAppProvider(mockProvider);
+ depman.setContexts(new ContextHandlerCollection());
+
+ // Start DepMan
+ depman.start();
+
+ // Trigger new App
+ mockProvider.findWebapp("foo-webapp-1.war");
+
+ App app = depman.getAppByOriginId("mock-foo-webapp-1.war");
+
+ // Request Deploy of App
+ depman.requestAppGoal(app,"deployed");
+
+ JmxServiceConnection jmxConnection = new JmxServiceConnection();
+ jmxConnection.connect();
+
+ MBeanServerConnection mbsConnection = jmxConnection.getConnection();
+ ObjectName dmObjName = new ObjectName("org.eclipse.jetty.deploy:type=deploymentmanager,id=0");
+ String[] params = new String[] {"mock-foo-webapp-1.war", "undeployed"};
+ String[] signature = new String[] {"java.lang.String", "java.lang.String"};
+ mbsConnection.invoke(dmObjName, "requestAppGoal", params, signature);
+
+ // Setup Expectations.
+ List<String> expected = new ArrayList<String>();
+ // SHOULD NOT SEE THIS NODE VISITED - expected.add("undeployed");
+ expected.add("deploying");
+ expected.add("deployed");
+ expected.add("undeploying");
+ expected.add("undeployed");
+
+ pathtracker.assertExpected("Test JMX StateTransition / Deployed -> Undeployed",expected);
+ }
}

Back to the top