Search in sources :

Example 1 with InstrumentedTimelockService

use of com.palantir.atlasdb.transaction.impl.InstrumentedTimelockService 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 2 with InstrumentedTimelockService

use of com.palantir.atlasdb.transaction.impl.InstrumentedTimelockService 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 3 with InstrumentedTimelockService

use of com.palantir.atlasdb.transaction.impl.InstrumentedTimelockService 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 4 with InstrumentedTimelockService

use of com.palantir.atlasdb.transaction.impl.InstrumentedTimelockService 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 5 with InstrumentedTimelockService

use of com.palantir.atlasdb.transaction.impl.InstrumentedTimelockService 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

InstrumentedTimelockService (com.palantir.atlasdb.transaction.impl.InstrumentedTimelockService)6 TimelockService (com.palantir.lock.v2.TimelockService)6 Test (org.junit.Test)4 TimelockTimestampServiceAdapter (com.palantir.atlasdb.transaction.impl.TimelockTimestampServiceAdapter)1 LegacyTimelockService (com.palantir.lock.impl.LegacyTimelockService)1