Search in sources :

Example 1 with TimestampService

use of com.palantir.timestamp.TimestampService in project atlasdb by palantir.

the class PaxosTimeLockServerIntegrationTest method timestampServiceShouldRespectDistinctClientsWhenIssuingTimestamps.

@Test
public void timestampServiceShouldRespectDistinctClientsWhenIssuingTimestamps() {
    TimestampService timestampService1 = getTimestampService(CLIENT_1);
    TimestampService timestampService2 = getTimestampService(CLIENT_2);
    long firstServiceFirstTimestamp = timestampService1.getFreshTimestamp();
    long secondServiceFirstTimestamp = timestampService2.getFreshTimestamp();
    long firstServiceSecondTimestamp = timestampService1.getFreshTimestamp();
    long secondServiceSecondTimestamp = timestampService2.getFreshTimestamp();
    assertEquals(firstServiceFirstTimestamp + 1, firstServiceSecondTimestamp);
    assertEquals(secondServiceFirstTimestamp + 1, secondServiceSecondTimestamp);
}
Also used : TimestampService(com.palantir.timestamp.TimestampService) Test(org.junit.Test)

Example 2 with TimestampService

use of com.palantir.timestamp.TimestampService in project atlasdb by palantir.

the class SweepStatsKeyValueServiceTest method before.

@Before
public void before() {
    TimestampService timestampService = mock(TimestampService.class);
    kvs = SweepStatsKeyValueService.create(delegate, timestampService, () -> AtlasDbConstants.DEFAULT_SWEEP_WRITE_THRESHOLD, () -> AtlasDbConstants.DEFAULT_SWEEP_WRITE_SIZE_THRESHOLD);
}
Also used : TimestampService(com.palantir.timestamp.TimestampService) Before(org.junit.Before)

Example 3 with TimestampService

use of com.palantir.timestamp.TimestampService in project atlasdb by palantir.

the class ServiceExposureEteTest method shouldExposeATimestampServer.

@Test
public void shouldExposeATimestampServer() {
    TimestampService timestampClient = EteSetup.createClientToAllNodes(TimestampService.class);
    assertThat(timestampClient.getFreshTimestamp(), is(not(nullValue())));
}
Also used : TimestampService(com.palantir.timestamp.TimestampService) Test(org.junit.Test)

Example 4 with TimestampService

use of com.palantir.timestamp.TimestampService in project atlasdb by palantir.

the class TimeLockMigrationEteTest method automaticallyMigratesTimestampsAndFailsOnRestart.

@Test
public void automaticallyMigratesTimestampsAndFailsOnRestart() throws Exception {
    TimestampService timestampClient = createEteClientFor(TimestampService.class);
    TodoResource todoClient = createEteClientFor(TodoResource.class);
    todoClient.addTodo(TODO);
    softAssertions.assertThat(todoClient.getTodoList()).as("contains one todo pre-migration").contains(TODO);
    long embeddedTimestamp = timestampClient.getFreshTimestamp();
    softAssertions.assertThat(embeddedTimestamp).as("can get a timestamp before migration").isNotNull();
    upgradeAtlasClientToTimelock();
    assertTimeLockGivesHigherTimestampThan(embeddedTimestamp);
    softAssertions.assertThat(todoClient.getTodoList()).as("can still read todo after migration to TimeLock").contains(TODO);
    todoClient.addTodo(TODO_2);
    softAssertions.assertThat(todoClient.getTodoList()).as("can add a new todo using TimeLock").contains(TODO, TODO_2);
    assertNoLongerExposesEmbeddedTimestampService();
    downgradeAtlasClientFromTimelockWithoutMigration();
    assertCanNeitherReadNorWrite();
}
Also used : TodoResource(com.palantir.atlasdb.todo.TodoResource) TimestampService(com.palantir.timestamp.TimestampService) Test(org.junit.Test)

Example 5 with TimestampService

use of com.palantir.timestamp.TimestampService in project atlasdb by palantir.

the class TimeLockMigrationEteTest method assertNoLongerExposesEmbeddedTimestampService.

private void assertNoLongerExposesEmbeddedTimestampService() {
    TimestampService timestampClient = createEteClientFor(TimestampService.class);
    // as() is not compatible with assertThatThrownBy - see
    // http://joel-costigliola.github.io/assertj/core/api/org/assertj/core/api/Assertions.html
    softAssertions.assertThat(((AtlasDbRemoteException) catchThrowable(timestampClient::getFreshTimestamp)).getStatus()).isEqualTo(404).as("no longer exposes an embedded timestamp service");
}
Also used : TimestampService(com.palantir.timestamp.TimestampService)

Aggregations

TimestampService (com.palantir.timestamp.TimestampService)26 Test (org.junit.Test)12 InMemoryTimestampService (com.palantir.timestamp.InMemoryTimestampService)7 SerializableTransactionManager (com.palantir.atlasdb.transaction.impl.SerializableTransactionManager)6 LockService (com.palantir.lock.LockService)6 SingleBackendCliTestRunner (com.palantir.atlasdb.cli.runner.SingleBackendCliTestRunner)5 KeyValueService (com.palantir.atlasdb.keyvalue.api.KeyValueService)5 DaggerTestAtlasDbServices (com.palantir.atlasdb.services.test.DaggerTestAtlasDbServices)5 TestAtlasDbServices (com.palantir.atlasdb.services.test.TestAtlasDbServices)5 LockRefreshingLockService (com.palantir.lock.client.LockRefreshingLockService)4 Before (org.junit.Before)4 KvsBackedPersistentLockService (com.palantir.atlasdb.persistentlock.KvsBackedPersistentLockService)3 NoOpPersistentLockService (com.palantir.atlasdb.persistentlock.NoOpPersistentLockService)3 PersistentLockService (com.palantir.atlasdb.persistentlock.PersistentLockService)3 SweepStrategyManager (com.palantir.atlasdb.transaction.impl.SweepStrategyManager)3 TransactionService (com.palantir.atlasdb.transaction.service.TransactionService)3 LockClient (com.palantir.lock.LockClient)3 LegacyTimelockService (com.palantir.lock.impl.LegacyTimelockService)3 TimestampManagementService (com.palantir.timestamp.TimestampManagementService)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2