nosqlbench-861 Allow dry-run of op generation.

This commit is contained in:
Jonathan Shook 2022-12-19 15:47:03 -06:00
parent e29bfddc18
commit d1d21c8e5d
7 changed files with 62 additions and 7 deletions

View File

@ -166,6 +166,7 @@ public abstract class BaseDriverAdapter<R extends Op, S> implements DriverAdapte
.add(Param.optional("instrument", Boolean.class))
.add(Param.optional(List.of("workload", "yaml"), String.class, "location of workload yaml file"))
.add(Param.optional("driver", String.class))
.add(Param.defaultTo("dryrun",false))
.asReadOnly();
}

View File

@ -0,0 +1,16 @@
package io.nosqlbench.engine.api.activityimpl.uniform;
import io.nosqlbench.engine.api.activityimpl.uniform.flowtypes.Op;
import io.nosqlbench.engine.api.activityimpl.uniform.flowtypes.RunnableOp;
public class DryRunOp implements RunnableOp {
private final Op op;
public DryRunOp(Op op) {
this.op = op;
}
@Override
public void run() {
}
}

View File

@ -0,0 +1,21 @@
package io.nosqlbench.engine.api.activityimpl.uniform;
import io.nosqlbench.engine.api.activityimpl.BaseOpDispenser;
import io.nosqlbench.engine.api.activityimpl.OpDispenser;
import io.nosqlbench.engine.api.activityimpl.uniform.flowtypes.Op;
import io.nosqlbench.engine.api.templating.ParsedOp;
public class DryRunOpDispenserWrapper extends BaseOpDispenser<Op, Object> {
private final OpDispenser<? extends Op> realDispenser;
public DryRunOpDispenserWrapper(DriverAdapter<Op,Object> adapter, ParsedOp pop, OpDispenser<? extends Op> realDispenser) {
super(adapter, pop);
this.realDispenser = realDispenser;
}
@Override
public DryRunOp apply(long cycle) {
Op op = realDispenser.apply(cycle);
return new DryRunOp(op);
}
}

View File

@ -225,6 +225,8 @@ sstablegen
* Mac M1 support
- as of 08/15, all Mac M1 systems should be supported for the.jar and the docker image
* Dry-run mode for all adapter types
review:
- 7578e91d773a9ea8113250899ef46b7aacf95e70
- 392bbcc5954019ae58956850c980646cef14a1f7

View File

@ -17,7 +17,11 @@
package io.nosqlbench.engine.api.activityimpl;
import com.codahale.metrics.Timer;
import io.nosqlbench.api.config.standard.NBConfiguration;
import io.nosqlbench.api.engine.activityimpl.ActivityDef;
import io.nosqlbench.api.engine.metrics.ActivityMetrics;
import io.nosqlbench.api.errors.BasicError;
import io.nosqlbench.api.errors.OpConfigError;
import io.nosqlbench.engine.api.activityapi.core.*;
import io.nosqlbench.engine.api.activityapi.core.progress.ActivityMetricProgressMeter;
import io.nosqlbench.engine.api.activityapi.core.progress.ProgressCapable;
@ -37,14 +41,11 @@ import io.nosqlbench.engine.api.activityconfig.StatementsLoader;
import io.nosqlbench.engine.api.activityconfig.yaml.OpTemplate;
import io.nosqlbench.engine.api.activityconfig.yaml.StmtsDocList;
import io.nosqlbench.engine.api.activityimpl.uniform.DriverAdapter;
import io.nosqlbench.engine.api.activityimpl.uniform.DryRunOpDispenserWrapper;
import io.nosqlbench.engine.api.activityimpl.uniform.decorators.SyntheticOpTemplateProvider;
import io.nosqlbench.engine.api.activityimpl.uniform.flowtypes.Op;
import io.nosqlbench.api.engine.metrics.ActivityMetrics;
import io.nosqlbench.engine.api.templating.CommandTemplate;
import io.nosqlbench.engine.api.templating.ParsedOp;
import io.nosqlbench.api.config.standard.NBConfiguration;
import io.nosqlbench.api.errors.BasicError;
import io.nosqlbench.api.errors.OpConfigError;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -472,7 +473,6 @@ public class SimpleActivity implements Activity, ProgressCapable, ActivityDefObs
List<Long> ratios = new ArrayList<>(pops.size());
for (int i = 0; i < pops.size(); i++) {
ParsedOp pop = pops.get(i);
long ratio = pop.takeStaticConfigOr("ratio", 1);
ratios.add(ratio);
@ -484,6 +484,7 @@ public class SimpleActivity implements Activity, ProgressCapable, ActivityDefObs
.orElse(SequencerType.bucket);
SequencePlanner<OpDispenser<? extends O>> planner = new SequencePlanner<>(sequencerType);
int dryrunCount=0;
for (int i = 0; i < pops.size(); i++) {
long ratio = ratios.get(i);
ParsedOp pop = pops.get(i);
@ -491,14 +492,26 @@ public class SimpleActivity implements Activity, ProgressCapable, ActivityDefObs
logger.info("skipped mapping op '" + pop.getName() + "'");
continue;
}
boolean dryrun = pop.takeStaticConfigOr("dryrun", false);
DriverAdapter adapter = adapters.get(i);
OpMapper opMapper = adapter.getOpMapper();
OpDispenser<? extends Op> dispenser = opMapper.apply(pop);
if (dryrun) {
dispenser = new DryRunOpDispenserWrapper(adapter, pop, dispenser);
dryrunCount++;
}
// if (strict) {
// optemplate.assertConsumed();
// }
planner.addOp((OpDispenser<? extends O>) dispenser, ratio);
}
if (dryrunCount>0) {
logger.warn("initialized " + dryrunCount + " op templates for dry run only. These ops will be synthesized for each cycle, but will not be executed.");
}
return planner.resolve();

View File

@ -18,6 +18,7 @@ package io.nosqlbench.engine.api.activityimpl.uniform;
import io.nosqlbench.engine.api.activityapi.core.ActionDispenser;
import io.nosqlbench.engine.api.activityapi.core.Activity;
import io.nosqlbench.engine.api.activityimpl.uniform.actions.StandardAction;
public class StandardActionDispenser implements ActionDispenser {
private final StandardActivity<?,?> activity;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package io.nosqlbench.engine.api.activityimpl.uniform;
package io.nosqlbench.engine.api.activityimpl.uniform.actions;
import com.codahale.metrics.Histogram;
import com.codahale.metrics.Timer;
@ -25,6 +25,7 @@ import io.nosqlbench.engine.api.activityapi.errorhandling.modular.NBErrorHandler
import io.nosqlbench.engine.api.activityapi.planning.OpSequence;
import io.nosqlbench.api.engine.activityimpl.ActivityDef;
import io.nosqlbench.engine.api.activityimpl.OpDispenser;
import io.nosqlbench.engine.api.activityimpl.uniform.StandardActivity;
import io.nosqlbench.engine.api.activityimpl.uniform.flowtypes.*;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;