Add application configuration loader and boot startup.
This commit is contained in:
parent
809668ebc1
commit
be7b774a3e
|
|
@ -29,4 +29,51 @@
|
|||
|
||||
<artifactId>apm-collector-boot</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.yaml</groupId>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
<version>1.18</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.skywalking</groupId>
|
||||
<artifactId>apm-collector-core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<!-- cluster provider -->
|
||||
<dependency>
|
||||
<groupId>org.skywalking</groupId>
|
||||
<artifactId>collector-cluster-redis-provider</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.skywalking</groupId>
|
||||
<artifactId>collector-cluster-standalone-provider</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.skywalking</groupId>
|
||||
<artifactId>collector-cluster-zookeeper-provider</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<!-- cluster provider -->
|
||||
<!-- server manager provider -->
|
||||
<dependency>
|
||||
<groupId>org.skywalking</groupId>
|
||||
<artifactId>collector-grpc-manager-provider</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.skywalking</groupId>
|
||||
<artifactId>collector-jetty-manager-provider</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<!-- server manager provider -->
|
||||
<dependency>
|
||||
<groupId>org.skywalking</groupId>
|
||||
<artifactId>collector-ui-jetty-provider</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* 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.boot;
|
||||
|
||||
import org.skywalking.apm.collector.boot.config.ApplicationConfigLoader;
|
||||
import org.skywalking.apm.collector.boot.config.ConfigFileNotFoundException;
|
||||
import org.skywalking.apm.collector.core.module.ApplicationConfiguration;
|
||||
import org.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.skywalking.apm.collector.core.module.ModuleNotFoundException;
|
||||
import org.skywalking.apm.collector.core.module.ProviderNotFoundException;
|
||||
import org.skywalking.apm.collector.core.module.ServiceNotProvidedException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class CollectorBootStartUp {
|
||||
|
||||
public static void main(String[] args) {
|
||||
final Logger logger = LoggerFactory.getLogger(CollectorBootStartUp.class);
|
||||
|
||||
ApplicationConfigLoader configLoader = new ApplicationConfigLoader();
|
||||
ModuleManager manager = new ModuleManager();
|
||||
try {
|
||||
ApplicationConfiguration applicationConfiguration = configLoader.load();
|
||||
manager.init(applicationConfiguration);
|
||||
} catch (ConfigFileNotFoundException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
} catch (ModuleNotFoundException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
} catch (ProviderNotFoundException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
} catch (ServiceNotProvidedException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,96 @@
|
|||
/*
|
||||
* 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.boot.config;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.Reader;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import org.skywalking.apm.collector.core.module.ApplicationConfiguration;
|
||||
import org.skywalking.apm.collector.core.util.ResourceUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class ApplicationConfigLoader implements ConfigLoader<ApplicationConfiguration> {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(ApplicationConfigLoader.class);
|
||||
|
||||
private final Yaml yaml = new Yaml();
|
||||
|
||||
@Override public ApplicationConfiguration load() throws ConfigFileNotFoundException {
|
||||
ApplicationConfiguration configuration = new ApplicationConfiguration();
|
||||
this.loadConfig(configuration);
|
||||
this.loadDefaultConfig(configuration);
|
||||
return configuration;
|
||||
}
|
||||
|
||||
private void loadConfig(ApplicationConfiguration configuration) throws ConfigFileNotFoundException {
|
||||
try {
|
||||
Reader applicationReader = ResourceUtils.read("application.yml");
|
||||
Map<String, Map<String, Map<String, ?>>> moduleConfig = yaml.loadAs(applicationReader, Map.class);
|
||||
moduleConfig.forEach((moduleName, providerConfig) -> {
|
||||
if (providerConfig.size() > 0) {
|
||||
logger.info("Get a module define from application.yml, module name: {}", moduleName);
|
||||
ApplicationConfiguration.ModuleConfiguration moduleConfiguration = configuration.addModule(moduleName);
|
||||
providerConfig.forEach((name, propertiesConfig) -> {
|
||||
logger.info("Get a provider define belong to {} module, provider name: {}", moduleName, name);
|
||||
Properties properties = new Properties();
|
||||
if (propertiesConfig != null) {
|
||||
propertiesConfig.forEach((key, value) -> {
|
||||
properties.put(key, value);
|
||||
logger.info("The property with key: {}, value: {}, in {} provider", key, value, name);
|
||||
});
|
||||
}
|
||||
moduleConfiguration.addProviderConfiguration(name, properties);
|
||||
});
|
||||
} else {
|
||||
logger.warn("Get a module define from application.yml, but no provider define, use default, module name: {}", moduleName);
|
||||
}
|
||||
});
|
||||
} catch (FileNotFoundException e) {
|
||||
throw new ConfigFileNotFoundException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private void loadDefaultConfig(ApplicationConfiguration configuration) throws ConfigFileNotFoundException {
|
||||
try {
|
||||
Reader applicationReader = ResourceUtils.read("application-default.yml");
|
||||
Map<String, Map<String, Map<String, ?>>> moduleConfig = yaml.loadAs(applicationReader, Map.class);
|
||||
moduleConfig.forEach((moduleName, providerConfig) -> {
|
||||
if (!configuration.has(moduleName)) {
|
||||
logger.warn("The {} module did't define in application.yml, use default", moduleName);
|
||||
ApplicationConfiguration.ModuleConfiguration moduleConfiguration = configuration.addModule(moduleName);
|
||||
providerConfig.forEach((name, propertiesConfig) -> {
|
||||
Properties properties = new Properties();
|
||||
if (propertiesConfig != null) {
|
||||
propertiesConfig.forEach(properties::put);
|
||||
}
|
||||
moduleConfiguration.addProviderConfiguration(name, properties);
|
||||
});
|
||||
}
|
||||
});
|
||||
} catch (FileNotFoundException e) {
|
||||
throw new ConfigFileNotFoundException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* 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.boot.config;
|
||||
|
||||
import org.skywalking.apm.collector.core.CollectorException;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class ConfigFileNotFoundException extends CollectorException {
|
||||
|
||||
public ConfigFileNotFoundException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public ConfigFileNotFoundException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* 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.boot.config;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public interface ConfigLoader<T> {
|
||||
T load() throws ConfigFileNotFoundException;
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
cluster:
|
||||
zookeeper:
|
||||
hostPort: localhost:2181
|
||||
sessionTimeout: 100000
|
||||
#agent_server:
|
||||
# jetty:
|
||||
# host: localhost
|
||||
# port: 10800
|
||||
# context_path: /
|
||||
#agent_stream:
|
||||
# grpc:
|
||||
# host: localhost
|
||||
# port: 11800
|
||||
# jetty:
|
||||
# host: localhost
|
||||
# port: 12800
|
||||
# context_path: /
|
||||
# config:
|
||||
# buffer_offset_max_file_size: 10M
|
||||
# buffer_segment_max_file_size: 500M
|
||||
ui:
|
||||
jetty:
|
||||
host: localhost
|
||||
port: 12800
|
||||
context_path: /
|
||||
#collector_inside:
|
||||
# grpc:
|
||||
# host: localhost
|
||||
# port: 11800
|
||||
#storage:
|
||||
# elasticsearch:
|
||||
# cluster_name: CollectorDBCluster
|
||||
# cluster_transport_sniffer: true
|
||||
# cluster_nodes: localhost:9300
|
||||
# index_shards_number: 2
|
||||
# index_replicas_number: 0
|
||||
#storage:
|
||||
# h2:
|
||||
# url: jdbc:h2:tcp://localhost/~/test
|
||||
# user_name: sa
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ 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
|
||||
-->
|
||||
|
||||
<Configuration status="info">
|
||||
<Appenders>
|
||||
<Console name="Console" target="SYSTEM_OUT">
|
||||
<PatternLayout charset="UTF-8" pattern="%d - %c -%-4r [%t] %-5p %x - %m%n"/>
|
||||
</Console>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<logger name="org.eclipse.jetty" level="INFO"/>
|
||||
<logger name="org.apache.zookeeper" level="INFO"/>
|
||||
<logger name="org.skywalking.apm.collector.agentstream.worker.storage.PersistenceTimer" level="INFO"/>
|
||||
<logger name="io.grpc.netty.NettyServerHandler" level="INFO"/>
|
||||
<Root level="info">
|
||||
<AppenderRef ref="Console"/>
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
package org.skywalking.apm.collector.cluster;
|
||||
|
||||
import org.skywalking.apm.collector.cluster.service.ModuleListenerService;
|
||||
import org.skywalking.apm.collector.cluster.service.ModuleRegisterService;
|
||||
import org.skywalking.apm.collector.cluster.service.ModuleRegistrationGetService;
|
||||
import org.skywalking.apm.collector.core.module.Module;
|
||||
|
|
@ -28,13 +29,13 @@ import org.skywalking.apm.collector.core.module.Service;
|
|||
*/
|
||||
public class ClusterModule extends Module {
|
||||
|
||||
public static final String NAME = "Cluster";
|
||||
public static final String NAME = "cluster";
|
||||
|
||||
@Override public String name() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override public Class<? extends Service>[] services() {
|
||||
return new Class[] {ModuleRegisterService.class, ModuleRegistrationGetService.class};
|
||||
return new Class[] {ModuleListenerService.class, ModuleRegisterService.class, ModuleRegistrationGetService.class};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
package org.skywalking.apm.collector.cluster.redis.service;
|
||||
|
||||
import org.skywalking.apm.collector.cluster.ModuleRegistration;
|
||||
import org.skywalking.apm.collector.cluster.service.ModuleRegisterService;
|
||||
|
||||
/**
|
||||
|
|
@ -25,7 +26,7 @@ import org.skywalking.apm.collector.cluster.service.ModuleRegisterService;
|
|||
*/
|
||||
public class RedisModuleRegisterService implements ModuleRegisterService {
|
||||
|
||||
@Override public void register(String moduleName, String providerName, String address, String others) {
|
||||
@Override public void register(String moduleName, String providerName, ModuleRegistration registration) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
package org.skywalking.apm.collector.cluster.standalone.service;
|
||||
|
||||
import org.skywalking.apm.collector.cluster.ModuleRegistration;
|
||||
import org.skywalking.apm.collector.cluster.service.ModuleRegisterService;
|
||||
|
||||
/**
|
||||
|
|
@ -25,7 +26,7 @@ import org.skywalking.apm.collector.cluster.service.ModuleRegisterService;
|
|||
*/
|
||||
public class StandaloneModuleRegisterService implements ModuleRegisterService {
|
||||
|
||||
@Override public void register(String moduleName, String providerName, String address, String others) {
|
||||
|
||||
@Override public void register(String moduleName, String providerName, ModuleRegistration registration) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,8 +55,8 @@ public class ClusterModuleZookeeperProvider extends ModuleProvider {
|
|||
dataMonitor = new ClusterZKDataMonitor();
|
||||
|
||||
final String hostPort = config.getProperty(HOST_PORT);
|
||||
final String sessionTimeout = config.getProperty(SESSION_TIMEOUT);
|
||||
ZookeeperClient zookeeperClient = new ZookeeperClient(hostPort, Integer.valueOf(sessionTimeout), dataMonitor);
|
||||
final int sessionTimeout = (Integer)config.get(SESSION_TIMEOUT);
|
||||
ZookeeperClient zookeeperClient = new ZookeeperClient(hostPort, sessionTimeout, dataMonitor);
|
||||
dataMonitor.setClient(zookeeperClient);
|
||||
|
||||
this.registerServiceImplementation(ModuleListenerService.class, new ZookeeperModuleListenerService(dataMonitor));
|
||||
|
|
|
|||
|
|
@ -13,11 +13,6 @@
|
|||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.yaml</groupId>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
<version>1.18</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import java.util.Properties;
|
|||
/**
|
||||
* Modulization configurations. The {@link ModuleManager} is going to start, lookup, start modules based on this.
|
||||
*
|
||||
* @author wu-sheng
|
||||
* @author wu-sheng, peng-yongsheng
|
||||
*/
|
||||
public class ApplicationConfiguration {
|
||||
private HashMap<String, ModuleConfiguration> modules = new HashMap<>();
|
||||
|
|
@ -39,6 +39,10 @@ public class ApplicationConfiguration {
|
|||
return newModule;
|
||||
}
|
||||
|
||||
public boolean has(String moduleName) {
|
||||
return modules.containsKey(moduleName);
|
||||
}
|
||||
|
||||
public ModuleConfiguration getModuleConfiguration(String name) {
|
||||
return modules.get(name);
|
||||
}
|
||||
|
|
@ -56,6 +60,10 @@ public class ApplicationConfiguration {
|
|||
return providers.get(name).getProperties();
|
||||
}
|
||||
|
||||
public boolean has(String name) {
|
||||
return providers.containsKey(name);
|
||||
}
|
||||
|
||||
public ModuleConfiguration addProviderConfiguration(String name, Properties properties) {
|
||||
ProviderConfiguration newProvider = new ProviderConfiguration(properties);
|
||||
providers.put(name, newProvider);
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ package org.skywalking.apm.collector.core.module;
|
|||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.ServiceLoader;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* A module definition.
|
||||
|
|
@ -28,6 +30,9 @@ import java.util.ServiceLoader;
|
|||
* @author wu-sheng, peng-yongsheng
|
||||
*/
|
||||
public abstract class Module {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(Module.class);
|
||||
|
||||
private LinkedList<ModuleProvider> loadedProviders = new LinkedList<>();
|
||||
|
||||
/**
|
||||
|
|
@ -52,6 +57,10 @@ public abstract class Module {
|
|||
ServiceLoader<ModuleProvider> moduleProviderLoader = ServiceLoader.load(ModuleProvider.class);
|
||||
boolean providerExist = false;
|
||||
for (ModuleProvider provider : moduleProviderLoader) {
|
||||
if (!configuration.has(provider.name())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
providerExist = true;
|
||||
if (provider.module().equals(getClass())) {
|
||||
ModuleProvider newProvider;
|
||||
|
|
@ -69,10 +78,11 @@ public abstract class Module {
|
|||
}
|
||||
|
||||
if (!providerExist) {
|
||||
throw new ProviderNotFoundException("no provider exists.");
|
||||
throw new ProviderNotFoundException(this.name() + " module no provider exists.");
|
||||
}
|
||||
|
||||
for (ModuleProvider moduleProvider : loadedProviders) {
|
||||
logger.info("Prepare the {} provider in {} module.", moduleProvider.name(), this.name());
|
||||
moduleProvider.prepare(configuration.getProviderConfiguration(moduleProvider.name()));
|
||||
}
|
||||
}
|
||||
|
|
@ -105,7 +115,7 @@ public abstract class Module {
|
|||
*/
|
||||
final List<ModuleProvider> providers() throws ProviderNotFoundException {
|
||||
if (loadedProviders.size() == 0) {
|
||||
throw new ProviderNotFoundException("no provider exists.");
|
||||
throw new ProviderNotFoundException(this.name() + " module no provider exists.");
|
||||
}
|
||||
|
||||
return loadedProviders;
|
||||
|
|
@ -113,9 +123,9 @@ public abstract class Module {
|
|||
|
||||
final ModuleProvider provider() throws ProviderNotFoundException, DuplicateProviderException {
|
||||
if (loadedProviders.size() == 0) {
|
||||
throw new ProviderNotFoundException("no provider exists.");
|
||||
throw new ProviderNotFoundException(this.name() + " module no provider exists.");
|
||||
} else if (loadedProviders.size() > 1) {
|
||||
throw new DuplicateProviderException("exist " + loadedProviders.size() + " providers");
|
||||
throw new DuplicateProviderException(this.name() + " module exist " + loadedProviders.size() + " providers");
|
||||
}
|
||||
|
||||
return loadedProviders.getFirst();
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ public abstract class ModuleProvider {
|
|||
}
|
||||
|
||||
if (requiredServices.length != services.size()) {
|
||||
throw new ServiceNotProvidedException("Provide more service implementations than Module requirements.");
|
||||
throw new ServiceNotProvidedException("The " + this.name() + " provider in " + module.name() + " module provide more service implementations than Module requirements.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,39 @@
|
|||
cluster:
|
||||
h2:
|
||||
hostPort: localhost:2181
|
||||
sessionTimeout: 100000
|
||||
#agent_server:
|
||||
# jetty:
|
||||
# host: localhost
|
||||
# port: 10800
|
||||
# context_path: /
|
||||
#agent_stream:
|
||||
# grpc:
|
||||
# host: localhost
|
||||
# port: 11800
|
||||
# jetty:
|
||||
# host: localhost
|
||||
# port: 12800
|
||||
# context_path: /
|
||||
# config:
|
||||
# buffer_offset_max_file_size: 10M
|
||||
# buffer_segment_max_file_size: 500M
|
||||
ui:
|
||||
jetty:
|
||||
host: localhost
|
||||
port: 12800
|
||||
context_path: /
|
||||
server_manager:
|
||||
jetty:
|
||||
gRPC:
|
||||
#collector_inside:
|
||||
# grpc:
|
||||
# host: localhost
|
||||
# port: 11800
|
||||
#storage:
|
||||
# elasticsearch:
|
||||
# cluster_name: CollectorDBCluster
|
||||
# cluster_transport_sniffer: true
|
||||
# cluster_nodes: localhost:9300
|
||||
# index_shards_number: 2
|
||||
# index_replicas_number: 0
|
||||
|
|
@ -32,7 +32,7 @@ import org.skywalking.apm.collector.server.manager.service.GRPCServerManagerServ
|
|||
public class ServerManagerModuleGRPCProvider extends ModuleProvider {
|
||||
|
||||
@Override public String name() {
|
||||
return "Google_RPC";
|
||||
return "gRPC";
|
||||
}
|
||||
|
||||
@Override public Class<? extends Module> module() {
|
||||
|
|
@ -43,7 +43,11 @@ public class ServerManagerModuleGRPCProvider extends ModuleProvider {
|
|||
this.registerServiceImplementation(GRPCServerManagerService.class, new GRPCServerService());
|
||||
}
|
||||
|
||||
@Override public void init(Properties config) throws ServiceNotProvidedException {
|
||||
@Override public void start(Properties config) throws ServiceNotProvidedException {
|
||||
|
||||
}
|
||||
|
||||
@Override public void notifyAfterCompleted() throws ServiceNotProvidedException {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ import org.skywalking.apm.collector.server.manager.service.JettyServerManagerSer
|
|||
public class ServerManagerModuleJettyProvider extends ModuleProvider {
|
||||
|
||||
@Override public String name() {
|
||||
return "Jetty";
|
||||
return "jetty";
|
||||
}
|
||||
|
||||
@Override public Class<? extends Module> module() {
|
||||
|
|
@ -43,7 +43,11 @@ public class ServerManagerModuleJettyProvider extends ModuleProvider {
|
|||
this.registerServiceImplementation(JettyServerManagerService.class, new JettyServerService());
|
||||
}
|
||||
|
||||
@Override public void init(Properties config) throws ServiceNotProvidedException {
|
||||
@Override public void start(Properties config) throws ServiceNotProvidedException {
|
||||
|
||||
}
|
||||
|
||||
@Override public void notifyAfterCompleted() throws ServiceNotProvidedException {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import org.skywalking.apm.collector.server.manager.service.JettyServerManagerSer
|
|||
*/
|
||||
public class ServerManagerModule extends Module {
|
||||
|
||||
public static final String NAME = "Server_Manager";
|
||||
public static final String NAME = "server_manager";
|
||||
|
||||
@Override public String name() {
|
||||
return NAME;
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import org.skywalking.apm.collector.core.module.Module;
|
|||
*/
|
||||
public class UIModule extends Module {
|
||||
|
||||
public static final String NAME = "Naming";
|
||||
public static final String NAME = "ui";
|
||||
|
||||
@Override public String name() {
|
||||
return NAME;
|
||||
|
|
|
|||
|
|
@ -40,8 +40,10 @@ public class UIModuleJettyProvider extends ModuleProvider {
|
|||
private static final String PORT = "port";
|
||||
private static final String CONTEXT_PATH = "context_path";
|
||||
|
||||
private JettyServerConfig serverConfig;
|
||||
|
||||
@Override public String name() {
|
||||
return "Jetty";
|
||||
return "jetty";
|
||||
}
|
||||
|
||||
@Override public Class<? extends Module> module() {
|
||||
|
|
@ -50,10 +52,12 @@ public class UIModuleJettyProvider extends ModuleProvider {
|
|||
|
||||
@Override public void prepare(Properties config) throws ServiceNotProvidedException {
|
||||
String host = config.getProperty(HOST);
|
||||
String port = config.getProperty(PORT);
|
||||
Integer port = (Integer)config.get(PORT);
|
||||
String contextPath = config.getProperty(CONTEXT_PATH);
|
||||
JettyServerConfig serverConfig = new JettyServerConfig(host, Integer.valueOf(port), contextPath);
|
||||
serverConfig = new JettyServerConfig(host, port, contextPath);
|
||||
}
|
||||
|
||||
@Override public void start(Properties config) throws ServiceNotProvidedException {
|
||||
try {
|
||||
JettyServerManagerService managerService = getManager().find(ServerManagerModule.NAME).getService(JettyServerManagerService.class);
|
||||
Server jettyServer = managerService.getElseCreateServer(serverConfig);
|
||||
|
|
@ -64,10 +68,6 @@ public class UIModuleJettyProvider extends ModuleProvider {
|
|||
}
|
||||
}
|
||||
|
||||
@Override public void start(Properties config) throws ServiceNotProvidedException {
|
||||
|
||||
}
|
||||
|
||||
@Override public void notifyAfterCompleted() throws ServiceNotProvidedException {
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue