@Override
  public ICompletableFuture<Long> addAllAsync(
      Collection<? extends E> collection, OverflowPolicy overflowPolicy) {
    checkNotNull(collection, "collection can't be null");
    checkNotNull(overflowPolicy, "overflowPolicy can't be null");
    checkFalse(collection.isEmpty(), "collection can't be empty");
    checkTrue(
        collection.size() <= MAX_BATCH_SIZE, "collection can't be larger than " + MAX_BATCH_SIZE);

    final List<Data> valueList = new ArrayList<Data>(collection.size());
    for (E e : collection) {
      throwExceptionIfNull(e);
      valueList.add(toData(e));
    }

    ClientMessage request =
        RingbufferAddAllAsyncCodec.encodeRequest(name, valueList, overflowPolicy.getId());
    request.setPartitionId(partitionId);

    try {
      ClientInvocationFuture invocationFuture = new ClientInvocation(getClient(), request).invoke();
      return new ClientDelegatingFuture<Long>(
          invocationFuture, getContext().getSerializationService(), ADD_ALL_ASYNC_RESPONSE_DECODER);
    } catch (Exception e) {
      throw ExceptionUtil.rethrow(e);
    }
  }
  @Override
  public ICompletableFuture<Long> addAsync(E item, OverflowPolicy overflowPolicy) {
    checkNotNull(item, "item can't be null");
    checkNotNull(overflowPolicy, "overflowPolicy can't be null");

    Data element = toData(item);
    ClientMessage request = RingbufferAddCodec.encodeRequest(name, overflowPolicy.getId(), element);
    request.setPartitionId(partitionId);

    try {
      ClientInvocationFuture invocationFuture = new ClientInvocation(getClient(), request).invoke();
      return new ClientDelegatingFuture<Long>(
          invocationFuture,
          getContext().getSerializationService(),
          ADD_ASYNC_ASYNC_RESPONSE_DECODER);
    } catch (Exception e) {
      throw ExceptionUtil.rethrow(e);
    }
  }
  @Override
  public ICompletableFuture<ReadResultSet<E>> readManyAsync(
      long startSequence, int minCount, int maxCount, IFunction<E, Boolean> filter) {

    checkSequence(startSequence);
    checkNotNegative(minCount, "minCount can't be smaller than 0");
    checkTrue(maxCount >= minCount, "maxCount should be equal or larger than minCount");
    checkTrue(
        minCount <= capacity(), "the minCount should be smaller than or equal to the capacity");
    checkTrue(maxCount <= MAX_BATCH_SIZE, "maxCount can't be larger than " + MAX_BATCH_SIZE);

    ClientMessage request =
        RingbufferReadManyAsyncCodec.encodeRequest(
            name, startSequence, minCount, maxCount, toData(filter));
    request.setPartitionId(partitionId);

    try {
      ClientInvocationFuture invocationFuture = new ClientInvocation(getClient(), request).invoke();
      return new ClientDelegatingFuture<ReadResultSet<E>>(
          invocationFuture, getContext().getSerializationService(), readManyAsyncResponseDecoder);
    } catch (Exception e) {
      throw ExceptionUtil.rethrow(e);
    }
  }
 protected void sendClientMessage(Object key, ClientMessage resultClientMessage) {
   int partitionId = key == null ? -1 : nodeEngine.getPartitionService().getPartitionId(key);
   resultClientMessage.setPartitionId(partitionId);
   sendClientMessage(resultClientMessage);
 }