Search in sources :

Example 1 with InMemoryAtlasDbConfig

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

the class TimeLockTestUtils method createTransactionManager.

static SerializableTransactionManager createTransactionManager(TestableTimelockCluster cluster) {
    List<String> serverUris = cluster.servers().stream().map(server -> server.serverHolder().getTimelockUri()).collect(Collectors.toList());
    AtlasDbConfig config = ImmutableAtlasDbConfig.builder().namespace("test").keyValueService(new InMemoryAtlasDbConfig()).timelock(ImmutableTimeLockClientConfig.builder().serversList(ImmutableServerListConfig.builder().servers(serverUris).sslConfiguration(SslConfiguration.of(Paths.get("var/security/trustStore.jks"))).build()).build()).build();
    return TransactionManagers.builder().config(config).userAgent("test").globalMetricsRegistry(new MetricRegistry()).globalTaggedMetricRegistry(DefaultTaggedMetricRegistry.getDefault()).build().serializable();
}
Also used : ImmutableServerListConfig(com.palantir.atlasdb.config.ImmutableServerListConfig) MetricRegistry(com.codahale.metrics.MetricRegistry) ImmutableTimeLockClientConfig(com.palantir.atlasdb.config.ImmutableTimeLockClientConfig) InMemoryAtlasDbConfig(com.palantir.atlasdb.memory.InMemoryAtlasDbConfig) DefaultTaggedMetricRegistry(com.palantir.tritium.metrics.registry.DefaultTaggedMetricRegistry) Collectors(java.util.stream.Collectors) TransactionManagers(com.palantir.atlasdb.factory.TransactionManagers) List(java.util.List) ImmutableAtlasDbConfig(com.palantir.atlasdb.config.ImmutableAtlasDbConfig) SslConfiguration(com.palantir.remoting.api.config.ssl.SslConfiguration) Paths(java.nio.file.Paths) SerializableTransactionManager(com.palantir.atlasdb.transaction.impl.SerializableTransactionManager) AtlasDbConfig(com.palantir.atlasdb.config.AtlasDbConfig) MetricRegistry(com.codahale.metrics.MetricRegistry) DefaultTaggedMetricRegistry(com.palantir.tritium.metrics.registry.DefaultTaggedMetricRegistry) InMemoryAtlasDbConfig(com.palantir.atlasdb.memory.InMemoryAtlasDbConfig) ImmutableAtlasDbConfig(com.palantir.atlasdb.config.ImmutableAtlasDbConfig) AtlasDbConfig(com.palantir.atlasdb.config.AtlasDbConfig) InMemoryAtlasDbConfig(com.palantir.atlasdb.memory.InMemoryAtlasDbConfig)

Example 2 with InMemoryAtlasDbConfig

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

the class AtlasDbConfigTest method inMemoryConfigWorksWithNonTestNamespace.

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

Example 3 with InMemoryAtlasDbConfig

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

the class AtlasDbConfigTest method inMemoryKeyspaceAndTimelockClientCanBeDifferent.

// Documenting that for in-memory, we don't care what the timelock client is - it just has to be non-empty.
@Test
public void inMemoryKeyspaceAndTimelockClientCanBeDifferent() {
    InMemoryAtlasDbConfig kvsConfig = new InMemoryAtlasDbConfig();
    assertFalse("This test assumes the InMemoryAtlasDbConfig has no namespace by default", kvsConfig.namespace().isPresent());
    ImmutableAtlasDbConfig config = ImmutableAtlasDbConfig.builder().keyValueService(kvsConfig).timelock(TIMELOCK_CONFIG_WITH_OTHER_CLIENT).build();
    assertThat(config.getNamespaceString(), equalTo(OTHER_CLIENT));
}
Also used : InMemoryAtlasDbConfig(com.palantir.atlasdb.memory.InMemoryAtlasDbConfig) Test(org.junit.Test)

Example 4 with InMemoryAtlasDbConfig

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

the class TransactionManagersTest method keyValueServiceMetricsDoNotContainUserAgent.

