Search in sources :

Example 6 with InMemoryAtlasDbConfig

use of com.palantir.atlasdb.memory.InMemoryAtlasDbConfig in project atlasdb by palantir.

the class AtlasDbConfigDeserializationTest method canDeserializeAtlasDbConfig.

@Test
public void canDeserializeAtlasDbConfig() throws IOException {
    AtlasDbConfig config = AtlasDbConfigs.load(TEST_CONFIG_FILE, AtlasDbConfig.class);
    assertThat(config.namespace().get()).isEqualTo("brian");
    assertThat(config.keyValueService()).isEqualTo(new InMemoryAtlasDbConfig());
    assertThat(config.timelock().isPresent()).isTrue();
    assertTimeLockConfigDeserializedCorrectly(config.timelock().get());
    assertThat(config.leader().isPresent()).isFalse();
    assertThat(config.enableSweep()).isTrue();
}
Also used : InMemoryAtlasDbConfig(com.palantir.atlasdb.memory.InMemoryAtlasDbConfig) InMemoryAtlasDbConfig(com.palantir.atlasdb.memory.InMemoryAtlasDbConfig) Test(org.junit.Test)

Example 7 with InMemoryAtlasDbConfig

use of com.palantir.atlasdb.memory.InMemoryAtlasDbConfig in project atlasdb by palantir.

the class AtlasDbConfigTest method inMemoryConfigCannotHaveEmptyNamespaceWithEmptyTimelockClient.

@Test
public void inMemoryConfigCannotHaveEmptyNamespaceWithEmptyTimelockClient() {
    InMemoryAtlasDbConfig kvsConfig = new InMemoryAtlasDbConfig();
    assertFalse("This test assumes the InMemoryAtlasDbConfig has no namespace by default", kvsConfig.namespace().isPresent());
    assertThatThrownBy(() -> ImmutableAtlasDbConfig.builder().namespace(Optional.empty()).keyValueService(kvsConfig).timelock(TIMELOCK_CONFIG_WITH_OPTIONAL_EMPTY_CLIENT).build()).isInstanceOf(IllegalStateException.class).satisfies((exception) -> assertThat(exception.getMessage(), containsString("TimeLock client should not be empty")));
}
Also used : InMemoryAtlasDbConfig(com.palantir.atlasdb.memory.InMemoryAtlasDbConfig) Test(org.junit.Test)

Example 8 with InMemoryAtlasDbConfig

use of com.palantir.atlasdb.memory.InMemoryAtlasDbConfig in project atlasdb by palantir.

the class AtlasDbConfigTest method inMemoryConfigCanHaveEmptyNamespace.

@Test
public void inMemoryConfigCanHaveEmptyNamespace() {
    InMemoryAtlasDbConfig kvsConfig = new InMemoryAtlasDbConfig();
    assertFalse("This test assumes the InMemoryAtlasDbConfig has no namespace by default", kvsConfig.namespace().isPresent());
    ImmutableAtlasDbConfig config = ImmutableAtlasDbConfig.builder().namespace(Optional.empty()).keyValueService(kvsConfig).build();
    assertThat(config.getNamespaceString(), equalTo(AtlasDbConfig.UNSPECIFIED_NAMESPACE));
}
Also used : InMemoryAtlasDbConfig(com.palantir.atlasdb.memory.InMemoryAtlasDbConfig) Test(org.junit.Test)

Example 9 with InMemoryAtlasDbConfig

use of com.palantir.atlasdb.memory.InMemoryAtlasDbConfig in project atlasdb by palantir.

the class TransactionManagersTest method setup.

