Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

[QoS] Qos ete test #2708

Merged
merged 70 commits into from
Nov 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
2e8c960
Fix SweepBatchConfig values to properly decrease to 1 with each failu…
tboam Nov 8, 2017
f116645
SweeperService logging improvements (#2618)
tboam Nov 8, 2017
c1e21ee
Refactor TracingKVS (#2643)
fsamuel-bs Nov 8, 2017
53afd91
Delete docs (#2657)
hsaraogi Nov 9, 2017
e25d806
[20 minute tasks] Add test for when a batch is full (#2655)
tboam Nov 9, 2017
88e3ffe
MetricRegistry log level downgrade + multiple timestamp tracker tests…
jeremyk-91 Nov 9, 2017
8b67855
Extract interface for Cassandra client (#2660)
fsamuel-bs Nov 10, 2017
c0c05f6
client -> namespace [no release notes] (#2654)
hsaraogi Nov 10, 2017
fede1c3
0.65.2 and 0.66.0 release notes (#2663)
fsamuel-bs Nov 10, 2017
a2be749
[QoS] Add getNamespace to AtlasDBConfig (#2661)
hsaraogi Nov 10, 2017
18d35b6
Live Reloading the TimeLock Block, Part 1: Pull to Push (#2621)
jeremyk-91 Nov 10, 2017
a953328
Live Reloading the TimeLock Block, Part 2: TransactionManagers Plumbi…
jeremyk-91 Nov 10, 2017
8fdd50b
[TTT] [no release notes] Document behaviour regarding index rows (#2658)
jeremyk-91 Nov 13, 2017
6fed36f
Refactor and Instrument CassandraClient api (#2665)
fsamuel-bs Nov 13, 2017
e8e85f9
Live Reloading the TimeLock Block, Part 3: Working with 0 Nodes (#2647)
jeremyk-91 Nov 13, 2017
74180cf
check immutable ts (#2406)
nziebart Nov 13, 2017
d4bf805
Propagate top-level KVS method names to CassandraClient (#2669)
fsamuel-bs Nov 13, 2017
247f60c
Extract cql executor interface (#2670)
fsamuel-bs Nov 13, 2017
913e5e7
bump awaitility (#2668)
hsaraogi Nov 13, 2017
cafc479
Bump Atlas on Tritium 0.8.4 to fix dependency conflicts (#2662)
Nov 14, 2017
7fb4d17
Correctly log Paxos events (#2674)
fsamuel-bs Nov 14, 2017
14216ac
Slow log and tracing (#2673)
fsamuel-bs Nov 14, 2017
78791cf
Refactor cassandra client (#2676)
fsamuel-bs Nov 14, 2017
22e129a
use supplier for object size [no release notes]
Nov 14, 2017
757a282
fix merge
Nov 14, 2017
a45809d
fix merge in AtlasDbConfig
Nov 14, 2017
e3bd685
rate limiting
Nov 15, 2017
dd55403
total-time
Nov 15, 2017
2318f69
qos config
Nov 15, 2017
c7dff29
respect max backoff itme
Nov 15, 2017
76fd664
query weights
Nov 16, 2017
710d216
extra tests
Nov 16, 2017
575b583
num rows
Nov 16, 2017
c9b4839
checkstyle
Nov 16, 2017
29ca959
fix tests
Nov 17, 2017
b35bb7f
no int casting
Nov 17, 2017
f014f56
Qos ete tests
hsaraogi Nov 17, 2017
46e1308
shouldFailIfWritingTooManyBytes
hsaraogi Nov 17, 2017
e6035d0
fix test
hsaraogi Nov 17, 2017
887aa5b
rm file
hsaraogi Nov 17, 2017
3a8f467
Remove metrics
hsaraogi Nov 17, 2017
08a07b2
Test shouldFailIfReadingTooManyBytes
hsaraogi Nov 17, 2017
da40d23
canBeWritingLargeNumberOfBytesConcurrently
hsaraogi Nov 17, 2017
27073f2
checkstyle
hsaraogi Nov 17, 2017
05531a1
cannotWriteLargeNumberOfBytesConcurrently
hsaraogi Nov 17, 2017
e370121
fix tests
hsaraogi Nov 20, 2017
8eef5d5
create tm in test
hsaraogi Nov 21, 2017
53f732e
More read tests (after writing a lot of data at once)
hsaraogi Nov 21, 2017
e2642cf
WIP
hsaraogi Nov 21, 2017
f1887ee
Merge branch 'feature/qos-service-api' into qos-ete-test
hsaraogi Nov 21, 2017
d18c007
Tests that should pas
hsaraogi Nov 21, 2017
fa0b731
Actually update the rate
hsaraogi Nov 21, 2017
6e4745e
Add another test
hsaraogi Nov 21, 2017
a01eef7
More tests and address comments
hsaraogi Nov 22, 2017
2aa69da
Dont extend etesetup
hsaraogi Nov 22, 2017
55a82f2
Make dumping data faster
hsaraogi Nov 22, 2017
2f49e0e
cleanup
hsaraogi Nov 22, 2017
be06b19
wip
hsaraogi Nov 22, 2017
d5b5a8a
Add back lost file
hsaraogi Nov 22, 2017
3f080db
Cleanup
hsaraogi Nov 22, 2017
504f345
Write tests
hsaraogi Nov 22, 2017
59e2b6b
numReadsPerThread -> numThreads
hsaraogi Nov 22, 2017
35327a9
More write tests, cleanup, check style fixes
hsaraogi Nov 22, 2017
b04b4fd
Refactor to avoid code duplication
hsaraogi Nov 22, 2017
c9ebe6e
Cleanup
hsaraogi Nov 22, 2017
af9d67c
cr comments
hsaraogi Nov 23, 2017
6f483d9
Small read/write after a rate-limited read/write
hsaraogi Nov 23, 2017
dd18730
annoying no new linw at eof
hsaraogi Nov 23, 2017
be0759c
Uniform parameters for hard limiting
hsaraogi Nov 23, 2017
304f4ed
Merge branch 'feature/qos-service-api' into qos-ete-test
hsaraogi Nov 24, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,13 @@
*/
package com.palantir.atlasdb.dropwizard;

import java.util.Optional;

import com.palantir.atlasdb.config.AtlasDbConfig;
import com.palantir.atlasdb.config.AtlasDbRuntimeConfig;

public interface AtlasDbConfigurationProvider {
AtlasDbConfig getAtlasDbConfig();

Optional<AtlasDbRuntimeConfig> getAtlasDbRuntimeConfig();
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicReference;

import org.junit.Test;
Expand All @@ -30,6 +31,7 @@
import com.google.common.base.Throwables;
import com.palantir.atlasdb.config.AtlasDbConfig;
import com.palantir.atlasdb.config.AtlasDbConfigs;
import com.palantir.atlasdb.config.AtlasDbRuntimeConfig;
import com.palantir.atlasdb.config.ImmutableAtlasDbConfig;
import com.palantir.atlasdb.config.ImmutableLeaderConfig;
import com.palantir.atlasdb.dropwizard.AtlasDbConfigurationProvider;
Expand Down Expand Up @@ -100,5 +102,10 @@ private class AtlasDbDropwizardConfig extends Configuration implements AtlasDbCo
public AtlasDbConfig getAtlasDbConfig() {
return atlasDbConfig;
}

@Override
public Optional<AtlasDbRuntimeConfig> getAtlasDbRuntimeConfig() {
return Optional.empty();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,33 @@
*/
package com.palantir.atlasdb;

import java.util.Optional;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.palantir.atlasdb.config.AtlasDbConfig;
import com.palantir.atlasdb.config.AtlasDbRuntimeConfig;
import com.palantir.atlasdb.dropwizard.AtlasDbConfigurationProvider;

import io.dropwizard.Configuration;

public class AtlasDbEteConfiguration extends Configuration implements AtlasDbConfigurationProvider {
private final AtlasDbConfig atlasdb;
private final Optional<AtlasDbRuntimeConfig> atlasdbRuntime;

public AtlasDbEteConfiguration(@JsonProperty("atlasdb") AtlasDbConfig atlasdb) {
public AtlasDbEteConfiguration(@JsonProperty("atlasdb") AtlasDbConfig atlasdb,
@JsonProperty("atlasDbRuntime") Optional<AtlasDbRuntimeConfig> atlasDbRuntimeConfig) {
this.atlasdb = atlasdb;
this.atlasdbRuntime = atlasDbRuntimeConfig;
}

@Override
public AtlasDbConfig getAtlasDbConfig() {
return atlasdb;
}

@Override
public Optional<AtlasDbRuntimeConfig> getAtlasDbRuntimeConfig() {
return atlasdbRuntime;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package com.palantir.atlasdb;

import java.util.Optional;
import java.util.Set;
import java.util.concurrent.TimeUnit;

Expand All @@ -28,6 +29,7 @@
import com.palantir.atlasdb.cas.CheckAndSetSchema;
import com.palantir.atlasdb.cas.SimpleCheckAndSetResource;
import com.palantir.atlasdb.config.AtlasDbConfig;
import com.palantir.atlasdb.config.AtlasDbRuntimeConfig;
import com.palantir.atlasdb.dropwizard.AtlasDbBundle;
import com.palantir.atlasdb.factory.TransactionManagers;
import com.palantir.atlasdb.http.NotInitializedExceptionMapper;
Expand Down Expand Up @@ -77,18 +79,22 @@ public void run(AtlasDbEteConfiguration config, final Environment environment) t
private TransactionManager tryToCreateTransactionManager(AtlasDbEteConfiguration config, Environment environment)
throws InterruptedException {
if (config.getAtlasDbConfig().initializeAsync()) {
return createTransactionManager(config.getAtlasDbConfig(), environment);
return createTransactionManager(config.getAtlasDbConfig(), config.getAtlasDbRuntimeConfig(), environment);
} else {
return createTransactionManagerWithRetry(config.getAtlasDbConfig(), environment);
return createTransactionManagerWithRetry(config.getAtlasDbConfig(),
config.getAtlasDbRuntimeConfig(),
environment);
}
}

private TransactionManager createTransactionManagerWithRetry(AtlasDbConfig config, Environment environment)
private TransactionManager createTransactionManagerWithRetry(AtlasDbConfig config,
Optional<AtlasDbRuntimeConfig> atlasDbRuntimeConfig,
Environment environment)
throws InterruptedException {
Stopwatch sw = Stopwatch.createStarted();
while (sw.elapsed(TimeUnit.SECONDS) < CREATE_TRANSACTION_MANAGER_MAX_WAIT_TIME_SECS) {
try {
return createTransactionManager(config, environment);
return createTransactionManager(config, atlasDbRuntimeConfig, environment);
} catch (RuntimeException e) {
log.warn("An error occurred while trying to create transaction manager. Retrying...", e);
Thread.sleep(CREATE_TRANSACTION_MANAGER_POLL_INTERVAL_SECS);
Expand All @@ -97,12 +103,14 @@ private TransactionManager createTransactionManagerWithRetry(AtlasDbConfig confi
throw new IllegalStateException("Timed-out because we were unable to create transaction manager");
}

private TransactionManager createTransactionManager(AtlasDbConfig config, Environment environment) {
private TransactionManager createTransactionManager(AtlasDbConfig config,
Optional<AtlasDbRuntimeConfig> atlasDbRuntimeConfigOptional, Environment environment) {
return TransactionManagers.builder()
.config(config)
.schemas(ETE_SCHEMAS)
.registrar(environment.jersey()::register)
.userAgent("ete test")
.runtimeConfigSupplier(() -> atlasDbRuntimeConfigOptional)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, this works. I think we probably want a comment somewhere that the runtime configuration is not actually live reloaded, in case we try to use this for live reloading.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, i forgot about this. this is probably a requirement before shipping, since it needs to be able to be turned off live

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually i think i'm referring to something different - the QosClient does not respect the live-reloadability of the QoS config

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah. There are 2 things here I guess -

  1. the rate limiters take a config directly, so don't support live reload
  2. the atlas ete server gives a constant supplier, so it doesn't live reload either

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The AtlasDbEteServer does not need the live reloading as of now unless we want to test the live-reloadability here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jeremyk-91 @nziebart Just checking: are these comments now resolved elsewhere?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As Himangi mentions we aren't dealing with 2 for now.

1 is done - see QosRateLimiter https://github.com/palantir/atlasdb/blob/feature/qos-service-api/qos-service-impl/src/main/java/com/palantir/atlasdb/qos/ratelimit/QosRateLimiter.java.

Aside: the concurrency in that class feels a bit weird (I think it is correct, but could result in multiple creations on a change - though last-one-wins is probably fine), but that's not the scope of this.

.buildSerializable();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
/*
* Copyright 2017 Palantir Technologies, Inc. All rights reserved.
*
* Licensed under the BSD-3 License (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://opensource.org/licenses/BSD-3-Clause
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.palantir.atlasdb.ete;


import java.net.InetSocketAddress;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.Random;

import org.awaitility.Awaitility;
import org.awaitility.Duration;
import org.junit.After;
import org.junit.Before;
import org.junit.ClassRule;

import com.codahale.metrics.MetricRegistry;
import com.google.common.collect.ImmutableList;
import com.palantir.atlasdb.cassandra.CassandraKeyValueServiceConfig;
import com.palantir.atlasdb.cassandra.ImmutableCassandraCredentialsConfig;
import com.palantir.atlasdb.cassandra.ImmutableCassandraKeyValueServiceConfig;
import com.palantir.atlasdb.config.AtlasDbConfig;
import com.palantir.atlasdb.config.AtlasDbRuntimeConfig;
import com.palantir.atlasdb.config.ImmutableAtlasDbConfig;
import com.palantir.atlasdb.config.ImmutableAtlasDbRuntimeConfig;
import com.palantir.atlasdb.config.ImmutableSweepConfig;
import com.palantir.atlasdb.factory.TransactionManagers;
import com.palantir.atlasdb.keyvalue.api.Cell;
import com.palantir.atlasdb.qos.config.ImmutableQosClientConfig;
import com.palantir.atlasdb.qos.config.ImmutableQosLimitsConfig;
import com.palantir.atlasdb.table.description.ValueType;
import com.palantir.atlasdb.todo.TodoSchema;
import com.palantir.atlasdb.transaction.impl.SerializableTransactionManager;
import com.palantir.atlasdb.util.AtlasDbMetrics;
import com.palantir.docker.compose.DockerComposeRule;
import com.palantir.docker.compose.configuration.ShutdownStrategy;
import com.palantir.docker.compose.connection.Container;
import com.palantir.docker.compose.connection.DockerPort;
import com.palantir.docker.compose.logging.LogDirectory;
import com.palantir.remoting.api.config.service.HumanReadableDuration;

public class QosCassandraEteTestSetup {
private static final Random random = new Random();
protected static SerializableTransactionManager serializableTransactionManager;
protected static final int readBytesPerSecond = 10_000;
protected static final int writeBytesPerSecond = 10_000;
private static final int CASSANDRA_PORT_NUMBER = 9160;
protected static final int MAX_SOFT_LIMITING_SLEEP_MILLIS = 2000;

@ClassRule
public static DockerComposeRule docker = DockerComposeRule.builder()
.file("src/test/resources/cassandra-docker-compose.yml")
.waitingForService("cassandra", Container::areAllPortsOpen)
.saveLogsTo(LogDirectory.circleAwareLogDirectory(QosCassandraReadEteTest.class))
.shutdownStrategy(ShutdownStrategy.AGGRESSIVE_WITH_NETWORK_CLEANUP)
.build();

@Before
public void setup() {
AtlasDbMetrics.setMetricRegistry(new MetricRegistry());
ensureTransactionManagerIsCreated();
}

protected static void ensureTransactionManagerIsCreated() {
serializableTransactionManager = TransactionManagers.builder()
.config(getAtlasDbConfig())
.runtimeConfigSupplier(QosCassandraEteTestSetup::getAtlasDbRuntimeConfig)
.schemas(ImmutableList.of(TodoSchema.getSchema()))
.userAgent("qos-test")
.buildSerializable();

Awaitility.await()
.atMost(Duration.ONE_MINUTE)
.pollInterval(Duration.ONE_SECOND)
.until(serializableTransactionManager::isInitialized);
}

protected static void writeNTodosOfSize(int numTodos, int size) {
serializableTransactionManager.runTaskWithRetry((transaction) -> {
Map<Cell, byte[]> write = new HashMap<>();
for (int i = 0; i < numTodos; i++) {
Cell thisCell = Cell.create(ValueType.FIXED_LONG.convertFromJava(random.nextLong()),
TodoSchema.todoTextColumn());
write.put(thisCell, ValueType.STRING.convertFromJava(getTodoOfSize(size)));
}
transaction.put(TodoSchema.todoTable(), write);
return null;
});
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(as before, protected?)


private static AtlasDbConfig getAtlasDbConfig() {
DockerPort cassandraPort = docker.containers()
.container("cassandra")
.port(CASSANDRA_PORT_NUMBER);

InetSocketAddress cassandraAddress = new InetSocketAddress(cassandraPort.getIp(),
cassandraPort.getExternalPort());

CassandraKeyValueServiceConfig kvsConfig = ImmutableCassandraKeyValueServiceConfig.builder()
.servers(ImmutableList.of(cassandraAddress))
.credentials(ImmutableCassandraCredentialsConfig.builder()
.username("cassandra")
.password("cassandra")
.build())
.ssl(false)
.replicationFactor(1)
.autoRefreshNodes(false)
.build();

return ImmutableAtlasDbConfig.builder()
.namespace("qosete")
.keyValueService(kvsConfig)
.initializeAsync(true)
.build();
}

private static Optional<AtlasDbRuntimeConfig> getAtlasDbRuntimeConfig() {
return Optional.of(ImmutableAtlasDbRuntimeConfig.builder()
.sweep(ImmutableSweepConfig.builder().enabled(false).build())
.qos(ImmutableQosClientConfig.builder()
.limits(ImmutableQosLimitsConfig.builder()
.readBytesPerSecond(readBytesPerSecond)
.writeBytesPerSecond(writeBytesPerSecond)
.build())
.maxBackoffSleepTime(HumanReadableDuration.milliseconds(MAX_SOFT_LIMITING_SLEEP_MILLIS))
.build())
.build());
}

private static String getTodoOfSize(int size) {
// Note that the size of the cell for 1000 length text is actually 1050.
return String.join("", Collections.nCopies(size, "a"));
}

@After
public void after() {
serializableTransactionManager.close();
}
}
Loading