Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip namespace check for InMemoryKVS #2541

Merged
merged 2 commits into from
Oct 26, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.google.common.base.Preconditions;
import com.palantir.atlasdb.AtlasDbConstants;
import com.palantir.atlasdb.memory.InMemoryAtlasDbConfig;
import com.palantir.atlasdb.spi.KeyValueServiceConfig;

@JsonDeserialize(as = ImmutableAtlasDbConfig.class)
Expand Down Expand Up @@ -293,7 +294,7 @@ private void checkNamespaceConfig() {
Preconditions.checkState(client.equals(namespace),
"If present, the TimeLock client config should be the same as the"
+ " atlas root-level namespace config.")));
} else {
} else if (!(keyValueService() instanceof InMemoryAtlasDbConfig)) {
Preconditions.checkState(keyValueService().namespace().isPresent(),
"Either the atlas root-level namespace"
+ " or the keyspace/dbName/sid config needs to be set.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class AtlasDbConfigDeserializationTest {
@Test
public void canDeserializeAtlasDbConfig() throws IOException {
AtlasDbConfig config = AtlasDbConfigs.load(TEST_CONFIG_FILE);
assertThat(config.namespace().get()).isEqualTo("test");
assertThat(config.namespace().get()).isEqualTo("brian");
assertThat(config.keyValueService()).isEqualTo(new InMemoryAtlasDbConfig());

assertThat(config.timelock().isPresent()).isTrue();
Expand All @@ -60,7 +60,7 @@ public void canDeserializeMinimalAtlasDbConfig() throws IOException {
}

private void assertTimeLockConfigDeserializedCorrectly(TimeLockClientConfig timeLockClientConfig) {
assertThat(timeLockClientConfig.getClientOrThrow()).isEqualTo("test");
assertThat(timeLockClientConfig.getClientOrThrow()).isEqualTo("brian");
assertThat(timeLockClientConfig.serversList().servers()).containsExactlyInAnyOrder(
"timelock1:8080", "timelock2:8080", "timelock3:8080");
assertThat(timeLockClientConfig.serversList().sslConfiguration().isPresent()).isTrue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
Expand All @@ -29,6 +30,7 @@
import org.junit.BeforeClass;
import org.junit.Test;

import com.palantir.atlasdb.memory.InMemoryAtlasDbConfig;
import com.palantir.atlasdb.spi.KeyValueServiceConfig;
import com.palantir.remoting.api.config.ssl.SslConfiguration;

Expand Down Expand Up @@ -216,6 +218,28 @@ public void namespaceAcceptsEmptyKvsNamespaceAndTimelockClient() {
.build();
}

@Test
public void inMemoryConfigCanHaveEmptyNamespace() {
InMemoryAtlasDbConfig kvsConfig = new InMemoryAtlasDbConfig();
assertFalse("This test assumes the InMemoryAtlasDbConfig has no namespace by default",
kvsConfig.namespace().isPresent());
ImmutableAtlasDbConfig.builder()
.namespace(Optional.empty())
.keyValueService(kvsConfig)
.build();
}

@Test
public void inMemoryConfigWorksWithNonTestNamespace() {
InMemoryAtlasDbConfig kvsConfig = new InMemoryAtlasDbConfig();
assertFalse("This test assumes the InMemoryAtlasDbConfig has no namespace by default",
kvsConfig.namespace().isPresent());
ImmutableAtlasDbConfig.builder()
.namespace("clive")
.keyValueService(kvsConfig)
.build();
}

@Test
public void namespaceAndTimelockClientShouldMatch() {
assertThatThrownBy(() -> ImmutableAtlasDbConfig.builder()
Expand Down
4 changes: 2 additions & 2 deletions atlasdb-config/src/test/resources/test-config.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
atlasdb:
namespace: test
namespace: brian

keyValueService:
type: memory

timelock:
client: test
client: brian
serversList:
servers:
- timelock1:8080
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ public int hashCode() {
@Override
@JsonIgnore
public Optional<String> namespace() {
return Optional.of("test");
return Optional.empty();
}
}
19 changes: 12 additions & 7 deletions docs/source/release_notes/release-notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ develop
Note that the ``clock.monitor-exception`` metric is still incremented on every call, even if we do not log.
(`Pull Request <https://github.com/palantir/atlasdb/pull/2456>`__)

* - |fixed|
- ``InMemoryAtlasDbConfig`` now has an empty namespace, instead of "test".
This means that internal products will no longer have to set their root-level namespace to "test" in order to use ``InMemoryKeyValueService`` for testing.
(`Pull Request <https://github.com/palantir/atlasdb/pull/2541>`__)

* - |improved| |userbreak|
- The ``ProfilingKeyValueService`` now reports its multipart log lines as a single line.
This should improve log readability in log ingestion tools when AtlasDB is run in multithreaded environments.
Expand Down Expand Up @@ -109,13 +114,13 @@ v0.61.0
=======
v0.60.1
=======

16 October 2017

.. list-table::
:widths: 5 40
:header-rows: 1

* - Type
- Change

Expand All @@ -131,7 +136,7 @@ v0.60.1
The default value for the config is ``false`` in order to preserve previous behaviour.
(`Pull Request 1 <https://github.com/palantir/atlasdb/pull/2390>`__ and
`Pull Request 2 <https://github.com/palantir/atlasdb/pull/2476>`__)

* - |new|
- Timelock server can now be configured to persist the timestamp bound in the database, specifically in Cassandra/Postgres/Oracle.
We recommend this to be configured only for cases where you absolutely need to persist all state in the database, for example,
Expand All @@ -149,7 +154,7 @@ v0.60.1

Now the factory methods for the above classes return the interfaces. The actual implementation of such classes was moved to their corresponding \*Impl files.
(`Pull Request <https://github.com/palantir/atlasdb/pull/2390>`__)

* - |devbreak| |improved|
- ``LockRefreshingTimelockService`` has been moved to the ``lock-api`` project under the package name ``com.palantir.lock.client``, and now implements
``AutoCloseable``, shutting down its internal executor service.
Expand Down Expand Up @@ -307,11 +312,11 @@ v0.58.0

* - |improved|
- AtlasDB now logs slow queries CQL queries (via ``kvs-slow-log``) used for sweep
(`Pull Request <https://github.com/palantir/atlasdb/pull/2363>`__)
(`Pull Request <https://github.com/palantir/atlasdb/pull/2363>`__)

* - |devbreak| |fixed|
- AtlasDB now depends on okhttp 3.8.1. This is expected to fix an issue where connections would constantly throw "shutdown" exceptions, which was likely due to a documented bug in okhttp 3.4.1.
(`Pull Request <https://github.com/palantir/atlasdb/pull/2343>`__)
(`Pull Request <https://github.com/palantir/atlasdb/pull/2343>`__)

* - |devbreak| |improved|
- Upgraded all uses of `http-remoting <https://github.com/palantir/http-remoting>`__ from remoting2 to remoting3, except for serialization of errors (preserved for backwards wire compatibility).
Expand Down