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
This commit is contained in:
parent
db438ca86f
commit
266195cc0b
|
@ -21,6 +21,7 @@ jetty-7.3.1.v20110304 4 March 2011
|
|||
+ 338068 Leaking ConstraintMappings on redeploy
|
||||
+ 338092 ProxyServlet leaks memory
|
||||
+ 338607 Removed managed attributes when context is stopped
|
||||
+ 338819 Externally control Deployment Manager application lifecycle
|
||||
+ JETTY-1304 Allow quoted boundaries in Multipart filter
|
||||
+ JETTY-1317 More elegent handling of bad URIs in requests
|
||||
+ JETTY-1331 Allow alternate XML configuration processors (eg spring)
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,10 @@
|
|||
DeploymentManager: Deployment Manager
|
||||
apps:MBean:Deployed Apps
|
||||
contexts:MMBean:Deployed Contexts
|
||||
appProviders:MMBean:Application Providers
|
||||
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
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue