Examples of ZkCyclicBarrier


Examples of org.menagerie.latches.spi.ZkCyclicBarrier

    public final static DistributedCountDownLatch newCountDownLatch(long total, String latchNode, ZkSessionManager zkSessionManager, List<ACL> privileges, boolean tolerateFailures) {
        return new ZkCountDownLatch(total, latchNode, zkSessionManager, privileges, tolerateFailures);
    }

    public final static DistributedCyclicBarrier newCyclicBarrier(long size, ZkSessionManager zkSessionManager, String barrierNode) {
        return new ZkCyclicBarrier(size, zkSessionManager, barrierNode);
    }
View Full Code Here

Examples of org.menagerie.latches.spi.ZkCyclicBarrier

    public final static DistributedCyclicBarrier newCyclicBarrier(long size, ZkSessionManager zkSessionManager, String barrierNode) {
        return new ZkCyclicBarrier(size, zkSessionManager, barrierNode);
    }

    public final static DistributedCyclicBarrier newCyclicBarrier(long size, ZkSessionManager zkSessionManager, String barrierNode, List<ACL> privileges) {
        return new ZkCyclicBarrier(size, zkSessionManager, barrierNode, privileges);
    }
View Full Code Here

Examples of org.menagerie.latches.spi.ZkCyclicBarrier

    public final static DistributedCyclicBarrier newCyclicBarrier(long size, ZkSessionManager zkSessionManager, String barrierNode, List<ACL> privileges) {
        return new ZkCyclicBarrier(size, zkSessionManager, barrierNode, privileges);
    }

    public final static DistributedCyclicBarrier newCyclicBarrier(long size, ZkSessionManager zkSessionManager, String barrierNode, List<ACL> privileges, boolean tolerateFailures) {
        return new ZkCyclicBarrier(size, zkSessionManager, barrierNode, privileges, tolerateFailures);
    }
View Full Code Here

Examples of org.menagerie.latches.spi.ZkCyclicBarrier

        }
    }

    @Test(timeout = 5000l)
    public void testBarrierWorks()throws Exception{
        cyclicBarrier = new ZkCyclicBarrier(1, new BaseZkSessionManager(zk), barrierPath);
        cyclicBarrier.await();
        //this method would timeout if await doesn't move forward
    }
View Full Code Here

Examples of org.menagerie.latches.spi.ZkCyclicBarrier

        //this method would timeout if await doesn't move forward
    }

    @Test(timeout = 5000l)
    public void testBarrierWorksWithTwoThreads() throws Exception{
        cyclicBarrier = new ZkCyclicBarrier(2, new BaseZkSessionManager(zk), barrierPath);

        executor.submit(new Runnable() {
            @Override
            public void run() {
                try {
View Full Code Here

Examples of org.menagerie.latches.spi.ZkCyclicBarrier

        cyclicBarrier.await();
    }

    @Test(timeout = 5000l)
    public void testBarrierWorksWithTwoClients() throws Exception{
        cyclicBarrier = new ZkCyclicBarrier(2, new BaseZkSessionManager(zk), barrierPath);

        Future<Void> errorFuture = executor.submit(new Callable<Void>() {
            @Override
            public Void call() throws Exception {
                ZooKeeper otherZooKeeper = newZooKeeper();
                try {
                    DistributedCyclicBarrier otherCyclicBarrier = new ZkCyclicBarrier(2, new BaseZkSessionManager(otherZooKeeper), barrierPath);
                    System.out.printf("%s: Waiting on barrier%n",Thread.currentThread().getName());
                    otherCyclicBarrier.await();
                } finally {
                    otherZooKeeper.close();
                }
                System.out.printf("%s; Barrier returned on secondary thread%n",Thread.currentThread().getName());
                return null;
View Full Code Here

Examples of org.menagerie.latches.spi.ZkCyclicBarrier

    }

    @Test(timeout = 10000l)
    public void testBarrierWorksWithManyClients() throws Exception{
        final int numClients=9;
        cyclicBarrier = new ZkCyclicBarrier(numClients, new BaseZkSessionManager(zk), barrierPath);

        List<Future<Void>> futures = new ArrayList<Future<Void>>(numClients);
        for(int client=0;client<numClients;client++){
            futures.add(executor.submit(new Callable<Void>() {
                @Override
                public Void call() throws Exception {
                    ZooKeeper otherZooKeeper = newZooKeeper();
                    try {
                        DistributedCyclicBarrier otherCyclicBarrier = new ZkCyclicBarrier(numClients, new BaseZkSessionManager(otherZooKeeper), barrierPath);
//                        System.out.printf("%s: Waiting on barrier%n",Thread.currentThread().getName());
                        otherCyclicBarrier.await();
                    } finally {
                        otherZooKeeper.close();
                    }
//                    System.out.printf("%s; Barrier returned on secondary thread%n",Thread.currentThread().getName());
                    return null;
View Full Code Here

Examples of org.menagerie.latches.spi.ZkCyclicBarrier

        }
    }

    @Test(timeout = 5000l, expected = TimeoutException.class)
    public void testBarrierTimeOutThrowsTimeoutException() throws Exception{
        cyclicBarrier = new ZkCyclicBarrier(2, new BaseZkSessionManager(zk), barrierPath);
//        assertEquals("Cyclic Barrier is not properly constructed!",1,zk.getChildren(baseBarrierPath,false).size());
        cyclicBarrier.await(500, TimeUnit.MILLISECONDS);
    }
View Full Code Here

Examples of org.menagerie.latches.spi.ZkCyclicBarrier

        cyclicBarrier.await(500, TimeUnit.MILLISECONDS);
    }

    @Test(timeout = 1000l, expected = BrokenBarrierException.class)
    public void testBarrierTimeoutCausesBrokenBarrierOnOtherThread() throws Exception{
        cyclicBarrier = new ZkCyclicBarrier(3, new BaseZkSessionManager(zk), barrierPath);
//        assertEquals("Cyclic Barrier is not properly constructed!",1,zk.getChildren(baseBarrierPath,false).size());

        Future<?> errorFuture = executor.submit(new Runnable() {
            @Override
            public void run() {
View Full Code Here

Examples of org.menagerie.latches.spi.ZkCyclicBarrier

        errorFuture.get();
    }

    @Test(timeout = 1000l, expected = BrokenBarrierException.class)
    public void testBarrierTimeoutCausesBrokenBarrierOnOtherClients() throws Exception{
        cyclicBarrier = new ZkCyclicBarrier(3, new BaseZkSessionManager(zk), barrierPath);

        Future<Void> errorFuture = executor.submit(new Callable<Void>() {
            @Override
            public Void call() throws Exception {
                ZooKeeper newZk = newZooKeeper();
                boolean thrown = false;
                try{
                    DistributedCyclicBarrier otherCyclicBarrier = new ZkCyclicBarrier(3, new BaseZkSessionManager(newZk), barrierPath);
                    otherCyclicBarrier.await(500,TimeUnit.MILLISECONDS);
                } catch (TimeoutException e) {
                    thrown = true;
                }finally{
                    newZk.close();
                }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.