mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
organize virtdata entry points
This commit is contained in:
parent
4f2b292945
commit
be16085663
@ -1,11 +1,10 @@
|
||||
package io.nosqlbench.virtdata.userlibs.apps;
|
||||
|
||||
import io.nosqlbench.virtdata.userlibs.apps.docsapp.AutoDocsApp;
|
||||
import io.nosqlbench.virtdata.userlibs.apps.valuesapp.ValuesCheckerApp;
|
||||
import io.nosqlbench.docsys.core.DocServerApp;
|
||||
import io.nosqlbench.virtdata.userlibs.apps.diagnoseapp.VirtDataDiagnoseApp;
|
||||
import io.nosqlbench.virtdata.userlibs.apps.docsapp.VirtDataGenDocsApp;
|
||||
import io.nosqlbench.virtdata.userlibs.apps.valuesapp.VirtDataCheckPerfApp;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* This just routes the user to the correct sub-app depending on the leading verb, stripping it off in the process.
|
||||
@ -14,18 +13,16 @@ public class VirtDataMainApp {
|
||||
|
||||
private final static String APP_TESTMAPPER = "testmapper";
|
||||
private final static String APP_GENDOCS = "gendocs";
|
||||
private final static String APP_DOCSERVER = "docserver";
|
||||
private final static String[] names = new String[]{APP_DOCSERVER, APP_GENDOCS, APP_TESTMAPPER};
|
||||
private final static String APP_DIAGNOSE = "diagnose";
|
||||
private final static String[] names = new String[]{APP_GENDOCS, APP_TESTMAPPER, APP_DIAGNOSE};
|
||||
|
||||
public static boolean hasNamedApp(String appname) {
|
||||
return (appname.equals(APP_TESTMAPPER)
|
||||
|| appname.equals(APP_GENDOCS)
|
||||
|| appname.equals(APP_DOCSERVER));
|
||||
return (appname.equals(APP_TESTMAPPER) || appname.equals(APP_GENDOCS) || appname.equals(APP_DIAGNOSE));
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
if (args.length == 0) {
|
||||
System.out.println("Usage: app (" + APP_TESTMAPPER + "|" + APP_GENDOCS + "|" + APP_DOCSERVER + ")");
|
||||
System.out.println("Usage: app (" + APP_TESTMAPPER + "|" + APP_GENDOCS + "|" + APP_DIAGNOSE +")");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
@ -36,13 +33,13 @@ public class VirtDataMainApp {
|
||||
}
|
||||
|
||||
if (appSelection.toLowerCase().equals(APP_TESTMAPPER)) {
|
||||
ValuesCheckerApp.main(appArgs);
|
||||
VirtDataCheckPerfApp.main(appArgs);
|
||||
} else if (appSelection.toLowerCase().equals(APP_GENDOCS)) {
|
||||
AutoDocsApp.main(appArgs);
|
||||
} else if (appSelection.toLowerCase().equals(APP_DOCSERVER)) {
|
||||
DocServerApp.main(appArgs);
|
||||
VirtDataGenDocsApp.main(appArgs);
|
||||
} else if (appSelection.toLowerCase().equals(APP_DIAGNOSE)) {
|
||||
VirtDataDiagnoseApp.main(appArgs);
|
||||
} else {
|
||||
System.err.println("Error in command line. The first argument must one of " + Arrays.stream(names).collect(Collectors.joining(",")));
|
||||
System.err.println("Error in command line. The first argument must one of " + String.join(",", names));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,31 @@
|
||||
package io.nosqlbench.virtdata.userlibs.apps.diagnoseapp;
|
||||
|
||||
import io.nosqlbench.virtdata.core.bindings.ResolverDiagnostics;
|
||||
import io.nosqlbench.virtdata.core.bindings.VirtData;
|
||||
import io.nosqlbench.virtdata.userlibs.apps.valuesapp.RunData;
|
||||
import io.nosqlbench.virtdata.userlibs.apps.valuesapp.ValuesCheckerCoordinator;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class VirtDataDiagnoseApp {
|
||||
|
||||
private final static Logger logger = LogManager.getLogger(VirtDataDiagnoseApp.class);
|
||||
|
||||
public static void main(String[] args) {
|
||||
if (args.length==1) {
|
||||
diagnose(args[0]);
|
||||
} else {
|
||||
System.out.println(" ARGS: 'specifier'");
|
||||
System.exit(2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void diagnose(String mapperSpec) {
|
||||
ResolverDiagnostics diags = VirtData.getMapperDiagnostics(mapperSpec);
|
||||
System.out.println("mapper diagnostics:\n" + diags.toString());
|
||||
}
|
||||
|
||||
}
|
@ -19,9 +19,9 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
|
||||
public class AutoDocsApp implements Runnable {
|
||||
public class VirtDataGenDocsApp implements Runnable {
|
||||
|
||||
private final static Logger logger = LogManager.getLogger(AutoDocsApp.class);
|
||||
private final static Logger logger = LogManager.getLogger(VirtDataGenDocsApp.class);
|
||||
|
||||
private final static String CATEGORIES = "categories";
|
||||
private final static String CATEGORIES_SPLIT = "split";
|
||||
@ -46,10 +46,10 @@ public class AutoDocsApp implements Runnable {
|
||||
private String basedir = "";
|
||||
|
||||
public static void main(String[] args) {
|
||||
new AutoDocsApp(args).run();
|
||||
new VirtDataGenDocsApp(args).run();
|
||||
}
|
||||
|
||||
public AutoDocsApp(String[] args) {
|
||||
public VirtDataGenDocsApp(String[] args) {
|
||||
this.args = args;
|
||||
}
|
||||
|
||||
@ -66,7 +66,7 @@ public class AutoDocsApp implements Runnable {
|
||||
while (largs.peekFirst() != null) {
|
||||
String argtype = largs.removeFirst();
|
||||
if (largs.peekFirst() == null) {
|
||||
throw new RuntimeException(AutoDocsApp.class.toString() + " expects args in param value couplets.");
|
||||
throw new RuntimeException(VirtDataGenDocsApp.class.toString() + " expects args in param value couplets.");
|
||||
}
|
||||
|
||||
String argval = largs.removeFirst().toLowerCase();
|
@ -1,53 +0,0 @@
|
||||
package io.nosqlbench.virtdata.userlibs.apps.valuesapp;
|
||||
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
public class ValuesCheckerApp {
|
||||
|
||||
private final static Logger logger = LogManager.getLogger(ValuesCheckerApp.class);
|
||||
|
||||
public static void main(String[] args) {
|
||||
if (args.length<5) {
|
||||
System.out.println("ARGS: 'specifier' threads bufsize start end");
|
||||
System.out.println("example: 'timeuuid()' 100 1000 0 10000");
|
||||
System.out.println(" specifier: A VirtData function specifier.");
|
||||
System.out.println(" threads: The number of concurrent threads to run.");
|
||||
System.out.println(" bufsize: The number of cycles to give each thread at a time.");
|
||||
System.out.println(" start: The start cycle for the test, inclusive.");
|
||||
System.out.println(" end: The end cycle for the test, exclusive.");
|
||||
System.exit(2);
|
||||
}
|
||||
String spec = args[0];
|
||||
int threads = Integer.valueOf(args[1]);
|
||||
int bufsize = Integer.valueOf(args[2]);
|
||||
long start = Long.valueOf(args[3]);
|
||||
long end = Long.valueOf(args[4]);
|
||||
|
||||
boolean isolated = false;
|
||||
|
||||
if (args.length==6) {
|
||||
isolated=args[5].toLowerCase().equals("isolated") || args[5].toLowerCase().equals("true");
|
||||
}
|
||||
|
||||
ValuesCheckerCoordinator checker = new ValuesCheckerCoordinator(spec, threads, bufsize, start, end, isolated);
|
||||
|
||||
if (!isolated) {
|
||||
logger.warn("You are testing functions which are not intended to be thread-safe in a non-threadsafe way.");
|
||||
logger.warn("This is only advisable if you are doing development against the core libraries.");
|
||||
logger.warn("Results may vary.");
|
||||
}
|
||||
|
||||
RunData runData;
|
||||
try {
|
||||
runData = checker.call();
|
||||
System.out.println(runData.toString());
|
||||
System.exit(0);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.exit(2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
package io.nosqlbench.virtdata.userlibs.apps.valuesapp;
|
||||
|
||||
import io.nosqlbench.virtdata.core.bindings.ResolverDiagnostics;
|
||||
import io.nosqlbench.virtdata.core.bindings.VirtData;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class VirtDataCheckPerfApp {
|
||||
|
||||
private final static Logger logger = LogManager.getLogger(VirtDataCheckPerfApp.class);
|
||||
|
||||
public static void main(String[] args) {
|
||||
if (args.length==5) {
|
||||
checkperf(args);
|
||||
} else {
|
||||
System.out.println(" ARGS: checkperf 'specifier' threads bufsize start end");
|
||||
System.out.println(" example: 'timeuuid()' 100 1000 0 10000");
|
||||
System.out.println(" specifier: A VirtData function specifier.");
|
||||
System.out.println(" threads: The number of concurrent threads to run.");
|
||||
System.out.println(" bufsize: The number of cycles to give each thread at a time.");
|
||||
System.out.println(" start: The start cycle for the test, inclusive.");
|
||||
System.out.println(" end: The end cycle for the test, exclusive.");
|
||||
System.out.println(" OR");
|
||||
System.out.println(" ARGS: diagnose 'specifier'");
|
||||
System.exit(2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void checkperf(String[] args) {
|
||||
String spec = args[0];
|
||||
int threads = Integer.parseInt(args[1]);
|
||||
int bufsize = Integer.parseInt(args[2]);
|
||||
long start = Long.parseLong(args[3]);
|
||||
long end = Long.parseLong(args[4]);
|
||||
|
||||
boolean isolated = false;
|
||||
|
||||
ValuesCheckerCoordinator checker = new ValuesCheckerCoordinator(spec, threads, bufsize, start, end, isolated);
|
||||
|
||||
RunData runData;
|
||||
try {
|
||||
runData = checker.call();
|
||||
System.out.println(runData.toString());
|
||||
System.exit(0);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.exit(2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void diagnose(String[] args) {
|
||||
String mapperSpec = args[0];
|
||||
|
||||
ResolverDiagnostics diags = VirtData.getMapperDiagnostics(mapperSpec);
|
||||
System.out.println("mapper diagnostics:\n" + diags.toString());
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user