use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.
the class TransactionManagerServiceImpl method finalize.
private boolean finalize(String uuid, String txnId, TxBackupLog log) {
OperationService operationService = nodeEngine.getOperationService();
if (!uuid.equals(log.callerUuid)) {
return false;
}
if (log.state == ACTIVE) {
if (logger.isFinestEnabled()) {
logger.finest("Rolling-back transaction[id:" + txnId + ", state:ACTIVE] of endpoint " + uuid);
}
Collection<Member> memberList = nodeEngine.getClusterService().getMembers();
Collection<Future> futures = new ArrayList<Future>(memberList.size());
for (Member member : memberList) {
Operation op = new BroadcastTxRollbackOperation(txnId);
Future f = operationService.invokeOnTarget(SERVICE_NAME, op, member.getAddress());
futures.add(f);
}
long timeoutMillis = TransactionOptions.getDefault().getTimeoutMillis();
waitWithDeadline(futures, timeoutMillis, TimeUnit.MILLISECONDS, finalizeExceptionHandler);
} else {
TransactionImpl tx;
if (log.allowedDuringPassiveState) {
tx = new AllowedDuringPassiveStateTransactionImpl(this, nodeEngine, txnId, log.records, log.timeoutMillis, log.startTime, log.callerUuid);
} else {
tx = new TransactionImpl(this, nodeEngine, txnId, log.records, log.timeoutMillis, log.startTime, log.callerUuid);
}
if (log.state == COMMITTING) {
if (logger.isFinestEnabled()) {
logger.finest("Committing transaction[id:" + txnId + ", state:COMMITTING] of endpoint " + uuid);
}
try {
tx.commit();
} catch (Throwable e) {
logger.warning("Error during committing from tx backup!", e);
}
} else {
if (logger.isFinestEnabled()) {
logger.finest("Rolling-back transaction[id:" + txnId + ", state:" + log.state + "] of endpoint " + uuid);
}
try {
tx.rollback();
} catch (Throwable e) {
logger.warning("Error during rolling-back from tx backup!", e);
}
}
}
return true;
}
use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.
the class InvokeOnPartitions method retryFailedPartitions.
private void retryFailedPartitions() throws InterruptedException, ExecutionException {
List<Integer> failedPartitions = new LinkedList<Integer>();
for (Map.Entry<Integer, Object> partitionResult : partitionResults.entrySet()) {
int partitionId = partitionResult.getKey();
Object result = partitionResult.getValue();
if (result instanceof Throwable) {
failedPartitions.add(partitionId);
}
}
for (Integer failedPartition : failedPartitions) {
Operation operation;
PartitionAwareOperationFactory partitionAwareFactory = extractPartitionAware(operationFactory);
if (partitionAwareFactory != null) {
operation = partitionAwareFactory.createPartitionOperation(failedPartition);
} else {
operation = operationFactory.createOperation();
}
Future future = operationService.createInvocationBuilder(serviceName, operation, failedPartition).invoke();
partitionResults.put(failedPartition, future);
}
for (Integer failedPartition : failedPartitions) {
Future future = (Future) partitionResults.get(failedPartition);
Object result = future.get();
partitionResults.put(failedPartition, result);
}
}
use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.
the class LockProxySupport method getLockCount.
public int getLockCount(NodeEngine nodeEngine, Data key) {
Operation operation = new GetLockCountOperation(namespace, key);
InternalCompletableFuture<Number> f = invoke(nodeEngine, operation, key);
return f.join().intValue();
}
use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.
the class LockProxySupport method getRemainingLeaseTime.
public long getRemainingLeaseTime(NodeEngine nodeEngine, Data key) {
Operation operation = new GetRemainingLeaseTimeOperation(namespace, key);
InternalCompletableFuture<Number> f = invoke(nodeEngine, operation, key);
return f.join().longValue();
}
use of com.hazelcast.spi.Operation in project hazelcast by hazelcast.
the class CountDownLatchProxy method getCount.
@Override
public int getCount() {
Operation op = new GetCountOperation(name).setPartitionId(partitionId);
InternalCompletableFuture<Integer> f = invokeOnPartition(op);
return f.join();
}
Aggregations