curator-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jordan Zimmerman <jor...@jordanzimmerman.com>
Subject Re: Usage of semaphore
Date Thu, 09 Jan 2014 16:10:51 GMT
Here’s a portion of the JavaDoc for the class:

There are two modes for determining the max leases for the semaphore. In the first mode the
max leases is a convention maintained by the users of a given path. In the second mode a SharedCountReader
is used as the method for semaphores of a given path to determine the max leases.

If a SharedCountReader is not used, no internal checks are done to prevent Process A acting
as if there are 10 leases and Process B acting as if there are 20. Therefore, make sure that
all instances in all processes use the same numberOfLeases value.

-JZ

From: Sznajder ForMailingList Sznajder ForMailingList
Reply: user@curator.apache.org user@curator.apache.org
Date: January 9, 2014 at 9:51:36 AM
To: user@curator.incubator.apache.org user@curator.incubator.apache.org
Subject:  Usage of semaphore  
Hi

I need to allow the access to a shared resource only MAX_CON times.

It sounds natural to use the semaphore for that.

However, something is not clear to me in the API.

What is the difference between the two constructors:

public InterProcessSemaphoreV2(CuratorFramework client,
                       String path,
                       int maxLeases)

public InterProcessSemaphoreV2(CuratorFramework client,
                       String path,
                       SharedCountReader count)





And especially, with the second constructor signature, how do I define the maxLeases value?
How can I limit the access to be only MAX_CONN?

Many thanks

Benjamin



Mime
View raw message