@Override public long add(E item) { checkNotNull(item, "item can't be null"); Data element = toData(item); ClientMessage request = RingbufferAddCodec.encodeRequest(name, OverflowPolicy.OVERWRITE.getId(), element); ClientMessage response = invoke(request, partitionId); RingbufferAddCodec.ResponseParameters resultParameters = RingbufferAddCodec.decodeResponse(response); return resultParameters.response; }
@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); } }