Search in sources :

Example 6 with TimelockService

use of com.palantir.lock.v2.TimelockService in project atlasdb by palantir.

the class MetricsBasedTimelockHealthCheckTest method getFreshInstrumentedTimelockService.

private static TimelockService getFreshInstrumentedTimelockService() {
    // Remove previously set metrics
    AtlasDbMetrics.getMetricRegistry().remove(AtlasDbMetricNames.TIMELOCK_FAILED_REQUEST);
    AtlasDbMetrics.getMetricRegistry().remove(AtlasDbMetricNames.TIMELOCK_SUCCESSFUL_REQUEST);
    timelockService = mock(TimelockService.class);
    TimelockService instrumentedTimelockService = new InstrumentedTimelockService(timelockService, AtlasDbMetrics.getMetricRegistry());
    return instrumentedTimelockService;
}
Also used : InstrumentedTimelockService(com.palantir.atlasdb.transaction.impl.InstrumentedTimelockService) TimelockService(com.palantir.lock.v2.TimelockService) InstrumentedTimelockService(com.palantir.atlasdb.transaction.impl.InstrumentedTimelockService)

Example 7 with TimelockService

use of com.palantir.lock.v2.TimelockService in project atlasdb by palantir.

the class MetricsBasedTimelockHealthCheckTest method timlockIsUnhealthyAfterOneSuccessMultipleFailures.

@Test
public void timlockIsUnhealthyAfterOneSuccessMultipleFailures() {
    TimelockService instrumentedTimelockService = getFreshInstrumentedTimelockService();
    when(timelockService.getFreshTimestamp()).thenReturn(0L).thenThrow(new RuntimeException());
    tryGetFreshTimestamp(instrumentedTimelockService, 10);
    waitForClockTick();
    assertThat(timelockHealthCheck.getStatus().isHealthy()).isFalse();
}
Also used : InstrumentedTimelockService(com.palantir.atlasdb.transaction.impl.InstrumentedTimelockService) TimelockService(com.palantir.lock.v2.TimelockService) Test(org.junit.Test)

Example 8 with TimelockService

use of com.palantir.lock.v2.TimelockService in project atlasdb by palantir.

the class MetricsBasedTimelockHealthCheckTest method timelockIsHealthyAfterSuccessfulRequests.

@Test
public void timelockIsHealthyAfterSuccessfulRequests() {
    TimelockService instrumentedTimelockService = getFreshInstrumentedTimelockService();
    when(timelockService.getFreshTimestamp()).thenReturn(0L);
    tryGetFreshTimestamp(instrumentedTimelockService, 10);
    waitForClockTick();
    assertThat(timelockHealthCheck.getStatus().isHealthy()).isTrue();
}
Also used : InstrumentedTimelockService(com.palantir.atlasdb.transaction.impl.InstrumentedTimelockService) TimelockService(com.palantir.lock.v2.TimelockService) Test(org.junit.Test)

Example 9 with TimelockService

use of com.palantir.lock.v2.TimelockService in project atlasdb by palantir.

the class MetricsBasedTimelockHealthCheckTest method timlockIsHealthyAfterOneFailureMultipleSuccesses.

@Test
public void timlockIsHealthyAfterOneFailureMultipleSuccesses() {
    TimelockService instrumentedTimelockService = getFreshInstrumentedTimelockService();
    when(timelockService.getFreshTimestamp()).thenThrow(new RuntimeException()).thenReturn(0L);
    tryGetFreshTimestamp(instrumentedTimelockService, 10);
    waitForClockTick();
    assertThat(timelockHealthCheck.getStatus().isHealthy()).isTrue();
}
Also used : InstrumentedTimelockService(com.palantir.atlasdb.transaction.impl.InstrumentedTimelockService) TimelockService(com.palantir.lock.v2.TimelockService) Test(org.junit.Test)

Example 10 with TimelockService

use of com.palantir.lock.v2.TimelockService in project atlasdb by palantir.

the class MetricsBasedTimelockHealthCheckTest method timelockIsUnhealthyAfterFailedRequests.

@Test
public void timelockIsUnhealthyAfterFailedRequests() {
    TimelockService instrumentedTimelockService = getFreshInstrumentedTimelockService();
    when(timelockService.getFreshTimestamp()).thenThrow(new RuntimeException());
    tryGetFreshTimestamp(instrumentedTimelockService, 10);
    waitForClockTick();
    assertThat(timelockHealthCheck.getStatus().isHealthy()).isFalse();
}
Also used : InstrumentedTimelockService(com.palantir.atlasdb.transaction.impl.InstrumentedTimelockService) TimelockService(com.palantir.lock.v2.TimelockService) Test(org.junit.Test)

Aggregations

TimelockService (com.palantir.lock.v2.TimelockService)15 Test (org.junit.Test)11 InstrumentedTimelockService (com.palantir.atlasdb.transaction.impl.InstrumentedTimelockService)7 LockService (com.palantir.lock.LockService)5 LockToken (com.palantir.lock.v2.LockToken)4 TransactionManager (com.palantir.atlasdb.transaction.api.TransactionManager)3 LegacyTimelockService (com.palantir.lock.impl.LegacyTimelockService)3 TimelockTimestampServiceAdapter (com.palantir.atlasdb.transaction.impl.TimelockTimestampServiceAdapter)2 KvsBackedPersistentLockService (com.palantir.atlasdb.persistentlock.KvsBackedPersistentLockService)1 NoOpPersistentLockService (com.palantir.atlasdb.persistentlock.NoOpPersistentLockService)1 PersistentLockService (com.palantir.atlasdb.persistentlock.PersistentLockService)1 ManagedTimestampService (com.palantir.atlasdb.timelock.paxos.ManagedTimestampService)1 AsyncOrLegacyTimelockService (com.palantir.atlasdb.timelock.util.AsyncOrLegacyTimelockService)1 LockRefreshingLockService (com.palantir.lock.client.LockRefreshingLockService)1