Search in sources :

Example 86 with OperationService

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

the class ExecutorServiceProxy 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 {
            Future f = submitShutdownOperation(operationService, member);
            calls.add(f);
        }
    }
    waitWithDeadline(calls, 1, TimeUnit.SECONDS, WHILE_SHUTDOWN_EXCEPTION_HANDLER);
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) InternalCompletableFuture(com.hazelcast.spi.InternalCompletableFuture) Future(java.util.concurrent.Future) CompletedFuture(com.hazelcast.util.executor.CompletedFuture) OperationService(com.hazelcast.spi.OperationService) Member(com.hazelcast.core.Member) LinkedList(java.util.LinkedList)

Example 87 with OperationService

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

the class BasicRecordStoreLoader method sendOperation.

private Future<?> sendOperation(List<Data> keyValueSequence, AtomicInteger finishedBatchCounter) {
    OperationService operationService = mapServiceContext.getNodeEngine().getOperationService();
    final Operation operation = createOperation(keyValueSequence, finishedBatchCounter);
    //operationService.executeOperation(operation);
    return operationService.invokeOnPartition(MapService.SERVICE_NAME, operation, partitionId);
}
Also used : OperationService(com.hazelcast.spi.OperationService) MapOperation(com.hazelcast.map.impl.operation.MapOperation) Operation(com.hazelcast.spi.Operation) RemoveFromLoadAllOperation(com.hazelcast.map.impl.operation.RemoveFromLoadAllOperation)

Example 88 with OperationService

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

the class BasicRecordStoreLoader method removeExistingKeys.

private Future removeExistingKeys(List<Data> keys) {
    OperationService operationService = mapServiceContext.getNodeEngine().getOperationService();
    final Operation operation = new RemoveFromLoadAllOperation(name, keys);
    return operationService.invokeOnPartition(MapService.SERVICE_NAME, operation, partitionId);
}
Also used : RemoveFromLoadAllOperation(com.hazelcast.map.impl.operation.RemoveFromLoadAllOperation) OperationService(com.hazelcast.spi.OperationService) MapOperation(com.hazelcast.map.impl.operation.MapOperation) Operation(com.hazelcast.spi.Operation) RemoveFromLoadAllOperation(com.hazelcast.map.impl.operation.RemoveFromLoadAllOperation)

Example 89 with OperationService

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

the class MapReduceUtil method notifyRemoteException.

public static void notifyRemoteException(JobSupervisor supervisor, Throwable throwable) {
    MapReduceService mapReduceService = supervisor.getMapReduceService();
    NodeEngine nodeEngine = mapReduceService.getNodeEngine();
    try {
        Address jobOwner = supervisor.getJobOwner();
        if (supervisor.isOwnerNode()) {
            supervisor.notifyRemoteException(jobOwner, throwable);
        } else {
            String name = supervisor.getConfiguration().getName();
            String jobId = supervisor.getConfiguration().getJobId();
            NotifyRemoteExceptionOperation operation = new NotifyRemoteExceptionOperation(name, jobId, throwable);
            OperationService os = nodeEngine.getOperationService();
            os.send(operation, jobOwner);
        }
    } catch (Exception e) {
        ILogger logger = nodeEngine.getLogger(MapReduceUtil.class);
        logger.warning("Could not notify remote map-reduce owner", e);
    }
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) Address(com.hazelcast.nio.Address) ILogger(com.hazelcast.logging.ILogger) OperationService(com.hazelcast.spi.OperationService) NotifyRemoteExceptionOperation(com.hazelcast.mapreduce.impl.operation.NotifyRemoteExceptionOperation) RemoteMapReduceException(com.hazelcast.mapreduce.RemoteMapReduceException) TimeoutException(java.util.concurrent.TimeoutException)

Example 90 with OperationService

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

the class MapReduceUtil method executeOperation.

public static <V> V executeOperation(Operation operation, Address address, MapReduceService mapReduceService, NodeEngine nodeEngine) {
    ClusterService cs = nodeEngine.getClusterService();
    OperationService os = nodeEngine.getOperationService();
    boolean returnsResponse = operation.returnsResponse();
    try {
        if (cs.getThisAddress().equals(address)) {
            // Locally we can call the operation directly
            operation.setNodeEngine(nodeEngine);
            operation.setCallerUuid(nodeEngine.getLocalMember().getUuid());
            operation.setService(mapReduceService);
            operation.run();
            if (returnsResponse) {
                return (V) operation.getResponse();
            }
        } else {
            if (returnsResponse) {
                InvocationBuilder ib = os.createInvocationBuilder(SERVICE_NAME, operation, address);
                return (V) ib.invoke().get();
            } else {
                os.send(operation, address);
            }
        }
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return null;
}
Also used : ClusterService(com.hazelcast.internal.cluster.ClusterService) OperationService(com.hazelcast.spi.OperationService) InvocationBuilder(com.hazelcast.spi.InvocationBuilder) RemoteMapReduceException(com.hazelcast.mapreduce.RemoteMapReduceException) TimeoutException(java.util.concurrent.TimeoutException)

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