bugfix:no data collected after application started 20+seconds

This commit is contained in:
carlvine 2018-02-07 09:53:19 +08:00
parent b40f8191f3
commit 5c44dd96a2
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);
}