@Override public MapOperation createTxnLockAndGetOperation(String name, Data dataKey, long timeout, long ttl, String ownerUuid, boolean shouldLoad, boolean blockReads) { return getDelegate().createTxnLockAndGetOperation(name, dataKey, timeout, ttl, ownerUuid, shouldLoad, blockReads); }
@Override public MapOperation createTxnLockAndGetOperation(String name, Data dataKey, long timeout, long ttl, String ownerUuid, boolean shouldLoad, boolean blockReads) { return getDelegate().createTxnLockAndGetOperation(name, dataKey, timeout, ttl, ownerUuid, shouldLoad, blockReads); }
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); } }
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); } }