<semaphore name="PERMITS.10.*"> <initial-permits>10</initial-permits> </semaphore>
<semaphore name="PERMITS.20.*">
<initial-permits>20</initial-permits> </semaphore><semaphore name="default">
<initial-permits>20</initial-permits>
<semaphore-factory enabled="false">
</semaphore-factory>
</semaphore>
@Override public ClusterSemaphore createSemaphoreIfAbsent(@NotNull final String name, final int permits)
/**
* The hazelcast semaphore gets its initial value from the hazelcast.xml configuration. We cannot change this at runtime so in order to
* get semaphores that are of a differing size, we need to either reduce the number of permits or increase them by releasing them. This
* is all done in this critical section, however it is possible to access the semaphore during this time by manually fetching it from
* the hazelcast instance - DO NOT DO THIS - all semaphore creations and gets should be done vis this method or
* {@link #getSemaphore(String)}.
*/
ISemaphore semaphore = hc.getSemaphore(name);
if (semaphore.availablePermits() > permits) {
semaphore.reducePermits(semaphore.availablePermits() - permits);
}
else if (semaphore.availablePermits() < permits) {
semaphore.releaseDetach(permits - semaphore.availablePermits());
}
Tom--
You received this message because you are subscribed to the Google Groups "Hazelcast" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hazelcast+...@googlegroups.com.
To post to this group, send email to haze...@googlegroups.com.
Visit this group at http://groups.google.com/group/hazelcast?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.