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

Commit

Permalink
[QoS] Qos ete test (#2708)
Browse files Browse the repository at this point in the history
* Fix SweepBatchConfig values to properly decrease to 1 with each failure and increase with each success (#2630)

* Fix SweepBatchConfig values to properly decrease to 1 with each failure and increase with each success

* add logging when we stop reducing the batch size multiplier

* further improve the tests

* Allow sweep to recover faster after backing off.  Before we would increase by 1% for each successive success, if we had reduced a value to 1 it would be 70 iterations before we got 2 and 700 iterations before we got back to 1000.  Now we always 25 iterations with the lower batch size and then try increasing the rate by doubling each time.  This means that when sweep has to back off it should speed up again quickly.

* Use an AtomicInteger to handle concurrent updates

* SweeperService logging improvements (#2618)

* SweeperServiceImpl now logs when it starts sweeping make it clear if it is running full sweep or not

* Added sweep parameters to the log lines

* no longer default the service parameter in the interface, this way we can see when the parameter isn't provided and we are defaulting to true.  Behaviour is unchanged but we can log a message when defaulting.

* Refactor TracingKVS (#2643)

* Wrap next() and hasNext() in traces

* Use span names as safe

* Remove iterator wrappings

* checkstyle

* refactor methods and remove misleading traces

* Fix unit tests

* release notes

* Final nits

* fix java arrays usage

* Delete docs (#2657)

* [20 minute tasks] Add test for when a batch is full (#2655)

* [no release notes] Drive-by add test for when a batch is full

* MetricRegistry log level downgrade + multiple timestamp tracker tests (#2636)

* change metrics manager to warn plus log the metric name

* more timestamp tracker tests

* release notes

* Extract interface for Cassandra client (#2660)

* Create a CassandraClient

* Propagate CassandraClient to all classes but CKVS

* Use CassandraClient on CKVS

* Propagate CassandraClient to remaining Impl classes

* Use CassandraClient in tests

* [no release notes]

* client -> namespace [no release notes] (#2654)

* 0.65.2 and 0.66.0 release notes (#2663)

* Release notes banners

* fix pr numbers

* [QoS] Add getNamespace to AtlasDBConfig (#2661)

* Add getNamespace [no release notes]

* Timelock client config cannot be empty

* Make it explicit that unspecified namespace is only possible for InMemoryKVS

* CR comments

* Live Reloading the TimeLock Block, Part 1: Pull to Push (#2621)

* thoughts

* More tests for RIH

* Paranoid logging

* statics

* javadoc part 1

* polling refreshable

* Unit tests

* Remove the old RIH

* lock lock

* Tests that test how we deal with exceptions

* logging

* [no release notes]

* CR comments part 1

* Make interval configurable

* Standard nasty time edge cases

* lastSeenValue does not need to be volatile

* Live Reloading the TimeLock Block, Part 2: TransactionManagers Plumbing (#2622)

* ServiceCreator.applyDynamic()

* Propagate config through TMs

* Json Serialization fixes

* Some refactoring

* lock/lock

* Fixed checkstyle

* CR comments part 1

* Switch to RPIH

* add test

* [no release notes] forthcoming in part 4

* checkstyle

* [TTT] [no release notes] Document behaviour regarding index rows (#2658)

* [no release notes] Document behaviour regarding index rows

* fix compile bug

* ``List``

* Refactor and Instrument CassandraClient api (#2665)

* Sanitize Client API

* Instrument CassandraClient

* checkstyle

* Address comment

* [no release notes]

* checkstyle

* Fix cas

* Live Reloading the TimeLock Block, Part 3: Working with 0 Nodes (#2647)

* 0 nodes part 1

* add support for 0 servers in a ServerListConfig

* extend deserialization tests

* More tests

* code defensively

* [no release notes] defer to 2648

* Fixed CR nits

* singleton server list

* check immutable ts (#2406)

* check immutable ts

* checkstyle

* release notes

* Fix TM creation

* checkstyle

* Propagate top-level KVS method names to CassandraClient (#2669)

* Propagate method names down to multiget_slice

* Add the corresponding KVS method to remaining methods

* Add TODO

* [no release notes]

* nit

* Extract cql executor interface (#2670)

* Instrument CqlExecutor

* [no release notes]

* bump awaitility (#2668)

* Upgrade to newer Awaitility.

* locks [no release notes]

* unused import

* Bump Atlas on Tritium 0.8.4 to fix dependency conflicts (#2662)

* Bump Atlas on Tritium 0.8.4 to fix dependency conflicts

* Add changes into missing file

* Doc changes

* Exclude Tracing and HdrHistogram from Tritium dependencies

* update locks

* Add excluded dependencies explicitly

* Fix merge conflict in relase notes

* Uncomment dependencies

* Regenerate locks

* Correctly log Paxos events (#2674)

* Log out Paxos values when recording Paxos events

* Updated release notes

* Checkstyle

* Pull request number

* Address comments

* fix docs

* Slow log and tracing (#2673)

* Trace and instrument the thrift client

* Instrument CqlExecutor

* Fix metric names of IntrumentedCassandraClient

* Fix nit

* Also log internal table references

* Checkstyle

* simplify metric names

* Address comments

* add slow logging to the cassandra thrift client

* add slow logging to cqlExecutor

* fix typos

* Add tracing to the CassandraClient

* trace cqlExecutor queries

* Add slow-logging in the CassandraClient

* Delete InstrumentedCC and InstrumentedCqlExec

* Fix small nits

* Checkstyle

* Add kvs method names to slow logs

* Fix wrapping of exception

* Extract CqlQuery

* Move kvs-slow-log and tracing of CqlExecutor to CCI

* Propagate execute_cql3_query api breaks

* checkstyle

* delete unused string

* checkstyle

* fix number of mutations on batch_mutate

* some refactors

* fix compile

* Refactor cassandra client (#2676)

* Extract TracingCassandraClient

Extract ProfilingCassandraClient

Move todos and some cleanup

Cherry-pick QoS metrics to develop (#2679)

* [QoS] Feature/qos meters (#2640)

* Metrics for bytes and counts in each read/write

* Refactors, dont throw if recordMetrics throws

* Use meters instead of histograms

* Multiget bytes

* Batch mutate exact size

* Cqlresult size

* Calculate exact byte sizes for all thrift objects

* tests and bugfixes - partial

* More tests and bugs fixed

* More tests and cr comments

* byte buffer size

* Remove register histogram

* checkstyle

* checkstyle

* locks and license

* Qos metrics CassandraClient

* Exclude unused classes

* fix cherry pick

* use supplier for object size [no release notes]

* fix merge in AtlasDbConfig

* rate limiting

* total-time

* qos config

* respect max backoff itme

* query weights

* extra tests

* num rows

* checkstyle

* fix tests

* no int casting

* Qos ete tests

* shouldFailIfWritingTooManyBytes

* fix test

* rm file

* Remove metrics

* Test shouldFailIfReadingTooManyBytes

* canBeWritingLargeNumberOfBytesConcurrently

* checkstyle

* cannotWriteLargeNumberOfBytesConcurrently

* fix tests

* create tm in test

* More read tests (after writing a lot of data at once)

* WIP

* Tests that should pas

* Actually update the rate

* Add another test

* More tests and address comments

* Dont extend etesetup

* Make dumping data faster

* cleanup

* wip

* Add back lost file

* Cleanup

* Write tests

* numReadsPerThread -> numThreads

* More write tests, cleanup, check style fixes

* Refactor to avoid code duplication

* Cleanup

* cr comments

* Small read/write after a rate-limited read/write

* annoying no new linw at eof

* Uniform parameters for hard limiting
  • Loading branch information
hsaraogi authored Nov 24, 2017
1 parent bbd272e commit d2d7b18
Show file tree
Hide file tree
Showing 9 changed files with 494 additions and 6 deletions.
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)
.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;
});
}

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

0 comments on commit d2d7b18

Please sign in to comment.