Search in sources :

Example 6 with AtlasDbConfig

use of com.palantir.atlasdb.config.AtlasDbConfig in project atlasdb by palantir.

the class AtlasDbCliCommand method run.

@Override
protected void run(Bootstrap<T> bootstrap, Namespace namespace, T configuration) throws Exception {
    AtlasDbConfig cliConfiguration = AtlasDbCommandUtils.convertServerConfigToClientConfig(configuration.getAtlasDbConfig(), configuration.getAtlasDbRuntimeConfig());
    Map<String, OptionType> optionTypes = getCliOptionTypes();
    Map<String, Object> globalAttrs = Maps.filterKeys(namespace.getAttrs(), key -> optionTypes.get(key) == OptionType.GLOBAL);
    Map<String, Object> groupAttrs = Maps.filterKeys(namespace.getAttrs(), key -> optionTypes.get(key) == OptionType.GROUP);
    Map<String, Object> commandAttrs = Maps.filterKeys(namespace.getAttrs(), key -> optionTypes.get(key) == OptionType.COMMAND);
    Iterable<String> groups = Iterables.limit(namespace.getList(COMMAND_NAME_ATTR), 1);
    Iterable<String> commands = Iterables.skip(namespace.getList(COMMAND_NAME_ATTR), 1);
    List<String> allArgs = ImmutableList.<String>builder().add("--inline-config").add(AtlasDbCommandUtils.serialiseConfiguration(cliConfiguration)).addAll(AtlasDbCommandUtils.gatherPassedInArguments(globalAttrs)).addAll(groups).addAll(AtlasDbCommandUtils.gatherPassedInArguments(groupAttrs)).addAll(commands).addAll(AtlasDbCommandUtils.gatherPassedInArguments(commandAttrs)).build();
    try {
        CLI.parse(allArgs).call();
    } catch (Throwable e) {
        log.error("Error running AtlasDB CLI", e);
        throw e;
    }
}
Also used : AtlasDbConfig(com.palantir.atlasdb.config.AtlasDbConfig) OptionType(io.airlift.airline.OptionType)

Example 7 with AtlasDbConfig

use of com.palantir.atlasdb.config.AtlasDbConfig in project atlasdb by palantir.

the class AtlasDbConsoleCommandTest method lockAndTimestampFieldsShouldBeSetWhenRunningOnline.

@Test
public void lockAndTimestampFieldsShouldBeSetWhenRunningOnline() throws JsonProcessingException {
    AtlasDbConfig cliConfig = getConfigFromConsoleCommand(ONLINE_PARAMS, MINIMAL_LEADER_CONFIG);
    assertThat(cliConfig.lock().isPresent()).describedAs("Lock block must be present").isTrue();
    assertThat(cliConfig.timestamp().isPresent()).describedAs("Timestamp block must be present").isTrue();
}
Also used : InMemoryAtlasDbConfig(com.palantir.atlasdb.memory.InMemoryAtlasDbConfig) ImmutableAtlasDbConfig(com.palantir.atlasdb.config.ImmutableAtlasDbConfig) AtlasDbConfig(com.palantir.atlasdb.config.AtlasDbConfig) Test(org.junit.Test)

Example 8 with AtlasDbConfig

use of com.palantir.atlasdb.config.AtlasDbConfig in project atlasdb by palantir.

the class KvsMigrationCommand method connectToServices.

public AtlasDbServices connectToServices() throws IOException {
    AtlasDbConfig toConfig = toConfigFile != null ? AtlasDbConfigs.load(toConfigFile, configRoot, AtlasDbConfig.class) : AtlasDbConfigs.loadFromString(inlineConfig, null, AtlasDbConfig.class);
    ServicesConfigModule scm = ServicesConfigModule.create(makeOfflineIfNecessary(toConfig), AtlasDbRuntimeConfig.withSweepDisabled());
    return DaggerAtlasDbServices.builder().servicesConfigModule(scm).build();
}
Also used : ServicesConfigModule(com.palantir.atlasdb.services.ServicesConfigModule) AtlasDbConfig(com.palantir.atlasdb.config.AtlasDbConfig)

Example 9 with AtlasDbConfig

use of com.palantir.atlasdb.config.AtlasDbConfig in project atlasdb by palantir.

the class KvsMigrationCommand method connectFromServices.

public AtlasDbServices connectFromServices() throws IOException {
    AtlasDbConfig fromConfig = AtlasDbConfigs.load(fromConfigFile, configRoot, AtlasDbConfig.class);
    ServicesConfigModule scm = ServicesConfigModule.create(makeOfflineIfNecessary(fromConfig), AtlasDbRuntimeConfig.withSweepDisabled());
    return DaggerAtlasDbServices.builder().servicesConfigModule(scm).build();
}
Also used : ServicesConfigModule(com.palantir.atlasdb.services.ServicesConfigModule) AtlasDbConfig(com.palantir.atlasdb.config.AtlasDbConfig)

Example 10 with AtlasDbConfig

use of com.palantir.atlasdb.config.AtlasDbConfig 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)

Aggregations

AtlasDbConfig (com.palantir.atlasdb.config.AtlasDbConfig)20 ImmutableAtlasDbConfig (com.palantir.atlasdb.config.ImmutableAtlasDbConfig)15 Test (org.junit.Test)12 InMemoryAtlasDbConfig (com.palantir.atlasdb.memory.InMemoryAtlasDbConfig)8 MetricRegistry (com.codahale.metrics.MetricRegistry)4 SerializableTransactionManager (com.palantir.atlasdb.transaction.impl.SerializableTransactionManager)4 DefaultTaggedMetricRegistry (com.palantir.tritium.metrics.registry.DefaultTaggedMetricRegistry)4 AtlasDbRuntimeConfig (com.palantir.atlasdb.config.AtlasDbRuntimeConfig)2 ImmutableServerListConfig (com.palantir.atlasdb.config.ImmutableServerListConfig)2 ImmutableTimeLockClientConfig (com.palantir.atlasdb.config.ImmutableTimeLockClientConfig)2 ServicesConfigModule (com.palantir.atlasdb.services.ServicesConfigModule)2 List (java.util.List)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)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