mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
provide fconfigs for cluster
This commit is contained in:
parent
2686095265
commit
70d8a7a187
@ -133,6 +133,9 @@ public class CqlActivity extends SimpleActivity implements Activity, ActivityDef
|
||||
|
||||
private void initSequencer() {
|
||||
|
||||
Session session = getSession();
|
||||
Map<String,Object> fconfig = Map.of("cluster",session.getCluster());
|
||||
|
||||
SequencerType sequencerType = SequencerType.valueOf(
|
||||
getParams().getOptionalString("seq").orElse("bucket")
|
||||
);
|
||||
@ -203,7 +206,8 @@ public class CqlActivity extends SimpleActivity implements Activity, ActivityDef
|
||||
CqlBinderTypes binderType = CqlBinderTypes.valueOf(stmtDef.getParams()
|
||||
.getOrDefault("binder", CqlBinderTypes.DEFAULT.toString()));
|
||||
|
||||
template = new ReadyCQLStatementTemplate(binderType, getSession(), prepare, ratio, parsed.getName());
|
||||
template = new ReadyCQLStatementTemplate(fconfig, binderType, getSession(), prepare, ratio,
|
||||
parsed.getName());
|
||||
} else {
|
||||
SimpleStatement simpleStatement = new SimpleStatement(stmtForDriver);
|
||||
cl.ifPresent((conlvl) -> {
|
||||
@ -218,7 +222,8 @@ public class CqlActivity extends SimpleActivity implements Activity, ActivityDef
|
||||
psummary.append(" idempotent=>").append(i);
|
||||
simpleStatement.setIdempotent(i);
|
||||
});
|
||||
template = new ReadyCQLStatementTemplate(getSession(), simpleStatement, ratio, parsed.getName());
|
||||
template = new ReadyCQLStatementTemplate(fconfig, getSession(), simpleStatement, ratio,
|
||||
parsed.getName());
|
||||
}
|
||||
|
||||
Optional.ofNullable(stmtDef.getParams().getOrDefault("save", null))
|
||||
|
@ -19,6 +19,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.Writer;
|
||||
import java.util.Map;
|
||||
|
||||
public class ReadyCQLStatementTemplate {
|
||||
|
||||
@ -36,7 +37,8 @@ public class ReadyCQLStatementTemplate {
|
||||
private Histogram rowsFetchedHisto;
|
||||
private Writer resultCsvWriter;
|
||||
|
||||
public ReadyCQLStatementTemplate(CqlBinderTypes binderType, Session session, PreparedStatement preparedStmt, long ratio, String name) {
|
||||
public ReadyCQLStatementTemplate(Map<String,Object> fconfig, CqlBinderTypes binderType, Session session,
|
||||
PreparedStatement preparedStmt, long ratio, String name) {
|
||||
this.session = session;
|
||||
this.name = name;
|
||||
ValuesArrayBinder<PreparedStatement, Statement> binder = binderType.get(session);
|
||||
@ -44,18 +46,20 @@ public class ReadyCQLStatementTemplate {
|
||||
|
||||
template = new ContextualBindingsArrayTemplate<>(
|
||||
preparedStmt,
|
||||
new BindingsTemplate(),
|
||||
new BindingsTemplate(fconfig),
|
||||
binder
|
||||
);
|
||||
this.ratio = ratio;
|
||||
}
|
||||
|
||||
public ReadyCQLStatementTemplate(Session session, SimpleStatement simpleStatement, long ratio, String name) {
|
||||
public ReadyCQLStatementTemplate(Map<String,Object> fconfig, Session session, SimpleStatement simpleStatement,
|
||||
long ratio,
|
||||
String name) {
|
||||
this.session = session;
|
||||
this.name = name;
|
||||
template = new ContextualBindingsArrayTemplate<>(
|
||||
simpleStatement,
|
||||
new BindingsTemplate(),
|
||||
new BindingsTemplate(fconfig),
|
||||
new SimpleStatementValuesBinder()
|
||||
);
|
||||
this.ratio = ratio;
|
||||
|
@ -39,6 +39,7 @@ import java.util.Optional;
|
||||
*/
|
||||
public class BindingsTemplate {
|
||||
private final static Logger logger = LogManager.getLogger(BindingsTemplate.class);
|
||||
private final Map<String, Object> fconfig;
|
||||
private List<String> bindPointNames = new ArrayList<>();
|
||||
private List<String> specifiers = new ArrayList<>();
|
||||
|
||||
@ -46,7 +47,8 @@ public class BindingsTemplate {
|
||||
// specs.forEach(this::addFieldBinding);
|
||||
// }
|
||||
|
||||
public BindingsTemplate(List<String> anchors, List<String> specs) {
|
||||
public BindingsTemplate(Map<String,Object> config, List<String> anchors, List<String> specs) {
|
||||
this.fconfig = config;
|
||||
if (anchors.size() != specs.size()) {
|
||||
throw new InvalidParameterException("Anchors and Specifiers must be matched pair-wise.");
|
||||
}
|
||||
@ -55,11 +57,22 @@ public class BindingsTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
public BindingsTemplate(List<BindPoint> bindpoints) {
|
||||
public BindingsTemplate(Map<String,Object> config, List<BindPoint> bindpoints) {
|
||||
this.fconfig = config;
|
||||
addFieldBindings(bindpoints);
|
||||
}
|
||||
public BindingsTemplate(List<BindPoint> bindPoints) {
|
||||
this.fconfig = Map.of();
|
||||
addFieldBindings(bindPoints);
|
||||
|
||||
}
|
||||
|
||||
public BindingsTemplate(Map<String,Object> config) {
|
||||
this.fconfig = config;
|
||||
}
|
||||
|
||||
public BindingsTemplate() {
|
||||
this.fconfig = Map.of();
|
||||
}
|
||||
|
||||
public void addFieldBindings(List<BindPoint> bindPoints) {
|
||||
@ -119,7 +132,7 @@ public class BindingsTemplate {
|
||||
public Bindings resolveBindings() {
|
||||
List<DataMapper<?>> dataMappers = new ArrayList<>();
|
||||
for (String specifier : specifiers) {
|
||||
Optional<DataMapper<Object>> optionalDataMapper = VirtData.getOptionalMapper(specifier);
|
||||
Optional<DataMapper<Object>> optionalDataMapper = VirtData.getOptionalMapper(specifier,fconfig);
|
||||
if (optionalDataMapper.isPresent()) {
|
||||
dataMappers.add(optionalDataMapper.get());
|
||||
} else {
|
||||
|
@ -19,7 +19,7 @@ public class VirtData {
|
||||
* @param namesAndSpecs names and specs in "name", "spec", ... form
|
||||
* @return A bindings template that can be used to resolve a bindings instance
|
||||
*/
|
||||
public static BindingsTemplate getTemplate(String... namesAndSpecs) {
|
||||
public static BindingsTemplate getTemplate(Map<String,Object> config, String... namesAndSpecs) {
|
||||
if ((namesAndSpecs.length % 2) != 0) {
|
||||
throw new RuntimeException(
|
||||
"args must be in 'name','spec', pairs. " +
|
||||
@ -29,7 +29,11 @@ public class VirtData {
|
||||
for (int i = 0; i < namesAndSpecs.length; i += 2) {
|
||||
bindPoints.add(new BindPoint(namesAndSpecs[i],namesAndSpecs[i+1]));
|
||||
}
|
||||
return getTemplate(bindPoints);
|
||||
return getTemplate(config, bindPoints);
|
||||
}
|
||||
|
||||
public static BindingsTemplate getTemplate(String... namesAndSpecs) {
|
||||
return getTemplate(Map.of(), namesAndSpecs);
|
||||
}
|
||||
|
||||
// /**
|
||||
@ -57,7 +61,7 @@ public class VirtData {
|
||||
* @param bindPoints A list of {@link BindPoint}s
|
||||
* @return A BindingsTemplate
|
||||
*/
|
||||
public static BindingsTemplate getTemplate(List<BindPoint> bindPoints) {
|
||||
public static BindingsTemplate getTemplate(Map<String,Object> config, List<BindPoint> bindPoints) {
|
||||
for (BindPoint bindPoint : bindPoints) {
|
||||
String bindspec = bindPoint.getBindspec();
|
||||
VirtDataDSL.ParseResult parseResult = VirtDataDSL.parse(bindspec);
|
||||
@ -65,7 +69,7 @@ public class VirtData {
|
||||
throw new RuntimeException(parseResult.throwable);
|
||||
}
|
||||
}
|
||||
return new BindingsTemplate(bindPoints);
|
||||
return new BindingsTemplate(config, bindPoints);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -42,8 +42,8 @@ public class LoadElement implements Function<Object,Object>, ConfigAware {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyConfig(Map<String, ?> element) {
|
||||
Map<String,?> vars = (Map<String, ?>) element.get(mapname);
|
||||
public void applyConfig(Map<String, ?> elements) {
|
||||
Map<String,?> vars = (Map<String, ?>) elements.get(mapname);
|
||||
if (vars!=null) {
|
||||
this.vars = vars;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user