You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by li...@apache.org on 2018/01/26 01:24:37 UTC

[incubator-servicecomb-java-chassis] branch master updated (86ab2ec -> 8e84b30)

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

liubao pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-java-chassis.git.


    from 86ab2ec  [SCB-177] add traceId element in access log
     new 0c77d0b  [SCB-297] The local cache is not update when the server reboots between different application
     new 8e84b30  [SCB-297] The local cache is not update when the server reboots between different application

The 2 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.


Summary of changes:
 .../consumer/MicroserviceVersions.java             | 12 ++++--
 .../consumer/TestMicroserviceVersions.java         | 49 +++++++++++++++++++++-
 2 files changed, 57 insertions(+), 4 deletions(-)

-- 
To stop receiving notification emails like this one, please contact
liubao@apache.org.

[incubator-servicecomb-java-chassis] 02/02: [SCB-297] The local cache is not update when the server reboots between different application

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

liubao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-java-chassis.git

commit 8e84b30ad678eed7616d2fc38540feaf66d579f2
Author: laijianbin <la...@huawei.com>
AuthorDate: Thu Jan 25 16:49:12 2018 +0800

    [SCB-297] The local cache is not update when the server reboots between different application
---
 .../consumer/TestMicroserviceVersions.java         | 56 ++++++++++++++++------
 1 file changed, 41 insertions(+), 15 deletions(-)

diff --git a/service-registry/src/test/java/org/apache/servicecomb/serviceregistry/consumer/TestMicroserviceVersions.java b/service-registry/src/test/java/org/apache/servicecomb/serviceregistry/consumer/TestMicroserviceVersions.java
index 1920bc3..be1e8c7 100644
--- a/service-registry/src/test/java/org/apache/servicecomb/serviceregistry/consumer/TestMicroserviceVersions.java
+++ b/service-registry/src/test/java/org/apache/servicecomb/serviceregistry/consumer/TestMicroserviceVersions.java
@@ -290,27 +290,53 @@ public class TestMicroserviceVersions {
     };
 
     microserviceVersions.safeSetInstances(null, null);
-    
+
     Assert.assertEquals(1, pendingPullCount.get());
   }
-  
+
+  public void checkIsEventAccept(MicroserviceKey key, boolean expected) {
+
+    MicroserviceInstanceChangedEvent changeEvent = new MicroserviceInstanceChangedEvent();
+    changeEvent.setKey(key);
+    boolean isEventAccept = microserviceVersions.isEventAccept(changeEvent);
+    Assert.assertEquals(expected, isEventAccept);
+  }
+
   @Test
-  public void  testIsEventAccept(){
+  public void testIsEventAccept() {
     MicroserviceKey key = new MicroserviceKey();
+
     key.setAppId(appId);
     key.setServiceName(microserviceName);
-    MicroserviceInstanceChangedEvent changeEvent = new MicroserviceInstanceChangedEvent();
-    changeEvent.setKey(key);
-    boolean isEventAccept = microserviceVersions.isEventAccept(changeEvent);
-    Assert.assertEquals(true, isEventAccept);
-    
-    microserviceVersions = new MicroserviceVersions(appManager, appId, appId+Const.APP_SERVICE_SEPARATOR+microserviceName);
+    checkIsEventAccept(key, true);
+
+    key.setServiceName("falseMicroserviceName");
+    checkIsEventAccept(key, false);
+
+    key.setAppId("falseAppId");
+    checkIsEventAccept(key, false);
+
+    key.setServiceName(microserviceName);
+    checkIsEventAccept(key, false);
+
+
     key.setAppId(appId);
-    key.setServiceName(appId+Const.APP_SERVICE_SEPARATOR+microserviceName);
-    changeEvent.setKey(key);
-    boolean isEventAcceptWhenAccrossApp = microserviceVersions.isEventAccept(changeEvent);
-    Assert.assertEquals(true, isEventAcceptWhenAccrossApp);
-    
-  }
+    key.setServiceName(appId + Const.APP_SERVICE_SEPARATOR + microserviceName);
+
+    microserviceVersions =
+        new MicroserviceVersions(appManager, appId, appId + Const.APP_SERVICE_SEPARATOR + microserviceName);
+    checkIsEventAccept(key, true);
 
+    microserviceVersions =
+        new MicroserviceVersions(appManager, "falseAppId", appId + Const.APP_SERVICE_SEPARATOR + microserviceName);
+    checkIsEventAccept(key, false);
+
+    microserviceVersions = new MicroserviceVersions(appManager, "falseAppId",
+        "false" + appId + Const.APP_SERVICE_SEPARATOR + microserviceName);
+    checkIsEventAccept(key, false);
+
+    microserviceVersions =
+        new MicroserviceVersions(appManager, appId, "false" + appId + Const.APP_SERVICE_SEPARATOR + microserviceName);
+    checkIsEventAccept(key, false);
+  }
 }

