shayshim commented on a change in pull request #320: [CURATOR-533] - improve
circuit breaking behavior
URL: https://github.com/apache/curator/pull/320#discussion_r310363954
##########
File path:
curator-recipes/src/test/java/org/apache/curator/framework/recipes/leader/TestLeaderLatch.java
##########
@@ -43,60 +43,119 @@
import org.testng.annotations.Test;
import java.util.Arrays;
import java.util.Collection;
+import java.util.Collections;
import java.util.List;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorCompletionService;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
+import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
public class TestLeaderLatch extends BaseClassForTests
{
private static final String PATH_NAME = "/one/two/me";
private static final int MAX_LOOPS = 5;
+ private static class Holder
+ {
+ final AtomicInteger stateChangeCount = new AtomicInteger(0);
+ final CountDownLatch isLockedLatch = new CountDownLatch(1);
+ volatile LeaderLatch latch;
+ }
+
@Test
public void testWithCircuitBreaker() throws Exception
{
+ final int threadQty = 5;
+
+ ExecutorService executorService =
Executors.newFixedThreadPool(threadQty);
+ List<Holder> holders = Collections.emptyList();
Timing2 timing = new Timing2();
- ConnectionStateListenerDecorator decorator =
ConnectionStateListenerDecorator.circuitBreaking(new
RetryForever(timing.multiple(2).milliseconds()));
- try ( CuratorFramework client = CuratorFrameworkFactory.builder()
+ ConnectionStateListenerManagerFactory managerFactory =
ConnectionStateListenerManagerFactory.circuitBreaking(new
RetryForever(timing.multiple(2).milliseconds()));
+ CuratorFramework client = CuratorFrameworkFactory.builder()
.connectString(server.getConnectString())
.retryPolicy(new RetryOneTime(1))
- .connectionStateListenerDecorator(decorator)
+ .connectionStateListenerManagerFactory(managerFactory)
.connectionTimeoutMs(timing.connection())
.sessionTimeoutMs(timing.session())
- .build() )
- {
+ .build();
+ try {
client.start();
- AtomicInteger resetCount = new AtomicInteger(0);
- try ( LeaderLatch latch = new LeaderLatch(client, "/foo/bar")
+ client.create().forPath("/hey");
+
+ Semaphore lostSemaphore = new Semaphore(0);
+ ConnectionStateListener undecoratedListener = new
ConnectionStateListener()
Review comment:
unproxiedListener/nonCircuitBreakingListener?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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