Search in sources :

Example 1 with TimestampRange

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

the class AsyncTimelockServiceIntegrationTest method canGetBatchTimestamps.

@Test
public void canGetBatchTimestamps() {
    TimestampRange range1 = cluster.getFreshTimestamps(5);
    TimestampRange range2 = cluster.timelockService().getFreshTimestamps(5);
    assertThat(range1.getUpperBound()).isLessThan(range2.getLowerBound());
}
Also used : TimestampRange(com.palantir.timestamp.TimestampRange) Test(org.junit.Test)

Example 2 with TimestampRange

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

the class AbstractTimestampServiceTests method canRequestTimestampRangeWithGetFreshTimestamps.

@Test
public void canRequestTimestampRangeWithGetFreshTimestamps() {
    int expectedNumTimestamps = 5;
    TimestampRange range = timestampService.getFreshTimestamps(expectedNumTimestamps);
    Assertions.assertThat((int) range.size()).withFailMessage("Expected %d timestamps, got %d timestamps. (The returned range was: %d-%d)", expectedNumTimestamps, range.size(), range.getLowerBound(), range.getUpperBound()).isGreaterThanOrEqualTo(1).isLessThanOrEqualTo(expectedNumTimestamps);
}
Also used : TimestampRange(com.palantir.timestamp.TimestampRange) Test(org.junit.Test)

Example 3 with TimestampRange

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

the class AbstractTimestampServiceTests method timestampRangesAreReturnedInNonOverlappingOrder.

@Test
public void timestampRangesAreReturnedInNonOverlappingOrder() {
    TimestampRange timestampRange1 = timestampService.getFreshTimestamps(10);
    TimestampRange timestampRange2 = timestampService.getFreshTimestamps(10);
    long firstUpperBound = timestampRange1.getUpperBound();
    long secondLowerBound = timestampRange2.getLowerBound();
    Assertions.assertThat(firstUpperBound).isLessThan(secondLowerBound);
}
Also used : TimestampRange(com.palantir.timestamp.TimestampRange) Test(org.junit.Test)

Example 4 with TimestampRange

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

the class TimestampRemotingTest method testSerializing.

@Test
public void testSerializing() {
    ObjectMapper mapper = new ObjectMapper();
    String uri = dropwizard.baseUri().toString();
    TimestampService ts = Feign.builder().decoder(new JacksonDecoder(mapper)).encoder(new JacksonEncoder(mapper)).contract(new JAXRSContract()).target(TimestampService.class, uri);
    long freshTimestamp = ts.getFreshTimestamp();
    TimestampRange freshTimestamps = ts.getFreshTimestamps(100);
}
Also used : JacksonEncoder(feign.jackson.JacksonEncoder) JAXRSContract(feign.jaxrs.JAXRSContract) TimestampRange(com.palantir.timestamp.TimestampRange) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) InMemoryTimestampService(com.palantir.timestamp.InMemoryTimestampService) TimestampService(com.palantir.timestamp.TimestampService) JacksonDecoder(feign.jackson.JacksonDecoder) Test(org.junit.Test)

Example 5 with TimestampRange

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

the class TimeLockClientTest method getTimestampsDelegates.

@Test
public void getTimestampsDelegates() {
    int numTimestamps = 5;
    TimestampRange timestamps = TimestampRange.createInclusiveRange(1L, numTimestamps);
    when(delegate.getFreshTimestamps(numTimestamps)).thenReturn(timestamps);
    assertThat(timelock.getFreshTimestamps(numTimestamps)).isEqualTo(timestamps);
}
Also used : TimestampRange(com.palantir.timestamp.TimestampRange) Test(org.junit.Test)

Aggregations

TimestampRange (com.palantir.timestamp.TimestampRange)6 Test (org.junit.Test)6 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 InMemoryTimestampService (com.palantir.timestamp.InMemoryTimestampService)1 TimestampService (com.palantir.timestamp.TimestampService)1 JacksonDecoder (feign.jackson.JacksonDecoder)1 JacksonEncoder (feign.jackson.JacksonEncoder)1 JAXRSContract (feign.jaxrs.JAXRSContract)1