com.hazelcast.client.proxy

## Class ClientQueueProxy<E>

- java.lang.Object
- - com.hazelcast.client.spi.ClientProxy
  - - com.hazelcast.client.proxy.ClientQueueProxy<E>

- Type Parameters:
    `E` - the type of elements in this queue
  All Implemented Interfaces:
    BaseQueue<E>, DistributedObject, ICollection<E>, IQueue<E>, Iterable<E>, Collection<E>, BlockingQueue<E>, Queue<E>

      public final class ClientQueueProxy<E>
      extends ClientProxy
      implements IQueue<E>

  Proxy implementation of `IQueue`.

- - ### Field Summary

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

      `name`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ClientQueueProxy(String serviceName, String name, ClientContext context)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `add(E e)`
    `boolean` | `addAll(Collection<? extends E> c)`
    `String` | `addItemListener(ItemListener<E> listener, boolean includeValue)` Adds an item listener for this collection.
    `void` | `clear()`
    `boolean` | `contains(Object o)`
    `boolean` | `containsAll(Collection<?> c)`
    `int` | `drainTo(Collection<? super E> objects)`
    `int` | `drainTo(Collection<? super E> c, int maxElements)`
    `E` | `element()`
    `LocalQueueStats` | `getLocalQueueStats()` Returns LocalQueueStats for this queue.
    `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)`
    `boolean` | `isEmpty()`
    `Iterator<E>` | `iterator()`
    `boolean` | `offer(E e)` It is advised to use this method in a try-catch block to take the offer operation full lifecycle control, in a "lost node" scenario you can not be sure offer is succeeded or not so you may want to retry.
    `boolean` | `offer(E e, long timeout, TimeUnit unit)` Inserts the specified element into this queue, waiting up to the specified wait time if necessary for space to become available.
    `protected void` | `onInitialize()` Called when proxy is created.
    `E` | `peek()`
    `E` | `poll()` Retrieves and removes the head of this queue, or returns `null` if this queue is empty.
    `E` | `poll(long timeout, TimeUnit unit)` Retrieves and removes the head of this queue, waiting up to the specified wait time if necessary for an element to become available.
    `void` | `put(E e)`
    `int` | `remainingCapacity()`
    `E` | `remove()`
    `boolean` | `remove(Object o)`
    `boolean` | `removeAll(Collection<?> c)`
    `boolean` | `removeItemListener(String registrationId)` Removes the specified item listener.
    `boolean` | `retainAll(Collection<?> c)`
    `int` | `size()` Returns the number of elements in this collection.
    `E` | `take()` Retrieves and removes the head of this queue, waiting if necessary until an element becomes available.
    `Object[]` | `toArray()`
    `<T> T[]` | `toArray(T[] ts)`
    `String` | `toString()`

    - ### 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, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface java.util.Collection

      `equals, hashCode, parallelStream, removeIf, spliterator, stream`

    - ### Methods inherited from interface java.lang.Iterable

      `forEach`

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

      `getName`

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

      `destroy, getPartitionKey, getServiceName`

