Search in sources :

Example 1 with TimeDuration

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");
}
Also used : AtlasRowLockDescriptor(com.palantir.lock.AtlasRowLockDescriptor) LockDescriptor(com.palantir.lock.LockDescriptor) HeldLocksToken(com.palantir.lock.HeldLocksToken) ImmutableSortedMap(com.google.common.collect.ImmutableSortedMap) SimpleTimeDuration(com.palantir.lock.SimpleTimeDuration) TimeDuration(com.palantir.lock.TimeDuration) LockMode(com.palantir.lock.LockMode)

Example 2 with TimeDuration

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");
}
Also used : HeldLocksToken(com.palantir.lock.HeldLocksToken) SimpleTimeDuration(com.palantir.lock.SimpleTimeDuration) TimeDuration(com.palantir.lock.TimeDuration)

Example 3 with TimeDuration

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());
}
Also used : DefaultTaggedMetricRegistry(com.palantir.tritium.metrics.registry.DefaultTaggedMetricRegistry) MetricRegistry(com.codahale.metrics.MetricRegistry) SimpleTimeDuration(com.palantir.lock.SimpleTimeDuration) TimeDuration(com.palantir.lock.TimeDuration) ImmutableAtlasDbConfig(com.palantir.atlasdb.config.ImmutableAtlasDbConfig) InMemoryAtlasDbConfig(com.palantir.atlasdb.memory.InMemoryAtlasDbConfig) AtlasDbConfig(com.palantir.atlasdb.config.AtlasDbConfig) InMemoryAtlasDbConfig(com.palantir.atlasdb.memory.InMemoryAtlasDbConfig) LockRequest(com.palantir.lock.LockRequest) Test(org.junit.Test)

Aggregations

SimpleTimeDuration (com.palantir.lock.SimpleTimeDuration)3 TimeDuration (com.palantir.lock.TimeDuration)3 HeldLocksToken (com.palantir.lock.HeldLocksToken)2 MetricRegistry (com.codahale.metrics.MetricRegistry)1 ImmutableSortedMap (com.google.common.collect.ImmutableSortedMap)1 AtlasDbConfig (com.palantir.atlasdb.config.AtlasDbConfig)1 ImmutableAtlasDbConfig (com.palantir.atlasdb.config.ImmutableAtlasDbConfig)1 InMemoryAtlasDbConfig (com.palantir.atlasdb.memory.InMemoryAtlasDbConfig)1 AtlasRowLockDescriptor (com.palantir.lock.AtlasRowLockDescriptor)1 LockDescriptor (com.palantir.lock.LockDescriptor)1 LockMode (com.palantir.lock.LockMode)1 LockRequest (com.palantir.lock.LockRequest)1 DefaultTaggedMetricRegistry (com.palantir.tritium.metrics.registry.DefaultTaggedMetricRegistry)1 Test (org.junit.Test)1