curator-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jordan Zimmerman <jor...@jordanzimmerman.com>
Subject Re: Error thrown using the InterprocessSemaphoreV2#getParticipantsNodes()
Date Thu, 09 Jan 2014 18:31:42 GMT
This was fixed in 2.3.0

https://issues.apache.org/jira/browse/CURATOR-19

-JZ

From: Sznajder ForMailingList Sznajder ForMailingList
Reply: user@curator.apache.org user@curator.apache.org
Date: January 9, 2014 at 11:06:42 AM
To: user@curator.incubator.apache.org user@curator.incubator.apache.org
Subject:  Error thrown using the InterprocessSemaphoreV2#getParticipantsNodes()  
Hi

When calling the method getParticipantsNodes() from InterprocessSemaphoreV2, we systematically
get a org.apache.zookeeper.KeeperException$NoNodeException

I created a simple test for showing that..

Benjamin






package counter.semaphore;

import java.util.Collection;

import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.recipes.locks.InterProcessSemaphoreV2;
import org.apache.curator.framework.recipes.locks.Lease;
import org.apache.curator.test.TestingServer;

import com.ibm.hrl.crawler.Utils;

public class SemaphoreErrorTest {
    private static final String PATH = "/semaphore_test_path";

    public static void main(String[] args) {
        TestingServer server;
        try {
            server = new TestingServer();
            String connectString = server.getConnectString();
           
            final CuratorFramework framework = Utils.newFramework(connectString);
            framework.start();
           
            // We create a semaphore:
            InterProcessSemaphoreV2 semaphore = new InterProcessSemaphoreV2(framework,
PATH, 2);
           
            // We acquire the semaphore
            Lease lease = null;
            try {
                lease = semaphore.acquire();
               
                try {
                    Collection<String> participantNodes = semaphore.getParticipantNodes();
                    System.out.println("There are " + participantNodes == null
? 0 : participantNodes.size() + " participant nodes");
                } catch (Exception e) {
                    System.err.println("!! - Error! I got the following exception
" + e);
                }
               
            } finally {
                if (lease != null) {
                    semaphore.returnLease(lease);
                }
            }
           
           
            framework.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}


Mime
View raw message