do not set speculative on cql when it is not provided

This commit is contained in:
Jonathan Shook 2020-09-08 17:47:13 -05:00
parent a2a4a5eacc
commit 7ba14409ad
2 changed files with 97 additions and 90 deletions

View File

@ -153,7 +153,11 @@ public class CQLOptions {
public static SpeculativeExecutionPolicy speculativeFor(String spec) {
Matcher pctileMatcher = PERCENTILE_EAGER_PATTERN.matcher(spec);
Matcher constantMatcher = CONSTANT_EAGER_PATTERN.matcher(spec);
if (pctileMatcher.matches()) {
if (spec.toLowerCase().trim().matches("disabled|none")) {
return null;
} else if (spec.toLowerCase().trim().equals("default")) {
return defaultSpeculativePolicy();
} else if (pctileMatcher.matches()) {
double pctile = Double.valueOf(pctileMatcher.group("pctile"));
if (pctile > 100.0 || pctile < 0.0) {
throw new RuntimeException("pctile must be between 0.0 and 100.0");

View File

@ -1,33 +1,10 @@
package io.nosqlbench.activitytype.cql.statements.core;
import java.io.File;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import javax.net.ssl.SSLContext;
import io.nosqlbench.nb.api.errors.BasicError;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.ProtocolOptions;
import com.datastax.driver.core.RemoteEndpointAwareJdkSSLOptions;
import com.datastax.driver.core.Session;
import com.datastax.driver.core.policies.DefaultRetryPolicy;
import com.datastax.driver.core.policies.LoadBalancingPolicy;
import com.datastax.driver.core.policies.LoggingRetryPolicy;
import com.datastax.driver.core.policies.RetryPolicy;
import com.datastax.driver.core.policies.RoundRobinPolicy;
import com.datastax.driver.core.policies.SpeculativeExecutionPolicy;
import com.datastax.driver.core.policies.WhiteListPolicy;
import com.datastax.driver.core.policies.*;
import com.datastax.driver.dse.DseCluster;
import io.nosqlbench.activitytype.cql.core.CQLOptions;
import io.nosqlbench.activitytype.cql.core.ProxyTranslator;
@ -36,13 +13,25 @@ import io.nosqlbench.engine.api.activityimpl.ActivityDef;
import io.nosqlbench.engine.api.metrics.ActivityMetrics;
import io.nosqlbench.engine.api.scripting.NashornEvaluator;
import io.nosqlbench.engine.api.util.SSLKsFactory;
import io.nosqlbench.nb.api.errors.BasicError;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.net.ssl.SSLContext;
import java.io.File;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*;
public class CQLSessionCache implements Shutdownable {
private final static Logger logger = LoggerFactory.getLogger(CQLSessionCache.class);
private final static String DEFAULT_SESSION_ID = "default";
private static final CQLSessionCache instance = new CQLSessionCache();
private Map<String, Session> sessionCache = new HashMap<>();
private final Map<String, Session> sessionCache = new HashMap<>();
private CQLSessionCache() {
}
@ -76,7 +65,7 @@ public class CQLSessionCache implements Shutdownable {
driverType.toLowerCase().equals("dse") ? DseCluster.builder() :
driverType.toLowerCase().equals("oss") ? Cluster.builder() : null;
if (builder==null) {
if (builder == null) {
throw new RuntimeException("The driver type '" + driverType + "' is not recognized");
}
@ -154,25 +143,39 @@ public class CQLSessionCache implements Shutdownable {
builder = clusterEval.eval();
logger.info("successfully applied:" + clusteropts.get());
} catch (Exception e) {
throw new RuntimeException("Unable to evaluate: " + clusteropts.get() + " in script context:",e);
throw new RuntimeException("Unable to evaluate: " + clusteropts.get() + " in script context:", e);
}
}
if (activityDef.getParams().getOptionalString("whitelist").isPresent() &&
activityDef.getParams().getOptionalString("lbp","loadbalancingpolicy").isPresent()) {
activityDef.getParams().getOptionalString("lbp", "loadbalancingpolicy").isPresent()) {
throw new BasicError("You specified both whitelist=.. and lbp=..., if you need whitelist and other policies together," +
" be sure to use the lbp option only with a whitelist policy included.");
}
SpeculativeExecutionPolicy speculativePolicy = activityDef.getParams()
.getOptionalString("speculative")
Optional<String> specSpec = activityDef.getParams()
.getOptionalString("speculative");
if (specSpec.isPresent()) {
specSpec
.map(speculative -> {
logger.info("speculative=>" + speculative);
return speculative;
})
.map(CQLOptions::speculativeFor)
.orElse(CQLOptions.defaultSpeculativePolicy());
builder.withSpeculativeExecutionPolicy(speculativePolicy);
.ifPresent(builder::withSpeculativeExecutionPolicy);
} else {
logger.warn(
"If the cql speculative parameter is not provided, it uses a default speculative\n" +
"policy, as in speculative=default, rather than leaving speculative off.\n" +
"If you want to keep this behavior or silence this warning, add one of\n" +
"speculative=none OR speculative=default to your activity params.\n" +
"This release, the default is speculative=default if the parameter is not specified.\n" +
"After Oct/2020, the default will be speculative=none if the parameter is not specified.\n" +
"Note: speculative=default is the same as speculative=p99.0:5:15000\n" +
"which is considered aggressive for some systems. This warning will go away after Oct/2020.\n");
builder.withSpeculativeExecutionPolicy(CQLOptions.defaultSpeculativePolicy());
}
activityDef.getParams().getOptionalString("socketoptions")
.map(sockopts -> {
@ -183,7 +186,7 @@ public class CQLSessionCache implements Shutdownable {
.ifPresent(builder::withSocketOptions);
activityDef.getParams().getOptionalString("reconnectpolicy")
.map(reconnectpolicy-> {
.map(reconnectpolicy -> {
logger.info("reconnectpolicy=>" + reconnectpolicy);
return reconnectpolicy;
})
@ -212,7 +215,7 @@ public class CQLSessionCache implements Shutdownable {
logger.info("lbp=>" + lbp);
return lbp;
})
.map(p -> CQLOptions.lbpolicyFor(p,null))
.map(p -> CQLOptions.lbpolicyFor(p, null))
.ifPresent(builder::withLoadBalancingPolicy);
activityDef.getParams().getOptionalString("tickduration")