Search in sources :

Example 1 with TransactionTimedOutException

use of com.hazelcast.transaction.TransactionTimedOutException in project hazelcast by hazelcast.

the class TransactionalMapProxySupport method lockAndGet.

private VersionedValue lockAndGet(Data key, long timeout, boolean shouldLoad) {
    VersionedValue versionedValue = valueMap.get(key);
    if (versionedValue != null) {
        return versionedValue;
    }
    boolean blockReads = tx.getTransactionType() == TransactionType.ONE_PHASE;
    MapOperation operation = operationProvider.createTxnLockAndGetOperation(name, key, timeout, timeout, tx.getOwnerUuid(), shouldLoad, blockReads);
    operation.setThreadId(ThreadUtil.getThreadId());
    try {
        int partitionId = partitionService.getPartitionId(key);
        Future<VersionedValue> future = operationService.invokeOnPartition(SERVICE_NAME, operation, partitionId);
        versionedValue = future.get();
        if (versionedValue == null) {
            throw new TransactionTimedOutException("Transaction couldn't obtain lock for the key: " + toObjectIfNeeded(key));
        }
        valueMap.put(key, versionedValue);
        return versionedValue;
    } catch (Throwable t) {
        throw rethrow(t);
    }
}
Also used : TransactionTimedOutException(com.hazelcast.transaction.TransactionTimedOutException) MapOperation(com.hazelcast.map.impl.operation.MapOperation)

Aggregations

MapOperation (com.hazelcast.map.impl.operation.MapOperation)1 TransactionTimedOutException (com.hazelcast.transaction.TransactionTimedOutException)1