Add detect point to be a part of unique key of the endpoint id. (#1874)
This commit is contained in:
parent
e9d4c52a03
commit
884dd8c59e
|
|
@ -60,13 +60,13 @@ public class EndpointInventoryCache implements Service {
|
|||
return cacheDAO;
|
||||
}
|
||||
|
||||
public int getEndpointId(int serviceId, String endpointName) {
|
||||
String id = EndpointInventory.buildId(serviceId, endpointName);
|
||||
public int getEndpointId(int serviceId, String endpointName, int detectPoint) {
|
||||
String id = EndpointInventory.buildId(serviceId, endpointName, detectPoint);
|
||||
|
||||
Integer endpointId = endpointNameCache.getIfPresent(id);
|
||||
|
||||
if (Objects.isNull(endpointId) || endpointId == Const.NONE) {
|
||||
endpointId = getCacheDAO().getEndpointId(serviceId, endpointName);
|
||||
endpointId = getCacheDAO().getEndpointId(serviceId, endpointName, detectPoint);
|
||||
if (endpointId != Const.NONE) {
|
||||
endpointNameCache.put(id, endpointId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,18 +18,15 @@
|
|||
|
||||
package org.apache.skywalking.oap.server.core.register;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import java.util.*;
|
||||
import lombok.*;
|
||||
import org.apache.skywalking.oap.server.core.Const;
|
||||
import org.apache.skywalking.oap.server.core.register.annotation.InventoryType;
|
||||
import org.apache.skywalking.oap.server.core.remote.annotation.StreamData;
|
||||
import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData;
|
||||
import org.apache.skywalking.oap.server.core.source.Scope;
|
||||
import org.apache.skywalking.oap.server.core.storage.StorageBuilder;
|
||||
import org.apache.skywalking.oap.server.core.storage.annotation.Column;
|
||||
import org.apache.skywalking.oap.server.core.storage.annotation.StorageEntity;
|
||||
import org.apache.skywalking.oap.server.core.storage.annotation.*;
|
||||
import org.apache.skywalking.oap.server.library.util.StringUtils;
|
||||
|
||||
/**
|
||||
|
|
@ -50,18 +47,19 @@ public class EndpointInventory extends RegisterSource {
|
|||
@Setter @Getter @Column(columnName = NAME, matchQuery = true) private String name = Const.EMPTY_STRING;
|
||||
@Setter @Getter @Column(columnName = DETECT_POINT) private int detectPoint;
|
||||
|
||||
public static String buildId(int serviceId, String endpointName) {
|
||||
return serviceId + Const.ID_SPLIT + endpointName;
|
||||
public static String buildId(int serviceId, String endpointName, int detectPoint) {
|
||||
return serviceId + Const.ID_SPLIT + endpointName + Const.ID_SPLIT + detectPoint;
|
||||
}
|
||||
|
||||
@Override public String id() {
|
||||
return buildId(serviceId, name);
|
||||
return buildId(serviceId, name, detectPoint);
|
||||
}
|
||||
|
||||
@Override public int hashCode() {
|
||||
int result = 17;
|
||||
result = 31 * result + serviceId;
|
||||
result = 31 * result + name.hashCode();
|
||||
result = 31 * result + detectPoint;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -78,6 +76,8 @@ public class EndpointInventory extends RegisterSource {
|
|||
return false;
|
||||
if (!name.equals(source.getName()))
|
||||
return false;
|
||||
if (detectPoint != source.getDetectPoint())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ public class EndpointInventoryRegister implements IEndpointInventoryRegister {
|
|||
}
|
||||
|
||||
@Override public int getOrCreate(int serviceId, String endpointName, DetectPoint detectPoint) {
|
||||
int endpointId = getCacheService().getEndpointId(serviceId, endpointName);
|
||||
int endpointId = getCacheService().getEndpointId(serviceId, endpointName, detectPoint.ordinal());
|
||||
|
||||
if (endpointId == Const.NONE) {
|
||||
EndpointInventory endpointInventory = new EndpointInventory();
|
||||
|
|
@ -68,8 +68,8 @@ public class EndpointInventoryRegister implements IEndpointInventoryRegister {
|
|||
return endpointId;
|
||||
}
|
||||
|
||||
@Override public int get(int serviceId, String endpointName) {
|
||||
return getCacheService().getEndpointId(serviceId, endpointName);
|
||||
@Override public int get(int serviceId, String endpointName, int detectPoint) {
|
||||
return getCacheService().getEndpointId(serviceId, endpointName, detectPoint);
|
||||
}
|
||||
|
||||
@Override public void heartbeat(int endpointId, long heartBeatTime) {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public interface IEndpointInventoryRegister extends Service {
|
|||
|
||||
int getOrCreate(int serviceId, String endpointName, DetectPoint detectPoint);
|
||||
|
||||
int get(int serviceId, String endpointName);
|
||||
int get(int serviceId, String endpointName, int detectPoint);
|
||||
|
||||
void heartbeat(int endpointId, long heartBeatTime);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ import org.apache.skywalking.oap.server.core.storage.DAO;
|
|||
*/
|
||||
public interface IEndpointInventoryCacheDAO extends DAO {
|
||||
|
||||
int getEndpointId(int serviceId, String endpointName);
|
||||
int getEndpointId(int serviceId, String endpointName, int detectPoint);
|
||||
|
||||
EndpointInventory get(int endpointId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ package org.apache.skywalking.oap.server.receiver.trace.provider.parser.standard
|
|||
import org.apache.skywalking.oap.server.core.*;
|
||||
import org.apache.skywalking.oap.server.core.cache.ServiceInstanceInventoryCache;
|
||||
import org.apache.skywalking.oap.server.core.register.service.*;
|
||||
import org.apache.skywalking.oap.server.core.source.DetectPoint;
|
||||
import org.apache.skywalking.oap.server.library.module.ModuleManager;
|
||||
import org.apache.skywalking.oap.server.library.util.StringUtils;
|
||||
import org.apache.skywalking.oap.server.receiver.trace.provider.parser.decorator.ReferenceDecorator;
|
||||
|
|
@ -54,7 +55,7 @@ public class ReferenceIdExchanger implements IdExchanger<ReferenceDecorator> {
|
|||
@Override public boolean exchange(ReferenceDecorator standardBuilder, int serviceId) {
|
||||
if (standardBuilder.getEntryServiceId() == 0) {
|
||||
String entryEndpointName = StringUtils.isNotEmpty(standardBuilder.getEntryServiceName()) ? standardBuilder.getEntryServiceName() : Const.DOMAIN_OPERATION_NAME;
|
||||
int entryEndpointId = endpointInventoryRegister.get(serviceInstanceInventoryCache.get(standardBuilder.getEntryApplicationInstanceId()).getServiceId(), entryEndpointName);
|
||||
int entryEndpointId = endpointInventoryRegister.get(serviceInstanceInventoryCache.get(standardBuilder.getEntryApplicationInstanceId()).getServiceId(), entryEndpointName, DetectPoint.SERVER.ordinal());
|
||||
|
||||
if (entryEndpointId == 0) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
|
|
@ -71,7 +72,7 @@ public class ReferenceIdExchanger implements IdExchanger<ReferenceDecorator> {
|
|||
|
||||
if (standardBuilder.getParentServiceId() == 0) {
|
||||
String parentEndpointName = StringUtils.isNotEmpty(standardBuilder.getParentServiceName()) ? standardBuilder.getParentServiceName() : Const.DOMAIN_OPERATION_NAME;
|
||||
int parentEndpointId = endpointInventoryRegister.get(serviceInstanceInventoryCache.get(standardBuilder.getParentApplicationInstanceId()).getServiceId(), parentEndpointName);
|
||||
int parentEndpointId = endpointInventoryRegister.get(serviceInstanceInventoryCache.get(standardBuilder.getParentApplicationInstanceId()).getServiceId(), parentEndpointName, DetectPoint.SERVER.ordinal());
|
||||
|
||||
if (parentEndpointId == 0) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
|
|
|
|||
|
|
@ -43,9 +43,9 @@ public class EndpointInventoryCacheEsDAO extends EsDAO implements IEndpointInven
|
|||
super(client);
|
||||
}
|
||||
|
||||
@Override public int getEndpointId(int serviceId, String endpointName) {
|
||||
@Override public int getEndpointId(int serviceId, String endpointName, int detectPoint) {
|
||||
try {
|
||||
String id = EndpointInventory.buildId(serviceId, endpointName);
|
||||
String id = EndpointInventory.buildId(serviceId, endpointName, detectPoint);
|
||||
GetResponse response = getClient().get(EndpointInventory.MODEL_NAME, id);
|
||||
if (response.isExists()) {
|
||||
return (int)response.getSource().getOrDefault(RegisterSource.SEQUENCE, 0);
|
||||
|
|
|
|||
|
|
@ -22,8 +22,7 @@ import java.io.IOException;
|
|||
import org.apache.skywalking.oap.server.core.register.EndpointInventory;
|
||||
import org.apache.skywalking.oap.server.core.storage.cache.IEndpointInventoryCacheDAO;
|
||||
import org.apache.skywalking.oap.server.library.client.jdbc.hikaricp.JDBCHikariCPClient;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.slf4j.*;
|
||||
|
||||
/**
|
||||
* @author wusheng
|
||||
|
|
@ -36,8 +35,8 @@ public class H2EndpointInventoryCacheDAO extends H2SQLExecutor implements IEndpo
|
|||
this.h2Client = h2Client;
|
||||
}
|
||||
|
||||
@Override public int getEndpointId(int serviceId, String endpointName) {
|
||||
String id = EndpointInventory.buildId(serviceId, endpointName);
|
||||
@Override public int getEndpointId(int serviceId, String endpointName, int detectPoint) {
|
||||
String id = EndpointInventory.buildId(serviceId, endpointName, detectPoint);
|
||||
return getEntityIDByID(h2Client, EndpointInventory.SEQUENCE, EndpointInventory.MODEL_NAME, id);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue