use of com.palantir.lock.TimeDuration in project atlasdb by palantir.
the class SnapshotTransactionTest method getExpiredHeldLocksToken.
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");
}
use of com.palantir.lock.TimeDuration in project atlasdb by palantir.
the class AdvisoryLocksConditionTest method getHeldLocksToken.
private static HeldLocksToken getHeldLocksToken(BigInteger tokenId) {
long creationDateMs = System.currentTimeMillis();
long expirationDateMs = creationDateMs - 1;
TimeDuration lockTimeout = SimpleTimeDuration.of(0, TimeUnit.SECONDS);
long versionId = 0L;
return new HeldLocksToken(tokenId, LockClient.of("fake lock client"), creationDateMs, expirationDateMs, LOCK_DESCRIPTORS, lockTimeout, versionId, "Dummy thread");
}
use of com.palantir.lock.TimeDuration in project atlasdb by palantir.
the class TransactionManagersTest method setsGlobalDefaultLockTimeout.
@Test
public void setsGlobalDefaultLockTimeout() {
TimeDuration expectedTimeout = SimpleTimeDuration.of(47, TimeUnit.SECONDS);
AtlasDbConfig atlasDbConfig = ImmutableAtlasDbConfig.builder().keyValueService(new InMemoryAtlasDbConfig()).defaultLockTimeoutSeconds((int) expectedTimeout.getTime()).build();
TransactionManagers.builder().config(atlasDbConfig).userAgent("test").globalMetricsRegistry(new MetricRegistry()).globalTaggedMetricRegistry(DefaultTaggedMetricRegistry.getDefault()).registrar(environment).build().serializable();
assertEquals(expectedTimeout, LockRequest.getDefaultLockTimeout());
LockRequest lockRequest = LockRequest.builder(ImmutableSortedMap.of(StringLockDescriptor.of("foo"), LockMode.WRITE)).build();
assertEquals(expectedTimeout, lockRequest.getLockTimeout());
}
Aggregations