Search in sources :

Example 11 with InMemoryZKServer

use of com.continuuity.weave.internal.zookeeper.InMemoryZKServer in project weave by continuuity.

the class ZKOperationsTest method recursiveDelete.

@Test
public void recursiveDelete() throws ExecutionException, InterruptedException, TimeoutException {
    InMemoryZKServer zkServer = InMemoryZKServer.builder().setTickTime(1000).build();
    zkServer.startAndWait();
    try {
        ZKClientService client = ZKClientService.Builder.of(zkServer.getConnectionStr()).build();
        client.startAndWait();
        try {
            client.create("/test1/test10/test101", null, CreateMode.PERSISTENT).get();
            client.create("/test1/test10/test102", null, CreateMode.PERSISTENT).get();
            client.create("/test1/test10/test103", null, CreateMode.PERSISTENT).get();
            client.create("/test1/test11/test111", null, CreateMode.PERSISTENT).get();
            client.create("/test1/test11/test112", null, CreateMode.PERSISTENT).get();
            client.create("/test1/test11/test113", null, CreateMode.PERSISTENT).get();
            ZKOperations.recursiveDelete(client, "/test1").get(2, TimeUnit.SECONDS);
            Assert.assertNull(client.exists("/test1").get(2, TimeUnit.SECONDS));
        } finally {
            client.stopAndWait();
        }
    } finally {
        zkServer.stopAndWait();
    }
}
Also used : InMemoryZKServer(com.continuuity.weave.internal.zookeeper.InMemoryZKServer) Test(org.junit.Test)

Aggregations

InMemoryZKServer (com.continuuity.weave.internal.zookeeper.InMemoryZKServer)11 Test (org.junit.Test)11 CountDownLatch (java.util.concurrent.CountDownLatch)5 RunId (com.continuuity.weave.api.RunId)4 ZKClientService (com.continuuity.weave.zookeeper.ZKClientService)4 AbstractIdleService (com.google.common.util.concurrent.AbstractIdleService)4 WeaveController (com.continuuity.weave.api.WeaveController)3 ServiceListenerAdapter (com.continuuity.weave.common.ServiceListenerAdapter)3 Service (com.google.common.util.concurrent.Service)3 WatchedEvent (org.apache.zookeeper.WatchedEvent)2 Watcher (org.apache.zookeeper.Watcher)2 ZKServiceDecorator (com.continuuity.weave.internal.ZKServiceDecorator)1 JsonObject (com.google.gson.JsonObject)1 File (java.io.File)1 ExecutionException (java.util.concurrent.ExecutionException)1 LinkedBlockingQueue (java.util.concurrent.LinkedBlockingQueue)1 Semaphore (java.util.concurrent.Semaphore)1 TimeoutException (java.util.concurrent.TimeoutException)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1