Search in sources :

Example 46 with OperationService

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

the class ClearOperation method replicateClearOperation.

private void replicateClearOperation(long version) {
    final OperationService operationService = getNodeEngine().getOperationService();
    Collection<Address> members = getMemberAddresses();
    for (Address address : members) {
        ClearOperation clearOperation = new ClearOperation(mapName, false, version);
        clearOperation.setPartitionId(getPartitionId());
        clearOperation.setValidateTarget(false);
        operationService.createInvocationBuilder(getServiceName(), clearOperation, address).setTryCount(INVOCATION_TRY_COUNT).invoke();
    }
}
Also used : Address(com.hazelcast.nio.Address) OperationService(com.hazelcast.spi.OperationService)

Example 47 with OperationService

use of com.hazelcast.spi.OperationService 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<Future>();
    for (Member member : members) {
        if (member.localMember()) {
            getService().shutdownExecutor(name);
        } else {
            Operation op = new ShutdownOperation(name);
            calls.add(operationService.invokeOnTarget(SERVICE_NAME, op, member.getAddress()));
        }
    }
    waitWithDeadline(calls, SHUTDOWN_TIMEOUT, TimeUnit.SECONDS, WHILE_SHUTDOWN_EXCEPTION_HANDLER);
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) Future(java.util.concurrent.Future) IScheduledFuture(com.hazelcast.scheduledexecutor.IScheduledFuture) ShutdownOperation(com.hazelcast.scheduledexecutor.impl.operations.ShutdownOperation) OperationService(com.hazelcast.spi.OperationService) GetAllScheduledOnMemberOperation(com.hazelcast.scheduledexecutor.impl.operations.GetAllScheduledOnMemberOperation) ScheduleTaskOperation(com.hazelcast.scheduledexecutor.impl.operations.ScheduleTaskOperation) Operation(com.hazelcast.spi.Operation) ShutdownOperation(com.hazelcast.scheduledexecutor.impl.operations.ShutdownOperation) Member(com.hazelcast.core.Member) LinkedList(java.util.LinkedList)

Example 48 with OperationService

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

the class EventServiceImpl method invokeRegistrationOnOtherNodes.

private void invokeRegistrationOnOtherNodes(String serviceName, Registration reg) {
    OperationService operationService = nodeEngine.getOperationService();
    Collection<Member> members = nodeEngine.getClusterService().getMembers();
    Collection<Future> calls = new ArrayList<Future>(members.size());
    for (Member member : members) {
        if (!member.localMember()) {
            RegistrationOperation operation = new RegistrationOperation(reg);
            Future f = operationService.invokeOnTarget(serviceName, operation, member.getAddress());
            calls.add(f);
        }
    }
    waitWithDeadline(calls, REGISTRATION_TIMEOUT_SECONDS, TimeUnit.SECONDS, registrationExceptionHandler);
}
Also used : ArrayList(java.util.ArrayList) Future(java.util.concurrent.Future) OperationService(com.hazelcast.spi.OperationService) RegistrationOperation(com.hazelcast.spi.impl.eventservice.impl.operations.RegistrationOperation) PostJoinRegistrationOperation(com.hazelcast.spi.impl.eventservice.impl.operations.PostJoinRegistrationOperation) Member(com.hazelcast.core.Member)

Example 49 with OperationService

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

the class EventServiceImpl method invokeDeregistrationOnOtherNodes.

private void invokeDeregistrationOnOtherNodes(String serviceName, String topic, String id) {
    OperationService operationService = nodeEngine.getOperationService();
    Collection<Member> members = nodeEngine.getClusterService().getMembers();
    Collection<Future> calls = new ArrayList<Future>(members.size());
    for (Member member : members) {
        if (!member.localMember()) {
            DeregistrationOperation operation = new DeregistrationOperation(topic, id);
            Future f = operationService.invokeOnTarget(serviceName, operation, member.getAddress());
            calls.add(f);
        }
    }
    waitWithDeadline(calls, DEREGISTER_TIMEOUT_SECONDS, TimeUnit.SECONDS, deregistrationExceptionHandler);
}
Also used : ArrayList(java.util.ArrayList) Future(java.util.concurrent.Future) OperationService(com.hazelcast.spi.OperationService) Member(com.hazelcast.core.Member) DeregistrationOperation(com.hazelcast.spi.impl.eventservice.impl.operations.DeregistrationOperation)

Example 50 with OperationService

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

the class PartitionIteratingOperation method executeOperations.

private void executeOperations() {
    NodeEngine nodeEngine = getNodeEngine();
    OperationResponseHandler responseHandler = new OperationResponseHandlerImpl(partitions);
    OperationService operationService = nodeEngine.getOperationService();
    Object service = getServiceName() == null ? null : getService();
    for (int partitionId : partitions) {
        Operation operation = operationFactory.createOperation().setNodeEngine(nodeEngine).setPartitionId(partitionId).setReplicaIndex(getReplicaIndex()).setOperationResponseHandler(responseHandler).setServiceName(getServiceName()).setService(service).setCallerUuid(extractCallerUuid());
        OperationAccessor.setCallerAddress(operation, getCallerAddress());
        operationService.execute(operation);
    }
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) OperationService(com.hazelcast.spi.OperationService) Operation(com.hazelcast.spi.Operation) OperationResponseHandler(com.hazelcast.spi.OperationResponseHandler)

Aggregations

OperationService (com.hazelcast.spi.OperationService)135 Test (org.junit.Test)49 QuickTest (com.hazelcast.test.annotation.QuickTest)48 ParallelTest (com.hazelcast.test.annotation.ParallelTest)46 HazelcastInstance (com.hazelcast.core.HazelcastInstance)45 Operation (com.hazelcast.spi.Operation)39 NodeEngine (com.hazelcast.spi.NodeEngine)30 Address (com.hazelcast.nio.Address)26 Future (java.util.concurrent.Future)26 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)24 Config (com.hazelcast.config.Config)21 InternalCompletableFuture (com.hazelcast.spi.InternalCompletableFuture)21 Member (com.hazelcast.core.Member)19 Data (com.hazelcast.nio.serialization.Data)14 ArrayList (java.util.ArrayList)11 Node (com.hazelcast.instance.Node)7 InternalOperationService (com.hazelcast.spi.impl.operationservice.InternalOperationService)7 ExecutionException (java.util.concurrent.ExecutionException)7 TimeoutException (java.util.concurrent.TimeoutException)7 OperationTimeoutException (com.hazelcast.core.OperationTimeoutException)6