Fixed #1679 - moving JMX specific behavior to jmx.DeploymentManagerMBean
This commit is contained in:
parent
9546db266b
commit
c417a18cc8
|
@ -28,7 +28,6 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.jetty.deploy.bindings.StandardDeployer;
|
||||
import org.eclipse.jetty.deploy.bindings.StandardStarter;
|
||||
|
@ -289,13 +288,13 @@ public class DeploymentManager extends ContainerLifeCycle
|
|||
|
||||
public Collection<AppEntry> getAppEntries()
|
||||
{
|
||||
return _apps;
|
||||
return Collections.unmodifiableCollection(_apps);
|
||||
}
|
||||
|
||||
@ManagedAttribute("Deployed Apps")
|
||||
public Collection<App> getApps()
|
||||
{
|
||||
List<App> ret = new ArrayList<App>();
|
||||
List<App> ret = new ArrayList< >();
|
||||
for (AppEntry entry : _apps)
|
||||
{
|
||||
ret.add(entry.app);
|
||||
|
@ -594,38 +593,11 @@ public class DeploymentManager extends ContainerLifeCycle
|
|||
return _lifecycle.getNodes();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@ManagedOperation(value="list nodes that are tracked by DeploymentManager", impact="INFO")
|
||||
public Collection<String> getNodeNames()
|
||||
{
|
||||
return _lifecycle.getNodes().stream().map(Node::getName).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public Collection<App> getApps(@Name("nodeName") String nodeName)
|
||||
public Collection<App> getApps(String nodeName)
|
||||
{
|
||||
return getApps(_lifecycle.getNodeByName(nodeName));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@ManagedOperation(value="list apps that are located at specified App LifeCycle nodes", impact="ACTION")
|
||||
public Collection<String> getAppNames(@Name("nodeName") String nodeName)
|
||||
{
|
||||
Node node = _lifecycle.getNodeByName(nodeName);
|
||||
if(node == null)
|
||||
{
|
||||
throw new IllegalArgumentException("Unable to find node [" + nodeName + "]");
|
||||
}
|
||||
|
||||
List<String> ret = new ArrayList<>();
|
||||
for (AppEntry entry : _apps)
|
||||
{
|
||||
if (entry.lifecyleNode == node)
|
||||
{
|
||||
ret.add(String.format("contextPath=%s,originId=%s,appProvider=%s", entry.app.getContextPath(), entry.app.getOriginId(), entry.app.getAppProvider().getClass().getName()));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void scope(XmlConfiguration xmlc, Resource webapp)
|
||||
throws IOException
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.eclipse.jetty.deploy.jmx;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.jetty.deploy.App;
|
||||
import org.eclipse.jetty.deploy.AppProvider;
|
||||
|
@ -28,7 +29,12 @@ 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;
|
||||
import org.eclipse.jetty.util.annotation.ManagedObject;
|
||||
import org.eclipse.jetty.util.annotation.ManagedOperation;
|
||||
import org.eclipse.jetty.util.annotation.Name;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@ManagedObject("MBean Wrapper for DeploymentManager")
|
||||
public class DeploymentManagerMBean extends ObjectMBean
|
||||
{
|
||||
private final DeploymentManager _manager;
|
||||
|
@ -36,37 +42,55 @@ public class DeploymentManagerMBean extends ObjectMBean
|
|||
public DeploymentManagerMBean(Object managedObject)
|
||||
{
|
||||
super(managedObject);
|
||||
_manager=(DeploymentManager)managedObject;
|
||||
}
|
||||
|
||||
public Collection<String> getNodes()
|
||||
{
|
||||
List<String> nodes = new ArrayList<String>();
|
||||
for (Node node: _manager.getNodes())
|
||||
nodes.add(node.getName());
|
||||
return nodes;
|
||||
_manager = (DeploymentManager) managedObject;
|
||||
}
|
||||
|
||||
@ManagedOperation(value = "list apps being tracked", impact = "INFO")
|
||||
public Collection<String> getApps()
|
||||
{
|
||||
List<String> apps=new ArrayList<String>();
|
||||
for (App app: _manager.getApps())
|
||||
apps.add(app.getOriginId());
|
||||
return apps;
|
||||
List<String> ret = new ArrayList<>();
|
||||
for (DeploymentManager.AppEntry entry : _manager.getAppEntries())
|
||||
{
|
||||
ret.add(toRef(entry.getApp()));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Collection<String> getApps(String nodeName)
|
||||
@ManagedOperation(value = "list nodes that are tracked by DeploymentManager", impact = "INFO")
|
||||
public Collection<String> getNodes()
|
||||
{
|
||||
List<String> apps=new ArrayList<String>();
|
||||
for (App app: _manager.getApps(nodeName))
|
||||
apps.add(app.getOriginId());
|
||||
return apps;
|
||||
return _manager.getNodes().stream().map(Node::getName).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@ManagedOperation(value = "list apps that are located at specified App LifeCycle nodes", impact = "ACTION")
|
||||
public Collection<String> getApps(@Name("nodeName") String nodeName)
|
||||
{
|
||||
Node node = _manager.getLifeCycle().getNodeByName(nodeName);
|
||||
if (node == null)
|
||||
{
|
||||
throw new IllegalArgumentException("Unable to find node [" + nodeName + "]");
|
||||
}
|
||||
|
||||
List<String> ret = new ArrayList<>();
|
||||
for (DeploymentManager.AppEntry entry : _manager.getAppEntries())
|
||||
{
|
||||
if (entry.getLifecyleNode() == node)
|
||||
{
|
||||
ret.add(toRef(entry.getApp()));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private String toRef(App app)
|
||||
{
|
||||
return String.format("originId=%s,contextPath=%s,appProvider=%s", app.getContextPath(), app.getOriginId(), app.getAppProvider().getClass().getName());
|
||||
}
|
||||
|
||||
public Collection<ContextHandler> getContexts() throws Exception
|
||||
{
|
||||
List<ContextHandler> apps=new ArrayList<ContextHandler>();
|
||||
for (App app: _manager.getApps())
|
||||
List<ContextHandler> apps = new ArrayList<ContextHandler>();
|
||||
for (App app : _manager.getApps())
|
||||
apps.add(app.getContextHandler());
|
||||
return apps;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue