Create ui module
This commit is contained in:
parent
9922278523
commit
a220ae9c78
|
|
@ -17,7 +17,10 @@ public class AgentJVMGRPCConfigParser implements ModuleConfigParser {
|
|||
@Override public void parse(Map config) throws ConfigParseException {
|
||||
if (ObjectUtils.isEmpty(config) || StringUtils.isEmpty(config.get(HOST))) {
|
||||
AgentJVMGRPCConfig.HOST = "localhost";
|
||||
} else {
|
||||
AgentJVMGRPCConfig.HOST = (String)config.get(HOST);
|
||||
}
|
||||
|
||||
if (ObjectUtils.isEmpty(config) || StringUtils.isEmpty(config.get(PORT))) {
|
||||
AgentJVMGRPCConfig.PORT = 11800;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,10 @@ public class AgentRegisterGRPCConfigParser implements ModuleConfigParser {
|
|||
@Override public void parse(Map config) throws ConfigParseException {
|
||||
if (ObjectUtils.isEmpty(config) || StringUtils.isEmpty(config.get(HOST))) {
|
||||
AgentRegisterGRPCConfig.HOST = "localhost";
|
||||
} else {
|
||||
AgentRegisterGRPCConfig.HOST = (String)config.get(HOST);
|
||||
}
|
||||
|
||||
if (ObjectUtils.isEmpty(config) || StringUtils.isEmpty(config.get(PORT))) {
|
||||
AgentRegisterGRPCConfig.PORT = 11800;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -33,5 +33,10 @@
|
|||
<artifactId>apm-collector-agentregister</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.skywalking</groupId>
|
||||
<artifactId>apm-collector-ui</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -20,7 +20,10 @@ public class AgentServerJettyConfigParser implements ModuleConfigParser {
|
|||
|
||||
if (ObjectUtils.isEmpty(config) || StringUtils.isEmpty(config.get(HOST))) {
|
||||
AgentServerJettyConfig.HOST = "localhost";
|
||||
} else {
|
||||
AgentServerJettyConfig.HOST = (String)config.get(HOST);
|
||||
}
|
||||
|
||||
if (ObjectUtils.isEmpty(config) || StringUtils.isEmpty(config.get(PORT))) {
|
||||
AgentServerJettyConfig.PORT = 10800;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,10 @@ public class AgentStreamGRPCConfigParser implements ModuleConfigParser {
|
|||
@Override public void parse(Map config) throws ConfigParseException {
|
||||
if (ObjectUtils.isEmpty(config) || StringUtils.isEmpty(config.get(HOST))) {
|
||||
AgentStreamGRPCConfig.HOST = "localhost";
|
||||
} else {
|
||||
AgentStreamGRPCConfig.HOST = (String)config.get(HOST);
|
||||
}
|
||||
|
||||
if (ObjectUtils.isEmpty(config) || StringUtils.isEmpty(config.get(PORT))) {
|
||||
AgentStreamGRPCConfig.PORT = 11800;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,10 @@ public class AgentStreamJettyConfigParser implements ModuleConfigParser {
|
|||
|
||||
if (ObjectUtils.isEmpty(config) || StringUtils.isEmpty(config.get(HOST))) {
|
||||
AgentStreamJettyConfig.HOST = "localhost";
|
||||
} else {
|
||||
AgentStreamJettyConfig.HOST = (String)config.get(HOST);
|
||||
}
|
||||
|
||||
if (ObjectUtils.isEmpty(config) || StringUtils.isEmpty(config.get(PORT))) {
|
||||
AgentStreamJettyConfig.PORT = 12800;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ ui:
|
|||
jetty:
|
||||
host: localhost
|
||||
port: 12800
|
||||
context_path: /ui
|
||||
storage:
|
||||
elasticsearch:
|
||||
cluster_name: CollectorDBCluster
|
||||
|
|
|
|||
|
|
@ -17,7 +17,10 @@ public class StreamGRPCConfigParser implements ModuleConfigParser {
|
|||
@Override public void parse(Map config) throws ConfigParseException {
|
||||
if (ObjectUtils.isEmpty(config) || StringUtils.isEmpty(config.get(HOST))) {
|
||||
StreamGRPCConfig.HOST = "localhost";
|
||||
} else {
|
||||
StreamGRPCConfig.HOST = (String)config.get(HOST);
|
||||
}
|
||||
|
||||
if (ObjectUtils.isEmpty(config) || StringUtils.isEmpty(config.get(PORT))) {
|
||||
StreamGRPCConfig.PORT = 11800;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -11,4 +11,27 @@
|
|||
|
||||
<artifactId>apm-collector-ui</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.skywalking</groupId>
|
||||
<artifactId>apm-collector-core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.skywalking</groupId>
|
||||
<artifactId>apm-collector-cluster</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.skywalking</groupId>
|
||||
<artifactId>apm-collector-server</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.skywalking</groupId>
|
||||
<artifactId>apm-collector-storage</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
package org.skywalking.apm.collector.ui;
|
||||
|
||||
import org.skywalking.apm.collector.core.framework.Context;
|
||||
|
||||
/**
|
||||
* @author pengys5
|
||||
*/
|
||||
public class UIModuleContext extends Context {
|
||||
|
||||
public UIModuleContext(String groupName) {
|
||||
super(groupName);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
package org.skywalking.apm.collector.ui;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.skywalking.apm.collector.cluster.ClusterModuleGroupDefine;
|
||||
import org.skywalking.apm.collector.core.client.Client;
|
||||
import org.skywalking.apm.collector.core.client.ClientException;
|
||||
import org.skywalking.apm.collector.core.client.DataMonitor;
|
||||
import org.skywalking.apm.collector.core.cluster.ClusterDataListenerDefine;
|
||||
import org.skywalking.apm.collector.core.cluster.ClusterModuleContext;
|
||||
import org.skywalking.apm.collector.core.config.ConfigParseException;
|
||||
import org.skywalking.apm.collector.core.framework.CollectorContextHelper;
|
||||
import org.skywalking.apm.collector.core.framework.DefineException;
|
||||
import org.skywalking.apm.collector.core.framework.Handler;
|
||||
import org.skywalking.apm.collector.core.module.ModuleDefine;
|
||||
import org.skywalking.apm.collector.core.server.Server;
|
||||
import org.skywalking.apm.collector.core.server.ServerException;
|
||||
import org.skywalking.apm.collector.core.server.ServerHolder;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author pengys5
|
||||
*/
|
||||
public abstract class UIModuleDefine extends ModuleDefine implements ClusterDataListenerDefine {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(UIModuleDefine.class);
|
||||
|
||||
@Override
|
||||
public final void initialize(Map config, ServerHolder serverHolder) throws DefineException, ClientException {
|
||||
try {
|
||||
configParser().parse(config);
|
||||
Server server = server();
|
||||
serverHolder.holdServer(server, handlerList());
|
||||
|
||||
((ClusterModuleContext)CollectorContextHelper.INSTANCE.getContext(ClusterModuleGroupDefine.GROUP_NAME)).getDataMonitor().addListener(listener(), registration());
|
||||
} catch (ConfigParseException | ServerException e) {
|
||||
throw new UIModuleException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override protected final Client createClient(DataMonitor dataMonitor) {
|
||||
throw new UnsupportedOperationException("");
|
||||
}
|
||||
|
||||
@Override public final boolean defaultModule() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public abstract List<Handler> handlerList();
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package org.skywalking.apm.collector.ui;
|
||||
|
||||
import org.skywalking.apm.collector.core.module.ModuleException;
|
||||
|
||||
/**
|
||||
* @author pengys5
|
||||
*/
|
||||
public class UIModuleException extends ModuleException {
|
||||
public UIModuleException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public UIModuleException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package org.skywalking.apm.collector.ui;
|
||||
|
||||
import org.skywalking.apm.collector.core.framework.Context;
|
||||
import org.skywalking.apm.collector.core.module.ModuleGroupDefine;
|
||||
import org.skywalking.apm.collector.core.module.ModuleInstaller;
|
||||
|
||||
/**
|
||||
* @author pengys5
|
||||
*/
|
||||
public class UIModuleGroupDefine implements ModuleGroupDefine {
|
||||
|
||||
public static final String GROUP_NAME = "ui";
|
||||
|
||||
@Override public String name() {
|
||||
return GROUP_NAME;
|
||||
}
|
||||
|
||||
@Override public Context groupContext() {
|
||||
return new UIModuleContext(GROUP_NAME);
|
||||
}
|
||||
|
||||
@Override public ModuleInstaller moduleInstaller() {
|
||||
return new UIModuleInstaller();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
package org.skywalking.apm.collector.ui;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import org.skywalking.apm.collector.core.client.ClientException;
|
||||
import org.skywalking.apm.collector.core.framework.CollectorContextHelper;
|
||||
import org.skywalking.apm.collector.core.framework.DefineException;
|
||||
import org.skywalking.apm.collector.core.module.ModuleDefine;
|
||||
import org.skywalking.apm.collector.core.module.ModuleInstaller;
|
||||
import org.skywalking.apm.collector.core.server.ServerHolder;
|
||||
import org.skywalking.apm.collector.core.util.ObjectUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author pengys5
|
||||
*/
|
||||
public class UIModuleInstaller implements ModuleInstaller {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(UIModuleInstaller.class);
|
||||
|
||||
@Override public void install(Map<String, Map> moduleConfig,
|
||||
Map<String, ModuleDefine> moduleDefineMap, ServerHolder serverHolder) throws DefineException, ClientException {
|
||||
logger.info("beginning ui module install");
|
||||
|
||||
UIModuleContext context = new UIModuleContext(UIModuleGroupDefine.GROUP_NAME);
|
||||
CollectorContextHelper.INSTANCE.putContext(context);
|
||||
|
||||
Iterator<Map.Entry<String, ModuleDefine>> moduleDefineEntry = moduleDefineMap.entrySet().iterator();
|
||||
while (moduleDefineEntry.hasNext()) {
|
||||
ModuleDefine moduleDefine = moduleDefineEntry.next().getValue();
|
||||
logger.info("module {} initialize", moduleDefine.getClass().getName());
|
||||
moduleDefine.initialize((ObjectUtils.isNotEmpty(moduleConfig) && moduleConfig.containsKey(moduleDefine.name())) ? moduleConfig.get(moduleDefine.name()) : null, serverHolder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package org.skywalking.apm.collector.ui.jetty;
|
||||
|
||||
/**
|
||||
* @author pengys5
|
||||
*/
|
||||
public class UIJettyConfig {
|
||||
public static String HOST;
|
||||
public static int PORT;
|
||||
public static String CONTEXT_PATH;
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
package org.skywalking.apm.collector.ui.jetty;
|
||||
|
||||
import java.util.Map;
|
||||
import org.skywalking.apm.collector.core.config.ConfigParseException;
|
||||
import org.skywalking.apm.collector.core.module.ModuleConfigParser;
|
||||
import org.skywalking.apm.collector.core.util.ObjectUtils;
|
||||
import org.skywalking.apm.collector.core.util.StringUtils;
|
||||
|
||||
/**
|
||||
* @author pengys5
|
||||
*/
|
||||
public class UIJettyConfigParser implements ModuleConfigParser {
|
||||
|
||||
private static final String HOST = "host";
|
||||
private static final String PORT = "port";
|
||||
public static final String CONTEXT_PATH = "contextPath";
|
||||
|
||||
@Override public void parse(Map config) throws ConfigParseException {
|
||||
UIJettyConfig.CONTEXT_PATH = "/";
|
||||
|
||||
if (ObjectUtils.isEmpty(config) || StringUtils.isEmpty(config.get(HOST))) {
|
||||
UIJettyConfig.HOST = "localhost";
|
||||
} else {
|
||||
UIJettyConfig.HOST = (String)config.get(HOST);
|
||||
}
|
||||
|
||||
if (ObjectUtils.isEmpty(config) || StringUtils.isEmpty(config.get(PORT))) {
|
||||
UIJettyConfig.PORT = 12800;
|
||||
} else {
|
||||
UIJettyConfig.PORT = (Integer)config.get(PORT);
|
||||
}
|
||||
if (ObjectUtils.isNotEmpty(config) && StringUtils.isNotEmpty(config.get(CONTEXT_PATH))) {
|
||||
UIJettyConfig.CONTEXT_PATH = (String)config.get(CONTEXT_PATH);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
package org.skywalking.apm.collector.ui.jetty;
|
||||
|
||||
import org.skywalking.apm.collector.cluster.ClusterModuleDefine;
|
||||
import org.skywalking.apm.collector.core.cluster.ClusterDataListener;
|
||||
import org.skywalking.apm.collector.ui.UIModuleGroupDefine;
|
||||
|
||||
/**
|
||||
* @author pengys5
|
||||
*/
|
||||
public class UIJettyDataListener extends ClusterDataListener {
|
||||
|
||||
public static final String PATH = ClusterModuleDefine.BASE_CATALOG + "." + UIModuleGroupDefine.GROUP_NAME + "." + UIJettyModuleDefine.MODULE_NAME;
|
||||
|
||||
@Override public String path() {
|
||||
return PATH;
|
||||
}
|
||||
|
||||
@Override public void addressChangedNotify() {
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
package org.skywalking.apm.collector.ui.jetty;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import org.skywalking.apm.collector.core.cluster.ClusterDataListener;
|
||||
import org.skywalking.apm.collector.core.framework.Handler;
|
||||
import org.skywalking.apm.collector.core.module.ModuleConfigParser;
|
||||
import org.skywalking.apm.collector.core.module.ModuleRegistration;
|
||||
import org.skywalking.apm.collector.core.server.Server;
|
||||
import org.skywalking.apm.collector.server.jetty.JettyServer;
|
||||
import org.skywalking.apm.collector.ui.UIModuleDefine;
|
||||
import org.skywalking.apm.collector.ui.UIModuleGroupDefine;
|
||||
import org.skywalking.apm.collector.ui.jetty.handler.UIJettyServerHandler;
|
||||
|
||||
/**
|
||||
* @author pengys5
|
||||
*/
|
||||
public class UIJettyModuleDefine extends UIModuleDefine {
|
||||
|
||||
public static final String MODULE_NAME = "jetty";
|
||||
|
||||
@Override protected String group() {
|
||||
return UIModuleGroupDefine.GROUP_NAME;
|
||||
}
|
||||
|
||||
@Override public String name() {
|
||||
return MODULE_NAME;
|
||||
}
|
||||
|
||||
@Override protected ModuleConfigParser configParser() {
|
||||
return new UIJettyConfigParser();
|
||||
}
|
||||
|
||||
@Override protected Server server() {
|
||||
return new JettyServer(UIJettyConfig.HOST, UIJettyConfig.PORT, UIJettyConfig.CONTEXT_PATH);
|
||||
}
|
||||
|
||||
@Override protected ModuleRegistration registration() {
|
||||
return new UIJettyModuleRegistration();
|
||||
}
|
||||
|
||||
@Override public ClusterDataListener listener() {
|
||||
return new UIJettyDataListener();
|
||||
}
|
||||
|
||||
@Override public List<Handler> handlerList() {
|
||||
List<Handler> handlers = new LinkedList<>();
|
||||
handlers.add(new UIJettyServerHandler());
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
package org.skywalking.apm.collector.ui.jetty;
|
||||
|
||||
import org.skywalking.apm.collector.core.module.ModuleRegistration;
|
||||
|
||||
/**
|
||||
* @author pengys5
|
||||
*/
|
||||
public class UIJettyModuleRegistration extends ModuleRegistration {
|
||||
|
||||
@Override public Value buildValue() {
|
||||
return new Value(UIJettyConfig.HOST, UIJettyConfig.PORT, UIJettyConfig.CONTEXT_PATH);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package org.skywalking.apm.collector.ui.jetty.handler;
|
||||
|
||||
import java.io.IOException;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.skywalking.apm.collector.server.jetty.JettyHandler;
|
||||
|
||||
/**
|
||||
* @author pengys5
|
||||
*/
|
||||
public class TraceDagGetHandler extends JettyHandler {
|
||||
|
||||
@Override public String pathSpec() {
|
||||
return "/traceDag";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
package org.skywalking.apm.collector.ui.jetty.handler;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.skywalking.apm.collector.cluster.ClusterModuleGroupDefine;
|
||||
import org.skywalking.apm.collector.core.cluster.ClusterModuleContext;
|
||||
import org.skywalking.apm.collector.core.cluster.ClusterModuleRegistrationReader;
|
||||
import org.skywalking.apm.collector.core.framework.CollectorContextHelper;
|
||||
import org.skywalking.apm.collector.server.jetty.JettyHandler;
|
||||
import org.skywalking.apm.collector.ui.jetty.UIJettyDataListener;
|
||||
|
||||
/**
|
||||
* @author pengys5
|
||||
*/
|
||||
public class UIJettyServerHandler extends JettyHandler {
|
||||
|
||||
@Override public String pathSpec() {
|
||||
return "/ui/jetty";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||
ClusterModuleRegistrationReader reader = ((ClusterModuleContext)CollectorContextHelper.INSTANCE.getContext(ClusterModuleGroupDefine.GROUP_NAME)).getReader();
|
||||
List<String> servers = reader.read(UIJettyDataListener.PATH);
|
||||
JsonArray serverArray = new JsonArray();
|
||||
servers.forEach(server -> {
|
||||
serverArray.add(server);
|
||||
});
|
||||
|
||||
reply(resp, serverArray, HttpServletResponse.SC_OK);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
org.skywalking.apm.collector.ui.UIModuleGroupDefine
|
||||
|
|
@ -0,0 +1 @@
|
|||
org.skywalking.apm.collector.ui.jetty.UIJettyModuleDefine
|
||||
Loading…
Reference in New Issue