mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
first functional version
This commit is contained in:
parent
b883ec6e69
commit
8b972bf9e3
@ -26,6 +26,7 @@ import io.nosqlbench.engine.core.lifecycle.scenario.container.NBCommandParams;
|
||||
import io.nosqlbench.engine.core.lifecycle.scenario.execution.NBBaseCommand;
|
||||
import io.nosqlbench.nb.annotations.Service;
|
||||
import io.nosqlbench.nb.api.components.events.ParamChange;
|
||||
import io.nosqlbench.nb.api.components.events.SetThreads;
|
||||
import io.nosqlbench.nb.api.engine.activityimpl.ActivityDef;
|
||||
import io.nosqlbench.nb.api.engine.activityimpl.ParameterMap;
|
||||
import io.nosqlbench.nb.api.errors.BasicError;
|
||||
@ -41,6 +42,8 @@ import java.util.Optional;
|
||||
@Service(value = NBBaseCommand.class,selector = "reset")
|
||||
public class CMD_reset extends NBBaseCommand {
|
||||
public final static Logger logger = LogManager.getLogger("reset");
|
||||
public static final String DEFAULT_RATE = "100";
|
||||
public static final String DEFAULT_THREADS = "10";
|
||||
|
||||
public CMD_reset(NBBufferedContainer parentComponent, String scenarioName, String context) {
|
||||
super(parentComponent, scenarioName, context);
|
||||
@ -55,14 +58,34 @@ public class CMD_reset extends NBBaseCommand {
|
||||
Activity flywheel = optionalActivity.or(controller::getSoloActivity)
|
||||
.orElseThrow(() -> new RuntimeException("You didn't provide the name of an activity to attach to, nor was there a solo activity available in this context"));
|
||||
|
||||
//if (flywheel.getActivityDef().getParams().getOptionalString("cycles").isEmpty()) {
|
||||
//params .getOptionalLong("rate")
|
||||
flywheel.onEvent(new ParamChange<>(new CycleRateSpec(100.0d, 1.1d, SimRateSpec.Verb.restart)));
|
||||
flywheel.getActivityDef().setEndCycle(Long.parseLong((String) flywheel.getActivityDef().getParams().get("cycles")));
|
||||
/*
|
||||
Set the CycleRateSpec. This should be found in params.get("rate") if the value from a previous step is specified.
|
||||
If not, the original might be found in the activity definition. If not, default to 100.
|
||||
*/
|
||||
String rateStr = params.hasMember("rate") ? params.get("rate") :
|
||||
flywheel.getActivityDef().getParams().getOptionalString("rate").orElse(DEFAULT_RATE);
|
||||
logger.debug("Resetting rate to " + rateStr + " cycles per second");
|
||||
flywheel.onEvent(new ParamChange<>(new CycleRateSpec(Double.parseDouble(rateStr), 1.1d, SimRateSpec.Verb.restart)));
|
||||
|
||||
// Get the original cycle count and re-apply it
|
||||
long cycles = Long.parseLong((String) flywheel.getActivityDef().getParams().get("cycles"));
|
||||
logger.debug("Resetting cycle count to " + cycles + " cycles");
|
||||
flywheel.getActivityDef().setEndCycle(cycles);
|
||||
|
||||
/*
|
||||
Set the thread count. First check for threads=${optimo.threads}. If that is not present check for
|
||||
threads specification in the original activity. If that also is not present default to UNDEF.
|
||||
Some odd behavior is noted with the optimo.threads value moving from params to the flywheel params
|
||||
if threads were initially set, and that initial value being present in params. So if you're going to use
|
||||
the reset command try not to explicitly set threads in the initial activity.
|
||||
*/
|
||||
String threadStr = params.hasMember("threads") ? params.get("threads") :
|
||||
flywheel.getActivityDef().getParams().getOptionalString("threads").orElse(DEFAULT_THREADS);
|
||||
logger.debug("Resetting threads to " + threadStr);
|
||||
flywheel.onEvent(ParamChange.of(new SetThreads((int)Math.round(Double.valueOf(threadStr)))));
|
||||
|
||||
SimFrameUtils.awaitActivity(flywheel);
|
||||
NBCommandParams newParams = NBCommandParams.of(flywheel.getActivityDef().getParams().getStringStringMap());
|
||||
// controller.run(newParams);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user