use of com.hazelcast.spi.impl.operationservice.Operation in project hazelcast by hazelcast.
the class AbstractPartitionMessageTask method processInternal.
@Override
protected CompletableFuture<Object> processInternal() {
Operation op = prepareOperation();
if (ClientMessage.isFlagSet(clientMessage.getHeaderFlags(), ClientMessage.BACKUP_AWARE_FLAG)) {
op.setClientCallId(clientMessage.getCorrelationId());
}
op.setCallerUuid(endpoint.getUuid());
return nodeEngine.getOperationService().createInvocationBuilder(getServiceName(), op, getPartitionId()).setResultDeserialized(false).invoke();
}
use of com.hazelcast.spi.impl.operationservice.Operation in project hazelcast by hazelcast.
the class XAClearRemoteTransactionMessageTask method call.
@Override
protected Object call() throws Exception {
OperationServiceImpl operationService = nodeEngine.getOperationService();
InternalPartitionService partitionService = nodeEngine.getPartitionService();
Data xidData = serializationService.toData(parameters);
Operation op = new ClearRemoteTransactionOperation(xidData);
op.setCallerUuid(endpoint.getUuid());
int partitionId = partitionService.getPartitionId(xidData);
InvocationBuilder builder = operationService.createInvocationBuilder(getServiceName(), op, partitionId);
builder.setTryCount(TRY_COUNT).setResultDeserialized(false);
builder.invoke();
return XATransactionClearRemoteCodec.encodeResponse();
}
use of com.hazelcast.spi.impl.operationservice.Operation in project hazelcast by hazelcast.
the class ScheduledExecutorShutdownMessageTask method prepareOperation.
@Override
protected Operation prepareOperation() {
Operation op = new ShutdownOperation(parameters.schedulerName);
op.setCallerUuid(endpoint.getUuid());
return op;
}
use of com.hazelcast.spi.impl.operationservice.Operation in project hazelcast by hazelcast.
the class RaftService method resetCPSubsystem.
InternalCompletableFuture<Void> resetCPSubsystem() {
checkState(cpSubsystemEnabled, "CP Subsystem is not enabled!");
InternalCompletableFuture<Void> future = newCompletableFuture();
ClusterService clusterService = nodeEngine.getClusterService();
Collection<Member> members = clusterService.getMembers(NON_LOCAL_MEMBER_SELECTOR);
if (!clusterService.isMaster()) {
return complete(future, new IllegalStateException("Only master can reset CP Subsystem!"));
}
if (config.getCPMemberCount() > members.size() + 1) {
return complete(future, new IllegalStateException("Not enough cluster members to reset CP Subsystem! " + "Required: " + config.getCPMemberCount() + ", available: " + (members.size() + 1)));
}
BiConsumer<Void, Throwable> callback = new BiConsumer<Void, Throwable>() {
final AtomicInteger latch = new AtomicInteger(members.size());
volatile Throwable failure;
@Override
public void accept(Void aVoid, Throwable throwable) {
if (throwable == null) {
if (latch.decrementAndGet() == 0) {
if (failure == null) {
future.complete(null);
} else {
complete(future, failure);
}
}
} else {
failure = throwable;
if (latch.decrementAndGet() == 0) {
complete(future, throwable);
}
}
}
};
long seed = newSeed();
logger.warning("Resetting CP Subsystem with groupId seed: " + seed);
resetLocal(seed);
OperationServiceImpl operationService = nodeEngine.getOperationService();
for (Member member : members) {
Operation op = new ResetCPMemberOp(seed);
operationService.<Void>invokeOnTarget(SERVICE_NAME, op, member.getAddress()).whenCompleteAsync(callback);
}
return future;
}
use of com.hazelcast.spi.impl.operationservice.Operation in project hazelcast by hazelcast.
the class RaftService method completeFutures.
/**
* Completes all futures registered with {@code indices}
* in the CP group associated with {@code groupId}.
*
* @return {@code true} if the CP group exists, {@code false} otherwise.
*/
public boolean completeFutures(CPGroupId groupId, Collection<Entry<Long, Object>> results) {
if (cpSubsystemEnabled) {
RaftNodeImpl raftNode = (RaftNodeImpl) getRaftNode(groupId);
if (raftNode == null) {
return false;
}
for (Entry<Long, Object> result : results) {
raftNode.completeFuture(result.getKey(), result.getValue());
}
} else {
int partitionId = getCPGroupPartitionId(groupId);
UnsafeModePartitionState unsafeModeState = unsafeModeStates[partitionId];
for (Entry<Long, Object> result : results) {
Operation op = unsafeModeState.removeWaitingOp(result.getKey());
sendOperationResponse(op, result.getValue());
}
}
return true;
}
Aggregations