Merge branch 'master' into releases

This commit is contained in:
Jonathan Shook
2020-03-17 12:47:59 -05:00
19 changed files with 756 additions and 138 deletions

View File

@@ -40,6 +40,13 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core-java8</artifactId>

View File

@@ -8,6 +8,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.InputStream;
import java.nio.file.Path;
import java.security.InvalidParameterException;
import java.util.*;
import java.util.stream.Collectors;
@@ -313,12 +314,26 @@ public class NBCLIOptions {
Cmd script = parseScriptCmd(arglist);
cmdList.add(script);
} else {
throw new InvalidParameterException("unrecognized option:" + word);
Optional<Path> path = NosqlBenchFiles.findOptionalPath(word, "yaml", "activities");
if(path.isPresent()){
arglist.removeFirst();
arglist.addFirst("yaml="+path.toString());
Cmd script = parseWorkloladYamlCmd(arglist);
cmdList.add(script);
}
else {
throw new InvalidParameterException("unrecognized option:" + word);
}
}
}
}
}
private Cmd parseWorkloladYamlCmd(LinkedList<String> arglist) {
return null;
}
private Map<String, Level> parseLogLevelOverrides(String levelsSpec) {
Map<String,Level> levels = new HashMap<>();
Arrays.stream(levelsSpec.split("[,;]")).forEach(kp -> {
@@ -549,100 +564,100 @@ public class NBCLIOptions {
histoLoggerConfigs.add(String.format("%s:%s:%s",file,pattern,interval));
}
public static enum CmdType {
start,
start2,
run,
run2,
stop,
await,
script,
fragment,
waitmillis,
public static enum CmdType {
start,
start2,
run,
run2,
stop,
await,
script,
fragment,
waitmillis,
}
public static class Cmd {
private CmdType cmdType;
private String cmdSpec;
private Map<String, String> cmdArgs;
public Cmd(CmdType cmdType, String cmdSpec) {
this.cmdSpec = cmdSpec;
this.cmdType = cmdType;
}
public static class Cmd {
private CmdType cmdType;
private String cmdSpec;
private Map<String, String> cmdArgs;
public Cmd(CmdType cmdType, String cmdSpec, Map<String, String> cmdArgs) {
this(cmdType, cmdSpec);
this.cmdArgs = cmdArgs;
}
public Cmd(CmdType cmdType, String cmdSpec) {
this.cmdSpec = cmdSpec;
this.cmdType = cmdType;
public String getCmdSpec() {
if (cmdSpec.startsWith("'") && cmdSpec.endsWith("'")) {
return cmdSpec.substring(1,cmdSpec.length()-1);
}
public Cmd(CmdType cmdType, String cmdSpec, Map<String, String> cmdArgs) {
this(cmdType, cmdSpec);
this.cmdArgs = cmdArgs;
if (cmdSpec.startsWith("\"") && cmdSpec.endsWith("\"")) {
return cmdSpec.substring(1,cmdSpec.length()-1);
}
return cmdSpec;
}
public String getCmdSpec() {
public CmdType getCmdType() {
return cmdType;
}
if (cmdSpec.startsWith("'") && cmdSpec.endsWith("'")) {
return cmdSpec.substring(1,cmdSpec.length()-1);
}
if (cmdSpec.startsWith("\"") && cmdSpec.endsWith("\"")) {
return cmdSpec.substring(1,cmdSpec.length()-1);
}
return cmdSpec;
}
public void setCmdType(CmdType cmdType) {
this.cmdType = cmdType;
}
public CmdType getCmdType() {
return cmdType;
}
public Map<String, String> getCmdArgs() {
return cmdArgs;
}
public void setCmdType(CmdType cmdType) {
this.cmdType = cmdType;
}
public String toString() {
return "type:" + cmdType + ";spec=" + cmdSpec
+ ((cmdArgs != null) ? ";cmdArgs=" + cmdArgs.toString() : "");
}
}
public Map<String, String> getCmdArgs() {
return cmdArgs;
}
public static class LoggerConfig {
public String file = "";
public String pattern = ".*";
public String interval = "30 seconds";
public String toString() {
return "type:" + cmdType + ";spec=" + cmdSpec
+ ((cmdArgs != null) ? ";cmdArgs=" + cmdArgs.toString() : "");
public LoggerConfig(String histoLoggerSpec) {
String[] words = histoLoggerSpec.split(":");
switch (words.length) {
case 3:
interval = words[2].isEmpty() ? interval : words[2];
case 2:
pattern = words[1].isEmpty() ? pattern : words[1];
case 1:
file = words[0];
if (file.isEmpty()) {
throw new RuntimeException("You must not specify an empty file here for logging data.");
}
break;
default:
throw new RuntimeException(
LOG_HISTO +
" options must be in either 'regex:filename:interval' or 'regex:filename' or 'filename' format"
);
}
}
public static class LoggerConfig {
public String file = "";
public String pattern = ".*";
public String interval = "30 seconds";
public LoggerConfig(String histoLoggerSpec) {
String[] words = histoLoggerSpec.split(":");
switch (words.length) {
case 3:
interval = words[2].isEmpty() ? interval : words[2];
case 2:
pattern = words[1].isEmpty() ? pattern : words[1];
case 1:
file = words[0];
if (file.isEmpty()) {
throw new RuntimeException("You must not specify an empty file here for logging data.");
}
break;
default:
throw new RuntimeException(
LOG_HISTO +
" options must be in either 'regex:filename:interval' or 'regex:filename' or 'filename' format"
);
}
}
public String getFilename() {
return file;
}
public String getFilename() {
return file;
}
}
private static class ProgressSpec {
public String intervalSpec;
public IndicatorMode indicatorMode;
public String toString() {
return indicatorMode.toString()+":" + intervalSpec;
}
private static class ProgressSpec {
public String intervalSpec;
public IndicatorMode indicatorMode;
public String toString() {
return indicatorMode.toString()+":" + intervalSpec;
}
}
private ProgressSpec parseProgressSpec(String interval) {
ProgressSpec progressSpec = new ProgressSpec();