Skip to content

Commit

Permalink
Introduced C* throttling
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrei Ivanov committed Sep 27, 2021
1 parent 34116f2 commit 1891038
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/main/java/net/iponweb/disthene/dumper/Dumper.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.datastax.oss.driver.api.core.metadata.Metadata;
import com.datastax.oss.driver.api.core.metadata.Node;
import com.datastax.oss.driver.internal.core.loadbalancing.DcInferringLoadBalancingPolicy;
import com.datastax.oss.driver.internal.core.session.throttling.ConcurrencyLimitingRequestThrottler;
import org.apache.http.HttpHost;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand Down Expand Up @@ -54,6 +55,9 @@ public class Dumper {
private static final String TABLE_FORMAT = "metric_%s_%d";
private static final String KEYSPACE = "metric";

private static final int MAX_QUEUE_SIZE = 1024*1024;
private static final int MAX_CONCURRENT_REQUESTS = 1024;

private static final Logger logger = LogManager.getLogger(Dumper.class);

private final DistheneDumperParameters parameters;
Expand Down Expand Up @@ -228,6 +232,9 @@ private void connectToCassandra() {
.withDuration(DefaultDriverOption.REQUEST_TIMEOUT, Duration.ofMillis(1_000_000))
.withString(DefaultDriverOption.REQUEST_CONSISTENCY, "ONE")
.withClass(DefaultDriverOption.LOAD_BALANCING_POLICY_CLASS, DcInferringLoadBalancingPolicy.class)
.withClass(DefaultDriverOption.REQUEST_THROTTLER_CLASS, ConcurrencyLimitingRequestThrottler.class)
.withInt(DefaultDriverOption.REQUEST_THROTTLER_MAX_CONCURRENT_REQUESTS, MAX_CONCURRENT_REQUESTS)
.withInt(DefaultDriverOption.REQUEST_THROTTLER_MAX_QUEUE_SIZE, MAX_QUEUE_SIZE)
.build();

session = CqlSession.builder().withConfigLoader(loader).build();
Expand Down

0 comments on commit 1891038

Please sign in to comment.