Create application, instance, network address when peer or network id register.
This commit is contained in:
parent
7d73fba84d
commit
a9ae31df8d
|
|
@ -51,7 +51,7 @@ public class ApplicationRegisterServiceHandler extends ApplicationRegisterServic
|
|||
ApplicationMappings.Builder builder = ApplicationMappings.newBuilder();
|
||||
for (int i = 0; i < applicationCodes.size(); i++) {
|
||||
String applicationCode = applicationCodes.get(i);
|
||||
int applicationId = applicationIDService.getOrCreate(applicationCode);
|
||||
int applicationId = applicationIDService.getOrCreateForApplicationCode(applicationCode);
|
||||
|
||||
if (applicationId != 0) {
|
||||
KeyWithIntegerValue value = KeyWithIntegerValue.newBuilder().setKey(applicationCode).setValue(applicationId).build();
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ public class InstanceDiscoveryServiceHandler extends InstanceDiscoveryServiceGrp
|
|||
@Override
|
||||
public void register(ApplicationInstance request, StreamObserver<ApplicationInstanceMapping> responseObserver) {
|
||||
long timeBucket = TimeBucketUtils.INSTANCE.getSecondTimeBucket(request.getRegisterTime());
|
||||
int instanceId = instanceIDService.getOrCreate(request.getApplicationId(), request.getAgentUUID(), timeBucket, buildOsInfo(request.getOsinfo()));
|
||||
int instanceId = instanceIDService.getOrCreateByAgentUUID(request.getApplicationId(), request.getAgentUUID(), timeBucket, buildOsInfo(request.getOsinfo()));
|
||||
ApplicationInstanceMapping.Builder builder = ApplicationInstanceMapping.newBuilder();
|
||||
builder.setApplicationId(request.getApplicationId());
|
||||
builder.setApplicationInstanceId(instanceId);
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ public class ApplicationRegisterServletHandler extends JettyHandler {
|
|||
JsonArray applicationCodes = gson.fromJson(req.getReader(), JsonArray.class);
|
||||
for (int i = 0; i < applicationCodes.size(); i++) {
|
||||
String applicationCode = applicationCodes.get(i).getAsString();
|
||||
int applicationId = applicationIDService.getOrCreate(applicationCode);
|
||||
int applicationId = applicationIDService.getOrCreateForApplicationCode(applicationCode);
|
||||
JsonObject mapping = new JsonObject();
|
||||
mapping.addProperty(APPLICATION_CODE, applicationCode);
|
||||
mapping.addProperty(APPLICATION_ID, applicationId);
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ public class InstanceDiscoveryServletHandler extends JettyHandler {
|
|||
long registerTime = instance.get(REGISTER_TIME).getAsLong();
|
||||
JsonObject osInfo = instance.get(OS_INFO).getAsJsonObject();
|
||||
|
||||
int instanceId = instanceIDService.getOrCreate(applicationId, agentUUID, registerTime, osInfo.toString());
|
||||
int instanceId = instanceIDService.getOrCreateByAgentUUID(applicationId, agentUUID, registerTime, osInfo.toString());
|
||||
responseJson.addProperty(APPLICATION_ID, applicationId);
|
||||
responseJson.addProperty(INSTANCE_ID, instanceId);
|
||||
} catch (IOException e) {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.collector.analysis.register.define.service;
|
||||
|
||||
import org.apache.skywalking.apm.collector.core.module.Service;
|
||||
|
|
@ -25,5 +24,7 @@ import org.apache.skywalking.apm.collector.core.module.Service;
|
|||
* @author peng-yongsheng
|
||||
*/
|
||||
public interface IApplicationIDService extends Service {
|
||||
int getOrCreate(String applicationCode);
|
||||
int getOrCreateForApplicationCode(String applicationCode);
|
||||
|
||||
int getOrCreateForAddressId(int addressId, String networkAddress);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.collector.analysis.register.define.service;
|
||||
|
||||
import org.apache.skywalking.apm.collector.core.module.Service;
|
||||
|
|
@ -25,7 +24,9 @@ import org.apache.skywalking.apm.collector.core.module.Service;
|
|||
* @author peng-yongsheng
|
||||
*/
|
||||
public interface IInstanceIDService extends Service {
|
||||
int getOrCreate(int applicationId, String agentUUID, long registerTime, String osInfo);
|
||||
int getOrCreateByAgentUUID(int applicationId, String agentUUID, long registerTime, String osInfo);
|
||||
|
||||
void recover(int instanceId, int applicationId, long registerTime, String osInfo);
|
||||
|
||||
int getOrCreateByAddressId(int applicationId, int addressId, long registerTime);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ public class ApplicationRegisterSerialWorker extends AbstractLocalAsyncWorker<Ap
|
|||
|
||||
@Override protected void onWork(Application application) throws WorkerException {
|
||||
logger.debug("register application, application code: {}", application.getApplicationCode());
|
||||
int applicationId = applicationCacheService.get(application.getApplicationCode());
|
||||
int applicationId = applicationCacheService.getApplicationIdByCode(application.getApplicationCode());
|
||||
|
||||
if (applicationId == 0) {
|
||||
Application newApplication;
|
||||
|
|
@ -63,11 +63,15 @@ public class ApplicationRegisterSerialWorker extends AbstractLocalAsyncWorker<Ap
|
|||
Application userApplication = new Application(String.valueOf(Const.USER_ID));
|
||||
userApplication.setApplicationCode(Const.USER_CODE);
|
||||
userApplication.setApplicationId(Const.USER_ID);
|
||||
userApplication.setAddressId(Const.NONE);
|
||||
userApplication.setIsAddress(false);
|
||||
applicationRegisterDAO.save(userApplication);
|
||||
|
||||
newApplication = new Application("-1");
|
||||
newApplication.setApplicationId(-1);
|
||||
newApplication.setApplicationCode(application.getApplicationCode());
|
||||
newApplication.setAddressId(application.getAddressId());
|
||||
newApplication.setIsAddress(application.getIsAddress());
|
||||
} else {
|
||||
int max = applicationRegisterDAO.getMaxApplicationId();
|
||||
applicationId = IdAutoIncrement.INSTANCE.increment(min, max);
|
||||
|
|
@ -75,6 +79,8 @@ public class ApplicationRegisterSerialWorker extends AbstractLocalAsyncWorker<Ap
|
|||
newApplication = new Application(String.valueOf(applicationId));
|
||||
newApplication.setApplicationId(applicationId);
|
||||
newApplication.setApplicationCode(application.getApplicationCode());
|
||||
newApplication.setAddressId(application.getAddressId());
|
||||
newApplication.setIsAddress(application.getIsAddress());
|
||||
}
|
||||
applicationRegisterDAO.save(newApplication);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ public class InstanceRegisterSerialWorker extends AbstractLocalAsyncWorker<Insta
|
|||
|
||||
@Override protected void onWork(Instance instance) throws WorkerException {
|
||||
logger.debug("register instance, application id: {}, agentUUID: {}", instance.getApplicationId(), instance.getAgentUUID());
|
||||
int instanceId = instanceCacheService.getInstanceId(instance.getApplicationId(), instance.getAgentUUID());
|
||||
int instanceId = instanceCacheService.getInstanceIdByAgentUUID(instance.getApplicationId(), instance.getAgentUUID());
|
||||
if (instanceId == 0) {
|
||||
Instance newInstance;
|
||||
|
||||
|
|
@ -67,6 +67,8 @@ public class InstanceRegisterSerialWorker extends AbstractLocalAsyncWorker<Insta
|
|||
newInstance.setHeartBeatTime(instance.getHeartBeatTime());
|
||||
newInstance.setOsInfo(instance.getOsInfo());
|
||||
newInstance.setRegisterTime(instance.getRegisterTime());
|
||||
newInstance.setAddressId(instance.getAddressId());
|
||||
newInstance.setIsAddress(instance.getIsAddress());
|
||||
} else {
|
||||
newInstance = new Instance(String.valueOf(max + 1));
|
||||
newInstance.setInstanceId(max + 1);
|
||||
|
|
@ -75,6 +77,8 @@ public class InstanceRegisterSerialWorker extends AbstractLocalAsyncWorker<Insta
|
|||
newInstance.setHeartBeatTime(instance.getHeartBeatTime());
|
||||
newInstance.setOsInfo(instance.getOsInfo());
|
||||
newInstance.setRegisterTime(instance.getRegisterTime());
|
||||
newInstance.setAddressId(instance.getAddressId());
|
||||
newInstance.setIsAddress(instance.getIsAddress());
|
||||
}
|
||||
instanceRegisterDAO.save(newInstance);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,9 +22,11 @@ import org.apache.skywalking.apm.collector.analysis.register.define.graph.GraphI
|
|||
import org.apache.skywalking.apm.collector.analysis.register.define.service.IApplicationIDService;
|
||||
import org.apache.skywalking.apm.collector.cache.CacheModule;
|
||||
import org.apache.skywalking.apm.collector.cache.service.ApplicationCacheService;
|
||||
import org.apache.skywalking.apm.collector.cache.service.NetworkAddressCacheService;
|
||||
import org.apache.skywalking.apm.collector.core.graph.Graph;
|
||||
import org.apache.skywalking.apm.collector.core.graph.GraphManager;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.core.util.Const;
|
||||
import org.apache.skywalking.apm.collector.core.util.ObjectUtils;
|
||||
import org.apache.skywalking.apm.collector.storage.table.register.Application;
|
||||
import org.slf4j.Logger;
|
||||
|
|
@ -39,6 +41,7 @@ public class ApplicationIDService implements IApplicationIDService {
|
|||
|
||||
private final ModuleManager moduleManager;
|
||||
private ApplicationCacheService applicationCacheService;
|
||||
private NetworkAddressCacheService networkAddressCacheService;
|
||||
private Graph<Application> applicationRegisterGraph;
|
||||
|
||||
public ApplicationIDService(ModuleManager moduleManager) {
|
||||
|
|
@ -59,13 +62,37 @@ public class ApplicationIDService implements IApplicationIDService {
|
|||
return applicationCacheService;
|
||||
}
|
||||
|
||||
public int getOrCreate(String applicationCode) {
|
||||
int applicationId = getApplicationCacheService().get(applicationCode);
|
||||
private NetworkAddressCacheService getNetworkAddressCacheService() {
|
||||
if (ObjectUtils.isEmpty(networkAddressCacheService)) {
|
||||
this.networkAddressCacheService = moduleManager.find(CacheModule.NAME).getService(NetworkAddressCacheService.class);
|
||||
}
|
||||
return networkAddressCacheService;
|
||||
}
|
||||
|
||||
@Override public int getOrCreateForApplicationCode(String applicationCode) {
|
||||
int applicationId = getApplicationCacheService().getApplicationIdByCode(applicationCode);
|
||||
|
||||
if (applicationId == 0) {
|
||||
Application application = new Application(applicationCode);
|
||||
application.setApplicationCode(applicationCode);
|
||||
application.setApplicationId(0);
|
||||
application.setAddressId(Const.NONE);
|
||||
application.setIsAddress(false);
|
||||
|
||||
getApplicationRegisterGraph().start(application);
|
||||
}
|
||||
return applicationId;
|
||||
}
|
||||
|
||||
@Override public int getOrCreateForAddressId(int addressId, String networkAddress) {
|
||||
int applicationId = getApplicationCacheService().getApplicationIdByAddressId(addressId);
|
||||
|
||||
if (applicationId == 0) {
|
||||
Application application = new Application(networkAddress);
|
||||
application.setApplicationCode(networkAddress);
|
||||
application.setApplicationId(0);
|
||||
application.setAddressId(addressId);
|
||||
application.setIsAddress(true);
|
||||
|
||||
getApplicationRegisterGraph().start(application);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import org.apache.skywalking.apm.collector.cache.service.InstanceCacheService;
|
|||
import org.apache.skywalking.apm.collector.core.graph.Graph;
|
||||
import org.apache.skywalking.apm.collector.core.graph.GraphManager;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.core.util.Const;
|
||||
import org.apache.skywalking.apm.collector.core.util.ObjectUtils;
|
||||
import org.apache.skywalking.apm.collector.storage.StorageModule;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.IInstanceRegisterDAO;
|
||||
|
|
@ -69,9 +70,9 @@ public class InstanceIDService implements IInstanceIDService {
|
|||
return instanceRegisterDAO;
|
||||
}
|
||||
|
||||
public int getOrCreate(int applicationId, String agentUUID, long registerTime, String osInfo) {
|
||||
logger.debug("getApplicationId or create instance id, application id: {}, agentUUID: {}, registerTime: {}, osInfo: {}", applicationId, agentUUID, registerTime, osInfo);
|
||||
int instanceId = getInstanceCacheService().getInstanceId(applicationId, agentUUID);
|
||||
@Override public int getOrCreateByAgentUUID(int applicationId, String agentUUID, long registerTime, String osInfo) {
|
||||
logger.debug("get or create instance id by agent UUID, application id: {}, agentUUID: {}, registerTime: {}, osInfo: {}", applicationId, agentUUID, registerTime, osInfo);
|
||||
int instanceId = getInstanceCacheService().getInstanceIdByAgentUUID(applicationId, agentUUID);
|
||||
|
||||
if (instanceId == 0) {
|
||||
Instance instance = new Instance("0");
|
||||
|
|
@ -81,13 +82,35 @@ public class InstanceIDService implements IInstanceIDService {
|
|||
instance.setHeartBeatTime(registerTime);
|
||||
instance.setInstanceId(0);
|
||||
instance.setOsInfo(osInfo);
|
||||
instance.setIsAddress(false);
|
||||
instance.setAddressId(Const.NONE);
|
||||
|
||||
getInstanceRegisterGraph().start(instance);
|
||||
}
|
||||
return instanceId;
|
||||
}
|
||||
|
||||
public void recover(int instanceId, int applicationId, long registerTime, String osInfo) {
|
||||
@Override public int getOrCreateByAddressId(int applicationId, int addressId, long registerTime) {
|
||||
logger.debug("get or create instance id by address id, application id: {}, address id: {}, registerTime: {}", applicationId, addressId, registerTime);
|
||||
int instanceId = getInstanceCacheService().getInstanceIdByAddressId(applicationId, addressId);
|
||||
|
||||
if (instanceId == 0) {
|
||||
Instance instance = new Instance("0");
|
||||
instance.setApplicationId(applicationId);
|
||||
instance.setAgentUUID(Const.EMPTY_STRING);
|
||||
instance.setRegisterTime(registerTime);
|
||||
instance.setHeartBeatTime(registerTime);
|
||||
instance.setInstanceId(0);
|
||||
instance.setOsInfo(Const.EMPTY_STRING);
|
||||
instance.setIsAddress(true);
|
||||
instance.setAddressId(addressId);
|
||||
|
||||
getInstanceRegisterGraph().start(instance);
|
||||
}
|
||||
return instanceId;
|
||||
}
|
||||
|
||||
@Override public void recover(int instanceId, int applicationId, long registerTime, String osInfo) {
|
||||
logger.debug("instance recover, instance id: {}, application id: {}, register time: {}", instanceId, applicationId, registerTime);
|
||||
Instance instance = new Instance(String.valueOf(instanceId));
|
||||
instance.setApplicationId(applicationId);
|
||||
|
|
|
|||
|
|
@ -18,7 +18,10 @@
|
|||
|
||||
package org.apache.skywalking.apm.collector.analysis.register.provider.service;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.register.define.AnalysisRegisterModule;
|
||||
import org.apache.skywalking.apm.collector.analysis.register.define.graph.GraphIdDefine;
|
||||
import org.apache.skywalking.apm.collector.analysis.register.define.service.IApplicationIDService;
|
||||
import org.apache.skywalking.apm.collector.analysis.register.define.service.IInstanceIDService;
|
||||
import org.apache.skywalking.apm.collector.analysis.register.define.service.INetworkAddressIDService;
|
||||
import org.apache.skywalking.apm.collector.cache.CacheModule;
|
||||
import org.apache.skywalking.apm.collector.cache.service.NetworkAddressCacheService;
|
||||
|
|
@ -39,6 +42,8 @@ public class NetworkAddressIDService implements INetworkAddressIDService {
|
|||
|
||||
private final ModuleManager moduleManager;
|
||||
private NetworkAddressCacheService networkAddressCacheService;
|
||||
private IApplicationIDService applicationIDService;
|
||||
private IInstanceIDService instanceIDService;
|
||||
private Graph<NetworkAddress> networkAddressGraph;
|
||||
|
||||
public NetworkAddressIDService(ModuleManager moduleManager) {
|
||||
|
|
@ -47,28 +52,53 @@ public class NetworkAddressIDService implements INetworkAddressIDService {
|
|||
|
||||
private NetworkAddressCacheService getNetworkAddressCacheService() {
|
||||
if (ObjectUtils.isEmpty(networkAddressCacheService)) {
|
||||
networkAddressCacheService = moduleManager.find(CacheModule.NAME).getService(NetworkAddressCacheService.class);
|
||||
this.networkAddressCacheService = moduleManager.find(CacheModule.NAME).getService(NetworkAddressCacheService.class);
|
||||
}
|
||||
return networkAddressCacheService;
|
||||
return this.networkAddressCacheService;
|
||||
}
|
||||
|
||||
private IApplicationIDService getApplicationIDService() {
|
||||
if (ObjectUtils.isEmpty(applicationIDService)) {
|
||||
this.applicationIDService = moduleManager.find(AnalysisRegisterModule.NAME).getService(IApplicationIDService.class);
|
||||
}
|
||||
return this.applicationIDService;
|
||||
}
|
||||
|
||||
private IInstanceIDService getInstanceIDService() {
|
||||
if (ObjectUtils.isEmpty(instanceIDService)) {
|
||||
this.instanceIDService = moduleManager.find(AnalysisRegisterModule.NAME).getService(IInstanceIDService.class);
|
||||
}
|
||||
return this.instanceIDService;
|
||||
}
|
||||
|
||||
private Graph<NetworkAddress> getNetworkAddressGraph() {
|
||||
if (ObjectUtils.isEmpty(networkAddressGraph)) {
|
||||
this.networkAddressGraph = GraphManager.INSTANCE.findGraph(GraphIdDefine.NETWORK_ADDRESS_NAME_REGISTER_GRAPH_ID, NetworkAddress.class);
|
||||
}
|
||||
return networkAddressGraph;
|
||||
return this.networkAddressGraph;
|
||||
}
|
||||
|
||||
@Override public int getOrCreate(String networkAddress) {
|
||||
int addressId = getNetworkAddressCacheService().getAddressId(networkAddress);
|
||||
|
||||
if (addressId == 0) {
|
||||
if (addressId != 0) {
|
||||
int applicationId = getApplicationIDService().getOrCreateForAddressId(addressId, networkAddress);
|
||||
|
||||
if (applicationId != 0) {
|
||||
int instanceId = getInstanceIDService().getOrCreateByAddressId(applicationId, addressId, System.currentTimeMillis());
|
||||
|
||||
if (instanceId != 0) {
|
||||
return addressId;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
NetworkAddress newNetworkAddress = new NetworkAddress("0");
|
||||
newNetworkAddress.setNetworkAddress(networkAddress);
|
||||
newNetworkAddress.setAddressId(0);
|
||||
|
||||
getNetworkAddressGraph().start(newNetworkAddress);
|
||||
}
|
||||
return addressId;
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.collector.analysis.segment.parser.provider.parser.standardization;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.segment.parser.define.decorator.StandardBuilder;
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ package org.apache.skywalking.apm.collector.analysis.segment.parser.provider.par
|
|||
|
||||
import org.apache.skywalking.apm.collector.analysis.register.define.AnalysisRegisterModule;
|
||||
import org.apache.skywalking.apm.collector.analysis.register.define.service.IApplicationIDService;
|
||||
import org.apache.skywalking.apm.collector.analysis.register.define.service.INetworkAddressIDService;
|
||||
import org.apache.skywalking.apm.collector.analysis.register.define.service.IServiceNameService;
|
||||
import org.apache.skywalking.apm.collector.analysis.segment.parser.define.decorator.ReferenceDecorator;
|
||||
import org.apache.skywalking.apm.collector.cache.CacheModule;
|
||||
|
|
@ -41,6 +42,7 @@ public class ReferenceIdExchanger implements IdExchanger<ReferenceDecorator> {
|
|||
private final IApplicationIDService applicationIDService;
|
||||
private final IServiceNameService serviceNameService;
|
||||
private final InstanceCacheService instanceCacheService;
|
||||
private final INetworkAddressIDService networkAddressIDService;
|
||||
|
||||
public static ReferenceIdExchanger getInstance(ModuleManager moduleManager) {
|
||||
if (EXCHANGER == null) {
|
||||
|
|
@ -50,9 +52,10 @@ public class ReferenceIdExchanger implements IdExchanger<ReferenceDecorator> {
|
|||
}
|
||||
|
||||
private ReferenceIdExchanger(ModuleManager moduleManager) {
|
||||
applicationIDService = moduleManager.find(AnalysisRegisterModule.NAME).getService(IApplicationIDService.class);
|
||||
serviceNameService = moduleManager.find(AnalysisRegisterModule.NAME).getService(IServiceNameService.class);
|
||||
instanceCacheService = moduleManager.find(CacheModule.NAME).getService(InstanceCacheService.class);
|
||||
this.applicationIDService = moduleManager.find(AnalysisRegisterModule.NAME).getService(IApplicationIDService.class);
|
||||
this.serviceNameService = moduleManager.find(AnalysisRegisterModule.NAME).getService(IServiceNameService.class);
|
||||
this.networkAddressIDService = moduleManager.find(AnalysisRegisterModule.NAME).getService(INetworkAddressIDService.class);
|
||||
this.instanceCacheService = moduleManager.find(CacheModule.NAME).getService(InstanceCacheService.class);
|
||||
}
|
||||
|
||||
@Override public boolean exchange(ReferenceDecorator standardBuilder, int applicationId) {
|
||||
|
|
@ -89,7 +92,7 @@ public class ReferenceIdExchanger implements IdExchanger<ReferenceDecorator> {
|
|||
}
|
||||
|
||||
if (standardBuilder.getNetworkAddressId() == 0 && StringUtils.isNotEmpty(standardBuilder.getNetworkAddress())) {
|
||||
int networkAddressId = applicationIDService.getOrCreate(standardBuilder.getNetworkAddress());
|
||||
int networkAddressId = networkAddressIDService.getOrCreate(standardBuilder.getNetworkAddress());
|
||||
if (networkAddressId == 0) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("network address: {} from application id: {} exchange failed", standardBuilder.getNetworkAddress(), applicationId);
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
package org.apache.skywalking.apm.collector.analysis.segment.parser.provider.parser.standardization;
|
||||
|
||||
import org.apache.skywalking.apm.collector.analysis.register.define.AnalysisRegisterModule;
|
||||
import org.apache.skywalking.apm.collector.analysis.register.define.service.IApplicationIDService;
|
||||
import org.apache.skywalking.apm.collector.analysis.register.define.service.INetworkAddressIDService;
|
||||
import org.apache.skywalking.apm.collector.analysis.register.define.service.IServiceNameService;
|
||||
import org.apache.skywalking.apm.collector.analysis.segment.parser.define.decorator.SpanDecorator;
|
||||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
|
|
@ -36,8 +36,8 @@ public class SpanIdExchanger implements IdExchanger<SpanDecorator> {
|
|||
private final Logger logger = LoggerFactory.getLogger(SpanIdExchanger.class);
|
||||
|
||||
private static SpanIdExchanger EXCHANGER;
|
||||
private final IApplicationIDService applicationIDService;
|
||||
private final IServiceNameService serviceNameService;
|
||||
private final INetworkAddressIDService networkAddressIDService;
|
||||
|
||||
public static SpanIdExchanger getInstance(ModuleManager moduleManager) {
|
||||
if (EXCHANGER == null) {
|
||||
|
|
@ -47,13 +47,14 @@ public class SpanIdExchanger implements IdExchanger<SpanDecorator> {
|
|||
}
|
||||
|
||||
private SpanIdExchanger(ModuleManager moduleManager) {
|
||||
applicationIDService = moduleManager.find(AnalysisRegisterModule.NAME).getService(IApplicationIDService.class);
|
||||
serviceNameService = moduleManager.find(AnalysisRegisterModule.NAME).getService(IServiceNameService.class);
|
||||
this.serviceNameService = moduleManager.find(AnalysisRegisterModule.NAME).getService(IServiceNameService.class);
|
||||
this.networkAddressIDService = moduleManager.find(AnalysisRegisterModule.NAME).getService(INetworkAddressIDService.class);
|
||||
}
|
||||
|
||||
@Override public boolean exchange(SpanDecorator standardBuilder, int applicationId) {
|
||||
if (standardBuilder.getPeerId() == 0 && StringUtils.isNotEmpty(standardBuilder.getPeer())) {
|
||||
int peerId = applicationIDService.getOrCreate(standardBuilder.getPeer());
|
||||
int peerId = networkAddressIDService.getOrCreate(standardBuilder.getPeer());
|
||||
|
||||
if (peerId == 0) {
|
||||
logger.debug("peer: {} in application: {} exchange failed", standardBuilder.getPeer(), applicationId);
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.collector.cache.service;
|
||||
|
||||
import org.apache.skywalking.apm.collector.core.module.Service;
|
||||
|
|
@ -25,7 +24,9 @@ import org.apache.skywalking.apm.collector.core.module.Service;
|
|||
* @author peng-yongsheng
|
||||
*/
|
||||
public interface ApplicationCacheService extends Service {
|
||||
int get(String applicationCode);
|
||||
int getApplicationIdByCode(String applicationCode);
|
||||
|
||||
String get(int applicationId);
|
||||
String getApplicationCodeById(int applicationId);
|
||||
|
||||
int getApplicationIdByAddressId(int addressId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.collector.cache.service;
|
||||
|
||||
import org.apache.skywalking.apm.collector.core.module.Service;
|
||||
|
|
@ -25,7 +24,9 @@ import org.apache.skywalking.apm.collector.core.module.Service;
|
|||
* @author peng-yongsheng
|
||||
*/
|
||||
public interface InstanceCacheService extends Service {
|
||||
int getApplicationId(int applicationInstanceId);
|
||||
int getApplicationId(int instanceId);
|
||||
|
||||
int getInstanceId(int applicationId, String agentUUID);
|
||||
int getInstanceIdByAgentUUID(int applicationId, String agentUUID);
|
||||
|
||||
int getInstanceIdByAddressId(int applicationId, int addressId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.collector.cache.guava.service;
|
||||
|
||||
import com.google.common.cache.Cache;
|
||||
|
|
@ -54,16 +53,16 @@ public class ApplicationCacheGuavaService implements ApplicationCacheService {
|
|||
return this.applicationCacheDAO;
|
||||
}
|
||||
|
||||
public int get(String applicationCode) {
|
||||
@Override public int getApplicationIdByCode(String applicationCode) {
|
||||
int applicationId = 0;
|
||||
try {
|
||||
applicationId = codeCache.get(applicationCode, () -> getApplicationCacheDAO().getApplicationId(applicationCode));
|
||||
applicationId = codeCache.get(applicationCode, () -> getApplicationCacheDAO().getApplicationIdByCode(applicationCode));
|
||||
} catch (Throwable e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
if (applicationId == 0) {
|
||||
applicationId = getApplicationCacheDAO().getApplicationId(applicationCode);
|
||||
applicationId = getApplicationCacheDAO().getApplicationIdByCode(applicationCode);
|
||||
if (applicationId != 0) {
|
||||
codeCache.put(applicationCode, applicationId);
|
||||
}
|
||||
|
|
@ -73,7 +72,7 @@ public class ApplicationCacheGuavaService implements ApplicationCacheService {
|
|||
|
||||
private final Cache<Integer, String> idCache = CacheBuilder.newBuilder().maximumSize(1000).build();
|
||||
|
||||
public String get(int applicationId) {
|
||||
@Override public String getApplicationCodeById(int applicationId) {
|
||||
String applicationCode = Const.EMPTY_STRING;
|
||||
try {
|
||||
applicationCode = idCache.get(applicationId, () -> getApplicationCacheDAO().getApplicationCode(applicationId));
|
||||
|
|
@ -89,4 +88,23 @@ public class ApplicationCacheGuavaService implements ApplicationCacheService {
|
|||
}
|
||||
return applicationCode;
|
||||
}
|
||||
|
||||
private final Cache<Integer, Integer> addressIdCache = CacheBuilder.newBuilder().maximumSize(1000).build();
|
||||
|
||||
@Override public int getApplicationIdByAddressId(int addressId) {
|
||||
int applicationId = 0;
|
||||
try {
|
||||
applicationId = addressIdCache.get(addressId, () -> getApplicationCacheDAO().getApplicationIdByAddressId(addressId));
|
||||
} catch (Throwable e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
if (applicationId == 0) {
|
||||
applicationId = getApplicationCacheDAO().getApplicationIdByAddressId(addressId);
|
||||
if (applicationId != 0) {
|
||||
addressIdCache.put(addressId, applicationId);
|
||||
}
|
||||
}
|
||||
return applicationId;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.collector.cache.guava.service;
|
||||
|
||||
import com.google.common.cache.Cache;
|
||||
|
|
@ -25,8 +24,8 @@ import org.apache.skywalking.apm.collector.cache.service.InstanceCacheService;
|
|||
import org.apache.skywalking.apm.collector.core.module.ModuleManager;
|
||||
import org.apache.skywalking.apm.collector.core.util.Const;
|
||||
import org.apache.skywalking.apm.collector.core.util.ObjectUtils;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.IInstanceCacheDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.StorageModule;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.IInstanceCacheDAO;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
|
@ -37,9 +36,11 @@ public class InstanceCacheGuavaService implements InstanceCacheService {
|
|||
|
||||
private final Logger logger = LoggerFactory.getLogger(InstanceCacheGuavaService.class);
|
||||
|
||||
private final Cache<Integer, Integer> integerCache = CacheBuilder.newBuilder().initialCapacity(100).maximumSize(5000).build();
|
||||
private final Cache<Integer, Integer> applicationIdCache = CacheBuilder.newBuilder().initialCapacity(100).maximumSize(5000).build();
|
||||
|
||||
private final Cache<String, Integer> stringCache = CacheBuilder.newBuilder().initialCapacity(100).maximumSize(5000).build();
|
||||
private final Cache<String, Integer> agentUUIDCache = CacheBuilder.newBuilder().initialCapacity(100).maximumSize(5000).build();
|
||||
|
||||
private final Cache<String, Integer> addressIdCache = CacheBuilder.newBuilder().initialCapacity(100).maximumSize(5000).build();
|
||||
|
||||
private final ModuleManager moduleManager;
|
||||
private IInstanceCacheDAO instanceCacheDAO;
|
||||
|
|
@ -55,38 +56,56 @@ public class InstanceCacheGuavaService implements InstanceCacheService {
|
|||
return this.instanceCacheDAO;
|
||||
}
|
||||
|
||||
public int getApplicationId(int applicationInstanceId) {
|
||||
|
||||
@Override public int getApplicationId(int instanceId) {
|
||||
int applicationId = 0;
|
||||
try {
|
||||
applicationId = integerCache.get(applicationInstanceId, () -> getInstanceCacheDAO().getApplicationId(applicationInstanceId));
|
||||
applicationId = applicationIdCache.get(instanceId, () -> getInstanceCacheDAO().getApplicationId(instanceId));
|
||||
} catch (Throwable e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
if (applicationId == 0) {
|
||||
applicationId = getInstanceCacheDAO().getApplicationId(applicationInstanceId);
|
||||
applicationId = getInstanceCacheDAO().getApplicationId(instanceId);
|
||||
if (applicationId != 0) {
|
||||
integerCache.put(applicationInstanceId, applicationId);
|
||||
applicationIdCache.put(instanceId, applicationId);
|
||||
}
|
||||
}
|
||||
return applicationId;
|
||||
}
|
||||
|
||||
@Override public int getInstanceId(int applicationId, String agentUUID) {
|
||||
@Override public int getInstanceIdByAgentUUID(int applicationId, String agentUUID) {
|
||||
String key = applicationId + Const.ID_SPLIT + agentUUID;
|
||||
|
||||
int instanceId = 0;
|
||||
try {
|
||||
instanceId = stringCache.get(key, () -> getInstanceCacheDAO().getInstanceId(applicationId, agentUUID));
|
||||
instanceId = agentUUIDCache.get(key, () -> getInstanceCacheDAO().getInstanceIdByAgentUUID(applicationId, agentUUID));
|
||||
} catch (Throwable e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
if (instanceId == 0) {
|
||||
instanceId = getInstanceCacheDAO().getInstanceId(applicationId, agentUUID);
|
||||
instanceId = getInstanceCacheDAO().getInstanceIdByAgentUUID(applicationId, agentUUID);
|
||||
if (applicationId != 0) {
|
||||
stringCache.put(key, instanceId);
|
||||
agentUUIDCache.put(key, instanceId);
|
||||
}
|
||||
}
|
||||
return instanceId;
|
||||
}
|
||||
|
||||
@Override public int getInstanceIdByAddressId(int applicationId, int addressId) {
|
||||
String key = applicationId + Const.ID_SPLIT + addressId;
|
||||
|
||||
int instanceId = 0;
|
||||
try {
|
||||
instanceId = addressIdCache.get(key, () -> getInstanceCacheDAO().getInstanceIdByAddressId(applicationId, addressId));
|
||||
} catch (Throwable e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
if (instanceId == 0) {
|
||||
instanceId = getInstanceCacheDAO().getInstanceIdByAddressId(applicationId, addressId);
|
||||
if (applicationId != 0) {
|
||||
addressIdCache.put(key, instanceId);
|
||||
}
|
||||
}
|
||||
return instanceId;
|
||||
|
|
|
|||
|
|
@ -16,13 +16,13 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.collector.core.util;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class Const {
|
||||
public static final int NONE = 0;
|
||||
public static final String ID_SPLIT = "_";
|
||||
public static final int USER_ID = 1;
|
||||
public static final int NONE_SERVICE_ID = 1;
|
||||
|
|
|
|||
|
|
@ -24,7 +24,9 @@ import org.apache.skywalking.apm.collector.storage.base.dao.DAO;
|
|||
* @author peng-yongsheng
|
||||
*/
|
||||
public interface IApplicationCacheDAO extends DAO {
|
||||
int getApplicationId(String applicationCode);
|
||||
int getApplicationIdByCode(String applicationCode);
|
||||
|
||||
String getApplicationCode(int applicationId);
|
||||
|
||||
int getApplicationIdByAddressId(int addressId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,5 +26,7 @@ import org.apache.skywalking.apm.collector.storage.base.dao.DAO;
|
|||
public interface IInstanceCacheDAO extends DAO {
|
||||
int getApplicationId(int instanceId);
|
||||
|
||||
int getInstanceId(int applicationId, String agentUUID);
|
||||
int getInstanceIdByAgentUUID(int applicationId, String agentUUID);
|
||||
|
||||
int getInstanceIdByAddressId(int applicationId, int addressId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.collector.storage.table.register;
|
||||
|
||||
import org.apache.skywalking.apm.collector.core.data.Column;
|
||||
|
|
@ -35,12 +34,18 @@ public class Application extends Data {
|
|||
};
|
||||
|
||||
private static final Column[] LONG_COLUMNS = {};
|
||||
|
||||
private static final Column[] DOUBLE_COLUMNS = {};
|
||||
|
||||
private static final Column[] INTEGER_COLUMNS = {
|
||||
new Column(ApplicationTable.COLUMN_APPLICATION_ID, new CoverOperation()),
|
||||
new Column(ApplicationTable.COLUMN_ADDRESS_ID, new CoverOperation()),
|
||||
};
|
||||
|
||||
private static final Column[] BOOLEAN_COLUMNS = {
|
||||
new Column(ApplicationTable.COLUMN_IS_ADDRESS, new CoverOperation()),
|
||||
};
|
||||
|
||||
private static final Column[] BOOLEAN_COLUMNS = {};
|
||||
private static final Column[] BYTE_COLUMNS = {};
|
||||
|
||||
public Application(String id) {
|
||||
|
|
@ -62,4 +67,20 @@ public class Application extends Data {
|
|||
public void setApplicationId(int applicationId) {
|
||||
setDataInteger(0, applicationId);
|
||||
}
|
||||
|
||||
public int getAddressId() {
|
||||
return getDataInteger(1);
|
||||
}
|
||||
|
||||
public void setAddressId(int addressId) {
|
||||
setDataInteger(1, addressId);
|
||||
}
|
||||
|
||||
public boolean getIsAddress() {
|
||||
return getDataBoolean(0);
|
||||
}
|
||||
|
||||
public void setIsAddress(boolean isAddress) {
|
||||
setDataBoolean(0, isAddress);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.collector.storage.table.register;
|
||||
|
||||
import org.apache.skywalking.apm.collector.core.data.CommonTable;
|
||||
|
|
@ -28,4 +27,6 @@ public class ApplicationTable extends CommonTable {
|
|||
public static final String TABLE = "application";
|
||||
public static final String COLUMN_APPLICATION_CODE = "application_code";
|
||||
public static final String COLUMN_APPLICATION_ID = "application_id";
|
||||
public static final String COLUMN_IS_ADDRESS = "is_address";
|
||||
public static final String COLUMN_ADDRESS_ID = "address_id";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,11 +16,10 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.collector.storage.table.register;
|
||||
|
||||
import org.apache.skywalking.apm.collector.core.data.Data;
|
||||
import org.apache.skywalking.apm.collector.core.data.Column;
|
||||
import org.apache.skywalking.apm.collector.core.data.Data;
|
||||
import org.apache.skywalking.apm.collector.core.data.operator.CoverOperation;
|
||||
import org.apache.skywalking.apm.collector.core.data.operator.NonOperation;
|
||||
|
||||
|
|
@ -39,13 +38,19 @@ public class Instance extends Data {
|
|||
new Column(InstanceTable.COLUMN_REGISTER_TIME, new CoverOperation()),
|
||||
new Column(InstanceTable.COLUMN_HEARTBEAT_TIME, new CoverOperation()),
|
||||
};
|
||||
|
||||
private static final Column[] DOUBLE_COLUMNS = {};
|
||||
|
||||
private static final Column[] INTEGER_COLUMNS = {
|
||||
new Column(InstanceTable.COLUMN_APPLICATION_ID, new CoverOperation()),
|
||||
new Column(InstanceTable.COLUMN_INSTANCE_ID, new CoverOperation()),
|
||||
new Column(InstanceTable.COLUMN_ADDRESS_ID, new CoverOperation()),
|
||||
};
|
||||
|
||||
private static final Column[] BOOLEAN_COLUMNS = {
|
||||
new Column(InstanceTable.COLUMN_IS_ADDRESS, new CoverOperation()),
|
||||
};
|
||||
|
||||
private static final Column[] BOOLEAN_COLUMNS = {};
|
||||
private static final Column[] BYTE_COLUMNS = {};
|
||||
|
||||
public Instance(String id) {
|
||||
|
|
@ -103,4 +108,20 @@ public class Instance extends Data {
|
|||
public void setOsInfo(String osInfo) {
|
||||
setDataString(2, osInfo);
|
||||
}
|
||||
|
||||
public int getAddressId() {
|
||||
return getDataInteger(2);
|
||||
}
|
||||
|
||||
public void setAddressId(int addressId) {
|
||||
setDataInteger(2, addressId);
|
||||
}
|
||||
|
||||
public boolean getIsAddress() {
|
||||
return getDataBoolean(0);
|
||||
}
|
||||
|
||||
public void setIsAddress(boolean isAddress) {
|
||||
setDataBoolean(0, isAddress);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.collector.storage.table.register;
|
||||
|
||||
import org.apache.skywalking.apm.collector.core.data.CommonTable;
|
||||
|
|
@ -32,4 +31,6 @@ public class InstanceTable extends CommonTable {
|
|||
public static final String COLUMN_INSTANCE_ID = "instance_id";
|
||||
public static final String COLUMN_HEARTBEAT_TIME = "heartbeat_time";
|
||||
public static final String COLUMN_OS_INFO = "os_info";
|
||||
public static final String COLUMN_IS_ADDRESS = "is_address";
|
||||
public static final String COLUMN_ADDRESS_ID = "address_id";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import org.elasticsearch.action.get.GetResponse;
|
|||
import org.elasticsearch.action.search.SearchRequestBuilder;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.action.search.SearchType;
|
||||
import org.elasticsearch.index.query.BoolQueryBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.elasticsearch.search.SearchHit;
|
||||
import org.slf4j.Logger;
|
||||
|
|
@ -44,13 +45,18 @@ public class ApplicationEsCacheDAO extends EsDAO implements IApplicationCacheDAO
|
|||
super(client);
|
||||
}
|
||||
|
||||
@Override public int getApplicationId(String applicationCode) {
|
||||
@Override public int getApplicationIdByCode(String applicationCode) {
|
||||
ElasticSearchClient client = getClient();
|
||||
|
||||
SearchRequestBuilder searchRequestBuilder = client.prepareSearch(ApplicationTable.TABLE);
|
||||
searchRequestBuilder.setTypes("type");
|
||||
searchRequestBuilder.setSearchType(SearchType.QUERY_THEN_FETCH);
|
||||
searchRequestBuilder.setQuery(QueryBuilders.termQuery(ApplicationTable.COLUMN_APPLICATION_CODE, applicationCode));
|
||||
|
||||
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
|
||||
boolQueryBuilder.must().add(QueryBuilders.termQuery(ApplicationTable.COLUMN_APPLICATION_CODE, applicationCode));
|
||||
boolQueryBuilder.must().add(QueryBuilders.termQuery(ApplicationTable.COLUMN_IS_ADDRESS, false));
|
||||
|
||||
searchRequestBuilder.setQuery(boolQueryBuilder);
|
||||
searchRequestBuilder.setSize(1);
|
||||
|
||||
SearchResponse searchResponse = searchRequestBuilder.execute().actionGet();
|
||||
|
|
@ -72,4 +78,26 @@ public class ApplicationEsCacheDAO extends EsDAO implements IApplicationCacheDAO
|
|||
}
|
||||
return Const.EMPTY_STRING;
|
||||
}
|
||||
|
||||
@Override public int getApplicationIdByAddressId(int addressId) {
|
||||
ElasticSearchClient client = getClient();
|
||||
|
||||
SearchRequestBuilder searchRequestBuilder = client.prepareSearch(ApplicationTable.TABLE);
|
||||
searchRequestBuilder.setTypes("type");
|
||||
searchRequestBuilder.setSearchType(SearchType.QUERY_THEN_FETCH);
|
||||
|
||||
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
|
||||
boolQueryBuilder.must().add(QueryBuilders.termQuery(ApplicationTable.COLUMN_ADDRESS_ID, addressId));
|
||||
boolQueryBuilder.must().add(QueryBuilders.termQuery(ApplicationTable.COLUMN_IS_ADDRESS, true));
|
||||
|
||||
searchRequestBuilder.setQuery(boolQueryBuilder);
|
||||
searchRequestBuilder.setSize(1);
|
||||
|
||||
SearchResponse searchResponse = searchRequestBuilder.execute().actionGet();
|
||||
if (searchResponse.getHits().totalHits > 0) {
|
||||
SearchHit searchHit = searchResponse.getHits().iterator().next();
|
||||
return (int)searchHit.getSource().get(ApplicationTable.COLUMN_APPLICATION_ID);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,6 +55,8 @@ public class ApplicationEsRegisterDAO extends EsDAO implements IApplicationRegis
|
|||
Map<String, Object> source = new HashMap<>();
|
||||
source.put(ApplicationTable.COLUMN_APPLICATION_CODE, application.getApplicationCode());
|
||||
source.put(ApplicationTable.COLUMN_APPLICATION_ID, application.getApplicationId());
|
||||
source.put(ApplicationTable.COLUMN_ADDRESS_ID, application.getAddressId());
|
||||
source.put(ApplicationTable.COLUMN_IS_ADDRESS, application.getIsAddress());
|
||||
|
||||
IndexResponse response = client.prepareIndex(ApplicationTable.TABLE, application.getId()).setSource(source).setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE).get();
|
||||
logger.debug("save application register info, application getId: {}, application code: {}, status: {}", application.getApplicationId(), application.getApplicationCode(), response.status().name());
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ public class InstanceEsCacheDAO extends EsDAO implements IInstanceCacheDAO {
|
|||
}
|
||||
}
|
||||
|
||||
@Override public int getInstanceId(int applicationId, String agentUUID) {
|
||||
@Override public int getInstanceIdByAgentUUID(int applicationId, String agentUUID) {
|
||||
ElasticSearchClient client = getClient();
|
||||
|
||||
SearchRequestBuilder searchRequestBuilder = client.prepareSearch(InstanceTable.TABLE);
|
||||
|
|
@ -61,6 +61,28 @@ public class InstanceEsCacheDAO extends EsDAO implements IInstanceCacheDAO {
|
|||
BoolQueryBuilder builder = QueryBuilders.boolQuery();
|
||||
builder.must().add(QueryBuilders.termQuery(InstanceTable.COLUMN_APPLICATION_ID, applicationId));
|
||||
builder.must().add(QueryBuilders.termQuery(InstanceTable.COLUMN_AGENT_UUID, agentUUID));
|
||||
builder.must().add(QueryBuilders.termQuery(InstanceTable.COLUMN_IS_ADDRESS, false));
|
||||
searchRequestBuilder.setQuery(builder);
|
||||
searchRequestBuilder.setSize(1);
|
||||
|
||||
SearchResponse searchResponse = searchRequestBuilder.execute().actionGet();
|
||||
if (searchResponse.getHits().totalHits > 0) {
|
||||
SearchHit searchHit = searchResponse.getHits().iterator().next();
|
||||
return (int)searchHit.getSource().get(InstanceTable.COLUMN_INSTANCE_ID);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override public int getInstanceIdByAddressId(int applicationId, int addressId) {
|
||||
ElasticSearchClient client = getClient();
|
||||
|
||||
SearchRequestBuilder searchRequestBuilder = client.prepareSearch(InstanceTable.TABLE);
|
||||
searchRequestBuilder.setTypes("type");
|
||||
searchRequestBuilder.setSearchType(SearchType.QUERY_THEN_FETCH);
|
||||
BoolQueryBuilder builder = QueryBuilders.boolQuery();
|
||||
builder.must().add(QueryBuilders.termQuery(InstanceTable.COLUMN_APPLICATION_ID, applicationId));
|
||||
builder.must().add(QueryBuilders.termQuery(InstanceTable.COLUMN_ADDRESS_ID, addressId));
|
||||
builder.must().add(QueryBuilders.termQuery(InstanceTable.COLUMN_IS_ADDRESS, true));
|
||||
searchRequestBuilder.setQuery(builder);
|
||||
searchRequestBuilder.setSize(1);
|
||||
|
||||
|
|
|
|||
|
|
@ -60,6 +60,8 @@ public class InstanceEsRegisterDAO extends EsDAO implements IInstanceRegisterDAO
|
|||
source.put(InstanceTable.COLUMN_REGISTER_TIME, instance.getRegisterTime());
|
||||
source.put(InstanceTable.COLUMN_HEARTBEAT_TIME, instance.getHeartBeatTime());
|
||||
source.put(InstanceTable.COLUMN_OS_INFO, instance.getOsInfo());
|
||||
source.put(InstanceTable.COLUMN_ADDRESS_ID, instance.getAddressId());
|
||||
source.put(InstanceTable.COLUMN_IS_ADDRESS, instance.getIsAddress());
|
||||
|
||||
IndexResponse response = client.prepareIndex(InstanceTable.TABLE, instance.getId()).setSource(source).setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE).get();
|
||||
logger.debug("save instance register info, application getId: {}, agentUUID: {}, status: {}", instance.getApplicationId(), instance.getAgentUUID(), response.status().name());
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.collector.storage.es.define;
|
||||
|
||||
import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchColumnDefine;
|
||||
|
|
@ -39,5 +38,7 @@ public class ApplicationEsTableDefine extends ElasticSearchTableDefine {
|
|||
@Override public void initialize() {
|
||||
addColumn(new ElasticSearchColumnDefine(ApplicationTable.COLUMN_APPLICATION_CODE, ElasticSearchColumnDefine.Type.Keyword.name()));
|
||||
addColumn(new ElasticSearchColumnDefine(ApplicationTable.COLUMN_APPLICATION_ID, ElasticSearchColumnDefine.Type.Integer.name()));
|
||||
addColumn(new ElasticSearchColumnDefine(ApplicationTable.COLUMN_ADDRESS_ID, ElasticSearchColumnDefine.Type.Integer.name()));
|
||||
addColumn(new ElasticSearchColumnDefine(ApplicationTable.COLUMN_IS_ADDRESS, ElasticSearchColumnDefine.Type.Boolean.name()));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,12 +16,11 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.collector.storage.es.define;
|
||||
|
||||
import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchColumnDefine;
|
||||
import org.apache.skywalking.apm.collector.storage.table.register.InstanceTable;
|
||||
import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchTableDefine;
|
||||
import org.apache.skywalking.apm.collector.storage.table.register.InstanceTable;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
|
|
@ -43,5 +42,7 @@ public class InstanceEsTableDefine extends ElasticSearchTableDefine {
|
|||
addColumn(new ElasticSearchColumnDefine(InstanceTable.COLUMN_INSTANCE_ID, ElasticSearchColumnDefine.Type.Integer.name()));
|
||||
addColumn(new ElasticSearchColumnDefine(InstanceTable.COLUMN_HEARTBEAT_TIME, ElasticSearchColumnDefine.Type.Long.name()));
|
||||
addColumn(new ElasticSearchColumnDefine(InstanceTable.COLUMN_OS_INFO, ElasticSearchColumnDefine.Type.Keyword.name()));
|
||||
addColumn(new ElasticSearchColumnDefine(InstanceTable.COLUMN_ADDRESS_ID, ElasticSearchColumnDefine.Type.Integer.name()));
|
||||
addColumn(new ElasticSearchColumnDefine(InstanceTable.COLUMN_IS_ADDRESS, ElasticSearchColumnDefine.Type.Boolean.name()));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,18 +16,17 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.collector.storage.h2.dao;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import org.apache.skywalking.apm.collector.client.h2.H2Client;
|
||||
import org.apache.skywalking.apm.collector.client.h2.H2ClientException;
|
||||
import org.apache.skywalking.apm.collector.core.util.Const;
|
||||
import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.IApplicationCacheDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO;
|
||||
import org.apache.skywalking.apm.collector.storage.table.register.ApplicationTable;
|
||||
import org.apache.skywalking.apm.collector.client.h2.H2ClientException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
|
@ -37,19 +36,21 @@ import org.slf4j.LoggerFactory;
|
|||
public class ApplicationH2CacheDAO extends H2DAO implements IApplicationCacheDAO {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(ApplicationH2CacheDAO.class);
|
||||
private static final String GET_APPLICATION_ID_OR_CODE_SQL = "select {0} from {1} where {2} = ?";
|
||||
|
||||
private static final String GET_APPLICATION_ID_SQL = "select {0} from {1} where {2} = ? and {3} = ?";
|
||||
private static final String GET_APPLICATION_CODE_SQL = "select {0} from {1} where {2} = ?";
|
||||
|
||||
public ApplicationH2CacheDAO(H2Client client) {
|
||||
super(client);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getApplicationId(String applicationCode) {
|
||||
logger.info("get the application getId with application code = {}", applicationCode);
|
||||
public int getApplicationIdByCode(String applicationCode) {
|
||||
logger.info("get the application id with application code = {}", applicationCode);
|
||||
H2Client client = getClient();
|
||||
String sql = SqlBuilder.buildSql(GET_APPLICATION_ID_OR_CODE_SQL, ApplicationTable.COLUMN_APPLICATION_ID, ApplicationTable.TABLE, ApplicationTable.COLUMN_APPLICATION_CODE);
|
||||
String sql = SqlBuilder.buildSql(GET_APPLICATION_ID_SQL, ApplicationTable.COLUMN_APPLICATION_ID, ApplicationTable.TABLE, ApplicationTable.COLUMN_APPLICATION_CODE, ApplicationTable.COLUMN_IS_ADDRESS);
|
||||
|
||||
Object[] params = new Object[] {applicationCode};
|
||||
Object[] params = new Object[] {applicationCode, false};
|
||||
try (ResultSet rs = client.executeQuery(sql, params)) {
|
||||
if (rs.next()) {
|
||||
return rs.getInt(1);
|
||||
|
|
@ -63,7 +64,7 @@ public class ApplicationH2CacheDAO extends H2DAO implements IApplicationCacheDAO
|
|||
@Override public String getApplicationCode(int applicationId) {
|
||||
logger.debug("get application code, applicationId: {}", applicationId);
|
||||
H2Client client = getClient();
|
||||
String sql = SqlBuilder.buildSql(GET_APPLICATION_ID_OR_CODE_SQL, ApplicationTable.COLUMN_APPLICATION_CODE, ApplicationTable.TABLE, ApplicationTable.COLUMN_APPLICATION_ID);
|
||||
String sql = SqlBuilder.buildSql(GET_APPLICATION_CODE_SQL, ApplicationTable.COLUMN_APPLICATION_CODE, ApplicationTable.TABLE, ApplicationTable.COLUMN_APPLICATION_ID);
|
||||
Object[] params = new Object[] {applicationId};
|
||||
try (ResultSet rs = client.executeQuery(sql, params)) {
|
||||
if (rs.next()) {
|
||||
|
|
@ -74,4 +75,20 @@ public class ApplicationH2CacheDAO extends H2DAO implements IApplicationCacheDAO
|
|||
}
|
||||
return Const.EMPTY_STRING;
|
||||
}
|
||||
|
||||
@Override public int getApplicationIdByAddressId(int addressId) {
|
||||
logger.info("get the application id with address id = {}", addressId);
|
||||
H2Client client = getClient();
|
||||
String sql = SqlBuilder.buildSql(GET_APPLICATION_ID_SQL, ApplicationTable.COLUMN_APPLICATION_ID, ApplicationTable.TABLE, ApplicationTable.COLUMN_ADDRESS_ID, ApplicationTable.COLUMN_IS_ADDRESS);
|
||||
|
||||
Object[] params = new Object[] {addressId, true};
|
||||
try (ResultSet rs = client.executeQuery(sql, params)) {
|
||||
if (rs.next()) {
|
||||
return rs.getInt(1);
|
||||
}
|
||||
} catch (SQLException | H2ClientException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,18 +16,17 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.collector.storage.h2.dao;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.apache.skywalking.apm.collector.client.h2.H2Client;
|
||||
import org.apache.skywalking.apm.collector.client.h2.H2ClientException;
|
||||
import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.IApplicationRegisterDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO;
|
||||
import org.apache.skywalking.apm.collector.storage.table.register.Application;
|
||||
import org.apache.skywalking.apm.collector.storage.table.register.ApplicationTable;
|
||||
import org.apache.skywalking.apm.collector.client.h2.H2ClientException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
|
@ -59,6 +58,8 @@ public class ApplicationH2RegisterDAO extends H2DAO implements IApplicationRegis
|
|||
source.put(ApplicationTable.COLUMN_ID, application.getId());
|
||||
source.put(ApplicationTable.COLUMN_APPLICATION_CODE, application.getApplicationCode());
|
||||
source.put(ApplicationTable.COLUMN_APPLICATION_ID, application.getApplicationId());
|
||||
source.put(ApplicationTable.COLUMN_ADDRESS_ID, application.getAddressId());
|
||||
source.put(ApplicationTable.COLUMN_IS_ADDRESS, application.getIsAddress());
|
||||
|
||||
String sql = SqlBuilder.buildBatchInsertSql(ApplicationTable.TABLE, source.keySet());
|
||||
Object[] params = source.values().toArray(new Object[0]);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.collector.storage.h2.dao;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
|
|
@ -38,14 +37,14 @@ public class InstanceH2CacheDAO extends H2DAO implements IInstanceCacheDAO {
|
|||
private final Logger logger = LoggerFactory.getLogger(InstanceH2CacheDAO.class);
|
||||
|
||||
private static final String GET_APPLICATION_ID_SQL = "select {0} from {1} where {2} = ?";
|
||||
private static final String GET_INSTANCE_ID_SQL = "select {0} from {1} where {2} = ? and {3} = ?";
|
||||
private static final String GET_INSTANCE_ID_SQL = "select {0} from {1} where {2} = ? and {3} = ? and {4} = ?";
|
||||
|
||||
public InstanceH2CacheDAO(H2Client client) {
|
||||
super(client);
|
||||
}
|
||||
|
||||
@Override public int getApplicationId(int instanceId) {
|
||||
logger.info("get the application getId with application getId = {}", instanceId);
|
||||
logger.info("get the application id by instance id = {}", instanceId);
|
||||
H2Client client = getClient();
|
||||
String sql = SqlBuilder.buildSql(GET_APPLICATION_ID_SQL, InstanceTable.COLUMN_APPLICATION_ID, InstanceTable.TABLE, InstanceTable.COLUMN_INSTANCE_ID);
|
||||
Object[] params = new Object[] {instanceId};
|
||||
|
|
@ -59,12 +58,28 @@ public class InstanceH2CacheDAO extends H2DAO implements IInstanceCacheDAO {
|
|||
return 0;
|
||||
}
|
||||
|
||||
@Override public int getInstanceId(int applicationId, String agentUUID) {
|
||||
logger.info("get the application getId with application getId = {}, agentUUID = {}", applicationId, agentUUID);
|
||||
@Override public int getInstanceIdByAgentUUID(int applicationId, String agentUUID) {
|
||||
logger.info("get the instance id by application id = {}, agentUUID = {}", applicationId, agentUUID);
|
||||
H2Client client = getClient();
|
||||
String sql = SqlBuilder.buildSql(GET_INSTANCE_ID_SQL, InstanceTable.COLUMN_INSTANCE_ID, InstanceTable.TABLE, InstanceTable.COLUMN_APPLICATION_ID,
|
||||
InstanceTable.COLUMN_AGENT_UUID);
|
||||
Object[] params = new Object[] {applicationId, agentUUID};
|
||||
InstanceTable.COLUMN_AGENT_UUID, InstanceTable.COLUMN_IS_ADDRESS);
|
||||
Object[] params = new Object[] {applicationId, agentUUID, false};
|
||||
try (ResultSet rs = client.executeQuery(sql, params)) {
|
||||
if (rs.next()) {
|
||||
return rs.getInt(InstanceTable.COLUMN_INSTANCE_ID);
|
||||
}
|
||||
} catch (SQLException | H2ClientException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override public int getInstanceIdByAddressId(int applicationId, int addressId) {
|
||||
logger.info("get the instance id by application id = {}, address id = {}", applicationId, addressId);
|
||||
H2Client client = getClient();
|
||||
String sql = SqlBuilder.buildSql(GET_INSTANCE_ID_SQL, InstanceTable.COLUMN_INSTANCE_ID, InstanceTable.TABLE, InstanceTable.COLUMN_APPLICATION_ID,
|
||||
InstanceTable.COLUMN_AGENT_UUID, InstanceTable.COLUMN_IS_ADDRESS);
|
||||
Object[] params = new Object[] {applicationId, addressId, true};
|
||||
try (ResultSet rs = client.executeQuery(sql, params)) {
|
||||
if (rs.next()) {
|
||||
return rs.getInt(InstanceTable.COLUMN_INSTANCE_ID);
|
||||
|
|
|
|||
|
|
@ -16,18 +16,17 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.collector.storage.h2.dao;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.apache.skywalking.apm.collector.client.h2.H2Client;
|
||||
import org.apache.skywalking.apm.collector.client.h2.H2ClientException;
|
||||
import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder;
|
||||
import org.apache.skywalking.apm.collector.storage.dao.IInstanceRegisterDAO;
|
||||
import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO;
|
||||
import org.apache.skywalking.apm.collector.storage.table.register.Instance;
|
||||
import org.apache.skywalking.apm.collector.storage.table.register.InstanceTable;
|
||||
import org.apache.skywalking.apm.collector.client.h2.H2ClientException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
|
@ -35,7 +34,7 @@ import org.slf4j.LoggerFactory;
|
|||
* @author peng-yongsheng, clevertension
|
||||
*/
|
||||
public class InstanceH2RegisterDAO extends H2DAO implements IInstanceRegisterDAO {
|
||||
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(InstanceH2RegisterDAO.class);
|
||||
|
||||
public InstanceH2RegisterDAO(H2Client client) {
|
||||
|
|
@ -62,6 +61,9 @@ public class InstanceH2RegisterDAO extends H2DAO implements IInstanceRegisterDAO
|
|||
source.put(InstanceTable.COLUMN_REGISTER_TIME, instance.getRegisterTime());
|
||||
source.put(InstanceTable.COLUMN_HEARTBEAT_TIME, instance.getHeartBeatTime());
|
||||
source.put(InstanceTable.COLUMN_OS_INFO, instance.getOsInfo());
|
||||
source.put(InstanceTable.COLUMN_ADDRESS_ID, instance.getAddressId());
|
||||
source.put(InstanceTable.COLUMN_IS_ADDRESS, instance.getIsAddress());
|
||||
|
||||
String sql = SqlBuilder.buildBatchInsertSql(InstanceTable.TABLE, source.keySet());
|
||||
Object[] params = source.values().toArray(new Object[0]);
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -16,11 +16,10 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.collector.storage.h2.define;
|
||||
|
||||
import org.apache.skywalking.apm.collector.storage.h2.base.define.H2TableDefine;
|
||||
import org.apache.skywalking.apm.collector.storage.h2.base.define.H2ColumnDefine;
|
||||
import org.apache.skywalking.apm.collector.storage.h2.base.define.H2TableDefine;
|
||||
import org.apache.skywalking.apm.collector.storage.table.register.ApplicationTable;
|
||||
|
||||
/**
|
||||
|
|
@ -36,5 +35,7 @@ public class ApplicationH2TableDefine extends H2TableDefine {
|
|||
addColumn(new H2ColumnDefine(ApplicationTable.COLUMN_ID, H2ColumnDefine.Type.Varchar.name()));
|
||||
addColumn(new H2ColumnDefine(ApplicationTable.COLUMN_APPLICATION_CODE, H2ColumnDefine.Type.Varchar.name()));
|
||||
addColumn(new H2ColumnDefine(ApplicationTable.COLUMN_APPLICATION_ID, H2ColumnDefine.Type.Int.name()));
|
||||
addColumn(new H2ColumnDefine(ApplicationTable.COLUMN_ADDRESS_ID, H2ColumnDefine.Type.Int.name()));
|
||||
addColumn(new H2ColumnDefine(ApplicationTable.COLUMN_IS_ADDRESS, H2ColumnDefine.Type.Boolean.name()));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,12 +16,11 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.collector.storage.h2.define;
|
||||
|
||||
import org.apache.skywalking.apm.collector.storage.h2.base.define.H2ColumnDefine;
|
||||
import org.apache.skywalking.apm.collector.storage.h2.base.define.H2TableDefine;
|
||||
import org.apache.skywalking.apm.collector.storage.table.register.InstanceTable;
|
||||
import org.apache.skywalking.apm.collector.storage.h2.base.define.H2ColumnDefine;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
|
|
@ -40,5 +39,7 @@ public class InstanceH2TableDefine extends H2TableDefine {
|
|||
addColumn(new H2ColumnDefine(InstanceTable.COLUMN_INSTANCE_ID, H2ColumnDefine.Type.Int.name()));
|
||||
addColumn(new H2ColumnDefine(InstanceTable.COLUMN_HEARTBEAT_TIME, H2ColumnDefine.Type.Bigint.name()));
|
||||
addColumn(new H2ColumnDefine(InstanceTable.COLUMN_OS_INFO, H2ColumnDefine.Type.Varchar.name()));
|
||||
addColumn(new H2ColumnDefine(InstanceTable.COLUMN_ADDRESS_ID, H2ColumnDefine.Type.Int.name()));
|
||||
addColumn(new H2ColumnDefine(InstanceTable.COLUMN_IS_ADDRESS, H2ColumnDefine.Type.Boolean.name()));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ public class ApplicationsGetHandler extends JettyHandler {
|
|||
|
||||
String startTimeStr = req.getParameter("startTime");
|
||||
String endTimeStr = req.getParameter("endTime");
|
||||
logger.debug("applications getApplicationId start time: {}, end time: {}", startTimeStr, endTimeStr);
|
||||
logger.debug("applications getApplicationIdByCode start time: {}, end time: {}", startTimeStr, endTimeStr);
|
||||
|
||||
long startTime;
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ public class InstanceHealthGetHandler extends JettyHandler {
|
|||
@Override protected JsonElement doGet(HttpServletRequest req) throws ArgumentsParseException {
|
||||
String timeBucketStr = req.getParameter("timeBucket");
|
||||
String[] applicationIdsStr = req.getParameterValues("applicationIds");
|
||||
logger.debug("instance health getApplicationId timeBucket: {}, applicationIdsStr: {}", timeBucketStr, applicationIdsStr);
|
||||
logger.debug("instance health getApplicationIdByCode timeBucket: {}, applicationIdsStr: {}", timeBucketStr, applicationIdsStr);
|
||||
|
||||
long timeBucket;
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ public class InstanceMetricGetOneTimeBucketHandler extends JettyHandler {
|
|||
String instanceIdStr = req.getParameter("instanceId");
|
||||
String[] metricTypes = req.getParameterValues("metricTypes");
|
||||
|
||||
logger.debug("instance jvm metric getApplicationId timeBucket: {}, instance id: {}, metric types: {}", timeBucketStr, instanceIdStr, metricTypes);
|
||||
logger.debug("instance jvm metric getApplicationIdByCode timeBucket: {}, instance id: {}, metric types: {}", timeBucketStr, instanceIdStr, metricTypes);
|
||||
|
||||
long timeBucket;
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ public class InstanceMetricGetRangeTimeBucketHandler extends JettyHandler {
|
|||
String instanceIdStr = req.getParameter("instanceId");
|
||||
String[] metricTypes = req.getParameterValues("metricTypes");
|
||||
|
||||
logger.debug("instance jvm metric getApplicationId start timeBucket: {}, end timeBucket:{} , instance id: {}, metric types: {}", startTimeBucketStr, endTimeBucketStr, instanceIdStr, metricTypes);
|
||||
logger.debug("instance jvm metric getApplicationIdByCode start timeBucket: {}, end timeBucket:{} , instance id: {}, metric types: {}", startTimeBucketStr, endTimeBucketStr, instanceIdStr, metricTypes);
|
||||
|
||||
long startTimeBucket;
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ public class InstanceOsInfoGetHandler extends JettyHandler {
|
|||
|
||||
@Override protected JsonElement doGet(HttpServletRequest req) throws ArgumentsParseException {
|
||||
String instanceIdStr = req.getParameter("instanceId");
|
||||
logger.debug("instance os info getApplicationId, instance id: {}", instanceIdStr);
|
||||
logger.debug("instance os info getApplicationIdByCode, instance id: {}", instanceIdStr);
|
||||
|
||||
int instanceId;
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ public class EntryServiceGetHandler extends JettyHandler {
|
|||
String endTimeStr = req.getParameter("endTime");
|
||||
String fromStr = req.getParameter("from");
|
||||
String sizeStr = req.getParameter("size");
|
||||
logger.debug("service entry getApplicationId applicationId: {}, entryServiceName: {}, startTime: {}, endTime: {}, from: {}, size: {}", applicationIdStr, entryServiceName, startTimeStr, endTimeStr, fromStr, sizeStr);
|
||||
logger.debug("service entry getApplicationIdByCode applicationId: {}, entryServiceName: {}, startTime: {}, endTime: {}, from: {}, size: {}", applicationIdStr, entryServiceName, startTimeStr, endTimeStr, fromStr, sizeStr);
|
||||
|
||||
int applicationId;
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ public class ServiceTreeGetByIdHandler extends JettyHandler {
|
|||
String entryServiceIdStr = req.getParameter("entryServiceId");
|
||||
String startTimeStr = req.getParameter("startTime");
|
||||
String endTimeStr = req.getParameter("endTime");
|
||||
logger.debug("service entry getApplicationId entryServiceId: {}, startTime: {}, endTime: {}", entryServiceIdStr, startTimeStr, endTimeStr);
|
||||
logger.debug("service entry getApplicationIdByCode entryServiceId: {}, startTime: {}, endTime: {}", entryServiceIdStr, startTimeStr, endTimeStr);
|
||||
|
||||
int entryServiceId;
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public class ApplicationService {
|
|||
applications.forEach(jsonElement -> {
|
||||
JsonObject application = jsonElement.getAsJsonObject();
|
||||
int applicationId = application.get("applicationId").getAsInt();
|
||||
String applicationCode = applicationCacheService.get(applicationId);
|
||||
String applicationCode = applicationCacheService.getApplicationCodeById(applicationId);
|
||||
application.addProperty("applicationCode", applicationCode);
|
||||
});
|
||||
return applications;
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ public class InstanceHealthService {
|
|||
response.add("instances", instances);
|
||||
|
||||
instanceList.forEach(instance -> {
|
||||
response.addProperty("applicationCode", applicationCacheService.get(applicationId));
|
||||
response.addProperty("applicationCode", applicationCacheService.getApplicationCodeById(applicationId));
|
||||
response.addProperty("applicationId", applicationId);
|
||||
|
||||
IInstanceMetricUIDAO.InstanceMetric performance = instanceMetricUIDAO.get(timeBuckets, instance.getInstanceId());
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ public class ServiceTreeService {
|
|||
for (JsonElement element : entryServices) {
|
||||
JsonObject entryService = element.getAsJsonObject();
|
||||
int respApplication = entryService.get(ColumnNameUtils.INSTANCE.rename(ServiceEntryTable.COLUMN_APPLICATION_ID)).getAsInt();
|
||||
String applicationCode = applicationCacheService.get(respApplication);
|
||||
String applicationCode = applicationCacheService.getApplicationCodeById(respApplication);
|
||||
entryService.addProperty("applicationCode", applicationCode);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ public class SpanService {
|
|||
if (spanObject.getPeerId() == 0) {
|
||||
peerJson.addProperty("value", spanObject.getPeer());
|
||||
} else {
|
||||
peerJson.addProperty("value", applicationCacheService.get(spanObject.getPeerId()));
|
||||
peerJson.addProperty("value", applicationCacheService.getApplicationCodeById(spanObject.getPeerId()));
|
||||
}
|
||||
tagsArray.add(peerJson);
|
||||
|
||||
|
|
|
|||
|
|
@ -108,9 +108,9 @@ public class TraceDagDataBuilder {
|
|||
for (int i = 0; i < nodesMappingArray.size(); i++) {
|
||||
JsonObject nodesMappingJsonObj = nodesMappingArray.get(i).getAsJsonObject();
|
||||
int applicationId = nodesMappingJsonObj.get(ApplicationMappingTable.COLUMN_APPLICATION_ID).getAsInt();
|
||||
String applicationCode = applicationCacheService.get(applicationId);
|
||||
String applicationCode = applicationCacheService.getApplicationCodeById(applicationId);
|
||||
int addressId = nodesMappingJsonObj.get(ApplicationMappingTable.COLUMN_ADDRESS_ID).getAsInt();
|
||||
String address = applicationCacheService.get(addressId);
|
||||
String address = applicationCacheService.getApplicationCodeById(addressId);
|
||||
mappingMap.put(address, applicationCode);
|
||||
}
|
||||
}
|
||||
|
|
@ -122,7 +122,7 @@ public class TraceDagDataBuilder {
|
|||
int componentId = nodesJsonObj.get(ApplicationComponentTable.COLUMN_COMPONENT_ID).getAsInt();
|
||||
String componentName = ComponentsDefine.getInstance().getComponentName(componentId);
|
||||
int peerId = nodesJsonObj.get(ApplicationComponentTable.COLUMN_PEER_ID).getAsInt();
|
||||
String peer = applicationCacheService.get(peerId);
|
||||
String peer = applicationCacheService.getApplicationCodeById(peerId);
|
||||
nodeCompMap.put(peer, componentName);
|
||||
}
|
||||
}
|
||||
|
|
@ -139,8 +139,8 @@ public class TraceDagDataBuilder {
|
|||
int frontApplicationId = nodeRefJsonObj.get(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID)).getAsInt();
|
||||
int behindApplicationId = nodeRefJsonObj.get(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID)).getAsInt();
|
||||
|
||||
String front = applicationCacheService.get(frontApplicationId);
|
||||
String behind = applicationCacheService.get(behindApplicationId);
|
||||
String front = applicationCacheService.getApplicationCodeById(frontApplicationId);
|
||||
String behind = applicationCacheService.getApplicationCodeById(behindApplicationId);
|
||||
|
||||
String id = front + Const.ID_SPLIT + behind;
|
||||
nodeRefJsonObj.addProperty("front", front);
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ public class TraceStackService {
|
|||
operationName = Const.EMPTY_STRING;
|
||||
}
|
||||
}
|
||||
String applicationCode = applicationCacheService.get(segment.getApplicationId());
|
||||
String applicationCode = applicationCacheService.getApplicationCodeById(segment.getApplicationId());
|
||||
|
||||
long cost = spanObject.getEndTime() - spanObject.getStartTime();
|
||||
if (cost == 0) {
|
||||
|
|
@ -149,9 +149,9 @@ public class TraceStackService {
|
|||
// StringBuilder segmentIdBuilder = new StringBuilder();
|
||||
// for (int i = 0; i < uniqueId.getIdPartsList().size(); i++) {
|
||||
// if (i == 0) {
|
||||
// segmentIdBuilder.append(String.valueOf(uniqueId.getIdPartsList().getApplicationId(i)));
|
||||
// segmentIdBuilder.append(String.valueOf(uniqueId.getIdPartsList().getApplicationIdByCode(i)));
|
||||
// } else {
|
||||
// segmentIdBuilder.append(".").append(String.valueOf(uniqueId.getIdPartsList().getApplicationId(i)));
|
||||
// segmentIdBuilder.append(".").append(String.valueOf(uniqueId.getIdPartsList().getApplicationIdByCode(i)));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
|
|
|
|||
Loading…
Reference in New Issue