use of com.hazelcast.spi.NodeEngine in project hazelcast by hazelcast.
the class GetAndAlterOperation method run.
@Override
public void run() throws Exception {
NodeEngine nodeEngine = getNodeEngine();
IFunction f = nodeEngine.toObject(function);
AtomicReferenceContainer atomicReferenceContainer = getReferenceContainer();
response = atomicReferenceContainer.get();
Object input = nodeEngine.toObject(atomicReferenceContainer.get());
//noinspection unchecked
Object output = f.apply(input);
Data serializedOutput = nodeEngine.toData(output);
shouldBackup = !isEquals(response, serializedOutput);
if (shouldBackup) {
atomicReferenceContainer.set(serializedOutput);
backup = serializedOutput;
}
}
use of com.hazelcast.spi.NodeEngine in project hazelcast by hazelcast.
the class SemaphoreDetachMemberOperation method shouldBackup.
@Override
public boolean shouldBackup() {
final NodeEngine nodeEngine = getNodeEngine();
IPartitionService partitionService = nodeEngine.getPartitionService();
IPartition partition = partitionService.getPartition(getPartitionId());
return partition.isLocal() && Boolean.TRUE.equals(response);
}
use of com.hazelcast.spi.NodeEngine 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);
}
use of com.hazelcast.spi.NodeEngine in project hazelcast by hazelcast.
the class ExecutorServiceProxy method submitToMembers.
@Override
public <T> void submitToMembers(Callable<T> task, Collection<Member> members, MultiExecutionCallback callback) {
NodeEngine nodeEngine = getNodeEngine();
ExecutionCallbackAdapterFactory executionCallbackFactory = new ExecutionCallbackAdapterFactory(nodeEngine.getLogger(ExecutionCallbackAdapterFactory.class), members, callback);
for (Member member : members) {
submitToMember(task, member, executionCallbackFactory.<T>callbackFor(member));
}
}
use of com.hazelcast.spi.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<Future>();
for (Member member : members) {
if (member.localMember()) {
getService().shutdownExecutor(name);
} else {
ShutdownOperation op = new ShutdownOperation(name);
Future f = operationService.invokeOnTarget(SERVICE_NAME, op, member.getAddress());
calls.add(f);
}
}
waitWithDeadline(calls, 1, TimeUnit.SECONDS, WHILE_SHUTDOWN_EXCEPTION_HANDLER);
}
Aggregations