Merge pull request #794 from carlvine500/master

bugfix:no data collected after application started
This commit is contained in:
吴晟 Wu Sheng 2018-02-07 12:38:07 +08:00 committed by GitHub
commit 75be8c879f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 5 deletions

View File

@ -19,8 +19,9 @@
package org.apache.skywalking.apm.agent.core.boot;
import java.util.HashMap;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.ServiceLoader;
import org.apache.skywalking.apm.agent.core.logging.api.LogManager;
@ -36,7 +37,7 @@ public enum ServiceManager {
INSTANCE;
private static final ILog logger = LogManager.getLogger(ServiceManager.class);
private Map<Class, BootService> bootedServices = new HashMap<Class, BootService>();
private Map<Class, BootService> bootedServices = Collections.emptyMap();
public void boot() {
bootedServices = loadAllServices();
@ -57,7 +58,7 @@ public enum ServiceManager {
}
private Map<Class, BootService> loadAllServices() {
HashMap<Class, BootService> bootedServices = new HashMap<Class, BootService>();
Map<Class, BootService> bootedServices = new LinkedHashMap<Class, BootService>();
Iterator<BootService> serviceIterator = load().iterator();
while (serviceIterator.hasNext()) {
BootService bootService = serviceIterator.next();

View File

@ -44,13 +44,15 @@ public class CollectorDiscoveryService implements BootService {
@Override
public void boot() throws Throwable {
DiscoveryRestServiceClient discoveryRestServiceClient = new DiscoveryRestServiceClient();
discoveryRestServiceClient.run();
future = Executors.newSingleThreadScheduledExecutor(new DefaultNamedThreadFactory("CollectorDiscoveryService"))
.scheduleAtFixedRate(new RunnableWithExceptionProtection(new DiscoveryRestServiceClient(),
.scheduleAtFixedRate(new RunnableWithExceptionProtection(discoveryRestServiceClient,
new RunnableWithExceptionProtection.CallbackWhenException() {
@Override public void handle(Throwable t) {
logger.error("unexpected exception.", t);
}
}), 0,
}), Config.Collector.DISCOVERY_CHECK_INTERVAL,
Config.Collector.DISCOVERY_CHECK_INTERVAL, TimeUnit.SECONDS);
}