Move service register to prepare method.
This commit is contained in:
parent
9c174d3ae5
commit
714b4ccbf7
|
|
@ -20,7 +20,6 @@ package org.skywalking.apm.collector.agent.grpc.handler;
|
|||
|
||||
import io.grpc.ManagedChannel;
|
||||
import io.grpc.ManagedChannelBuilder;
|
||||
import org.junit.Test;
|
||||
import org.skywalking.apm.network.proto.Application;
|
||||
import org.skywalking.apm.network.proto.ApplicationMapping;
|
||||
import org.skywalking.apm.network.proto.ApplicationRegisterServiceGrpc;
|
||||
|
|
@ -36,7 +35,6 @@ public class ApplicationRegisterServiceHandlerTestCase {
|
|||
|
||||
private ApplicationRegisterServiceGrpc.ApplicationRegisterServiceBlockingStub stub;
|
||||
|
||||
@Test
|
||||
public void testRegister() {
|
||||
ManagedChannel channel = ManagedChannelBuilder.forAddress("localhost", 11800).usePlaintext(true).build();
|
||||
stub = ApplicationRegisterServiceGrpc.newBlockingStub(channel);
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ 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.skywalking.apm.collector.storage.StorageModule;
|
||||
import org.skywalking.apm.collector.storage.service.DAOService;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
|
|
@ -48,15 +47,13 @@ public class CacheModuleGuavaProvider extends ModuleProvider {
|
|||
}
|
||||
|
||||
@Override public void prepare(Properties config) throws ServiceNotProvidedException {
|
||||
this.registerServiceImplementation(ApplicationCacheService.class, new ApplicationCacheGuavaService(getManager()));
|
||||
this.registerServiceImplementation(InstanceCacheService.class, new InstanceCacheGuavaService(getManager()));
|
||||
this.registerServiceImplementation(ServiceIdCacheService.class, new ServiceIdCacheGuavaService(getManager()));
|
||||
this.registerServiceImplementation(ServiceNameCacheService.class, new ServiceNameCacheGuavaService(getManager()));
|
||||
}
|
||||
|
||||
@Override public void start(Properties config) throws ServiceNotProvidedException {
|
||||
DAOService daoService = getManager().find(StorageModule.NAME).getService(DAOService.class);
|
||||
|
||||
this.registerServiceImplementation(ApplicationCacheService.class, new ApplicationCacheGuavaService(daoService));
|
||||
this.registerServiceImplementation(InstanceCacheService.class, new InstanceCacheGuavaService(daoService));
|
||||
this.registerServiceImplementation(ServiceIdCacheService.class, new ServiceIdCacheGuavaService(daoService));
|
||||
this.registerServiceImplementation(ServiceNameCacheService.class, new ServiceNameCacheGuavaService(daoService));
|
||||
}
|
||||
|
||||
@Override public void notifyAfterCompleted() throws ServiceNotProvidedException {
|
||||
|
|
|
|||
|
|
@ -21,8 +21,10 @@ package org.skywalking.apm.collector.cache.guava.service;
|
|||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import org.skywalking.apm.collector.cache.service.ApplicationCacheService;
|
||||
import org.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.skywalking.apm.collector.core.util.Const;
|
||||
import org.skywalking.apm.collector.core.util.StringUtils;
|
||||
import org.skywalking.apm.collector.storage.StorageModule;
|
||||
import org.skywalking.apm.collector.storage.dao.IApplicationCacheDAO;
|
||||
import org.skywalking.apm.collector.storage.service.DAOService;
|
||||
import org.slf4j.Logger;
|
||||
|
|
@ -39,8 +41,8 @@ public class ApplicationCacheGuavaService implements ApplicationCacheService {
|
|||
|
||||
private final DAOService daoService;
|
||||
|
||||
public ApplicationCacheGuavaService(DAOService daoService) {
|
||||
this.daoService = daoService;
|
||||
public ApplicationCacheGuavaService(ModuleManager moduleManager) {
|
||||
this.daoService = moduleManager.find(StorageModule.NAME).getService(DAOService.class);
|
||||
}
|
||||
|
||||
public int get(String applicationCode) {
|
||||
|
|
|
|||
|
|
@ -21,7 +21,9 @@ package org.skywalking.apm.collector.cache.guava.service;
|
|||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import org.skywalking.apm.collector.cache.service.InstanceCacheService;
|
||||
import org.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.skywalking.apm.collector.core.util.Const;
|
||||
import org.skywalking.apm.collector.storage.StorageModule;
|
||||
import org.skywalking.apm.collector.storage.dao.IInstanceCacheDAO;
|
||||
import org.skywalking.apm.collector.storage.service.DAOService;
|
||||
import org.slf4j.Logger;
|
||||
|
|
@ -40,8 +42,8 @@ public class InstanceCacheGuavaService implements InstanceCacheService {
|
|||
|
||||
private final DAOService daoService;
|
||||
|
||||
public InstanceCacheGuavaService(DAOService daoService) {
|
||||
this.daoService = daoService;
|
||||
public InstanceCacheGuavaService(ModuleManager moduleManager) {
|
||||
this.daoService = moduleManager.find(StorageModule.NAME).getService(DAOService.class);
|
||||
}
|
||||
|
||||
public int get(int applicationInstanceId) {
|
||||
|
|
|
|||
|
|
@ -21,7 +21,9 @@ package org.skywalking.apm.collector.cache.guava.service;
|
|||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import org.skywalking.apm.collector.cache.service.ServiceIdCacheService;
|
||||
import org.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.skywalking.apm.collector.core.util.Const;
|
||||
import org.skywalking.apm.collector.storage.StorageModule;
|
||||
import org.skywalking.apm.collector.storage.dao.IServiceNameCacheDAO;
|
||||
import org.skywalking.apm.collector.storage.service.DAOService;
|
||||
import org.slf4j.Logger;
|
||||
|
|
@ -38,8 +40,8 @@ public class ServiceIdCacheGuavaService implements ServiceIdCacheService {
|
|||
|
||||
private final DAOService daoService;
|
||||
|
||||
public ServiceIdCacheGuavaService(DAOService daoService) {
|
||||
this.daoService = daoService;
|
||||
public ServiceIdCacheGuavaService(ModuleManager moduleManager) {
|
||||
this.daoService = moduleManager.find(StorageModule.NAME).getService(DAOService.class);
|
||||
}
|
||||
|
||||
public int get(int applicationId, String serviceName) {
|
||||
|
|
|
|||
|
|
@ -21,8 +21,10 @@ package org.skywalking.apm.collector.cache.guava.service;
|
|||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import org.skywalking.apm.collector.cache.service.ServiceNameCacheService;
|
||||
import org.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.skywalking.apm.collector.core.util.Const;
|
||||
import org.skywalking.apm.collector.core.util.StringUtils;
|
||||
import org.skywalking.apm.collector.storage.StorageModule;
|
||||
import org.skywalking.apm.collector.storage.dao.IServiceNameCacheDAO;
|
||||
import org.skywalking.apm.collector.storage.service.DAOService;
|
||||
import org.slf4j.Logger;
|
||||
|
|
@ -39,8 +41,8 @@ public class ServiceNameCacheGuavaService implements ServiceNameCacheService {
|
|||
|
||||
private final DAOService daoService;
|
||||
|
||||
public ServiceNameCacheGuavaService(DAOService daoService) {
|
||||
this.daoService = daoService;
|
||||
public ServiceNameCacheGuavaService(ModuleManager moduleManager) {
|
||||
this.daoService = moduleManager.find(StorageModule.NAME).getService(DAOService.class);
|
||||
}
|
||||
|
||||
public String get(int serviceId) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue