Search in sources :

Example 6 with NodeEngine

use of com.hazelcast.spi.impl.NodeEngine in project hazelcast by hazelcast.

the class ApplyOp method callFunction.

private Data callFunction(Data currentData) {
    NodeEngine nodeEngine = getNodeEngine();
    IFunction func = nodeEngine.toObject(function);
    Object input = nodeEngine.toObject(currentData);
    // noinspection unchecked
    Object output = func.apply(input);
    return nodeEngine.toData(output);
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) IFunction(com.hazelcast.core.IFunction)

Example 7 with NodeEngine

use of com.hazelcast.spi.impl.NodeEngine in project hazelcast by hazelcast.

the class ExecutorServiceProxy method submitToMember.

private <T> void submitToMember(@Nonnull Data taskData, @Nonnull Member member, @Nullable ExecutionCallback<T> callback) {
    checkNotNull(member, "member must not be null");
    checkNotShutdown();
    NodeEngine nodeEngine = getNodeEngine();
    UUID uuid = newUnsecureUUID();
    MemberCallableTaskOperation op = new MemberCallableTaskOperation(name, uuid, taskData);
    OperationService operationService = nodeEngine.getOperationService();
    Address address = member.getAddress();
    InvocationFuture<T> future = operationService.createInvocationBuilder(DistributedExecutorService.SERVICE_NAME, op, address).invoke();
    if (callback != null) {
        future.whenCompleteAsync(new ExecutionCallbackAdapter<>(callback)).whenCompleteAsync((v, t) -> {
            if (t instanceof RejectedExecutionException) {
                callback.onFailure(t);
            }
        });
    }
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) Address(com.hazelcast.cluster.Address) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) UuidUtil.newUnsecureUUID(com.hazelcast.internal.util.UuidUtil.newUnsecureUUID) UUID(java.util.UUID) MemberCallableTaskOperation(com.hazelcast.executor.impl.operations.MemberCallableTaskOperation) RejectedExecutionException(java.util.concurrent.RejectedExecutionException)

Example 8 with NodeEngine

use of com.hazelcast.spi.impl.NodeEngine in project hazelcast by hazelcast.

the class ExecutorServiceProxy method submitToKeyOwner.

@Override
public <T> void submitToKeyOwner(@Nonnull Callable<T> task, @Nonnull Object key, @Nullable ExecutionCallback<T> callback) {
    checkNotNull(key, "key must not be null");
    checkNotNull(task, "task must not be null");
    NodeEngine nodeEngine = getNodeEngine();
    submitToPartitionOwner(task, callback, nodeEngine.getPartitionService().getPartitionId(key));
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine)

Example 9 with NodeEngine

use of com.hazelcast.spi.impl.NodeEngine in project hazelcast by hazelcast.

the class ExecutorServiceProxy method submitToKeyOwner.

@Override
public <T> Future<T> submitToKeyOwner(@Nonnull Callable<T> task, @Nonnull Object key) {
    checkNotNull(key, "key must not be null");
    NodeEngine nodeEngine = getNodeEngine();
    return submitToPartitionOwner(task, nodeEngine.getPartitionService().getPartitionId(key));
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine)

Example 10 with NodeEngine

use of com.hazelcast.spi.impl.NodeEngine in project hazelcast by hazelcast.

the class DurableExecutorServiceProxy 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) {
        ShutdownOperation op = new ShutdownOperation(name);
        Future f = operationService.invokeOnTarget(SERVICE_NAME, op, member.getAddress());
        calls.add(f);
    }
    waitWithDeadline(calls, 3, TimeUnit.SECONDS, shutdownExceptionHandler);
}
Also used : NodeEngine(com.hazelcast.spi.impl.NodeEngine) DurableExecutorServiceFuture(com.hazelcast.durableexecutor.DurableExecutorServiceFuture) InternalCompletableFuture(com.hazelcast.spi.impl.InternalCompletableFuture) Future(java.util.concurrent.Future) DelegatingCompletableFuture(com.hazelcast.spi.impl.DelegatingCompletableFuture) ShutdownOperation(com.hazelcast.durableexecutor.impl.operations.ShutdownOperation) OperationService(com.hazelcast.spi.impl.operationservice.OperationService) Member(com.hazelcast.cluster.Member) LinkedList(java.util.LinkedList)

Aggregations

NodeEngine (com.hazelcast.spi.impl.NodeEngine)165 Data (com.hazelcast.internal.serialization.Data)48 OperationService (com.hazelcast.spi.impl.operationservice.OperationService)30 Address (com.hazelcast.cluster.Address)22 Test (org.junit.Test)21 ILogger (com.hazelcast.logging.ILogger)20 HazelcastInstance (com.hazelcast.core.HazelcastInstance)18 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)18 QuickTest (com.hazelcast.test.annotation.QuickTest)18 Config (com.hazelcast.config.Config)17 Operation (com.hazelcast.spi.impl.operationservice.Operation)16 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)15 IPartitionService (com.hazelcast.internal.partition.IPartitionService)12 Nonnull (javax.annotation.Nonnull)12 ArrayList (java.util.ArrayList)11 Future (java.util.concurrent.Future)11 Member (com.hazelcast.cluster.Member)10 UUID (java.util.UUID)10 InitializingObject (com.hazelcast.spi.impl.InitializingObject)9 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)9