wu-sheng closed pull request #1874: Add detect point to be a part of unique key
of the endpoint id.
URL: https://github.com/apache/incubator-skywalking/pull/1874
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/cache/EndpointInventoryCache.java
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/cache/EndpointInventoryCache.java
index eb178a4ea..7fee3bbf5 100644
---
a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/cache/EndpointInventoryCache.java
+++
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/cache/EndpointInventoryCache.java
@@ -60,13 +60,13 @@ private IEndpointInventoryCacheDAO getCacheDAO() {
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);
}
diff --git
a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/register/EndpointInventory.java
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/register/EndpointInventory.java
index 3d330f86e..bb9eb3676 100644
---
a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/register/EndpointInventory.java
+++
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/register/EndpointInventory.java
@@ -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 @@
@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 static String buildId(int serviceId, String
endpointName) {
return false;
if (!name.equals(source.getName()))
return false;
+ if (detectPoint != source.getDetectPoint())
+ return false;
return true;
}
diff --git
a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/register/service/EndpointInventoryRegister.java
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/register/service/EndpointInventoryRegister.java
index eb361f5c0..5a000a6be 100644
---
a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/register/service/EndpointInventoryRegister.java
+++
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/register/service/EndpointInventoryRegister.java
@@ -51,7 +51,7 @@ private EndpointInventoryCache getCacheService() {
}
@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 @@ private EndpointInventoryCache getCacheService() {
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) {
diff --git
a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/register/service/IEndpointInventoryRegister.java
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/register/service/IEndpointInventoryRegister.java
index 2a7146145..6088cc93d 100644
---
a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/register/service/IEndpointInventoryRegister.java
+++
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/register/service/IEndpointInventoryRegister.java
@@ -28,7 +28,7 @@
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);
}
diff --git
a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/cache/IEndpointInventoryCacheDAO.java
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/cache/IEndpointInventoryCacheDAO.java
index d07aeb14a..3197ac6f0 100644
---
a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/cache/IEndpointInventoryCacheDAO.java
+++
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/cache/IEndpointInventoryCacheDAO.java
@@ -26,7 +26,7 @@
*/
public interface IEndpointInventoryCacheDAO extends DAO {
- int getEndpointId(int serviceId, String endpointName);
+ int getEndpointId(int serviceId, String endpointName, int detectPoint);
EndpointInventory get(int endpointId);
}
diff --git
a/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/standardization/ReferenceIdExchanger.java
b/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/standardization/ReferenceIdExchanger.java
index 5cfd58f98..3fd93ea76 100644
---
a/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/standardization/ReferenceIdExchanger.java
+++
b/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/standardization/ReferenceIdExchanger.java
@@ -21,6 +21,7 @@
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 @@ private ReferenceIdExchanger(ModuleManager moduleManager) {
@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 @@ private ReferenceIdExchanger(ModuleManager moduleManager) {
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()) {
diff --git
a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/cache/EndpointInventoryCacheEsDAO.java
b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/cache/EndpointInventoryCacheEsDAO.java
index df187ed3c..e79ea0a33 100644
---
a/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/cache/EndpointInventoryCacheEsDAO.java
+++
b/oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/cache/EndpointInventoryCacheEsDAO.java
@@ -43,9 +43,9 @@ public EndpointInventoryCacheEsDAO(ElasticSearchClient
client) {
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);
diff --git
a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2EndpointInventoryCacheDAO.java
b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2EndpointInventoryCacheDAO.java
index 7f423ace1..e6d5d9c1b 100644
---
a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2EndpointInventoryCacheDAO.java
+++
b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/h2/dao/H2EndpointInventoryCacheDAO.java
@@ -22,8 +22,7 @@
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 H2EndpointInventoryCacheDAO(JDBCHikariCPClient
h2Client) {
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);
}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services