Search in sources :

Example 1 with RingbufferAddCodec

use of com.hazelcast.client.impl.protocol.codec.RingbufferAddCodec in project hazelcast by hazelcast.

the class ClientRingbufferProxy method addAsync.

@Override
public InternalCompletableFuture<Long> addAsync(@Nonnull E item, @Nonnull 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);
    try {
        ClientInvocationFuture future = new ClientInvocation(getClient(), request, getName(), partitionId).invoke();
        return new ClientDelegatingFuture<>(future, getSerializationService(), RingbufferAddCodec::decodeResponse);
    } catch (Exception e) {
        throw rethrow(e);
    }
}
Also used : ClientDelegatingFuture(com.hazelcast.client.impl.ClientDelegatingFuture) RingbufferAddCodec(com.hazelcast.client.impl.protocol.codec.RingbufferAddCodec) Data(com.hazelcast.internal.serialization.Data) ClientInvocation(com.hazelcast.client.impl.spi.impl.ClientInvocation) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) StaleSequenceException(com.hazelcast.ringbuffer.StaleSequenceException) ClientInvocationFuture(com.hazelcast.client.impl.spi.impl.ClientInvocationFuture)

Aggregations

ClientDelegatingFuture (com.hazelcast.client.impl.ClientDelegatingFuture)1 ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)1 RingbufferAddCodec (com.hazelcast.client.impl.protocol.codec.RingbufferAddCodec)1 ClientInvocation (com.hazelcast.client.impl.spi.impl.ClientInvocation)1 ClientInvocationFuture (com.hazelcast.client.impl.spi.impl.ClientInvocationFuture)1 Data (com.hazelcast.internal.serialization.Data)1 StaleSequenceException (com.hazelcast.ringbuffer.StaleSequenceException)1