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