private static Cell getTransactionCell(long startTimestamp) { return Cell.create( TransactionConstants.getValueForTimestamp(startTimestamp), TransactionConstants.COMMIT_TS_COLUMN); } }
private static Cell getTransactionCell(long startTimestamp) { return Cell.create(TransactionConstants.getValueForTimestamp(startTimestamp), TransactionConstants.COMMIT_TS_COLUMN); }
private void commit(long timestamp) { Cell cell = Cell.create( TransactionConstants.getValueForTimestamp(timestamp), TransactionConstants.COMMIT_TS_COLUMN); byte[] value = TransactionConstants.getValueForTimestamp(timestamp); delegate().putUnlessExists(TransactionConstants.TRANSACTION_TABLE, ImmutableMap.of(cell, value)); } }
public void putAll(Map<Long, Long> timestampMap) throws KeyAlreadyExistsException { Map<Cell, byte[]> kvMap = new HashMap<>(); for (Map.Entry<Long, Long> entry : timestampMap.entrySet()) { kvMap.put( getTransactionCell(entry.getKey()), TransactionConstants.getValueForTimestamp(entry.getValue())); } keyValueService.put(TransactionConstants.TRANSACTION_TABLE, kvMap, 0); // This can throw unchecked exceptions }
public void putUnlessExists(long startTimestamp, long commitTimestamp) throws KeyAlreadyExistsException { Cell key = getTransactionCell(startTimestamp); byte[] value = TransactionConstants.getValueForTimestamp(commitTimestamp); keyValueService.putUnlessExists(TransactionConstants.TRANSACTION_TABLE, ImmutableMap.of(key, value)); }
@Override public void putUnlessExists(long startTimestamp, long commitTimestamp) { Cell key = getTransactionCell(startTimestamp); byte[] value = TransactionConstants .getValueForTimestamp(commitTimestamp); keyValueService.putUnlessExists(TransactionConstants.TRANSACTION_TABLE, ImmutableMap.of(key, value)); }
/** * We will block here until the passed transactions have released their lock. This means that * the committing transaction is either complete or it has failed and we are allowed to roll * it back. */ private void waitForCommitToComplete(Iterable<Long> startTimestamps) { boolean isEmpty = true; Set<LockDescriptor> lockDescriptors = Sets.newHashSet(); for (long start : startTimestamps) { if (start < immutableTimestamp) { // We don't need to block in this case because this transaction is already complete continue; } isEmpty = false; lockDescriptors.add( AtlasRowLockDescriptor.of( TransactionConstants.TRANSACTION_TABLE.getQualifiedName(), TransactionConstants.getValueForTimestamp(start))); } if (isEmpty) { return; } waitFor(lockDescriptors); }
e.getKey().getRowName()); if (Arrays.equals(e.getValue(), TransactionConstants.getValueForTimestamp(TransactionConstants.FAILED_COMMIT_TS))) { mapToAssertLockNotHeld.put(descriptor, LockMode.READ); } else {
AtlasRowLockDescriptor.of( TransactionConstants.TRANSACTION_TABLE.getQualifiedName(), TransactionConstants.getValueForTimestamp(getStartTimestamp()))); continue;
KeyValueService kvs = services.getKeyValueService(); byte[] startBytes = TransactionConstants.getValueForTimestamp(startTimestamp); byte[] timestampBytes = TransactionConstants.getValueForTimestamp(timestamp);
private HeldLocksToken getExpiredHeldLocksToken() { ImmutableSortedMap.Builder<LockDescriptor, LockMode> builder = ImmutableSortedMap.naturalOrder(); builder.put( AtlasRowLockDescriptor.of( TransactionConstants.TRANSACTION_TABLE.getQualifiedName(), TransactionConstants.getValueForTimestamp(0L)), LockMode.WRITE); long creationDateMs = System.currentTimeMillis(); long expirationDateMs = creationDateMs - 1; TimeDuration lockTimeout = SimpleTimeDuration.of(0, TimeUnit.SECONDS); long versionId = 0L; return new HeldLocksToken( BigInteger.ZERO, lockClient, creationDateMs, expirationDateMs, LockCollections.of(builder.build()), lockTimeout, versionId, "Dummy thread"); }
private static Cell getTransactionCell(long startTimestamp) { return Cell.create(TransactionConstants.getValueForTimestamp(startTimestamp), TransactionConstants.COMMIT_TS_COLUMN); }
private static Cell getTransactionCell(long startTimestamp) { return Cell.create( TransactionConstants.getValueForTimestamp(startTimestamp), TransactionConstants.COMMIT_TS_COLUMN); } }
public void putAll(Map<Long, Long> timestampMap) throws KeyAlreadyExistsException { Map<Cell, byte[]> kvMap = new HashMap<>(); for (Map.Entry<Long, Long> entry : timestampMap.entrySet()) { kvMap.put( getTransactionCell(entry.getKey()), TransactionConstants.getValueForTimestamp(entry.getValue())); } keyValueService.put(TransactionConstants.TRANSACTION_TABLE, kvMap, 0); // This can throw unchecked exceptions }
private void commit(long timestamp) { Cell cell = Cell.create( TransactionConstants.getValueForTimestamp(timestamp), TransactionConstants.COMMIT_TS_COLUMN); byte[] value = TransactionConstants.getValueForTimestamp(timestamp); delegate().putUnlessExists(TransactionConstants.TRANSACTION_TABLE, ImmutableMap.of(cell, value)); } }
public void putUnlessExists(long startTimestamp, long commitTimestamp) throws KeyAlreadyExistsException { Cell key = getTransactionCell(startTimestamp); byte[] value = TransactionConstants.getValueForTimestamp(commitTimestamp); keyValueService.putUnlessExists(TransactionConstants.TRANSACTION_TABLE, ImmutableMap.of(key, value)); }
@Override public void putUnlessExists(long startTimestamp, long commitTimestamp) { Cell key = getTransactionCell(startTimestamp); byte[] value = TransactionConstants .getValueForTimestamp(commitTimestamp); keyValueService.putUnlessExists(TransactionConstants.TRANSACTION_TABLE, ImmutableMap.of(key, value)); }
/** * We will block here until the passed transactions have released their lock. This means that * the committing transaction is either complete or it has failed and we are allowed to roll * it back. */ private void waitForCommitToComplete(Iterable<Long> startTimestamps) { boolean isEmpty = true; Set<LockDescriptor> lockDescriptors = Sets.newHashSet(); for (long start : startTimestamps) { if (start < immutableTimestamp) { // We don't need to block in this case because this transaction is already complete continue; } isEmpty = false; lockDescriptors.add( AtlasRowLockDescriptor.of( TransactionConstants.TRANSACTION_TABLE.getQualifiedName(), TransactionConstants.getValueForTimestamp(start))); } if (isEmpty) { return; } waitFor(lockDescriptors); }
e.getKey().getRowName()); if (Arrays.equals(e.getValue(), TransactionConstants.getValueForTimestamp(TransactionConstants.FAILED_COMMIT_TS))) { mapToAssertLockNotHeld.put(descriptor, LockMode.READ); } else {
AtlasRowLockDescriptor.of( TransactionConstants.TRANSACTION_TABLE.getQualifiedName(), TransactionConstants.getValueForTimestamp(getStartTimestamp()))); continue;