@Test
public void keyValueServiceMetricsDoNotContainUserAgent() {
    AtlasDbConfig atlasDbConfig = ImmutableAtlasDbConfig.builder().keyValueService(new InMemoryAtlasDbConfig()).build();
    TransactionManagers.builder().config(atlasDbConfig).userAgent("test").globalMetricsRegistry(new MetricRegistry()).globalTaggedMetricRegistry(DefaultTaggedMetricRegistry.getDefault()).registrar(environment).build().serializable();
    assertThat(metricsRule.metrics().getNames().stream().anyMatch(metricName -> metricName.contains(USER_AGENT_NAME)), is(false));
}
Also used : ImmutableTimeLockClientConfig(com.palantir.atlasdb.config.ImmutableTimeLockClientConfig) InMemoryTimestampService(com.palantir.timestamp.InMemoryTimestampService) ImmutableTimestampClientConfig(com.palantir.atlasdb.config.ImmutableTimestampClientConfig) Assert.assertThat(org.junit.Assert.assertThat) ImmutableAtlasDbConfig(com.palantir.atlasdb.config.ImmutableAtlasDbConfig) Mockito.doAnswer(org.mockito.Mockito.doAnswer) After(org.junit.After) ImmutableLeaderConfig(com.palantir.atlasdb.config.ImmutableLeaderConfig) SerializableTransactionManager(com.palantir.atlasdb.transaction.impl.SerializableTransactionManager) TimestampService(com.palantir.timestamp.TimestampService) WireMock.post(com.github.tomakehurst.wiremock.client.WireMock.post) ClassRule(org.junit.ClassRule) ImmutableSet(com.google.common.collect.ImmutableSet) TimestampManagementService(com.palantir.timestamp.TimestampManagementService) Matchers.isA(org.mockito.Matchers.isA) WireMock.aResponse(com.github.tomakehurst.wiremock.client.WireMock.aResponse) ImmutableTimeLockRuntimeConfig(com.palantir.atlasdb.config.ImmutableTimeLockRuntimeConfig) TransactionManager(com.palantir.atlasdb.transaction.api.TransactionManager) UUID(java.util.UUID) DefaultTaggedMetricRegistry(com.palantir.tritium.metrics.registry.DefaultTaggedMetricRegistry) LockMode(com.palantir.lock.LockMode) ServerListConfig(com.palantir.atlasdb.config.ServerListConfig) List(java.util.List) Assert.assertFalse(org.junit.Assert.assertFalse) Matchers.equalTo(org.hamcrest.Matchers.equalTo) TimestampRange(com.palantir.timestamp.TimestampRange) Optional(java.util.Optional) Matchers.is(org.hamcrest.Matchers.is) WireMock.getRequestedFor(com.github.tomakehurst.wiremock.client.WireMock.getRequestedFor) TimeLockClientConfig(com.palantir.atlasdb.config.TimeLockClientConfig) Awaitility(org.awaitility.Awaitility) Mockito.mock(org.mockito.Mockito.mock) ImmutableServerListConfig(com.palantir.atlasdb.config.ImmutableServerListConfig) WireMockConfiguration(com.github.tomakehurst.wiremock.core.WireMockConfiguration) InMemoryAtlasDbConfig(com.palantir.atlasdb.memory.InMemoryAtlasDbConfig) TimestampStoreInvalidator(com.palantir.timestamp.TimestampStoreInvalidator) MappingBuilder(com.github.tomakehurst.wiremock.client.MappingBuilder) SimpleTimeDuration(com.palantir.lock.SimpleTimeDuration) LockServiceImpl(com.palantir.lock.impl.LockServiceImpl) WireMock.postRequestedFor(com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor) Supplier(java.util.function.Supplier) WireMock(com.github.tomakehurst.wiremock.client.WireMock) WireMockRule(com.github.tomakehurst.wiremock.junit.WireMockRule) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) ImmutableList(com.google.common.collect.ImmutableList) LockRequest(com.palantir.lock.LockRequest) QosClientConfig(com.palantir.atlasdb.qos.config.QosClientConfig) ImmutableSortedMap(com.google.common.collect.ImmutableSortedMap) Before(org.junit.Before) WireMock.get(com.github.tomakehurst.wiremock.client.WireMock.get) MetricRegistry(com.codahale.metrics.MetricRegistry) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Assert.assertTrue(org.junit.Assert.assertTrue) Mockito.times(org.mockito.Mockito.times) IOException(java.io.IOException) Test(org.junit.Test) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) Mockito.when(org.mockito.Mockito.when) TimelockService(com.palantir.lock.v2.TimelockService) WireMock.urlMatching(com.github.tomakehurst.wiremock.client.WireMock.urlMatching) Mockito.verify(org.mockito.Mockito.verify) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) AtlasDbRuntimeConfig(com.palantir.atlasdb.config.AtlasDbRuntimeConfig) TimeDuration(com.palantir.lock.TimeDuration) Rule(org.junit.Rule) GenericTestSchema(com.palantir.atlasdb.table.description.GenericTestSchema) TimeLockMigrator(com.palantir.atlasdb.factory.startup.TimeLockMigrator) MetricsRule(com.palantir.atlasdb.util.MetricsRule) LockService(com.palantir.lock.LockService) StringLockDescriptor(com.palantir.lock.StringLockDescriptor) WireMock.urlEqualTo(com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo) Assert.assertEquals(org.junit.Assert.assertEquals) TemporaryFolder(org.junit.rules.TemporaryFolder) PingableLeader(com.palantir.leader.PingableLeader) AtlasDbConfig(com.palantir.atlasdb.config.AtlasDbConfig) DefaultTaggedMetricRegistry(com.palantir.tritium.metrics.registry.DefaultTaggedMetricRegistry) MetricRegistry(com.codahale.metrics.MetricRegistry) ImmutableAtlasDbConfig(com.palantir.atlasdb.config.ImmutableAtlasDbConfig) InMemoryAtlasDbConfig(com.palantir.atlasdb.memory.InMemoryAtlasDbConfig) AtlasDbConfig(com.palantir.atlasdb.config.AtlasDbConfig) InMemoryAtlasDbConfig(com.palantir.atlasdb.memory.InMemoryAtlasDbConfig) Test(org.junit.Test)

Example 5 with InMemoryAtlasDbConfig

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

the class AtlasDbConfigDeserializationTest method canDeserializeMinimalAtlasDbConfig.

@Test
public void canDeserializeMinimalAtlasDbConfig() throws IOException {
    AtlasDbConfig config = AtlasDbConfigs.load(MINIMAL_TEST_CONFIG_FILE, AtlasDbConfig.class);
    assertThat(config.namespace().isPresent()).isFalse();
    assertThat(config.keyValueService()).isEqualTo(new InMemoryAtlasDbConfig());
    assertThat(config.timelock().isPresent()).isFalse();
    assertThat(config.leader().isPresent()).isFalse();
    assertThat(config.enableSweep()).isEqualTo(AtlasDbConstants.DEFAULT_ENABLE_SWEEP);
}
Also used : InMemoryAtlasDbConfig(com.palantir.atlasdb.memory.InMemoryAtlasDbConfig) InMemoryAtlasDbConfig(com.palantir.atlasdb.memory.InMemoryAtlasDbConfig) 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