mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2024-12-28 17:51:06 -06:00
make scenarios run in workspace
This commit is contained in:
parent
6179692162
commit
9717487db4
@ -113,7 +113,7 @@ public class StdoutActivity extends SimpleActivity implements ActivityDefObserve
|
||||
protected Writer createPrintWriter() {
|
||||
PrintWriter pw;
|
||||
if (fileName.toLowerCase().equals("stdout")) {
|
||||
pw = new PrintWriter(System.out);
|
||||
pw = getConsoleOut();
|
||||
} else {
|
||||
try {
|
||||
pw = new PrintWriter(fileName);
|
||||
@ -144,8 +144,9 @@ public class StdoutActivity extends SimpleActivity implements ActivityDefObserve
|
||||
BindingsTemplate bt = new BindingsTemplate();
|
||||
stmtsDocList.getDocBindings().forEach(bt::addFieldBinding);
|
||||
String diagnostics = bt.getDiagnostics();
|
||||
System.out.println(diagnostics);
|
||||
System.out.flush();
|
||||
|
||||
getConsoleOut().println(diagnostics);
|
||||
getConsoleOut().flush();
|
||||
System.exit(2);
|
||||
} else {
|
||||
logger.info("Creating stdout statement template from bindings, since none is otherwise defined.");
|
||||
|
@ -26,6 +26,8 @@ import io.nosqlbench.engine.api.activityimpl.ActivityDef;
|
||||
import io.nosqlbench.engine.api.activityimpl.ParameterMap;
|
||||
import io.nosqlbench.engine.api.activityimpl.SimpleActivity;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
@ -181,4 +183,10 @@ public interface Activity extends Comparable<Activity>, ActivityDefObserver {
|
||||
* @return A new or existing instrumentation object for this activity.
|
||||
*/
|
||||
ActivityInstrumentation getInstrumentation();
|
||||
|
||||
PrintWriter getConsoleOut();
|
||||
|
||||
InputStream getConsoleIn();
|
||||
|
||||
void setConsoleOut(PrintWriter writer);
|
||||
}
|
||||
|
@ -13,8 +13,6 @@ import io.nosqlbench.engine.api.activityapi.ratelimits.RateLimiters;
|
||||
import io.nosqlbench.engine.api.activityapi.ratelimits.RateSpec;
|
||||
import io.nosqlbench.engine.api.activityconfig.StatementsLoader;
|
||||
import io.nosqlbench.engine.api.activityconfig.yaml.OpTemplate;
|
||||
import io.nosqlbench.engine.api.activityconfig.yaml.StmtDef;
|
||||
import io.nosqlbench.engine.api.activityconfig.yaml.StmtsDoc;
|
||||
import io.nosqlbench.engine.api.activityconfig.yaml.StmtsDocList;
|
||||
import io.nosqlbench.engine.api.metrics.ActivityMetrics;
|
||||
import io.nosqlbench.engine.api.templating.CommandTemplate;
|
||||
@ -23,6 +21,8 @@ import io.nosqlbench.nb.api.errors.BasicError;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
@ -48,6 +48,7 @@ public class SimpleActivity implements Activity {
|
||||
private RateLimiter phaseLimiter;
|
||||
private ActivityController activityController;
|
||||
private ActivityInstrumentation activityInstrumentation;
|
||||
private PrintWriter console;
|
||||
|
||||
public SimpleActivity(ActivityDef activityDef) {
|
||||
this.activityDef = activityDef;
|
||||
@ -232,6 +233,24 @@ public class SimpleActivity implements Activity {
|
||||
return activityInstrumentation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized PrintWriter getConsoleOut() {
|
||||
if (this.console==null) {
|
||||
this.console = new PrintWriter(System.out);
|
||||
}
|
||||
return this.console;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized InputStream getConsoleIn() {
|
||||
return System.in;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConsoleOut(PrintWriter writer) {
|
||||
this.console = writer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void onActivityDefUpdate(ActivityDef activityDef) {
|
||||
|
||||
|
@ -145,6 +145,7 @@ public class Scenario implements Callable<ScenarioResult> {
|
||||
.option("js.ecmascript-version", "2020")
|
||||
.option("js.nashorn-compat", "true");
|
||||
|
||||
// TODO: add in, out, err for this scenario
|
||||
this.scriptEngine = GraalJSScriptEngine.create(null, contextSettings);
|
||||
|
||||
// try {
|
||||
|
Loading…
Reference in New Issue
Block a user