allow specification of workspaces directory

This commit is contained in:
Jonathan Shook 2020-08-12 00:00:37 -05:00
parent f16f3fb325
commit f6108fef14
3 changed files with 28 additions and 11 deletions

View File

@ -1,5 +1,6 @@
package io.nosqlbench.docsys.core;
import io.nosqlbench.docsys.endpoints.DocsysMarkdownEndpoint;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -88,7 +89,7 @@ public class DocServerApp {
}
private static void runServer(String[] serverArgs) {
DocServer server = new DocServer();
NBWebServer server = new NBWebServer();
for (int i = 0; i < serverArgs.length; i++) {
String arg = serverArgs[i];
if (arg.matches(".*://.*")) {

View File

@ -41,9 +41,9 @@ import java.util.stream.Collectors;
/**
* For examples, see <a href="https://git.eclipse.org/c/jetty/org.eclipse.jetty.project.git/tree/examples/embedded/src/main/java/org/eclipse/jetty/embedded/">embedded examples</a>
*/
public class DocServer implements Runnable {
public class NBWebServer implements Runnable {
private final static Logger logger = LogManager.getLogger(DocServer.class);
private final static Logger logger = LogManager.getLogger(NBWebServer.class);
private final List<Path> basePaths = new ArrayList<>();
private final List<Class> servletClasses = new ArrayList<>();
@ -55,17 +55,29 @@ public class DocServer implements Runnable {
private String bindHost = "localhost";
private int bindPort = 12345;
public DocServer withHost(String bindHost) {
private Map<String,Object> contextParams = new LinkedHashMap<>();
public NBWebServer withContextParams(Map<String,Object> cp) {
this.contextParams.putAll(cp);
return this;
}
public NBWebServer withContextParam(String name, Object object) {
this.contextParams.put(name, object);
return this;
}
public NBWebServer withHost(String bindHost) {
this.bindHost = bindHost;
return this;
}
public DocServer withPort(int bindPort) {
public NBWebServer withPort(int bindPort) {
this.bindPort = bindPort;
return this;
}
public DocServer withURL(String urlSpec) {
public NBWebServer withURL(String urlSpec) {
try {
URL url = new URL(urlSpec);
this.bindPort = url.getPort();
@ -81,7 +93,7 @@ public class DocServer implements Runnable {
return this;
}
public DocServer withScheme(String scheme) {
public NBWebServer withScheme(String scheme) {
this.bindScheme = scheme;
return this;
}
@ -129,7 +141,7 @@ public class DocServer implements Runnable {
return servletHolder;
}
public DocServer addPaths(Path... paths) {
public NBWebServer addPaths(Path... paths) {
for (Path path : paths) {
try {
path.getFileSystem().provider().checkAccess(path, AccessMode.READ);
@ -216,6 +228,7 @@ public class DocServer implements Runnable {
ResourceConfig rc = new ResourceConfig();
rc.addProperties(contextParams);
rc.property("server", this);
ServletContainer container = new ServletContainer(rc);

View File

@ -2,11 +2,8 @@ package io.nosqlbench.engine.cli;
import ch.qos.logback.classic.Level;
import io.nosqlbench.engine.api.metrics.IndicatorMode;
import io.nosqlbench.engine.api.scenarios.NBCLIScenarioParser;
import io.nosqlbench.engine.api.util.Unit;
import io.nosqlbench.engine.core.script.Scenario;
import io.nosqlbench.nb.api.content.Content;
import io.nosqlbench.nb.api.content.NBIO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -54,6 +51,7 @@ public class NBCLIOptions {
private static final String SESSION_NAME = "--session-name";
private static final String LOGS_DIR = "--logs-dir";
private static final String WORKSPACES_DIR = "--workspaces-dir";
private static final String LOGS_MAX = "--logs-max";
private static final String LOGS_LEVEL = "--logs-level";
private static final String DASH_V_INFO = "-v";
@ -99,6 +97,7 @@ public class NBCLIOptions {
private final List<String> classicHistoConfigs = new ArrayList<>();
private String progressSpec = "console:1m";
private String logsDirectory = "logs";
private String workspacesDirectory = "workspaces";
private boolean wantsInputTypes = false;
private boolean wantsMarkerTypes = false;
private String[] rleDumpOptions = new String[0];
@ -209,6 +208,10 @@ public class NBCLIOptions {
arglist.removeFirst();
logsDirectory = readWordOrThrow(arglist, "a log directory");
break;
case WORKSPACES_DIR:
arglist.removeFirst();
workspacesDirectory = readWordOrThrow(arglist, "a workspaces directory");
break;
case HDR_DIGITS:
arglist.removeFirst();
hdr_digits = Integer.parseInt(readWordOrThrow(arglist, "significant digits"));