diff --git a/oap-server/server-cluster-plugin/cluster-standalone-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/standalone/ClusterModuleStandaloneProvider.java b/oap-server/server-cluster-plugin/cluster-standalone-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/standalone/ClusterModuleStandaloneProvider.java index a6f4bef338b056e8acbac569a09b7eb4424a5bad..a861e3efa5fa12034760d8202d2f386fe41d2ef4 100644 --- a/oap-server/server-cluster-plugin/cluster-standalone-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/standalone/ClusterModuleStandaloneProvider.java +++ b/oap-server/server-cluster-plugin/cluster-standalone-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/standalone/ClusterModuleStandaloneProvider.java @@ -18,9 +18,15 @@ package org.apache.skywalking.oap.server.cluster.plugin.standalone; -import org.apache.skywalking.oap.server.core.cluster.*; -import org.apache.skywalking.oap.server.library.module.*; -import org.slf4j.*; +import org.apache.skywalking.oap.server.core.cluster.ClusterModule; +import org.apache.skywalking.oap.server.core.cluster.ClusterNodesQuery; +import org.apache.skywalking.oap.server.core.cluster.ClusterRegister; +import org.apache.skywalking.oap.server.library.module.ModuleConfig; +import org.apache.skywalking.oap.server.library.module.ModuleProvider; +import org.apache.skywalking.oap.server.library.module.ModuleStartException; +import org.apache.skywalking.oap.server.library.module.ServiceNotProvidedException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @author peng-yongsheng @@ -29,11 +35,8 @@ public class ClusterModuleStandaloneProvider extends ModuleProvider { private static final Logger logger = LoggerFactory.getLogger(ClusterModuleStandaloneProvider.class); - private final StandaloneServiceManager serviceManager; - public ClusterModuleStandaloneProvider() { super(); - this.serviceManager = new StandaloneServiceManager(); } @Override public String name() { @@ -49,8 +52,9 @@ public class ClusterModuleStandaloneProvider extends ModuleProvider { } @Override public void prepare() throws ServiceNotProvidedException { - this.registerServiceImplementation(ModuleRegister.class, new StandaloneModuleRegister(serviceManager)); - this.registerServiceImplementation(ModuleQuery.class, new StandaloneModuleQuery(serviceManager)); + StandaloneManager standaloneManager = new StandaloneManager(); + this.registerServiceImplementation(ClusterRegister.class, standaloneManager); + this.registerServiceImplementation(ClusterNodesQuery.class, standaloneManager); } @Override public void start() throws ModuleStartException { diff --git a/oap-server/server-cluster-plugin/cluster-standalone-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/standalone/StandaloneManager.java b/oap-server/server-cluster-plugin/cluster-standalone-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/standalone/StandaloneManager.java new file mode 100644 index 0000000000000000000000000000000000000000..c266eb4e5ccb06a8f48915545bd6cf3ce5cd3d00 --- /dev/null +++ b/oap-server/server-cluster-plugin/cluster-standalone-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/standalone/StandaloneManager.java @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + * + */ + +package org.apache.skywalking.oap.server.cluster.plugin.standalone; + +import org.apache.skywalking.oap.server.core.cluster.ClusterNodesQuery; +import org.apache.skywalking.oap.server.core.cluster.ClusterRegister; +import org.apache.skywalking.oap.server.core.cluster.RemoteInstance; + +import java.util.ArrayList; +import java.util.List; + +/** + * A cluster manager simulator. Work in memory only. + * Also return the current instance. + * + * @author peng-yongsheng, Wu Sheng + */ +public class StandaloneManager implements ClusterNodesQuery, ClusterRegister { + + private volatile RemoteInstance remoteInstance; + + + @Override public void registerRemote(RemoteInstance remoteInstance) { + this.remoteInstance = remoteInstance; + } + + @Override + public List queryRemoteNodes() { + if(remoteInstance == null){ + return new ArrayList(0); + } + ArrayList remoteList = new ArrayList(1); + remoteList.add(remoteInstance); + return remoteList; + } +} diff --git a/oap-server/server-cluster-plugin/cluster-standalone-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/standalone/StandaloneModuleRegister.java b/oap-server/server-cluster-plugin/cluster-standalone-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/standalone/StandaloneModuleRegister.java deleted file mode 100644 index bb9241d4e9d9654f59a78eebf45dbae46892b984..0000000000000000000000000000000000000000 --- a/oap-server/server-cluster-plugin/cluster-standalone-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/standalone/StandaloneModuleRegister.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - * - */ - -package org.apache.skywalking.oap.server.cluster.plugin.standalone; - -import org.apache.skywalking.oap.server.core.cluster.*; - -/** - * @author peng-yongsheng - */ -public class StandaloneModuleRegister implements ModuleRegister { - - private final StandaloneServiceManager serviceManager; - - StandaloneModuleRegister(StandaloneServiceManager serviceManager) { - this.serviceManager = serviceManager; - } - - @Override public void register(String moduleName, String providerName, - InstanceDetails instanceDetails) { - serviceManager.put(moduleName, providerName, instanceDetails); - } -} diff --git a/oap-server/server-cluster-plugin/cluster-standalone-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/standalone/StandaloneRegister.java b/oap-server/server-cluster-plugin/cluster-standalone-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/standalone/StandaloneRegister.java deleted file mode 100644 index 7f923fa997f6312c005d9a56fbba736b9fe7b832..0000000000000000000000000000000000000000 --- a/oap-server/server-cluster-plugin/cluster-standalone-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/standalone/StandaloneRegister.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - * - */ - -package org.apache.skywalking.oap.server.cluster.plugin.standalone; - -import org.apache.skywalking.oap.server.core.cluster.*; - -/** - * @author peng-yongsheng - */ -public class StandaloneRegister implements ModuleRegister { - - @Override public void register(String moduleName, String providerName, - InstanceDetails instanceDetails) throws ServiceRegisterException { - - } -} diff --git a/oap-server/server-cluster-plugin/cluster-standalone-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/standalone/StandaloneServiceManager.java b/oap-server/server-cluster-plugin/cluster-standalone-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/standalone/StandaloneServiceManager.java deleted file mode 100644 index fe5fe1d89d6cd76df1d18ed1676f2402ec3a3608..0000000000000000000000000000000000000000 --- a/oap-server/server-cluster-plugin/cluster-standalone-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/standalone/StandaloneServiceManager.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - * - */ - -package org.apache.skywalking.oap.server.cluster.plugin.standalone; - -import java.util.*; -import org.apache.skywalking.oap.server.core.cluster.InstanceDetails; - -/** - * @author peng-yongsheng - */ -public class StandaloneServiceManager { - - private final Map instanceDetailsMap; - - public StandaloneServiceManager() { - this.instanceDetailsMap = new HashMap<>(); - } - - public void put(String moduleName, String providerName, InstanceDetails instanceDetails) { - instanceDetailsMap.put(moduleName + "/" + providerName, instanceDetails); - } - - public InstanceDetails get(String moduleName, String providerName) { - return instanceDetailsMap.get(moduleName + "/" + providerName); - } -} diff --git a/oap-server/server-cluster-plugin/cluster-standalone-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/standalone/StandaloneModuleQuery.java b/oap-server/server-cluster-plugin/cluster-standalone-plugin/src/test/java/org/apache/skywalking/oap/server/cluster/plugin/standalone/StandaloneManagerTest.java similarity index 58% rename from oap-server/server-cluster-plugin/cluster-standalone-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/standalone/StandaloneModuleQuery.java rename to oap-server/server-cluster-plugin/cluster-standalone-plugin/src/test/java/org/apache/skywalking/oap/server/cluster/plugin/standalone/StandaloneManagerTest.java index cc0b326f96f8fa198e948a6a9119914d8dd90d23..26794929017067319fc30fdb460bfe6bf5b5d50c 100644 --- a/oap-server/server-cluster-plugin/cluster-standalone-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/standalone/StandaloneModuleQuery.java +++ b/oap-server/server-cluster-plugin/cluster-standalone-plugin/src/test/java/org/apache/skywalking/oap/server/cluster/plugin/standalone/StandaloneManagerTest.java @@ -18,24 +18,20 @@ package org.apache.skywalking.oap.server.cluster.plugin.standalone; -import java.util.*; -import org.apache.skywalking.oap.server.core.cluster.*; +import org.apache.skywalking.oap.server.core.cluster.RemoteInstance; +import org.junit.Assert; +import org.junit.Test; -/** - * @author peng-yongsheng - */ -public class StandaloneModuleQuery implements ModuleQuery { - - private final StandaloneServiceManager serviceManager; - - StandaloneModuleQuery(StandaloneServiceManager serviceManager) { - this.serviceManager = serviceManager; - } +public class StandaloneManagerTest { + @Test + public void test(){ + StandaloneManager standaloneManager = new StandaloneManager(); + RemoteInstance remote1 = new RemoteInstance(); + RemoteInstance remote2 = new RemoteInstance(); - @Override - public List query(String moduleName, String providerName) { - List instanceDetails = new ArrayList<>(1); - instanceDetails.add(serviceManager.get(moduleName, providerName)); - return instanceDetails; + standaloneManager.registerRemote(remote1); + Assert.assertEquals(remote1, standaloneManager.queryRemoteNodes().get(0)); + standaloneManager.registerRemote(remote2); + Assert.assertEquals(remote2, standaloneManager.queryRemoteNodes().get(0)); } } diff --git a/oap-server/server-cluster-plugin/cluster-zookeeper-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/zookeeper/ClusterModuleZookeeperProvider.java b/oap-server/server-cluster-plugin/cluster-zookeeper-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/zookeeper/ClusterModuleZookeeperProvider.java index 0c52a81be5e2c6d40d3e6eb53ff57cbced3fb5e5..0cfa3d5b34612870fd19f20183ea946153efc1af 100644 --- a/oap-server/server-cluster-plugin/cluster-zookeeper-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/zookeeper/ClusterModuleZookeeperProvider.java +++ b/oap-server/server-cluster-plugin/cluster-zookeeper-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/zookeeper/ClusterModuleZookeeperProvider.java @@ -19,15 +19,27 @@ package org.apache.skywalking.oap.server.cluster.plugin.zookeeper; import org.apache.curator.RetryPolicy; -import org.apache.curator.framework.*; +import org.apache.curator.framework.CuratorFramework; +import org.apache.curator.framework.CuratorFrameworkFactory; import org.apache.curator.retry.ExponentialBackoffRetry; -import org.apache.curator.x.discovery.*; -import org.apache.skywalking.oap.server.core.cluster.*; -import org.apache.skywalking.oap.server.library.module.*; -import org.slf4j.*; +import org.apache.curator.x.discovery.ServiceCache; +import org.apache.curator.x.discovery.ServiceDiscovery; +import org.apache.curator.x.discovery.ServiceDiscoveryBuilder; +import org.apache.skywalking.oap.server.core.cluster.ClusterModule; +import org.apache.skywalking.oap.server.core.cluster.ClusterNodesQuery; +import org.apache.skywalking.oap.server.core.cluster.ClusterRegister; +import org.apache.skywalking.oap.server.core.cluster.RemoteInstance; +import org.apache.skywalking.oap.server.library.module.ModuleConfig; +import org.apache.skywalking.oap.server.library.module.ModuleProvider; +import org.apache.skywalking.oap.server.library.module.ModuleStartException; +import org.apache.skywalking.oap.server.library.module.ServiceNotProvidedException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** - * @author peng-yongsheng + * Use Zookeeper to manage all instances in SkyWalking cluster. + * + * @author peng-yongsheng, Wu Sheng */ public class ClusterModuleZookeeperProvider extends ModuleProvider { @@ -35,15 +47,13 @@ public class ClusterModuleZookeeperProvider extends ModuleProvider { private static final String BASE_PATH = "/skywalking"; - private final ServiceCacheManager cacheManager; private final ClusterModuleZookeeperConfig config; private CuratorFramework client; - private ServiceDiscovery serviceDiscovery; + private ServiceDiscovery serviceDiscovery; public ClusterModuleZookeeperProvider() { super(); this.config = new ClusterModuleZookeeperConfig(); - this.cacheManager = new ServiceCacheManager(); } @Override public String name() { @@ -58,27 +68,35 @@ public class ClusterModuleZookeeperProvider extends ModuleProvider { return config; } - @Override public void prepare() throws ServiceNotProvidedException { + @Override public void prepare() throws ServiceNotProvidedException, ModuleStartException { RetryPolicy retryPolicy = new ExponentialBackoffRetry(config.getBaseSleepTimeMs(), config.getMaxRetries()); client = CuratorFrameworkFactory.newClient(config.getHostPort(), retryPolicy); - serviceDiscovery = ServiceDiscoveryBuilder.builder(InstanceDetails.class).client(client) + serviceDiscovery = ServiceDiscoveryBuilder.builder(RemoteInstance.class).client(client) .basePath(BASE_PATH) .watchInstances(true) .serializer(new SWInstanceSerializer()).build(); - this.registerServiceImplementation(ModuleRegister.class, new ZookeeperModuleRegister(serviceDiscovery, cacheManager)); - this.registerServiceImplementation(ModuleQuery.class, new ZookeeperModuleQuery(cacheManager)); - } - - @Override public void start() throws ModuleStartException { + String remoteName = "remote"; + ServiceCache serviceCache = serviceDiscovery.serviceCacheBuilder() + .name(remoteName) + .build(); try { client.start(); client.blockUntilConnected(); serviceDiscovery.start(); + + serviceCache.start(); } catch (Exception e) { + logger.error(e.getMessage(), e); throw new ModuleStartException(e.getMessage(), e); } + + this.registerServiceImplementation(ClusterRegister.class, new ZookeeperNodeRegister(serviceDiscovery, remoteName)); + this.registerServiceImplementation(ClusterNodesQuery.class, new ZookeeperModuleQuery(serviceCache)); + } + + @Override public void start() { } @Override public void notifyAfterCompleted() { diff --git a/oap-server/server-cluster-plugin/cluster-zookeeper-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/zookeeper/SWInstanceSerializer.java b/oap-server/server-cluster-plugin/cluster-zookeeper-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/zookeeper/SWInstanceSerializer.java index 76b59b52fb576a87c2391b18fecd1e87e556ca66..3b86f9de3c8e51916a8becc39db2d608c01722c9 100644 --- a/oap-server/server-cluster-plugin/cluster-zookeeper-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/zookeeper/SWInstanceSerializer.java +++ b/oap-server/server-cluster-plugin/cluster-zookeeper-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/zookeeper/SWInstanceSerializer.java @@ -22,21 +22,21 @@ import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import org.apache.curator.x.discovery.ServiceInstance; import org.apache.curator.x.discovery.details.InstanceSerializer; -import org.apache.skywalking.oap.server.core.cluster.InstanceDetails; +import org.apache.skywalking.oap.server.core.cluster.RemoteInstance; /** * @author peng-yongsheng */ -public class SWInstanceSerializer implements InstanceSerializer { +public class SWInstanceSerializer implements InstanceSerializer { private final Gson gson = new Gson(); - @Override public byte[] serialize(ServiceInstance instance) throws Exception { + @Override public byte[] serialize(ServiceInstance instance) throws Exception { return gson.toJson(instance).getBytes(); } - @Override public ServiceInstance deserialize(byte[] bytes) throws Exception { - return gson.fromJson(new String(bytes), new TypeToken>() { + @Override public ServiceInstance deserialize(byte[] bytes) throws Exception { + return gson.fromJson(new String(bytes), new TypeToken>() { }.getType()); } } diff --git a/oap-server/server-cluster-plugin/cluster-zookeeper-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/zookeeper/ServiceCacheManager.java b/oap-server/server-cluster-plugin/cluster-zookeeper-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/zookeeper/ServiceCacheManager.java deleted file mode 100644 index e08a01bbd1e6998e6609186977d21e96595ce631..0000000000000000000000000000000000000000 --- a/oap-server/server-cluster-plugin/cluster-zookeeper-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/zookeeper/ServiceCacheManager.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - * - */ - -package org.apache.skywalking.oap.server.cluster.plugin.zookeeper; - -import java.util.*; -import java.util.concurrent.ConcurrentHashMap; -import org.apache.curator.x.discovery.ServiceCache; -import org.apache.skywalking.oap.server.core.cluster.InstanceDetails; - -/** - * @author peng-yongsheng - */ -public class ServiceCacheManager { - - private final Map> serviceCacheMap; - - public ServiceCacheManager() { - this.serviceCacheMap = new ConcurrentHashMap<>(); - } - - public void put(String name, ServiceCache cache) { - serviceCacheMap.put(name, cache); - } - - public ServiceCache get(String name) { - return serviceCacheMap.get(name); - } -} diff --git a/oap-server/server-cluster-plugin/cluster-zookeeper-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/zookeeper/ZookeeperModuleQuery.java b/oap-server/server-cluster-plugin/cluster-zookeeper-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/zookeeper/ZookeeperModuleQuery.java index 7dd93e86cad384260dfb9ec4025975485846b759..7a41531a1879910aa848a5b0eac0bf16e32f24a7 100644 --- a/oap-server/server-cluster-plugin/cluster-zookeeper-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/zookeeper/ZookeeperModuleQuery.java +++ b/oap-server/server-cluster-plugin/cluster-zookeeper-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/zookeeper/ZookeeperModuleQuery.java @@ -19,26 +19,27 @@ package org.apache.skywalking.oap.server.cluster.plugin.zookeeper; import java.util.*; +import org.apache.curator.x.discovery.ServiceCache; import org.apache.curator.x.discovery.ServiceInstance; import org.apache.skywalking.oap.server.core.cluster.*; /** - * @author peng-yongsheng + * @author peng-yongsheng, Wu Sheng */ -public class ZookeeperModuleQuery implements ModuleQuery { +public class ZookeeperModuleQuery implements ClusterNodesQuery { - private final ServiceCacheManager cacheManager; + private final ServiceCache serviceCache; - ZookeeperModuleQuery(ServiceCacheManager cacheManager) { - this.cacheManager = cacheManager; + ZookeeperModuleQuery(ServiceCache serviceCache) { + this.serviceCache = serviceCache; } @Override - public List query(String moduleName, String providerName) throws ServiceRegisterException { - List> serviceInstances = cacheManager.get(NodeNameBuilder.build(moduleName, providerName)).getInstances(); + public List queryRemoteNodes() throws ServiceRegisterException { + List> serviceInstances = serviceCache.getInstances(); - List instanceDetails = new ArrayList<>(serviceInstances.size()); - serviceInstances.forEach(serviceInstance -> instanceDetails.add(serviceInstance.getPayload())); - return instanceDetails; + List remoteInstanceDetails = new ArrayList<>(serviceInstances.size()); + serviceInstances.forEach(serviceInstance -> remoteInstanceDetails.add(serviceInstance.getPayload())); + return remoteInstanceDetails; } } diff --git a/oap-server/server-cluster-plugin/cluster-zookeeper-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/zookeeper/ZookeeperModuleRegister.java b/oap-server/server-cluster-plugin/cluster-zookeeper-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/zookeeper/ZookeeperModuleRegister.java deleted file mode 100644 index ede5fbdaac19cebf253eda5bcd1a974d05e9f96e..0000000000000000000000000000000000000000 --- a/oap-server/server-cluster-plugin/cluster-zookeeper-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/zookeeper/ZookeeperModuleRegister.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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. - * - */ - -package org.apache.skywalking.oap.server.cluster.plugin.zookeeper; - -import java.util.UUID; -import org.apache.curator.x.discovery.*; -import org.apache.skywalking.oap.server.core.cluster.*; - -/** - * @author peng-yongsheng - */ -public class ZookeeperModuleRegister implements ModuleRegister { - - private final ServiceDiscovery serviceDiscovery; - private final ServiceCacheManager cacheManager; - - ZookeeperModuleRegister(ServiceDiscovery serviceDiscovery, - ServiceCacheManager cacheManager) { - this.serviceDiscovery = serviceDiscovery; - this.cacheManager = cacheManager; - } - - @Override public synchronized void register(String moduleName, String providerName, - InstanceDetails instanceDetails) throws ServiceRegisterException { - try { - String name = NodeNameBuilder.build(moduleName, providerName); - - ServiceInstance thisInstance = ServiceInstance.builder() - .name(NodeNameBuilder.build(moduleName, providerName)) - .id(UUID.randomUUID().toString()) - .address(instanceDetails.getHost()) - .port(instanceDetails.getPort()) -// .uriSpec(new UriSpec(StringUtils.isEmpty(instanceDetails.getContextPath()) ? StringUtils.EMPTY_STRING : instanceDetails.getContextPath())) - .payload(instanceDetails) - .build(); - - serviceDiscovery.registerService(thisInstance); - - ServiceCache serviceCache = serviceDiscovery.serviceCacheBuilder() - .name(name) - .build(); - serviceCache.start(); - - cacheManager.put(name, serviceCache); - } catch (Exception e) { - e.printStackTrace(); - throw new ServiceRegisterException(e.getMessage()); - } - } -} diff --git a/oap-server/server-cluster-plugin/cluster-zookeeper-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/zookeeper/ZookeeperNodeRegister.java b/oap-server/server-cluster-plugin/cluster-zookeeper-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/zookeeper/ZookeeperNodeRegister.java new file mode 100644 index 0000000000000000000000000000000000000000..ba6b518130b18aabe74ff90af5e62f16d7970a01 --- /dev/null +++ b/oap-server/server-cluster-plugin/cluster-zookeeper-plugin/src/main/java/org/apache/skywalking/oap/server/cluster/plugin/zookeeper/ZookeeperNodeRegister.java @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + * + */ + +package org.apache.skywalking.oap.server.cluster.plugin.zookeeper; + +import java.util.UUID; +import org.apache.curator.x.discovery.ServiceDiscovery; +import org.apache.curator.x.discovery.ServiceInstance; +import org.apache.skywalking.oap.server.core.cluster.ClusterRegister; +import org.apache.skywalking.oap.server.core.cluster.RemoteInstance; +import org.apache.skywalking.oap.server.core.cluster.ServiceRegisterException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class ZookeeperNodeRegister implements ClusterRegister { + private static final Logger logger = LoggerFactory.getLogger(ZookeeperNodeRegister.class); + + private final ServiceDiscovery serviceDiscovery; + private final String nodeName; + + ZookeeperNodeRegister(ServiceDiscovery serviceDiscovery, String nodeName) { + this.serviceDiscovery = serviceDiscovery; + this.nodeName = nodeName; + } + + @Override public synchronized void registerRemote(RemoteInstance remoteInstance) throws ServiceRegisterException { + try { + ServiceInstance thisInstance = ServiceInstance.builder() + .name(nodeName) + .id(UUID.randomUUID().toString()) + .address(remoteInstance.getHost()) + .port(remoteInstance.getPort()) + .payload(remoteInstance) + .build(); + + serviceDiscovery.registerService(thisInstance); + } catch (Exception e) { + logger.error(e.getMessage(), e); + throw new ServiceRegisterException(e.getMessage()); + } + } +} diff --git a/oap-server/server-cluster-plugin/cluster-zookeeper-plugin/src/test/java/org/apache/skywalking/oap/server/cluster/plugin/zookeeper/ClusterModuleZookeeperProviderTestCase.java b/oap-server/server-cluster-plugin/cluster-zookeeper-plugin/src/test/java/org/apache/skywalking/oap/server/cluster/plugin/zookeeper/ClusterModuleZookeeperProviderTestCase.java index 218ecccd23cc29e207ade777f75973450a59518e..fafd1275eb2f2454f6ce6c9c12cc1d323e5a9df8 100644 --- a/oap-server/server-cluster-plugin/cluster-zookeeper-plugin/src/test/java/org/apache/skywalking/oap/server/cluster/plugin/zookeeper/ClusterModuleZookeeperProviderTestCase.java +++ b/oap-server/server-cluster-plugin/cluster-zookeeper-plugin/src/test/java/org/apache/skywalking/oap/server/cluster/plugin/zookeeper/ClusterModuleZookeeperProviderTestCase.java @@ -21,9 +21,16 @@ package org.apache.skywalking.oap.server.cluster.plugin.zookeeper; import java.io.IOException; import java.util.List; import org.apache.curator.test.TestingServer; -import org.apache.skywalking.oap.server.core.cluster.*; -import org.apache.skywalking.oap.server.library.module.*; -import org.junit.*; +import org.apache.skywalking.oap.server.core.cluster.ClusterNodesQuery; +import org.apache.skywalking.oap.server.core.cluster.ClusterRegister; +import org.apache.skywalking.oap.server.core.cluster.RemoteInstance; +import org.apache.skywalking.oap.server.core.cluster.ServiceRegisterException; +import org.apache.skywalking.oap.server.library.module.ModuleStartException; +import org.apache.skywalking.oap.server.library.module.ServiceNotProvidedException; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; /** * @author peng-yongsheng @@ -39,7 +46,7 @@ public class ClusterModuleZookeeperProviderTestCase { } @Test - public void testStart() throws ServiceNotProvidedException, ModuleStartException, ServiceRegisterException { + public void testStart() throws ServiceNotProvidedException, ModuleStartException, ServiceRegisterException, InterruptedException { ClusterModuleZookeeperProvider provider = new ClusterModuleZookeeperProvider(); ClusterModuleZookeeperConfig moduleConfig = (ClusterModuleZookeeperConfig)provider.createConfigBeanIfAbsent(); moduleConfig.setHostPort(server.getConnectString()); @@ -49,19 +56,26 @@ public class ClusterModuleZookeeperProviderTestCase { provider.prepare(); provider.start(); - ModuleRegister moduleRegister = provider.getService(ModuleRegister.class); - ModuleQuery moduleQuery = provider.getService(ModuleQuery.class); + ClusterRegister moduleRegister = provider.getService(ClusterRegister.class); + ClusterNodesQuery clusterNodesQuery = provider.getService(ClusterNodesQuery.class); - InstanceDetails instanceDetails = new InstanceDetails(); - instanceDetails.setHost("ProviderAHost"); - instanceDetails.setPort(1000); + RemoteInstance remoteInstance = new RemoteInstance(); + remoteInstance.setHost("ProviderAHost"); + remoteInstance.setPort(1000); - moduleRegister.register("ModuleA", "ProviderA", instanceDetails); + moduleRegister.registerRemote(remoteInstance); + + for (int i = 0; i < 20; i++) { + List detailsList = clusterNodesQuery.queryRemoteNodes(); + if(detailsList.size() == 0){ + Thread.sleep(500); + continue; + } + Assert.assertEquals(1, detailsList.size()); + Assert.assertEquals("ProviderAHost", detailsList.get(0).getHost()); + Assert.assertEquals(1000, detailsList.get(0).getPort()); + } - List detailsList = moduleQuery.query("ModuleA", "ProviderA"); - Assert.assertEquals(1, detailsList.size()); - Assert.assertEquals("ProviderAHost", detailsList.get(0).getHost()); - Assert.assertEquals(1000, detailsList.get(0).getPort()); } @After diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/CoreModuleProvider.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/CoreModuleProvider.java index 6a8ca4f5ef38307a0bfb1fdedec662051b3ff324..f58f2073e7a91b3c61db01230870026375c3b212 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/CoreModuleProvider.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/CoreModuleProvider.java @@ -18,14 +18,24 @@ package org.apache.skywalking.oap.server.core; -import org.apache.skywalking.oap.server.core.cluster.*; -import org.apache.skywalking.oap.server.core.receiver.*; -import org.apache.skywalking.oap.server.core.server.*; -import org.apache.skywalking.oap.server.library.module.*; +import org.apache.skywalking.oap.server.core.cluster.ClusterModule; +import org.apache.skywalking.oap.server.core.cluster.ClusterRegister; +import org.apache.skywalking.oap.server.core.cluster.RemoteInstance; +import org.apache.skywalking.oap.server.core.receiver.SourceReceiver; +import org.apache.skywalking.oap.server.core.receiver.SourceReceiverImpl; +import org.apache.skywalking.oap.server.core.server.GRPCHandlerRegister; +import org.apache.skywalking.oap.server.core.server.GRPCHandlerRegisterImpl; +import org.apache.skywalking.oap.server.core.server.JettyHandlerRegister; +import org.apache.skywalking.oap.server.core.server.JettyHandlerRegisterImpl; +import org.apache.skywalking.oap.server.library.module.ModuleConfig; +import org.apache.skywalking.oap.server.library.module.ModuleProvider; +import org.apache.skywalking.oap.server.library.module.ModuleStartException; +import org.apache.skywalking.oap.server.library.module.ServiceNotProvidedException; import org.apache.skywalking.oap.server.library.server.ServerException; import org.apache.skywalking.oap.server.library.server.grpc.GRPCServer; import org.apache.skywalking.oap.server.library.server.jetty.JettyServer; -import org.slf4j.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @author peng-yongsheng @@ -68,26 +78,22 @@ public class CoreModuleProvider extends ModuleProvider { this.registerServiceImplementation(SourceReceiver.class, new SourceReceiverImpl()); } - @Override public void start() throws ModuleStartException { + @Override public void start() { + + } + + @Override public void notifyAfterCompleted() throws ModuleStartException{ try { grpcServer.start(); jettyServer.start(); } catch (ServerException e) { throw new ModuleStartException(e.getMessage(), e); } - } - @Override public void notifyAfterCompleted() { - InstanceDetails gRPCServerInstance = new InstanceDetails(); + RemoteInstance gRPCServerInstance = new RemoteInstance(); gRPCServerInstance.setHost(moduleConfig.getGRPCHost()); gRPCServerInstance.setPort(moduleConfig.getGRPCPort()); - this.getManager().find(ClusterModule.NAME).getService(ModuleRegister.class).register(CoreModule.NAME, "gRPC", gRPCServerInstance); - - InstanceDetails restServerInstance = new InstanceDetails(); - restServerInstance.setHost(moduleConfig.getRestHost()); - restServerInstance.setPort(moduleConfig.getRestPort()); - restServerInstance.setContextPath(moduleConfig.getRestContextPath()); - this.getManager().find(ClusterModule.NAME).getService(ModuleRegister.class).register(CoreModule.NAME, "rest", restServerInstance); + this.getManager().find(ClusterModule.NAME).getService(ClusterRegister.class).registerRemote(gRPCServerInstance); } @Override diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/cluster/ClusterModule.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/cluster/ClusterModule.java index 992ed10d491a12b6227ba23ed0d3cc4d1263cb21..a4499dcbdbd8017e0e6d96bfbd93cfc3ba39ca70 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/cluster/ClusterModule.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/cluster/ClusterModule.java @@ -32,6 +32,6 @@ public class ClusterModule extends ModuleDefine { } @Override public Class[] services() { - return new Class[] {ModuleRegister.class, ModuleQuery.class}; + return new Class[] {ClusterRegister.class, ClusterNodesQuery.class}; } } diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/cluster/ModuleQuery.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/cluster/ClusterNodesQuery.java similarity index 86% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/cluster/ModuleQuery.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/cluster/ClusterNodesQuery.java index d44532adf297fde7cdcd87fdbc16265ff311a1c9..a7c0d82d0a1f8fce592df4f3e67e7e0b2b835f4d 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/cluster/ModuleQuery.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/cluster/ClusterNodesQuery.java @@ -25,7 +25,7 @@ import java.util.List; /** * @author peng-yongsheng */ -public interface ModuleQuery extends Service { +public interface ClusterNodesQuery extends Service { - List query(String moduleName, String providerName) throws ServiceRegisterException; + List queryRemoteNodes(); } diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/cluster/ModuleRegister.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/cluster/ClusterRegister.java similarity index 84% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/cluster/ModuleRegister.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/cluster/ClusterRegister.java index e3cdb0e6eb674ce4288ddb0c4ea55f468c575c62..3e5a8c2d053a1dfb8a7eb6df0c450443b5922e15 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/cluster/ModuleRegister.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/cluster/ClusterRegister.java @@ -23,8 +23,7 @@ import org.apache.skywalking.oap.server.library.module.Service; /** * @author peng-yongsheng */ -public interface ModuleRegister extends Service { +public interface ClusterRegister extends Service { - void register(String moduleName, String providerName, - InstanceDetails instanceDetails) throws ServiceRegisterException; + void registerRemote(RemoteInstance remoteInstance) throws ServiceRegisterException; } diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/cluster/InstanceDetails.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/cluster/RemoteInstance.java similarity index 83% rename from oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/cluster/InstanceDetails.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/cluster/RemoteInstance.java index a4f8dc260b7229cab881d2e3f092d6fcbe01d675..14018e197beb52bb94e3c12ce456a986c5a6b491 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/cluster/InstanceDetails.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/cluster/RemoteInstance.java @@ -21,11 +21,10 @@ package org.apache.skywalking.oap.server.core.cluster; /** * @author peng-yongsheng */ -public class InstanceDetails { +public class RemoteInstance { private String host; private int port; - private String contextPath; public String getHost() { return host; @@ -42,12 +41,4 @@ public class InstanceDetails { public void setPort(int port) { this.port = port; } - - public String getContextPath() { - return contextPath; - } - - public void setContextPath(String contextPath) { - this.contextPath = contextPath; - } } diff --git a/oap-server/server-core/src/main/resources/META-INF/services/org.apache.skywalking.oap.server.library.module.ModuleDefine b/oap-server/server-core/src/main/resources/META-INF/services/org.apache.skywalking.oap.server.library.module.ModuleDefine new file mode 100644 index 0000000000000000000000000000000000000000..d0a876f7cf6a92ff4da168e901ca77078ebc6b64 --- /dev/null +++ b/oap-server/server-core/src/main/resources/META-INF/services/org.apache.skywalking.oap.server.library.module.ModuleDefine @@ -0,0 +1,21 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You 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. +# +# + +org.apache.skywalking.oap.server.core.storage.StorageModule +org.apache.skywalking.oap.server.core.cluster.ClusterModule +org.apache.skywalking.oap.server.core.CoreModule \ No newline at end of file diff --git a/oap-server/server-library/library-module/src/main/java/org/apache/skywalking/oap/server/library/module/BootstrapFlow.java b/oap-server/server-library/library-module/src/main/java/org/apache/skywalking/oap/server/library/module/BootstrapFlow.java index 187575f486107ea344698ce0864d7532e21f653e..e41e2bea85629cf542cc3756407c0c7321895e48 100644 --- a/oap-server/server-library/library-module/src/main/java/org/apache/skywalking/oap/server/library/module/BootstrapFlow.java +++ b/oap-server/server-library/library-module/src/main/java/org/apache/skywalking/oap/server/library/module/BootstrapFlow.java @@ -63,7 +63,7 @@ class BootstrapFlow { } } - void notifyAfterCompleted() throws ServiceNotProvidedException { + void notifyAfterCompleted() throws ServiceNotProvidedException, ModuleStartException { for (ModuleProvider provider : startupSequence) { provider.notifyAfterCompleted(); } diff --git a/oap-server/server-library/library-module/src/main/java/org/apache/skywalking/oap/server/library/module/ModuleDefine.java b/oap-server/server-library/library-module/src/main/java/org/apache/skywalking/oap/server/library/module/ModuleDefine.java index 3f6a80c9e621408d3a0d0bbaf9766cd1a689de08..74c908d2b151cb1b43dd4f591db44c0ae70549ac 100644 --- a/oap-server/server-library/library-module/src/main/java/org/apache/skywalking/oap/server/library/module/ModuleDefine.java +++ b/oap-server/server-library/library-module/src/main/java/org/apache/skywalking/oap/server/library/module/ModuleDefine.java @@ -53,7 +53,7 @@ public abstract class ModuleDefine { * @throws ProviderNotFoundException when even don't find a single one providers. */ void prepare(ModuleManager moduleManager, - ApplicationConfiguration.ModuleConfiguration configuration) throws ProviderNotFoundException, ServiceNotProvidedException, ModuleConfigException { + ApplicationConfiguration.ModuleConfiguration configuration) throws ProviderNotFoundException, ServiceNotProvidedException, ModuleConfigException, ModuleStartException { ServiceLoader moduleProviderLoader = ServiceLoader.load(ModuleProvider.class); boolean providerExist = false; for (ModuleProvider provider : moduleProviderLoader) { diff --git a/oap-server/server-library/library-module/src/main/java/org/apache/skywalking/oap/server/library/module/ModuleProvider.java b/oap-server/server-library/library-module/src/main/java/org/apache/skywalking/oap/server/library/module/ModuleProvider.java index 78597ea5bb998d41e7962ea9d33e8eb470d38f2b..7596fb60b9a77641e153716f76aa9c1f1d6c5c0d 100644 --- a/oap-server/server-library/library-module/src/main/java/org/apache/skywalking/oap/server/library/module/ModuleProvider.java +++ b/oap-server/server-library/library-module/src/main/java/org/apache/skywalking/oap/server/library/module/ModuleProvider.java @@ -66,7 +66,7 @@ public abstract class ModuleProvider { /** * In prepare stage, the module should initialize things which are irrelative other modules. */ - public abstract void prepare() throws ServiceNotProvidedException; + public abstract void prepare() throws ServiceNotProvidedException, ModuleStartException; /** * In start stage, the module has been ready for interop. @@ -76,7 +76,7 @@ public abstract class ModuleProvider { /** * This callback executes after all modules start up successfully. */ - public abstract void notifyAfterCompleted() throws ServiceNotProvidedException; + public abstract void notifyAfterCompleted() throws ServiceNotProvidedException, ModuleStartException; /** * @return module names which does this module require? diff --git a/oap-server/server-starter/src/main/java/org/apache/skywalking/oap/server/starter/config/ApplicationConfigLoader.java b/oap-server/server-starter/src/main/java/org/apache/skywalking/oap/server/starter/config/ApplicationConfigLoader.java index ea4cafff43e36c62c4e8644d48bc153960fb2a2c..dbedbf6a4f4219cf91bd446446ffa18d1ff32dcc 100644 --- a/oap-server/server-starter/src/main/java/org/apache/skywalking/oap/server/starter/config/ApplicationConfigLoader.java +++ b/oap-server/server-starter/src/main/java/org/apache/skywalking/oap/server/starter/config/ApplicationConfigLoader.java @@ -48,7 +48,6 @@ public class ApplicationConfigLoader implements ConfigLoader>> moduleConfig = yaml.loadAs(applicationReader, Map.class); - if (CollectionUtils.isNotEmpty(moduleConfig)) { - 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); - } - } - private void overrideConfigBySystemEnv(ApplicationConfiguration configuration) { for (Map.Entry prop : System.getProperties().entrySet()) { overrideModuleSettings(configuration, prop.getKey().toString(), prop.getValue().toString()); diff --git a/oap-server/server-starter/src/main/resources/application.yml b/oap-server/server-starter/src/main/resources/application.yml index 5bdaa05e2e1dcdfe376ca404ad2cbb9d0bd77484..1faf0e2d8dd02848d0f7bebc6d2aa66d3e81b356 100644 --- a/oap-server/server-starter/src/main/resources/application.yml +++ b/oap-server/server-starter/src/main/resources/application.yml @@ -15,17 +15,12 @@ # limitations under the License. cluster: - zookeeper: - hostPort: localhost:2181 - # Retry Policy - baseSleepTimeMs: 1000 # initial amount of time to wait between retries - maxRetries: 3 # max number of times to retry -#naming: -# jetty: -# #OS real network IP(binding required), for agent to find collector cluster -# host: localhost -# port: 10800 -# contextPath: / + standalone: +# zookeeper: +# hostPort: localhost:2181 +# # Retry Policy +# baseSleepTimeMs: 1000 # initial amount of time to wait between retries +# maxRetries: 3 # max number of times to retry core: default: restHost: localhost