public class ClientSemaphoreProxy extends ClientProxy implements ISemaphore
ISemaphore.name| Constructor and Description | 
|---|
| ClientSemaphoreProxy(String serviceName,
                    String objectId,
                    ClientContext context) | 
| Modifier and Type | Method and Description | 
|---|---|
| void | acquire()Acquires a permit if one is available, and returns immediately,
 reducing the number of available permits by one. | 
| void | acquire(int permits)Acquires the given number of permits if they are available,
 and returns immediately, reducing the number of available permits
 by the given amount. | 
| int | availablePermits()Returns the current number of permits currently available in this semaphore. | 
| int | drainPermits()Acquires and returns all permits that are available at invocation time. | 
| void | increasePermits(int increase)Increases the number of available permits by the indicated amount. | 
| boolean | init(int permits)Tries to initialize this ISemaphore instance with the given permit count | 
| protected ClientMessage | invokeOnPartition(ClientMessage req) | 
| protected <T> T | invokeOnPartition(ClientMessage clientMessage,
                 long invocationTimeoutSeconds) | 
| protected <T> ClientDelegatingFuture<T> | invokeOnPartitionAsync(ClientMessage clientMessage,
                      ClientMessageDecoder clientMessageDecoder) | 
| protected <T> T | invokeOnPartitionInterruptibly(ClientMessage clientMessage) | 
| protected <T> T | invokeOnPartitionInterruptibly(ClientMessage clientMessage,
                              long invocationTimeoutSeconds) | 
| protected void | onInitialize()Called when proxy is created. | 
| void | reducePermits(int reduction)Reduces the number of available permits by the indicated amount. | 
| void | release()Releases a permit and increases the number of available permits by one. | 
| void | release(int permits)Releases the given number of permits and increases the number of
 available permits by that amount. | 
| String | toString() | 
| boolean | tryAcquire()Acquires a permit if one is available, and returns  trueimmediately. | 
| boolean | tryAcquire(int permits)Acquires the given number of permits if they are available, and
 returns  trueimmediately. | 
| boolean | tryAcquire(int permits,
          long timeout,
          TimeUnit unit)Acquires the given number of permits and returns  true, if they
 become available during the given waiting time. | 
| boolean | tryAcquire(long timeout,
          TimeUnit unit)Acquires a permit and returns  true, if one becomes available
 during the given waiting time and the current thread has not been
 interrupted. | 
deregisterListener, destroy, destroyLocally, destroyRemotely, equals, getClient, getConnectedServerVersion, getContext, getDistributedObjectName, getId, getName, getPartitionKey, getSerializationService, getServiceName, hashCode, invoke, invoke, invokeOnAddress, invokeOnPartition, invokeOnPartitionInterruptibly, onDestroy, onShutdown, postDestroy, preDestroy, registerListener, setContext, toData, toObjectclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetNamedestroy, getPartitionKey, getServiceNamepublic ClientSemaphoreProxy(String serviceName, String objectId, ClientContext context)
public boolean init(int permits)
ISemaphoreinit in interface ISemaphorepermits - the given permit countpublic void acquire()
             throws InterruptedException
ISemaphoreIf no permit is available, then the current thread becomes disabled for thread scheduling purposes and lies dormant until one of three things happens:
ISemaphore.release() methods for this
 semaphore and the current thread is next to be assigned a permit,If the current thread:
InterruptedException is thrown and the current thread's
 interrupted status is cleared.acquire in interface ISemaphoreInterruptedException - if the current thread is interruptedpublic void acquire(int permits)
             throws InterruptedException
ISemaphoreIf insufficient permits are available then the current thread becomes disabled for thread scheduling purposes and lies dormant until one of three things happens:
release
 methods for this semaphore, the current thread is next to be assigned
 permits and the number of available permits satisfies this request,InterruptedException is thrown and the current thread's
 interrupted status is cleared.acquire in interface ISemaphorepermits - the number of permits to acquireInterruptedException - if the current thread is interruptedpublic int availablePermits()
ISemaphoreThis method is typically used for debugging and testing purposes.
availablePermits in interface ISemaphorepublic int drainPermits()
ISemaphoredrainPermits in interface ISemaphorepublic void reducePermits(int reduction)
ISemaphoreacquire as it does not block until permits
 become available. Similarly, if the caller has acquired some permits,
 they are not released with this call.reducePermits in interface ISemaphorereduction - the number of permits to reducepublic void increasePermits(int increase)
