Search in sources :

Example 61 with Operation

use of com.hazelcast.spi.impl.operationservice.Operation in project hazelcast by hazelcast.

the class MultiMapTransactionLogRecord method size.

public int size() {
    int size = 0;
    for (Operation operation : opList) {
        if (operation instanceof TxnRemoveAllOperation) {
            TxnRemoveAllOperation removeAllOperation = (TxnRemoveAllOperation) operation;
            size -= removeAllOperation.getRecordIds().size();
        } else if (operation instanceof TxnRemoveOperation) {
            size--;
        } else {
            size++;
        }
    }
    return size;
}
Also used : Operation(com.hazelcast.spi.impl.operationservice.Operation)

Example 62 with Operation

use of com.hazelcast.spi.impl.operationservice.Operation in project hazelcast by hazelcast.

the class RingbufferProxy method readManyAsync.

@Override
public CompletionStage<ReadResultSet<E>> readManyAsync(long startSequence, int minCount, int maxCount, @Nullable 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(maxCount <= config.getCapacity(), "the maxCount should be smaller than or equal to the capacity");
    checkTrue(maxCount <= MAX_BATCH_SIZE, "maxCount can't be larger than " + MAX_BATCH_SIZE);
    Operation op = new ReadManyOperation<>(name, startSequence, minCount, maxCount, filter).setPartitionId(partitionId);
    OperationService operationService = getOperationService();
    return operationService.createInvocationBuilder(null, op, partitionId).setCallTimeout(Long.MAX_VALUE).invoke();
}
Also used : AddAllOperation(com.hazelcast.ringbuffer.impl.operations.AddAllOperation) GenericOperation(com.hazelcast.ringbuffer.impl.operations.GenericOperation) ReadOneOperation(com.hazelcast.ringbuffer.impl.operations.ReadOneOperation) ReadManyOperation(com.hazelcast.ringbuffer.impl.operations.ReadManyOperation) Operation(com.hazelcast.spi.impl.operationservice.Operation) AddOperation(com.hazelcast.ringbuffer.impl.operations.AddOperation) OperationService(com.hazelcast.spi.impl.operationservice.OperationService)

Example 63 with Operation

use of com.hazelcast.spi.impl.operationservice.Operation in project hazelcast by hazelcast.

the class RingbufferProxy method addAsync.

@Override
public CompletionStage<Long> addAsync(@Nonnull E item, @Nonnull OverflowPolicy overflowPolicy) {
    checkNotNull(item, "item can't be null");
    checkNotNull(overflowPolicy, "overflowPolicy can't be null");
    Operation op = new AddOperation(name, toData(item), overflowPolicy).setPartitionId(partitionId);
    return invokeOnPartition(op);
}
Also used : AddAllOperation(com.hazelcast.ringbuffer.impl.operations.AddAllOperation) GenericOperation(com.hazelcast.ringbuffer.impl.operations.GenericOperation) ReadOneOperation(com.hazelcast.ringbuffer.impl.operations.ReadOneOperation) ReadManyOperation(com.hazelcast.ringbuffer.impl.operations.ReadManyOperation) Operation(com.hazelcast.spi.impl.operationservice.Operation) AddOperation(com.hazelcast.ringbuffer.impl.operations.AddOperation) AddOperation(com.hazelcast.ringbuffer.impl.operations.AddOperation)

Example 64 with Operation

use of com.hazelcast.spi.impl.operationservice.Operation in project hazelcast by hazelcast.

the class RingbufferProxy method readOne.

@Override
public E readOne(long sequence) throws InterruptedException {
    checkSequence(sequence);
    Operation op = new ReadOneOperation(name, sequence).setPartitionId(partitionId);
    InvocationFuture<E> f = invokeOnPartition(op);
    try {
        return f.get();
    } catch (Throwable t) {
        throw rethrowAllowInterrupted(t);
    }
}
Also used : OVERWRITE(com.hazelcast.ringbuffer.OverflowPolicy.OVERWRITE) OPERATION_SIZE(com.hazelcast.ringbuffer.impl.operations.GenericOperation.OPERATION_SIZE) SERVICE_NAME(com.hazelcast.ringbuffer.impl.RingbufferService.SERVICE_NAME) ReadOneOperation(com.hazelcast.ringbuffer.impl.operations.ReadOneOperation) AddAllOperation(com.hazelcast.ringbuffer.impl.operations.AddAllOperation) GenericOperation(com.hazelcast.ringbuffer.impl.operations.GenericOperation) ReadOneOperation(com.hazelcast.ringbuffer.impl.operations.ReadOneOperation) ReadManyOperation(com.hazelcast.ringbuffer.impl.operations.ReadManyOperation) Operation(com.hazelcast.spi.impl.operationservice.Operation) AddOperation(com.hazelcast.ringbuffer.impl.operations.AddOperation)

Example 65 with Operation

use of com.hazelcast.spi.impl.operationservice.Operation in project hazelcast by hazelcast.

the class RingbufferProxy method add.

@Override
public long add(@Nonnull E item) {
    checkNotNull(item, "item can't be null");
    Operation op = new AddOperation(name, toData(item), OVERWRITE).setPartitionId(partitionId);
    InvocationFuture<Long> f = invokeOnPartition(op);
    return f.joinInternal();
}
Also used : AddAllOperation(com.hazelcast.ringbuffer.impl.operations.AddAllOperation) GenericOperation(com.hazelcast.ringbuffer.impl.operations.GenericOperation) ReadOneOperation(com.hazelcast.ringbuffer.impl.operations.ReadOneOperation) ReadManyOperation(com.hazelcast.ringbuffer.impl.operations.ReadManyOperation) Operation(com.hazelcast.spi.impl.operationservice.Operation) AddOperation(com.hazelcast.ringbuffer.impl.operations.AddOperation) AddOperation(com.hazelcast.ringbuffer.impl.operations.AddOperation)

Aggregations

Operation (com.hazelcast.spi.impl.operationservice.Operation)271 Test (org.junit.Test)80 QuickTest (com.hazelcast.test.annotation.QuickTest)79 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)59 OperationService (com.hazelcast.spi.impl.operationservice.OperationService)56 Address (com.hazelcast.cluster.Address)31 HazelcastInstance (com.hazelcast.core.HazelcastInstance)25 Data (com.hazelcast.internal.serialization.Data)24 Future (java.util.concurrent.Future)24 Member (com.hazelcast.cluster.Member)22 ArrayList (java.util.ArrayList)21 NodeEngine (com.hazelcast.spi.impl.NodeEngine)18 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)17 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)17 AssertTask (com.hazelcast.test.AssertTask)15 ILogger (com.hazelcast.logging.ILogger)14 UrgentSystemOperation (com.hazelcast.spi.impl.operationservice.UrgentSystemOperation)13 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)13 Config (com.hazelcast.config.Config)12 CompletableFuture (java.util.concurrent.CompletableFuture)12