You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2018/10/30 09:17:41 UTC

[incubator-skywalking] branch fix-concurrency created (now e63b5ab)

This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a change to branch fix-concurrency
in repository https://gitbox.apache.org/repos/asf/incubator-skywalking.git.


      at e63b5ab  Avoid service inventory object concurrency situation.

This branch includes the following new commits:

     new e63b5ab  Avoid service inventory object concurrency situation.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[incubator-skywalking] 01/01: Avoid service inventory object concurrency situation.

Posted by wu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a commit to branch fix-concurrency
in repository https://gitbox.apache.org/repos/asf/incubator-skywalking.git

commit e63b5ab7b82734cef1d3e3c43dbaf0bcfe2d687f
Author: Wu Sheng <wu...@foxmail.com>
AuthorDate: Tue Oct 30 17:17:30 2018 +0800

    Avoid service inventory object concurrency situation.
---
 .../oap/server/core/register/ServiceInventory.java        | 15 +++++++++++++++
 .../core/register/service/ServiceInventoryRegister.java   |  1 +
 2 files changed, 16 insertions(+)

diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/register/ServiceInventory.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/register/ServiceInventory.java
index c2c2199..7699918 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/register/ServiceInventory.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/register/ServiceInventory.java
@@ -76,6 +76,21 @@ public class ServiceInventory extends RegisterSource {
         return result;
     }
 
+    @Override
+    public ServiceInventory clone() {
+        ServiceInventory inventory = new ServiceInventory();
+        inventory.setSequence(getSequence());
+        inventory.setRegisterTime(getRegisterTime());
+        inventory.setHeartbeatTime(getHeartbeatTime());
+        inventory.setName(name);
+        inventory.setIsAddress(isAddress);
+        inventory.setAddressId(addressId);
+        inventory.setMappingLastUpdateTime(mappingLastUpdateTime);
+        inventory.setMappingServiceId(mappingServiceId);
+
+        return inventory;
+    }
+
     @Override public boolean equals(Object obj) {
         if (this == obj)
             return true;
diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/register/service/ServiceInventoryRegister.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/register/service/ServiceInventoryRegister.java
index 531d3f1..8bc2ac3 100644
--- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/register/service/ServiceInventoryRegister.java
+++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/register/service/ServiceInventoryRegister.java
@@ -103,6 +103,7 @@ public class ServiceInventoryRegister implements IServiceInventoryRegister {
     @Override public void updateMapping(int serviceId, int mappingServiceId) {
         ServiceInventory serviceInventory = getServiceInventoryCache().get(serviceId);
         if (Objects.nonNull(serviceInventory)) {
+            serviceInventory = serviceInventory.clone();
             serviceInventory.setMappingServiceId(mappingServiceId);
             serviceInventory.setMappingLastUpdateTime(System.currentTimeMillis());