ISemaphoreincreasePermits in interface ISemaphoreincrease - the number of permits to increasepublic void release()
ISemaphore
 If the underlying ISemaphore impl is the non-JDK compatible
 CP impl that is configured via CPSemaphoreConfig and fetched
 via CPSubsystem, then a HazelcastInstance can only release a permit which
 it has acquired before. In other words, a HazelcastInstance cannot release a permit
 without acquiring it first.
 
 Otherwise, which means the underlying impl is either the JDK compatible
 CP impl configured via CPSemaphoreConfig and fetched
 via CPSubsystem, or it is the old impl fetched via
 HazelcastInstance.getSemaphore(String), there is no requirement
 that a HazelcastInstance that releases a permit must have acquired that permit by
 calling one of the ISemaphore.acquire() methods. A HazelcastInstance can freely
 release a permit without acquiring it first. In this case, correct usage
 of a semaphore is established by programming convention in the application.
release in interface ISemaphorepublic void release(int permits)
ISemaphore
 If the underlying ISemaphore impl is the non-JDK compatible
 CP impl that is configured via CPSemaphoreConfig and fetched
 via CPSubsystem, then a HazelcastInstance can only release a permit which
 it has acquired before. In other words, a HazelcastInstance cannot release a permit
 without acquiring it first.
 
 Otherwise, which means the underlying impl is either the JDK compatible
 CP impl configured via CPSemaphoreConfig and fetched
 via CPSubsystem, or it is the old impl fetched via
 HazelcastInstance.getSemaphore(String), there is no requirement
 that a HazelcastInstance that releases a permit must have acquired that permit by
 calling one of the ISemaphore.acquire() methods. A HazelcastInstance can freely
 release a permit without acquiring it first. In this case, correct usage
 of a semaphore is established by programming convention in the application.
release in interface ISemaphorepermits - the number of permits to releasepublic boolean tryAcquire()
ISemaphoretrue
 immediately. If no permit is available, returns false
 immediately.tryAcquire in interface ISemaphoretrue if a permit was acquired, false otherwisepublic boolean tryAcquire(int permits)
ISemaphoretrue immediately. If the requested number of permits are
 not available, returns false immediately.tryAcquire in interface ISemaphorepermits - the number of permits to acquiretrue if the permits were acquired, false otherwisepublic boolean tryAcquire(long timeout,
                          TimeUnit unit)
                   throws InterruptedException
ISemaphoretrue, if one becomes available
 during the given waiting time and the current thread has not been
 interrupted. If a permit is acquired,
 the number of available permits in the ISemaphore instance is
 also reduced by one.
 If no permit is available, then the current thread becomes disabled for thread scheduling purposes and lies dormant until one of three things happens:
 Returns true if a permit is successfully acquired.
 
 Returns false if the specified waiting time elapses without
 acquiring a permit. If the time is less than or equal to zero,
 the method will not wait at all.
 
If the current thread:
InterruptedException is thrown and the current thread's
 interrupted status is cleared.tryAcquire in interface ISemaphoretimeout - the maximum time to wait for a permitunit - the time unit of the timeout argumenttrue if a permit was acquired and false
 if the waiting time elapsed before a permit was acquiredInterruptedException - if the current thread is interruptedpublic boolean tryAcquire(int permits,
                          long timeout,
                          TimeUnit unit)
                   throws InterruptedException
ISemaphoretrue, if they
 become available during the given waiting time. If permits are acquired,
 the number of available permits in the ISemaphore instance is
 also reduced by the given amount.
 If no sufficient permits are available, then the current thread becomes disabled for thread scheduling purposes and lies dormant until one of three things happens:
true if requested permits are successfully acquired.
 
 Returns false if the specified waiting time elapses without
 acquiring permits. If the time is less than or equal to zero,
 the method will not wait at all.
 
If the current thread:
InterruptedException is thrown and the current thread's
 interrupted status is cleared.tryAcquire in interface ISemaphorepermits - the number of permits to acquiretimeout - the maximum time to wait for the permitsunit - the time unit of the timeout argumenttrue if all permits were acquired,
 false if the waiting time elapsed before all permits could be acquiredInterruptedException - if the current thread is interruptedprotected void onInitialize()
ClientProxyonInitialize in class ClientProxyprotected ClientMessage invokeOnPartition(ClientMessage req)
protected <T> T invokeOnPartitionInterruptibly(ClientMessage clientMessage) throws InterruptedException
InterruptedExceptionprotected <T> ClientDelegatingFuture<T> invokeOnPartitionAsync(ClientMessage clientMessage, ClientMessageDecoder clientMessageDecoder)
protected <T> T invokeOnPartition(ClientMessage clientMessage, long invocationTimeoutSeconds)
protected <T> T invokeOnPartitionInterruptibly(ClientMessage clientMessage, long invocationTimeoutSeconds) throws InterruptedException
InterruptedExceptionCopyright © 2022 Hazelcast, Inc.. All Rights Reserved.