Search in sources :

Example 31 with Operation

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

the class WriteBehindStore method executeNotifyOperation.

private void executeNotifyOperation(Sequence flushSequence) {
    if (!flushSequence.isFullFlush() || !nodeEngine.getPartitionService().isPartitionOwner(partitionId)) {
        return;
    }
    Operation operation = new NotifyMapFlushOperation(mapName, flushSequence.getSequence());
    operation.setServiceName(SERVICE_NAME).setNodeEngine(nodeEngine).setPartitionId(partitionId).setCallerUuid(nodeEngine.getLocalMember().getUuid()).setOperationResponseHandler(createEmptyResponseHandler());
    operationService.execute(operation);
}
Also used : NotifyMapFlushOperation(com.hazelcast.map.impl.operation.NotifyMapFlushOperation) Operation(com.hazelcast.spi.impl.operationservice.Operation) NotifyMapFlushOperation(com.hazelcast.map.impl.operation.NotifyMapFlushOperation)

Example 32 with Operation

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

the class ScheduledExecutorContainer method publishTaskState.

/**
 * State is published after every run.
 * When replicas get promoted, they start with the latest state.
 */
void publishTaskState(String taskName, Map stateSnapshot, ScheduledTaskStatisticsImpl statsSnapshot, ScheduledTaskResult result) {
    if (logger.isFinestEnabled()) {
        log(FINEST, "Publishing state, to replicas. State: " + stateSnapshot);
    }
    Operation op = new SyncStateOperation(getName(), taskName, stateSnapshot, statsSnapshot, result);
    createInvocationBuilder(op).invoke().joinInternal();
}
Also used : Operation(com.hazelcast.spi.impl.operationservice.Operation) SyncStateOperation(com.hazelcast.scheduledexecutor.impl.operations.SyncStateOperation) SyncStateOperation(com.hazelcast.scheduledexecutor.impl.operations.SyncStateOperation)

Example 33 with Operation

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

the class InvokeOnMembers method retryFailedTargets.

private void retryFailedTargets() throws InterruptedException, ExecutionException {
    List<Member> failedMembers = new LinkedList<Member>();
    for (Map.Entry<Member, Object> memberResult : results.entrySet()) {
        Member member = memberResult.getKey();
        Object result = memberResult.getValue();
        if (result instanceof Throwable) {
            failedMembers.add(member);
        }
    }
    for (Member failedMember : failedMembers) {
        Operation operation = operationFactory.get();
        Future future = operationService.createInvocationBuilder(serviceName, operation, failedMember.getAddress()).invoke();
        results.put(failedMember, future);
    }
    for (Member failedMember : failedMembers) {
        Future future = (Future) results.get(failedMember);
        Object result = future.get();
        results.put(failedMember, result);
    }
}
Also used : Future(java.util.concurrent.Future) Operation(com.hazelcast.spi.impl.operationservice.Operation) Member(com.hazelcast.cluster.Member) HashMap(java.util.HashMap) Map(java.util.Map) LinkedList(java.util.LinkedList)

Example 34 with Operation

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

the class ScheduledExecutorServiceProxy method shutdown.

@Override
public void shutdown() {
    NodeEngine nodeEngine = getNodeEngine();
    Collection<Member> members = nodeEngine.getClusterService().getMembers();
    OperationService operationService = nodeEngine.getOperationService();
    Collection<Future> calls = new LinkedList<>();
    for (Member member : members) {
        Operation op = new ShutdownOperation(name);
        calls.add(operationService.invokeOnTarget(SERVICE_NAME, op, member.getAddress()));
    }
    waitWithDeadline(calls, SHUTDOWN_TIMEOUT, TimeUnit.SECONDS, shutdownExceptionHandler);
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) Future(java.util.concurrent.Future) IScheduledFuture(com.hazelcast.scheduledexecutor.IScheduledFuture) ShutdownOperation(com.hazelcast.scheduledexecutor.impl.operations.ShutdownOperation) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) Operation(com.hazelcast.spi.impl.operationservice.Operation) GetAllScheduledOnMemberOperation(com.hazelcast.scheduledexecutor.impl.operations.GetAllScheduledOnMemberOperation) ScheduleTaskOperation(com.hazelcast.scheduledexecutor.impl.operations.ScheduleTaskOperation) ShutdownOperation(com.hazelcast.scheduledexecutor.impl.operations.ShutdownOperation) Member(com.hazelcast.cluster.Member) LinkedList(java.util.LinkedList)

Example 35 with Operation

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

the class ScheduledFutureProxy method getDelay.

@Override
public long getDelay(TimeUnit unit) {
    checkNotNull(unit, "Unit is null");
    checkAccessibleHandler();
    checkAccessibleOwner();
    Operation op = new GetDelayOperation(handler, unit);
    return this.<Long>invoke(op).joinInternal();
}
Also used : GetDelayOperation(com.hazelcast.scheduledexecutor.impl.operations.GetDelayOperation) DisposeTaskOperation(com.hazelcast.scheduledexecutor.impl.operations.DisposeTaskOperation) GetResultOperation(com.hazelcast.scheduledexecutor.impl.operations.GetResultOperation) IsCanceledOperation(com.hazelcast.scheduledexecutor.impl.operations.IsCanceledOperation) Operation(com.hazelcast.spi.impl.operationservice.Operation) CancelTaskOperation(com.hazelcast.scheduledexecutor.impl.operations.CancelTaskOperation) GetStatisticsOperation(com.hazelcast.scheduledexecutor.impl.operations.GetStatisticsOperation) GetDelayOperation(com.hazelcast.scheduledexecutor.impl.operations.GetDelayOperation) IsDoneOperation(com.hazelcast.scheduledexecutor.impl.operations.IsDoneOperation)

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