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/servicecomb-java-chassis.git


The following commit(s) were added to refs/heads/master by this push:
     new 5afdf71  [SCB-2077] fix instance isolation trying chance not released 
problem (#1936)
5afdf71 is described below

commit 5afdf71abc27011340190dcc7d0c2d6056ecfb15
Author: yhs0092 <[email protected]>
AuthorDate: Tue Sep 8 08:54:12 2020 +0800

    [SCB-2077] fix instance isolation trying chance not released problem (#1936)
---
 .../servicecomb/loadbalance/Configuration.java     | 16 ++++++
 .../loadbalance/LoadbalanceHandler.java            |  5 +-
 .../loadbalance/ServiceCombServerStats.java        | 41 +++++++++++-----
 .../loadbalance/TryingIsolatedServerMarker.java    | 56 +++++++++++++++++++++
 .../filter/IsolationDiscoveryFilter.java           |  8 +--
 .../servicecomb/loadbalance/TestConfiguration.java | 18 ++++++-
 .../loadbalance/TestLoadBalanceHandler2.java       |  8 +--
 .../loadbalance/TestServiceCombServerStats.java    | 57 ++++++++++++++++++++++
 .../filter/IsolationDiscoveryFilterTest.java       | 14 +++---
 9 files changed, 187 insertions(+), 36 deletions(-)

diff --git 
a/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/Configuration.java
 
b/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/Configuration.java
index 60ab434..6ff3539 100644
--- 
a/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/Configuration.java
+++ 
b/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/Configuration.java
@@ -66,6 +66,8 @@ public final class Configuration {
 
   public static final String FILTER_SINGLE_TEST = "singleTestTime";
 
+  public static final String FILTER_MAX_SINGLE_TEST_WINDOW = 
"maxSingleTestWindow";
+
   public static final String FILTER_MIN_ISOLATION_TIME = "minIsolationTime";
 
   public static final String FILTER_CONTINUOUS_FAILURE_THRESHOLD = 
"continuousFailureThreshold";
@@ -183,7 +185,21 @@ public final class Configuration {
         return result;
       }
       return defaultValue;
+    } catch (NumberFormatException e) {
+      return defaultValue;
+    }
+  }
 
+  public int getMaxSingleTestWindow() {
+    final int defaultValue = 60000;
+    String p = getStringProperty(Integer.toString(defaultValue),
+        ROOT + FILTER_ISOLATION + FILTER_MAX_SINGLE_TEST_WINDOW);
+    try {
+      int result = Integer.parseInt(p);
+      if (result >= 0) {
+        return result;
+      }
+      return defaultValue;
     } catch (NumberFormatException e) {
       return defaultValue;
     }
diff --git 
a/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/LoadbalanceHandler.java
 
b/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/LoadbalanceHandler.java
index a539f90..8f7a524 100644
--- 
a/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/LoadbalanceHandler.java
+++ 
b/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/LoadbalanceHandler.java
@@ -40,7 +40,6 @@ import 
org.apache.servicecomb.core.provider.consumer.SyncResponseExecutor;
 import org.apache.servicecomb.foundation.common.cache.VersionedCache;
 import org.apache.servicecomb.foundation.common.concurrent.ConcurrentHashMapEx;
 import org.apache.servicecomb.foundation.common.utils.ExceptionUtils;
-import org.apache.servicecomb.loadbalance.filter.IsolationDiscoveryFilter;
 import org.apache.servicecomb.loadbalance.filter.ServerDiscoveryFilter;
 import org.apache.servicecomb.registry.discovery.DiscoveryContext;
 import org.apache.servicecomb.registry.discovery.DiscoveryFilter;
@@ -196,9 +195,7 @@ public class LoadbalanceHandler implements Handler {
   public void handle(Invocation invocation, AsyncResponse asyncResp) throws 
Exception {
     AsyncResponse response = asyncResp;
     asyncResp = async -> {
-      if 
(Boolean.TRUE.equals(invocation.getLocalContext(IsolationDiscoveryFilter.TRYING_INSTANCES_EXISTING)))
 {
-        ServiceCombServerStats.releaseTryingChance();
-      }
+      ServiceCombServerStats.checkAndReleaseTryingChance(invocation);
       response.handle(async);
     };
 
diff --git 
a/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/ServiceCombServerStats.java
 
b/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/ServiceCombServerStats.java
index daf83dc..6afc0f6 100644
--- 
a/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/ServiceCombServerStats.java
+++ 
b/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/ServiceCombServerStats.java
@@ -18,9 +18,10 @@
 package org.apache.servicecomb.loadbalance;
 
 import java.time.Clock;
-import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicLong;
+import java.util.concurrent.atomic.AtomicReference;
 
+import org.apache.servicecomb.core.Invocation;
 import org.apache.servicecomb.foundation.common.utils.TimeUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -35,15 +36,14 @@ public class ServiceCombServerStats {
 
   private static final Logger LOGGER = 
LoggerFactory.getLogger(ServiceCombServerStats.class);
 
+  private final Object lock = new Object();
+
   /**
    * There is not more than 1 server allowed to stay in TRYING status 
concurrently.
-   * If the value of globalAllowIsolatedServerTryingFlag is false, there have 
been 1 server in
-   * TRYING status, so the other isolated servers cannot be transferred into
-   * TRYING status; otherwise the value of globalAllowIsolatedServerTryingFlag 
is true.
+   * This flag is designed to ensure such mechanism. And it makes the 
ServiceCombServerStats stateful.
+   * Therefore, the flag should be reset correctly after the trying server 
gets handled.
    */
-  private static AtomicBoolean globalAllowIsolatedServerTryingFlag = new 
AtomicBoolean(true);
-
-  private final Object lock = new Object();
+  static AtomicReference<TryingIsolatedServerMarker> 
globalAllowIsolatedServerTryingFlag = new AtomicReference<>();
 
   Clock clock;
 
@@ -73,7 +73,7 @@ public class ServiceCombServerStats {
     init();
   }
 
-  private void init(){
+  private void init() {
     lastWindow = clock.millis();
     continuousFailureCount = new AtomicLong(0);
     lastVisitTime = clock.millis();
@@ -84,7 +84,11 @@ public class ServiceCombServerStats {
   }
 
   public static boolean isolatedServerCanTry() {
-    return globalAllowIsolatedServerTryingFlag.get();
+    TryingIsolatedServerMarker marker = 
globalAllowIsolatedServerTryingFlag.get();
+    if (marker == null) {
+      return true;
+    }
+    return marker.isOutdated();
   }
 
   /**
@@ -92,12 +96,23 @@ public class ServiceCombServerStats {
    *
    * @return true if the chance is applied successfully, otherwise false
    */
-  public static boolean applyForTryingChance() {
-    return isolatedServerCanTry() && 
globalAllowIsolatedServerTryingFlag.compareAndSet(true, false);
+  public static boolean applyForTryingChance(Invocation invocation) {
+    TryingIsolatedServerMarker marker = 
globalAllowIsolatedServerTryingFlag.get();
+    if (marker == null) {
+      return globalAllowIsolatedServerTryingFlag.compareAndSet(null, new 
TryingIsolatedServerMarker(invocation));
+    }
+    if (marker.isOutdated()) {
+      return globalAllowIsolatedServerTryingFlag.compareAndSet(marker, new 
TryingIsolatedServerMarker(invocation));
+    }
+    return false;
   }
 
-  public static void releaseTryingChance() {
-    globalAllowIsolatedServerTryingFlag.set(true);
+  public static void checkAndReleaseTryingChance(Invocation invocation) {
+    TryingIsolatedServerMarker marker = 
globalAllowIsolatedServerTryingFlag.get();
+    if (marker == null || marker.getInvocation() != invocation) {
+      return;
+    }
+    globalAllowIsolatedServerTryingFlag.compareAndSet(marker, null);
   }
 
   public void markIsolated(boolean isolated) {
diff --git 
a/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/TryingIsolatedServerMarker.java
 
b/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/TryingIsolatedServerMarker.java
new file mode 100644
index 0000000..a741a8d
--- /dev/null
+++ 
b/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/TryingIsolatedServerMarker.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.servicecomb.loadbalance;
+
+import java.time.Clock;
+import java.util.Objects;
+
+import org.apache.servicecomb.core.Invocation;
+import org.apache.servicecomb.foundation.common.utils.TimeUtils;
+
+public class TryingIsolatedServerMarker {
+  Clock clock;
+
+  final long startTryingTimestamp;
+
+  private final Invocation invocation;
+
+  /**
+   * To make sure even if some error interrupted the releasing operation of
+   * {@link ServiceCombServerStats#globalAllowIsolatedServerTryingFlag},
+   * the state can still be recovered.
+   */
+  private final int maxSingleTestWindow;
+
+  public TryingIsolatedServerMarker(Invocation invocation) {
+    Objects.requireNonNull(invocation, "invocation should be non-null");
+    this.invocation = invocation;
+    clock = TimeUtils.getSystemDefaultZoneClock();
+    startTryingTimestamp = clock.millis();
+    maxSingleTestWindow = Configuration.INSTANCE.getMaxSingleTestWindow();
+  }
+
+  public boolean isOutdated() {
+    return this.invocation.isFinished()
+        || clock.millis() - startTryingTimestamp >= maxSingleTestWindow;
+  }
+
+  public Invocation getInvocation() {
+    return invocation;
+  }
+}
diff --git 
a/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/filter/IsolationDiscoveryFilter.java
 
b/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/filter/IsolationDiscoveryFilter.java
index c8f4289..46dec17 100644
--- 
a/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/filter/IsolationDiscoveryFilter.java
+++ 
b/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/filter/IsolationDiscoveryFilter.java
@@ -144,13 +144,7 @@ public class IsolationDiscoveryFilter implements 
DiscoveryFilter {
     if (!checkThresholdAllowed(settings, serverStats)) {
       if (serverStats.isIsolated()
           && (System.currentTimeMillis() - serverStats.getLastVisitTime()) > 
settings.singleTestTime) {
-        if (!ServiceCombServerStats.applyForTryingChance()) {
-          // this server hasn't been isolated for enough long time, or there 
is no trying chance
-          return false;
-        }
-        // [1]we can implement better recovery based on several attempts, but 
here we do not know if this attempt is success
-        invocation.addLocalContext(TRYING_INSTANCES_EXISTING, Boolean.TRUE);
-        return true;
+        return ServiceCombServerStats.applyForTryingChance(invocation);
       }
       if (!serverStats.isIsolated()) {
         serverStats.markIsolated(true);
diff --git 
a/handlers/handler-loadbalance/src/test/java/org/apache/servicecomb/loadbalance/TestConfiguration.java
 
b/handlers/handler-loadbalance/src/test/java/org/apache/servicecomb/loadbalance/TestConfiguration.java
index 862e2dc..2dfaa52 100644
--- 
a/handlers/handler-loadbalance/src/test/java/org/apache/servicecomb/loadbalance/TestConfiguration.java
+++ 
b/handlers/handler-loadbalance/src/test/java/org/apache/servicecomb/loadbalance/TestConfiguration.java
@@ -21,10 +21,13 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 
-import com.netflix.config.ConcurrentCompositeConfiguration;
 import org.apache.servicecomb.config.ConfigUtil;
+import org.apache.servicecomb.foundation.test.scaffolding.config.ArchaiusUtils;
+import org.junit.After;
 import org.junit.Test;
 
+import com.netflix.config.ConcurrentCompositeConfiguration;
+
 import mockit.Mock;
 import mockit.MockUp;
 
@@ -32,6 +35,10 @@ import mockit.MockUp;
  *
  */
 public class TestConfiguration {
+  @After
+  public void after() {
+    ArchaiusUtils.resetConfig();
+  }
 
   @Test
   public void testConstants() {
@@ -42,6 +49,7 @@ public class TestConfiguration {
     assertEquals("retryOnNext", Configuration.RETRY_ON_NEXT);
     assertEquals("retryOnSame", Configuration.RETRY_ON_SAME);
     assertEquals("SessionStickinessRule.successiveFailedTimes", 
Configuration.SUCCESSIVE_FAILED_TIMES);
+    assertEquals("maxSingleTestWindow", 
Configuration.FILTER_MAX_SINGLE_TEST_WINDOW);
 
     assertNotNull(Configuration.INSTANCE);
   }
@@ -173,4 +181,12 @@ public class TestConfiguration {
     localConfiguration = ConfigUtil.createLocalConfig();
     assertEquals("100", 
localConfiguration.getProperty(Configuration.TIMER_INTERVAL_IN_MILLIS));
   }
+
+  @Test
+  public void testGetMaxSingleTestWindow() {
+    assertEquals(60000, Configuration.INSTANCE.getMaxSingleTestWindow());
+
+    
ArchaiusUtils.setProperty("servicecomb.loadbalance.isolation.maxSingleTestWindow",
 5000);
+    assertEquals(5000, Configuration.INSTANCE.getMaxSingleTestWindow());
+  }
 }
diff --git 
a/handlers/handler-loadbalance/src/test/java/org/apache/servicecomb/loadbalance/TestLoadBalanceHandler2.java
 
b/handlers/handler-loadbalance/src/test/java/org/apache/servicecomb/loadbalance/TestLoadBalanceHandler2.java
index 0ff8852..13e57ba 100644
--- 
a/handlers/handler-loadbalance/src/test/java/org/apache/servicecomb/loadbalance/TestLoadBalanceHandler2.java
+++ 
b/handlers/handler-loadbalance/src/test/java/org/apache/servicecomb/loadbalance/TestLoadBalanceHandler2.java
@@ -94,7 +94,7 @@ public class TestLoadBalanceHandler2 {
 
     // avoid mock
     ServiceCombLoadBalancerStats.INSTANCE.init();
-    ServiceCombServerStats.releaseTryingChance();
+    TestServiceCombServerStats.releaseTryingChance();
 
     mockTimeMillis = new Holder<>(1L);
     new MockUp<System>() {
@@ -107,7 +107,7 @@ public class TestLoadBalanceHandler2 {
 
   @After
   public void teardown() {
-    ServiceCombServerStats.releaseTryingChance();
+    TestServiceCombServerStats.releaseTryingChance();
   }
 
   @Test
@@ -866,7 +866,7 @@ public class TestLoadBalanceHandler2 {
           aysnc.success("OK");
         });
 
-    Assert.assertTrue(ServiceCombServerStats.applyForTryingChance());
+    Assert.assertTrue(ServiceCombServerStats.applyForTryingChance(invocation));
     
invocation.addLocalContext(IsolationDiscoveryFilter.TRYING_INSTANCES_EXISTING, 
true);
     try {
       handler.handle(invocation, (response) -> Assert.assertEquals("OK", 
response.getResult()));
@@ -923,7 +923,7 @@ public class TestLoadBalanceHandler2 {
           }
         });
 
-    Assert.assertTrue(ServiceCombServerStats.applyForTryingChance());
+    Assert.assertTrue(ServiceCombServerStats.applyForTryingChance(invocation));
     
invocation.addLocalContext(IsolationDiscoveryFilter.TRYING_INSTANCES_EXISTING, 
true);
     try {
       handler.handle(invocation, (response) -> Assert.assertEquals("OK", 
response.getResult()));
diff --git 
a/handlers/handler-loadbalance/src/test/java/org/apache/servicecomb/loadbalance/TestServiceCombServerStats.java
 
b/handlers/handler-loadbalance/src/test/java/org/apache/servicecomb/loadbalance/TestServiceCombServerStats.java
index 9fd3aaf..2ea105a 100644
--- 
a/handlers/handler-loadbalance/src/test/java/org/apache/servicecomb/loadbalance/TestServiceCombServerStats.java
+++ 
b/handlers/handler-loadbalance/src/test/java/org/apache/servicecomb/loadbalance/TestServiceCombServerStats.java
@@ -17,15 +17,29 @@
 
 package org.apache.servicecomb.loadbalance;
 
+import java.util.Optional;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
+import org.apache.servicecomb.core.Invocation;
 import org.apache.servicecomb.foundation.common.Holder;
 import org.apache.servicecomb.foundation.common.testing.MockClock;
+import org.junit.After;
 import org.junit.Assert;
+import org.junit.Before;
 import org.junit.Test;
 
 public class TestServiceCombServerStats {
+  @Before
+  public void before() {
+    releaseTryingChance();
+  }
+
+  @After
+  public void after() {
+    releaseTryingChance();
+  }
+
   @Test
   public void testSimpleThread() {
     long time = System.currentTimeMillis();
@@ -80,4 +94,47 @@ public class TestServiceCombServerStats {
     Assert.assertEquals(0, stats.getFailedRate());
     Assert.assertEquals(100, stats.getSuccessRate());
   }
+
+  @Test
+  public void 
testGlobalAllowIsolatedServerTryingFlag_apply_with_null_precondition() {
+    Invocation invocation = new Invocation();
+    Assert.assertTrue(ServiceCombServerStats.applyForTryingChance(invocation));
+    Assert.assertSame(invocation, 
ServiceCombServerStats.globalAllowIsolatedServerTryingFlag.get().getInvocation());
+  }
+
+  @Test
+  public void 
testGlobalAllowIsolatedServerTryingFlag_apply_with_chance_occupied() {
+    Invocation invocation = new Invocation();
+    Assert.assertTrue(ServiceCombServerStats.applyForTryingChance(invocation));
+    Assert.assertSame(invocation, 
ServiceCombServerStats.globalAllowIsolatedServerTryingFlag.get().getInvocation());
+
+    Invocation otherInvocation = new Invocation();
+    
Assert.assertFalse(ServiceCombServerStats.applyForTryingChance(otherInvocation));
+    Assert.assertSame(invocation, 
ServiceCombServerStats.globalAllowIsolatedServerTryingFlag.get().getInvocation());
+  }
+
+  @Test
+  public void 
testGlobalAllowIsolatedServerTryingFlag_apply_with_flag_outdated() {
+    Invocation invocation = new Invocation();
+    Assert.assertTrue(ServiceCombServerStats.applyForTryingChance(invocation));
+    Assert.assertSame(invocation, 
ServiceCombServerStats.globalAllowIsolatedServerTryingFlag.get().getInvocation());
+    ServiceCombServerStats.globalAllowIsolatedServerTryingFlag.get().clock = 
new MockClock(new Holder<>(
+        
ServiceCombServerStats.globalAllowIsolatedServerTryingFlag.get().startTryingTimestamp
 + 60000
+    ));
+
+    Invocation otherInvocation = new Invocation();
+    
Assert.assertTrue(ServiceCombServerStats.applyForTryingChance(otherInvocation));
+    Assert
+        .assertSame(otherInvocation, 
ServiceCombServerStats.globalAllowIsolatedServerTryingFlag.get().getInvocation());
+  }
+
+  public static void releaseTryingChance() {
+    ServiceCombServerStats.globalAllowIsolatedServerTryingFlag.set(null);
+  }
+
+  public static Invocation getTryingIsolatedServerInvocation() {
+    return 
Optional.ofNullable(ServiceCombServerStats.globalAllowIsolatedServerTryingFlag.get())
+        .map(TryingIsolatedServerMarker::getInvocation)
+        .orElse(null);
+  }
 }
diff --git 
a/handlers/handler-loadbalance/src/test/java/org/apache/servicecomb/loadbalance/filter/IsolationDiscoveryFilterTest.java
 
b/handlers/handler-loadbalance/src/test/java/org/apache/servicecomb/loadbalance/filter/IsolationDiscoveryFilterTest.java
index d1d0467..1728161 100644
--- 
a/handlers/handler-loadbalance/src/test/java/org/apache/servicecomb/loadbalance/filter/IsolationDiscoveryFilterTest.java
+++ 
b/handlers/handler-loadbalance/src/test/java/org/apache/servicecomb/loadbalance/filter/IsolationDiscoveryFilterTest.java
@@ -27,6 +27,7 @@ import org.apache.servicecomb.loadbalance.Configuration;
 import org.apache.servicecomb.loadbalance.ServiceCombLoadBalancerStats;
 import org.apache.servicecomb.loadbalance.ServiceCombServer;
 import org.apache.servicecomb.loadbalance.ServiceCombServerStats;
+import org.apache.servicecomb.loadbalance.TestServiceCombServerStats;
 import org.apache.servicecomb.registry.api.registry.MicroserviceInstance;
 import org.apache.servicecomb.registry.cache.CacheEndpoint;
 import org.apache.servicecomb.registry.discovery.DiscoveryContext;
@@ -80,13 +81,13 @@ public class IsolationDiscoveryFilterTest {
     discoveryTreeNode.data(data);
 
     filter = new IsolationDiscoveryFilter();
-    ServiceCombServerStats.releaseTryingChance();
+    TestServiceCombServerStats.releaseTryingChance();
   }
 
   @After
   public void after() {
     Deencapsulation.invoke(ServiceCombLoadBalancerStats.INSTANCE, "init");
-    ServiceCombServerStats.releaseTryingChance();
+    TestServiceCombServerStats.releaseTryingChance();
   }
 
   @Test
@@ -137,8 +138,7 @@ public class IsolationDiscoveryFilterTest {
     ServiceCombLoadBalancerStats.INSTANCE.markIsolated(server0, true);
 
     Assert.assertTrue(ServiceCombServerStats.isolatedServerCanTry());
-    Assert.assertFalse(
-        
Boolean.TRUE.equals(invocation.getLocalContext(IsolationDiscoveryFilter.TRYING_INSTANCES_EXISTING)));
+    
Assert.assertNull(TestServiceCombServerStats.getTryingIsolatedServerInvocation());
     DiscoveryTreeNode childNode = filter.discovery(discoveryContext, 
discoveryTreeNode);
     Map<String, MicroserviceInstance> childNodeData = childNode.data();
     Assert.assertThat(childNodeData.keySet(), 
Matchers.containsInAnyOrder("i0", "i1", "i2"));
@@ -147,8 +147,7 @@ public class IsolationDiscoveryFilterTest {
     Assert.assertEquals(data.get("i2"), childNodeData.get("i2"));
     Assert.assertTrue(serviceCombServerStats.isIsolated());
     Assert.assertFalse(ServiceCombServerStats.isolatedServerCanTry());
-    Assert.assertTrue(
-        
Boolean.TRUE.equals(invocation.getLocalContext(IsolationDiscoveryFilter.TRYING_INSTANCES_EXISTING)));
+    Assert.assertSame(invocation, 
TestServiceCombServerStats.getTryingIsolatedServerInvocation());
   }
 
   @Test
@@ -180,7 +179,8 @@ public class IsolationDiscoveryFilterTest {
     Assert.assertEquals(data.get("i1"), childNodeData.get("i1"));
     Assert.assertEquals(data.get("i2"), childNodeData.get("i2"));
 
-    ServiceCombServerStats.releaseTryingChance(); // after the first 
invocation releases the trying chance
+    ServiceCombServerStats
+        .checkAndReleaseTryingChance(invocation); // after the first 
invocation releases the trying chance
 
     // Other invocation can get the trying chance
     childNode = filter.discovery(discoveryContext, discoveryTreeNode);

Reply via email to