Search in sources :

Example 1 with RingbufferAddAllCodec

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

the class ClientRingbufferProxy method addAllAsync.

@Override
public InternalCompletableFuture<Long> addAllAsync(@Nonnull Collection<? extends E> collection, @Nonnull 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);
    Collection<Data> dataCollection = objectToDataCollection(collection, getSerializationService());
    ClientMessage request = RingbufferAddAllCodec.encodeRequest(name, dataCollection, overflowPolicy.getId());
    try {
        ClientInvocationFuture future = new ClientInvocation(getClient(), request, getName(), partitionId).invoke();
        return new ClientDelegatingFuture<>(future, getSerializationService(), RingbufferAddAllCodec::decodeResponse);
    } catch (Exception e) {
        throw rethrow(e);
    }
}
Also used : ClientDelegatingFuture(com.hazelcast.client.impl.ClientDelegatingFuture) Data(com.hazelcast.internal.serialization.Data) ClientInvocation(com.hazelcast.client.impl.spi.impl.ClientInvocation) ClientMessage(com.hazelcast.client.impl.protocol.ClientMessage) RingbufferAddAllCodec(com.hazelcast.client.impl.protocol.codec.RingbufferAddAllCodec) 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 RingbufferAddAllCodec (com.hazelcast.client.impl.protocol.codec.RingbufferAddAllCodec)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