com.hazelcast.client.proxy

## Class ClientCountDownLatchProxy

- java.lang.Object
- - com.hazelcast.client.spi.ClientProxy
  - - com.hazelcast.client.proxy.ClientCountDownLatchProxy

- All Implemented Interfaces:
    DistributedObject, ICountDownLatch

      public class ClientCountDownLatchProxy
      extends ClientProxy
      implements ICountDownLatch

  Proxy implementation of `ICountDownLatch`.

- - ### Field Summary

    - ### Fields inherited from class com.hazelcast.client.spi.ClientProxy

      `name`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ClientCountDownLatchProxy(String serviceName, String objectId, ClientContext context)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `await(long timeout, TimeUnit unit)` Causes the current thread to wait until the latch has counted down to zero, or an exception is thrown, or the specified waiting time elapses.
    `void` | `countDown()` Decrements the count of the latch, releasing all waiting threads if the count reaches zero.
    `int` | `getCount()` Returns the current count.
    `protected com.hazelcast.client.impl.protocol.ClientMessage` | `invokeOnPartition(com.hazelcast.client.impl.protocol.ClientMessage req)`
    `protected <T> T` | `invokeOnPartition(com.hazelcast.client.impl.protocol.ClientMessage clientMessage, long invocationTimeoutSeconds)`
    `protected <T> ClientDelegatingFuture<T>` | `invokeOnPartitionAsync(com.hazelcast.client.impl.protocol.ClientMessage clientMessage, com.hazelcast.client.impl.clientside.ClientMessageDecoder clientMessageDecoder)`
    `protected <T> T` | `invokeOnPartitionInterruptibly(com.hazelcast.client.impl.protocol.ClientMessage clientMessage)`
    `protected <T> T` | `invokeOnPartitionInterruptibly(com.hazelcast.client.impl.protocol.ClientMessage clientMessage, long invocationTimeoutSeconds)`
    `protected void` | `onInitialize()` Called when proxy is created.
    `String` | `toString()`
    `boolean` | `trySetCount(int count)` Sets the count to the given value if the current count is zero.

    - ### Methods inherited from class com.hazelcast.client.spi.ClientProxy

      `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, toObject`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface com.hazelcast.core.DistributedObject

      `destroy, getName, getPartitionKey, getServiceName`

- - ### Constructor Detail

    - #### ClientCountDownLatchProxy

          public ClientCountDownLatchProxy(String serviceName,
                                           String objectId,
                                           ClientContext context)

  - ### Method Detail

    - #### await

          public boolean await(long timeout,
                               TimeUnit unit)
                        throws InterruptedException

      Description copied from interface: `ICountDownLatch`
      Causes the current thread to wait until the latch has counted down to zero, or an exception is thrown, or the specified waiting time elapses.

      If the current count is zero then this method returns immediately with the value `true`.

      If the current count is greater than zero, then the current thread becomes disabled for thread scheduling purposes and lies dormant until one of five things happen:

      - the count reaches zero due to invocations of the `ICountDownLatch.countDown()` method,
      - this ICountDownLatch instance is destroyed,
      - the countdown owner becomes disconnected,
      - some other thread interrupts the current thread, or
      - the specified waiting time elapses.
      If the count reaches zero, then the method returns with the value `true`.

      If the current thread:

      - has its interrupted status set on entry to this method, or
      - is interrupted while waiting,
      then `InterruptedException` is thrown and the current thread's interrupted status is cleared.

      If the specified waiting time elapses then the value `false` is returned. If the time is less than or equal to zero, the method will not wait at all.

      Specified by:
        `await` in interface `ICountDownLatch`
      Parameters:
        `timeout` - the maximum time to wait
        `unit` - the time unit of the `timeout` argument
      Returns:
        `true` if the count reached zero, `false` if the waiting time elapsed before the count reached zero
      Throws:
        `InterruptedException` - if the current thread is interrupted

    - #### countDown

          public void countDown()

      Description copied from interface: `ICountDownLatch`
      Decrements the count of the latch, releasing all waiting threads if the count reaches zero.

      If the current count is greater than zero, then it is decremented. If the new count is zero:

      - All waiting threads are re-enabled for thread scheduling purposes, and
      - Countdown owner is set to `null`.
      If the current count equals zero, then nothing happens.
      Specified by:
        `countDown` in interface `ICountDownLatch`

    - #### getCount

          public int getCount()

      Description copied from interface: `ICountDownLatch`
      Returns the current count.
      Specified by:
        `getCount` in interface `ICountDownLatch`
      Returns:
        the current count

    - #### trySetCount

          public boolean trySetCount(int count)

      Description copied from interface: `ICountDownLatch`
      Sets the count to the given value if the current count is zero.

      If count is not zero, then this method does nothing and returns `false`.

      Specified by:
        `trySetCount` in interface `ICountDownLatch`
      Parameters:
        `count` - the number of times `ICountDownLatch.countDown()` must be invoked before threads can pass through `ICountDownLatch.await(long, java.util.concurrent.TimeUnit)`
      Returns:
        `true` if the new count was set, `false` if the current count is not zero

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### onInitialize

          protected void onInitialize()

      Description copied from class: `ClientProxy`
      Called when proxy is created. Overriding implementations can add initialization specific logic into this method like registering a listener, creating a cleanup task etc.
      Overrides:
        `onInitialize` in class `ClientProxy`

    - #### invokeOnPartition

          protected com.hazelcast.client.impl.protocol.ClientMessage invokeOnPartition(com.hazelcast.client.impl.protocol.ClientMessage req)

    - #### invokeOnPartitionInterruptibly

          protected <T> T invokeOnPartitionInterruptibly(com.hazelcast.client.impl.protocol.ClientMessage clientMessage)
                                                  throws InterruptedException

      Throws:
        `InterruptedException`

    - #### invokeOnPartitionAsync

          protected <T> ClientDelegatingFuture<T> invokeOnPartitionAsync(com.hazelcast.client.impl.protocol.ClientMessage clientMessage,
                                                                         com.hazelcast.client.impl.clientside.ClientMessageDecoder clientMessageDecoder)

    - #### invokeOnPartition

          protected <T> T invokeOnPartition(com.hazelcast.client.impl.protocol.ClientMessage clientMessage,
                                            long invocationTimeoutSeconds)

    - #### invokeOnPartitionInterruptibly

          protected <T> T invokeOnPartitionInterruptibly(com.hazelcast.client.impl.protocol.ClientMessage clientMessage,
                                                         long invocationTimeoutSeconds)
                                                  throws InterruptedException

      Throws:
        `InterruptedException`

Copyright © 2020. All rights reserved.