- - ### Constructor Detail

    - #### ClientQueueProxy

          public ClientQueueProxy(String serviceName,
                                  String name,
                                  ClientContext context)

  - ### Method Detail

    - #### addItemListener

          public String addItemListener(ItemListener<E> listener,
                                        boolean includeValue)

      Description copied from interface: `ICollection`
      Adds an item listener for this collection. The listener will be notified of all collection add/remove events.
      Specified by:
        `addItemListener` in interface `ICollection<E>`
      Parameters:
        `listener` - the item listener
        `includeValue` - `true` if the updated item should be passed to the item listener, `false` otherwise
      Returns:
        returns the registration ID

    - #### removeItemListener

          public boolean removeItemListener(String registrationId)

      Description copied from interface: `ICollection`
      Removes the specified item listener. Returns silently if the specified listener was not added before.
      Specified by:
        `removeItemListener` in interface `ICollection<E>`
      Parameters:
        `registrationId` - ID of the listener registration
      Returns:
        `true` if the item listener is removed, `false` otherwise

    - #### getLocalQueueStats

          public LocalQueueStats getLocalQueueStats()

      Description copied from interface: `IQueue`
      Returns LocalQueueStats for this queue. LocalQueueStats is the statistics for the local portion of this queue.
      Specified by:
        `getLocalQueueStats` in interface `IQueue<E>`
      Returns:
        this queue's local statistics.

    - #### add

          public boolean add(E e)

      Specified by:
        `add` in interface `Collection<E>`
      Specified by:
        `add` in interface `BlockingQueue<E>`
      Specified by:
        `add` in interface `Queue<E>`

    - #### offer

          public boolean offer(E e)

      It is advised to use this method in a try-catch block to take the offer operation full lifecycle control, in a "lost node" scenario you can not be sure offer is succeeded or not so you may want to retry.
      Specified by:
        `offer` in interface `BaseQueue<E>`
      Specified by:
        `offer` in interface `BlockingQueue<E>`
      Specified by:
        `offer` in interface `Queue<E>`
      Parameters:
        `e` - the element to add
      Returns:
        `true` if the element was added to this queue. `false` if there is not enough capacity to insert the element.
      Throws:
        `HazelcastException` - if client loses the connected node.

    - #### put

          public void put(E e)
                   throws InterruptedException

      Specified by:
        `put` in interface `BlockingQueue<E>`
      Throws:
        `InterruptedException`

    - #### offer

          public boolean offer(E e,
                               long timeout,
                               TimeUnit unit)
                        throws InterruptedException

      Description copied from interface: `BaseQueue`
      Inserts the specified element into this queue, waiting up to the specified wait time if necessary for space to become available.
      Specified by:
        `offer` in interface `BaseQueue<E>`
      Specified by:
        `offer` in interface `BlockingQueue<E>`
      Parameters:
        `e` - the element to add
        `timeout` - how long to wait before giving up, in units of `unit`
        `unit` - a `TimeUnit` determines how to interpret the `timeout` parameter
      Returns:
        `true` if successful, or `false` if the specified waiting time elapses before space is available
      Throws:
        `InterruptedException` - if interrupted while waiting

    - #### take

          public E take()
                 throws InterruptedException

      Description copied from interface: `IQueue`
      Retrieves and removes the head of this queue, waiting if necessary until an element becomes available.
      Specified by:
        `take` in interface `BaseQueue<E>`
      Specified by:
        `take` in interface `IQueue<E>`
      Specified by:
        `take` in interface `BlockingQueue<E>`
      Returns:
        the head of this queue
      Throws:
        `InterruptedException` - if interrupted while waiting

    - #### poll

          public E poll(long timeout,
                        TimeUnit unit)
                 throws InterruptedException

      Description copied from interface: `IQueue`
      Retrieves and removes the head of this queue, waiting up to the specified wait time if necessary for an element to become available.
      Specified by:
        `poll` in interface `BaseQueue<E>`
      Specified by:
        `poll` in interface `IQueue<E>`
      Specified by:
        `poll` in interface `BlockingQueue<E>`
      Parameters:
        `timeout` - how long to wait before giving up, in units of `unit`
        `unit` - a `TimeUnit` determining how to interpret the `timeout` parameter
      Returns:
        the head of this queue, or `null` if the specified waiting time elapses before an element is available
      Throws:
        `InterruptedException` - if interrupted while waiting

    - #### remainingCapacity

          public int remainingCapacity()

      Specified by:
        `remainingCapacity` in interface `BlockingQueue<E>`

    - #### remove

          public boolean remove(Object o)

      Specified by:
        `remove` in interface `Collection<E>`
      Specified by:
        `remove` in interface `BlockingQueue<E>`

    - #### contains

          public boolean contains(Object o)

      Specified by:
        `contains` in interface `Collection<E>`
      Specified by:
        `contains` in interface `BlockingQueue<E>`

    - #### drainTo

          public int drainTo(Collection<? super E> objects)

      Specified by:
        `drainTo` in interface `BlockingQueue<E>`

    - #### drainTo

          public int drainTo(Collection<? super E> c,
                             int maxElements)

      Specified by:
        `drainTo` in interface `BlockingQueue<E>`

    - #### remove

          public E remove()

      Specified by:
        `remove` in interface `Queue<E>`

    - #### poll

          public E poll()

      Description copied from interface: `IQueue`
      Retrieves and removes the head of this queue, or returns `null` if this queue is empty.
      Specified by:
        `poll` in interface `BaseQueue<E>`
      Specified by:
        `poll` in interface `IQueue<E>`
      Specified by:
        `poll` in interface `Queue<E>`
      Returns:
        the head of this queue, or `null` if this queue is empty

    - #### element

          public E element()

      Specified by:
        `element` in interface `Queue<E>`

    - #### peek

          public E peek()

      Specified by:
        `peek` in interface `Queue<E>`

    - #### size

          public int size()

      Description copied from interface: `BaseQueue`
      Returns the number of elements in this collection. If this collection contains more than `Integer.MAX_VALUE` elements, returns `Integer.MAX_VALUE`.
      Specified by:
        `size` in interface `BaseQueue<E>`
      Specified by:
        `size` in interface `Collection<E>`
      Returns:
        the number of elements in this collection

    - #### isEmpty

          public boolean isEmpty()

      Specified by:
        `isEmpty` in interface `Collection<E>`

    - #### iterator

          public Iterator<E> iterator()

      Specified by:
        `iterator` in interface `Iterable<E>`
      Specified by:
        `iterator` in interface `Collection<E>`

    - #### toArray

          public Object[] toArray()

      Specified by:
        `toArray` in interface `Collection<E>`

    - #### toArray

          public <T> T[] toArray(T[] ts)

      Specified by:
        `toArray` in interface `Collection<E>`

    - #### containsAll

          public boolean containsAll(Collection<?> c)

      Specified by:
        `containsAll` in interface `Collection<E>`

    - #### addAll

          public boolean addAll(Collection<? extends E> c)

      Specified by:
        `addAll` in interface `Collection<E>`

    - #### removeAll

          public boolean removeAll(Collection<?> c)

      Specified by:
        `removeAll` in interface `Collection<E>`

    - #### retainAll

          public boolean retainAll(Collection<?> c)

      Specified by:
        `retainAll` in interface `Collection<E>`

    - #### clear

          public void clear()

      Specified by:
        `clear` in interface `Collection<E>`

    - #### 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 © 2019. All rights reserved.