@Before
public void setup() throws JsonProcessingException {
    // Change code to run synchronously, but with a timeout in case something's gone horribly wrong
    originalAsyncMethod = TransactionManagers.runAsync;
    TransactionManagers.runAsync = task -> Awaitility.await().atMost(10, TimeUnit.SECONDS).untilAsserted(task::run);
    availableServer.stubFor(LEADER_UUID_MAPPING.willReturn(aResponse().withStatus(200).withBody(("\"" + UUID.randomUUID().toString() + "\"").getBytes())));
    availableServer.stubFor(TIMESTAMP_MAPPING.willReturn(aResponse().withStatus(200).withBody("1")));
    availableServer.stubFor(LOCK_MAPPING.willReturn(aResponse().withStatus(200).withBody("2")));
    availableServer.stubFor(TIMELOCK_TIMESTAMP_MAPPING.willReturn(aResponse().withStatus(200).withBody("3")));
    availableServer.stubFor(TIMELOCK_ONE_TIMESTAMP_MAPPING.willReturn(aResponse().withStatus(200).withBody(new ObjectMapper().writeValueAsString(TimestampRange.createInclusiveRange(88, 88)))));
    availableServer.stubFor(TIMELOCK_LOCK_MAPPING.willReturn(aResponse().withStatus(200).withBody("4")));
    availableServer.stubFor(TIMELOCK_PING_MAPPING.willReturn(aResponse().withStatus(200).withBody(TimestampManagementService.PING_RESPONSE).withHeader("Content-Type", "text/plain")));
    availableServer.stubFor(TIMELOCK_FF_MAPPING.willReturn(aResponse().withStatus(204)));
    config = mock(AtlasDbConfig.class);
    when(config.leader()).thenReturn(Optional.empty());
    when(config.timestamp()).thenReturn(Optional.empty());
    when(config.lock()).thenReturn(Optional.empty());
    when(config.timelock()).thenReturn(Optional.empty());
    when(config.keyValueService()).thenReturn(new InMemoryAtlasDbConfig());
    when(config.initializeAsync()).thenReturn(false);
    runtimeConfig = mock(AtlasDbRuntimeConfig.class);
    when(runtimeConfig.timestampClient()).thenReturn(ImmutableTimestampClientConfig.of(false));
    when(runtimeConfig.qos()).thenReturn(QosClientConfig.DEFAULT);
    when(runtimeConfig.timelockRuntime()).thenReturn(Optional.empty());
    environment = mock(Consumer.class);
    invalidator = mock(TimestampStoreInvalidator.class);
    when(invalidator.backupAndInvalidate()).thenReturn(EMBEDDED_BOUND);
    availablePort = availableServer.port();
    mockClientConfig = getTimelockConfigForServers(ImmutableList.of(getUriForPort(availablePort)));
    rawRemoteServerConfig = ImmutableServerListConfig.builder().addServers(getUriForPort(availablePort)).build();
    configSupplier = () -> Optional.of(runtimeConfig);
}
Also used : Consumer(java.util.function.Consumer) TimestampStoreInvalidator(com.palantir.timestamp.TimestampStoreInvalidator) AtlasDbRuntimeConfig(com.palantir.atlasdb.config.AtlasDbRuntimeConfig) ImmutableAtlasDbConfig(com.palantir.atlasdb.config.ImmutableAtlasDbConfig) InMemoryAtlasDbConfig(com.palantir.atlasdb.memory.InMemoryAtlasDbConfig) AtlasDbConfig(com.palantir.atlasdb.config.AtlasDbConfig) InMemoryAtlasDbConfig(com.palantir.atlasdb.memory.InMemoryAtlasDbConfig) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Before(org.junit.Before)

Example 10 with InMemoryAtlasDbConfig

use of com.palantir.atlasdb.memory.InMemoryAtlasDbConfig 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

InMemoryAtlasDbConfig (com.palantir.atlasdb.memory.InMemoryAtlasDbConfig)13 Test (org.junit.Test)10 AtlasDbConfig (com.palantir.atlasdb.config.AtlasDbConfig)5 ImmutableAtlasDbConfig (com.palantir.atlasdb.config.ImmutableAtlasDbConfig)5 MetricRegistry (com.codahale.metrics.MetricRegistry)4 DefaultTaggedMetricRegistry (com.palantir.tritium.metrics.registry.DefaultTaggedMetricRegistry)4 SerializableTransactionManager (com.palantir.atlasdb.transaction.impl.SerializableTransactionManager)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 AtlasDbRuntimeConfig (com.palantir.atlasdb.config.AtlasDbRuntimeConfig)2 ImmutableServerListConfig (com.palantir.atlasdb.config.ImmutableServerListConfig)2 ImmutableTimeLockClientConfig (com.palantir.atlasdb.config.ImmutableTimeLockClientConfig)2 DatabaseTsBoundPersisterConfiguration (com.palantir.timelock.config.DatabaseTsBoundPersisterConfiguration)2 List (java.util.List)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 MappingBuilder (com.github.tomakehurst.wiremock.client.MappingBuilder)1 WireMock (com.github.tomakehurst.wiremock.client.WireMock)1 WireMock.aResponse (com.github.tomakehurst.wiremock.client.WireMock.aResponse)1 WireMock.get (com.github.tomakehurst.wiremock.client.WireMock.get)1 WireMock.getRequestedFor (com.github.tomakehurst.wiremock.client.WireMock.getRequestedFor)1 WireMock.post (com.github.tomakehurst.wiremock.client.WireMock.post)1