UI module register successful.
This commit is contained in:
parent
9b0b919f35
commit
cf544f44ae
|
|
@ -50,5 +50,10 @@ public class CollectorBootStartUp {
|
|||
} catch (ServiceNotProvidedException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
try {
|
||||
Thread.sleep(10000);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ import org.skywalking.apm.collector.client.ClientException;
|
|||
* @author peng-yongsheng
|
||||
*/
|
||||
public interface DataMonitor {
|
||||
String BASE_CATALOG = "/skywalking";
|
||||
|
||||
void setClient(Client client);
|
||||
|
||||
void addListener(ClusterModuleListener listener) throws ClientException;
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ package org.skywalking.apm.collector.cluster.zookeeper;
|
|||
|
||||
import java.util.Properties;
|
||||
import org.skywalking.apm.collector.client.zookeeper.ZookeeperClient;
|
||||
import org.skywalking.apm.collector.client.zookeeper.ZookeeperClientException;
|
||||
import org.skywalking.apm.collector.cluster.ClusterModule;
|
||||
import org.skywalking.apm.collector.cluster.service.ModuleListenerService;
|
||||
import org.skywalking.apm.collector.cluster.service.ModuleRegisterService;
|
||||
|
|
@ -32,15 +33,20 @@ import org.skywalking.apm.collector.core.UnexpectedException;
|
|||
import org.skywalking.apm.collector.core.module.Module;
|
||||
import org.skywalking.apm.collector.core.module.ModuleProvider;
|
||||
import org.skywalking.apm.collector.core.module.ServiceNotProvidedException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class ClusterModuleZookeeperProvider extends ModuleProvider {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(ClusterModuleZookeeperProvider.class);
|
||||
|
||||
private static final String HOST_PORT = "hostPort";
|
||||
private static final String SESSION_TIMEOUT = "sessionTimeout";
|
||||
|
||||
private ZookeeperClient zookeeperClient;
|
||||
private ClusterZKDataMonitor dataMonitor;
|
||||
|
||||
@Override public String name() {
|
||||
|
|
@ -56,7 +62,7 @@ public class ClusterModuleZookeeperProvider extends ModuleProvider {
|
|||
|
||||
final String hostPort = config.getProperty(HOST_PORT);
|
||||
final int sessionTimeout = (Integer)config.get(SESSION_TIMEOUT);
|
||||
ZookeeperClient zookeeperClient = new ZookeeperClient(hostPort, sessionTimeout, dataMonitor);
|
||||
zookeeperClient = new ZookeeperClient(hostPort, sessionTimeout, dataMonitor);
|
||||
dataMonitor.setClient(zookeeperClient);
|
||||
|
||||
this.registerServiceImplementation(ModuleListenerService.class, new ZookeeperModuleListenerService(dataMonitor));
|
||||
|
|
@ -66,14 +72,18 @@ public class ClusterModuleZookeeperProvider extends ModuleProvider {
|
|||
|
||||
@Override public void start(Properties config) throws ServiceNotProvidedException {
|
||||
try {
|
||||
dataMonitor.start();
|
||||
} catch (CollectorException e) {
|
||||
throw new UnexpectedException(e.getMessage());
|
||||
zookeeperClient.initialize();
|
||||
} catch (ZookeeperClientException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void notifyAfterCompleted() throws ServiceNotProvidedException {
|
||||
|
||||
try {
|
||||
dataMonitor.start();
|
||||
} catch (CollectorException e) {
|
||||
throw new UnexpectedException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override public String[] requiredModules() {
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ public class ClusterZKDataMonitor implements DataMonitor, Watcher {
|
|||
}
|
||||
|
||||
@Override public void register(String path, ModuleRegistration registration) {
|
||||
registrations.put(path, registration);
|
||||
registrations.put(BASE_CATALOG + path, registration);
|
||||
}
|
||||
|
||||
@Override public ClusterModuleListener getListener(String path) {
|
||||
|
|
|
|||
|
|
@ -98,6 +98,7 @@ public abstract class Module {
|
|||
}
|
||||
}
|
||||
}
|
||||
logger.info("start the provider {} in {} module.", provider.name(), provider.module().getName());
|
||||
provider.start(configuration.getProviderConfiguration(provider.name()));
|
||||
|
||||
provider.requiredCheck(services());
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
package org.skywalking.apm.collector.jetty.manager;
|
||||
|
||||
import org.skywalking.apm.collector.core.module.Module;
|
||||
import org.skywalking.apm.collector.jetty.manager.service.JettyManagerService;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
|
|
@ -32,6 +33,6 @@ public class JettyManagerModule extends Module {
|
|||
}
|
||||
|
||||
@Override public Class[] services() {
|
||||
return new Class[0];
|
||||
return new Class[] {JettyManagerService.class};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ public class UIModuleJettyProvider extends ModuleProvider {
|
|||
Server jettyServer = managerService.getElseCreateServer(host, port, contextPath);
|
||||
|
||||
ModuleRegisterService moduleRegisterService = getManager().find(ClusterModule.NAME).getService(ModuleRegisterService.class);
|
||||
moduleRegisterService.register(UIModule.NAME, this.name(), new UIModuleRegistration(host, port, contextPath));
|
||||
} catch (ModuleNotFoundException e) {
|
||||
throw new ServiceNotProvidedException(e.getMessage());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Copyright 2017, OpenSkywalking Organization All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Project repository: https://github.com/OpenSkywalking/skywalking
|
||||
*/
|
||||
|
||||
package org.skywalking.apm.collector.ui.jetty;
|
||||
|
||||
import org.skywalking.apm.collector.cluster.ModuleRegistration;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class UIModuleRegistration extends ModuleRegistration {
|
||||
|
||||
private final String host;
|
||||
private final int port;
|
||||
private final String contextPath;
|
||||
|
||||
public UIModuleRegistration(String host, int port, String contextPath) {
|
||||
this.host = host;
|
||||
this.port = port;
|
||||
this.contextPath = contextPath;
|
||||
}
|
||||
|
||||
@Override public Value buildValue() {
|
||||
return new Value(host, port, contextPath);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue