Search in sources :

Example 16 with Operation

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

the class SemaphoreProxy method release.

@Override
public void release(int permits) {
    checkNotNegative(permits, "permits can't be negative");
    Operation operation = new ReleaseOperation(name, permits).setPartitionId(partitionId);
    InternalCompletableFuture future = invokeOnPartition(operation);
    future.join();
}
Also used : InternalCompletableFuture(com.hazelcast.spi.InternalCompletableFuture) Operation(com.hazelcast.spi.Operation) AvailableOperation(com.hazelcast.concurrent.semaphore.operations.AvailableOperation) ReduceOperation(com.hazelcast.concurrent.semaphore.operations.ReduceOperation) AcquireOperation(com.hazelcast.concurrent.semaphore.operations.AcquireOperation) DrainOperation(com.hazelcast.concurrent.semaphore.operations.DrainOperation) ReleaseOperation(com.hazelcast.concurrent.semaphore.operations.ReleaseOperation) InitOperation(com.hazelcast.concurrent.semaphore.operations.InitOperation) ReleaseOperation(com.hazelcast.concurrent.semaphore.operations.ReleaseOperation)

Example 17 with Operation

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

the class CountDownLatchProxy method trySetCount.

@Override
public boolean trySetCount(int count) {
    checkNotNegative(count, "count can't be negative");
    Operation op = new SetCountOperation(name, count).setPartitionId(partitionId);
    InternalCompletableFuture<Boolean> f = invokeOnPartition(op);
    return f.join();
}
Also used : SetCountOperation(com.hazelcast.concurrent.countdownlatch.operations.SetCountOperation) CountDownOperation(com.hazelcast.concurrent.countdownlatch.operations.CountDownOperation) Operation(com.hazelcast.spi.Operation) GetCountOperation(com.hazelcast.concurrent.countdownlatch.operations.GetCountOperation) AwaitOperation(com.hazelcast.concurrent.countdownlatch.operations.AwaitOperation) SetCountOperation(com.hazelcast.concurrent.countdownlatch.operations.SetCountOperation)

Example 18 with Operation

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

the class DistributedExecutorService method populate.

@Override
public void populate(LiveOperations liveOperations) {
    for (CallableProcessor processor : submittedTasks.values()) {
        Operation op = processor.op;
        liveOperations.add(op.getCallerAddress(), op.getCallId());
    }
}
Also used : Operation(com.hazelcast.spi.Operation)

Example 19 with Operation

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

the class ExecutorServiceProxy method submitToPartitionOwner.

private <T> Future<T> submitToPartitionOwner(Callable<T> task, int partitionId, boolean preventSync) {
    checkNotNull(task, "task can't be null");
    checkNotShutdown();
    NodeEngine nodeEngine = getNodeEngine();
    Data taskData = nodeEngine.toData(task);
    String uuid = newUnsecureUuidString();
    boolean sync = !preventSync && checkSync();
    Operation op = new CallableTaskOperation(name, uuid, taskData).setPartitionId(partitionId);
    InternalCompletableFuture future = invokeOnPartition(op);
    if (sync) {
        Object response;
        try {
            response = future.get();
        } catch (Exception e) {
            response = e;
        }
        return new CompletedFuture<T>(nodeEngine.getSerializationService(), response, getAsyncExecutor());
    }
    return new CancellableDelegatingFuture<T>(future, nodeEngine, uuid, partitionId);
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) InternalCompletableFuture(com.hazelcast.spi.InternalCompletableFuture) Data(com.hazelcast.nio.serialization.Data) AbstractDistributedObject(com.hazelcast.spi.AbstractDistributedObject) UuidUtil.newUnsecureUuidString(com.hazelcast.util.UuidUtil.newUnsecureUuidString) ShutdownOperation(com.hazelcast.executor.impl.operations.ShutdownOperation) CallableTaskOperation(com.hazelcast.executor.impl.operations.CallableTaskOperation) Operation(com.hazelcast.spi.Operation) MemberCallableTaskOperation(com.hazelcast.executor.impl.operations.MemberCallableTaskOperation) HazelcastInstanceNotActiveException(com.hazelcast.core.HazelcastInstanceNotActiveException) TimeoutException(java.util.concurrent.TimeoutException) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) ExecutionException(java.util.concurrent.ExecutionException) CallableTaskOperation(com.hazelcast.executor.impl.operations.CallableTaskOperation) MemberCallableTaskOperation(com.hazelcast.executor.impl.operations.MemberCallableTaskOperation) CompletedFuture(com.hazelcast.util.executor.CompletedFuture)

Example 20 with Operation

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

the class DurableExecutorServiceProxy method disposeResult.

@Override
public void disposeResult(long uniqueId) {
    int partitionId = Bits.extractInt(uniqueId, false);
    int sequence = Bits.extractInt(uniqueId, true);
    Operation op = new DisposeResultOperation(name, sequence).setPartitionId(partitionId);
    InternalCompletableFuture<?> future = invokeOnPartition(op);
    future.join();
}
Also used : DisposeResultOperation(com.hazelcast.durableexecutor.impl.operations.DisposeResultOperation) RetrieveAndDisposeResultOperation(com.hazelcast.durableexecutor.impl.operations.RetrieveAndDisposeResultOperation) ShutdownOperation(com.hazelcast.durableexecutor.impl.operations.ShutdownOperation) TaskOperation(com.hazelcast.durableexecutor.impl.operations.TaskOperation) Operation(com.hazelcast.spi.Operation) DisposeResultOperation(com.hazelcast.durableexecutor.impl.operations.DisposeResultOperation) RetrieveAndDisposeResultOperation(com.hazelcast.durableexecutor.impl.operations.RetrieveAndDisposeResultOperation) RetrieveResultOperation(com.hazelcast.durableexecutor.impl.operations.RetrieveResultOperation)

Aggregations

Operation (com.hazelcast.spi.Operation)216 QuickTest (com.hazelcast.test.annotation.QuickTest)60 Test (org.junit.Test)60 OperationService (com.hazelcast.spi.OperationService)39 ParallelTest (com.hazelcast.test.annotation.ParallelTest)39 Future (java.util.concurrent.Future)19 Member (com.hazelcast.core.Member)18 Address (com.hazelcast.nio.Address)18 Data (com.hazelcast.nio.serialization.Data)18 HazelcastInstance (com.hazelcast.core.HazelcastInstance)17 AssertTask (com.hazelcast.test.AssertTask)17 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)15 ArrayList (java.util.ArrayList)15 InternalCompletableFuture (com.hazelcast.spi.InternalCompletableFuture)14 NodeEngine (com.hazelcast.spi.NodeEngine)14 BackupAwareOperation (com.hazelcast.spi.BackupAwareOperation)13 BlockingOperation (com.hazelcast.spi.BlockingOperation)13 MapOperation (com.hazelcast.map.impl.operation.MapOperation)12 AtomicReference (java.util.concurrent.atomic.AtomicReference)11 Config (com.hazelcast.config.Config)10