-- 
To stop receiving notification emails like this one, please contact
liubao@apache.org.

[incubator-servicecomb-java-chassis] 01/02: [SCB-297] The local cache is not update when the server reboots between different application

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

liubao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-java-chassis.git

commit 0c77d0b80b3e06f6060179fe459ee6dc366c42f5
Author: laijianbin <la...@huawei.com>
AuthorDate: Thu Jan 25 11:49:05 2018 +0800

    [SCB-297] The local cache is not update when the server reboots between different application
---
 .../consumer/MicroserviceVersions.java              | 12 +++++++++---
 .../consumer/TestMicroserviceVersions.java          | 21 +++++++++++++++++++++
 2 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/consumer/MicroserviceVersions.java b/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/consumer/MicroserviceVersions.java
index 8a712bb..f26ee05 100644
--- a/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/consumer/MicroserviceVersions.java
+++ b/service-registry/src/main/java/org/apache/servicecomb/serviceregistry/consumer/MicroserviceVersions.java
@@ -25,6 +25,7 @@ import java.util.stream.Collectors;
 
 import org.apache.servicecomb.foundation.common.concurrent.ConcurrentHashMapEx;
 import org.apache.servicecomb.serviceregistry.RegistryUtils;
+import org.apache.servicecomb.serviceregistry.api.Const;
 import org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance;
 import org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstanceStatus;
 import org.apache.servicecomb.serviceregistry.api.response.MicroserviceInstanceChangedEvent;
@@ -195,11 +196,9 @@ public class MicroserviceVersions {
 
   @Subscribe
   public void onMicroserviceInstanceChanged(MicroserviceInstanceChangedEvent changedEvent) {
-    if (!appId.equals(changedEvent.getKey().getAppId()) ||
-        !microserviceName.equals(changedEvent.getKey().getServiceName())) {
+    if (!isEventAccept(changedEvent)) {
       return;
     }
-
     // pull instances always replace old instances, not append
     //
     // pull result and watch event sequence is not defined even inside SC.
@@ -213,4 +212,11 @@ public class MicroserviceVersions {
     //   black/white config in SC changed, we must refresh all data from sc.
     postPullInstanceEvent(TimeUnit.MILLISECONDS.toMillis(1));
   }
+  
+  protected boolean isEventAccept(MicroserviceInstanceChangedEvent changedEvent) {
+    return (appId.equals(changedEvent.getKey().getAppId()) &&
+        microserviceName.equals(changedEvent.getKey().getServiceName())) ||
+        microserviceName.equals(
+            changedEvent.getKey().getAppId() + Const.APP_SERVICE_SEPARATOR + changedEvent.getKey().getServiceName());
+  }
 }
diff --git a/service-registry/src/test/java/org/apache/servicecomb/serviceregistry/consumer/TestMicroserviceVersions.java b/service-registry/src/test/java/org/apache/servicecomb/serviceregistry/consumer/TestMicroserviceVersions.java
index 770318c..1920bc3 100644
--- a/service-registry/src/test/java/org/apache/servicecomb/serviceregistry/consumer/TestMicroserviceVersions.java
+++ b/service-registry/src/test/java/org/apache/servicecomb/serviceregistry/consumer/TestMicroserviceVersions.java
@@ -24,6 +24,7 @@ import java.util.Map;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.servicecomb.serviceregistry.RegistryUtils;
+import org.apache.servicecomb.serviceregistry.api.Const;
 import org.apache.servicecomb.serviceregistry.api.MicroserviceKey;
 import org.apache.servicecomb.serviceregistry.api.registry.Microservice;
 import org.apache.servicecomb.serviceregistry.api.registry.MicroserviceInstance;
@@ -292,4 +293,24 @@ public class TestMicroserviceVersions {
     
     Assert.assertEquals(1, pendingPullCount.get());
   }
+  
+  @Test
+  public void  testIsEventAccept(){
+    MicroserviceKey key = new MicroserviceKey();
+    key.setAppId(appId);
+    key.setServiceName(microserviceName);
+    MicroserviceInstanceChangedEvent changeEvent = new MicroserviceInstanceChangedEvent();
+    changeEvent.setKey(key);
+    boolean isEventAccept = microserviceVersions.isEventAccept(changeEvent);
+    Assert.assertEquals(true, isEventAccept);
+    
+    microserviceVersions = new MicroserviceVersions(appManager, appId, appId+Const.APP_SERVICE_SEPARATOR+microserviceName);
+    key.setAppId(appId);
+    key.setServiceName(appId+Const.APP_SERVICE_SEPARATOR+microserviceName);
+    changeEvent.setKey(key);
+    boolean isEventAcceptWhenAccrossApp = microserviceVersions.isEventAccept(changeEvent);
+    Assert.assertEquals(true, isEventAcceptWhenAccrossApp);
+    
+  }
+
 }

-- 
To stop receiving notification emails like this one, please contact
liubao@apache.org.