mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
Add NBAdvisor Framework
This commit is contained in:
parent
ea7fceae49
commit
f2f448ffc3
@ -1,115 +0,0 @@
|
||||
<!--
|
||||
~ Copyright (c) nosqlbench
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>adapter-s4j</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<artifactId>mvn-defaults</artifactId>
|
||||
<groupId>io.nosqlbench</groupId>
|
||||
<version>${revision}</version>
|
||||
<relativePath>../../mvn-defaults</relativePath>
|
||||
</parent>
|
||||
|
||||
<name>${project.artifactId}</name>
|
||||
<description>
|
||||
A Starlight for JMS driver for nosqlbench. This provides the ability to inject synthetic data
|
||||
into a pulsar system via JMS 2.0 compatible APIs.
|
||||
|
||||
NOTE: this is JMS compatible driver from DataStax that allows using a Pulsar cluster
|
||||
as the potential JMS Destination
|
||||
</description>
|
||||
|
||||
<properties>
|
||||
<s4j.version>5.0.5</s4j.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.nosqlbench</groupId>
|
||||
<artifactId>adapters-api</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/com.datastax.oss/pulsar-jms -->
|
||||
<dependency>
|
||||
<groupId>com.datastax.oss</groupId>
|
||||
<artifactId>pulsar-jms-all</artifactId>
|
||||
<version>${s4j.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.14.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/commons-beanutils/commons-beanutils -->
|
||||
<dependency>
|
||||
<groupId>commons-beanutils</groupId>
|
||||
<artifactId>commons-beanutils-core</artifactId>
|
||||
<version>1.8.3</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-configuration2 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-configuration2</artifactId>
|
||||
<version>2.10.1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.conscrypt/conscrypt-openjdk -->
|
||||
<dependency>
|
||||
<groupId>org.conscrypt</groupId>
|
||||
<artifactId>conscrypt-openjdk</artifactId>
|
||||
<version>2.5.2</version>
|
||||
<classifier>${os.detected.classifier}</classifier>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>kr.motd.maven</groupId>
|
||||
<artifactId>os-maven-plugin</artifactId>
|
||||
<version>1.7.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>initialize</phase>
|
||||
<goals>
|
||||
<goal>detect</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<!-- <extensions>-->
|
||||
<!-- <extension>-->
|
||||
<!-- <groupId>kr.motd.maven</groupId>-->
|
||||
<!-- <artifactId>os-maven-plugin</artifactId>-->
|
||||
<!-- <version>1.7.1</version>-->
|
||||
<!-- </extension>-->
|
||||
<!-- </extensions>-->
|
||||
|
||||
</build>
|
||||
|
||||
</project>
|
@ -20,6 +20,7 @@ import com.amazonaws.util.StringInputStream;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import io.nosqlbench.nb.api.nbio.Content;
|
||||
import io.nosqlbench.nb.api.nbio.NBIO;
|
||||
import io.nosqlbench.nb.api.errors.ProcessingEarlyExit;
|
||||
import io.nosqlbench.nb.api.errors.BasicError;
|
||||
import io.nosqlbench.adapters.api.activityconfig.rawyaml.RawOpsDocList;
|
||||
import io.nosqlbench.adapters.api.activityconfig.rawyaml.RawOpsLoader;
|
||||
@ -129,10 +130,10 @@ public class OpsLoader {
|
||||
System.err.println(stderrOutput);
|
||||
if (resultStatus==0 && stderrOutput.isEmpty()) {
|
||||
logger.info("no errors detected during jsonnet evaluation.");
|
||||
System.exit(0);
|
||||
throw new ProcessingEarlyExit("dryrun=jsonnet: No errors detected.", 0);
|
||||
} else {
|
||||
logger.error("ERRORS detected during jsonnet evaluation:\n" + stderrOutput);
|
||||
System.exit(2);
|
||||
throw new ProcessingEarlyExit("dryrun=jsonnet: Errors detected.", 2);
|
||||
}
|
||||
}
|
||||
if (!stderrOutput.isEmpty()) {
|
||||
|
@ -178,6 +178,7 @@ public abstract class BaseDriverAdapter<R extends CycleOp<?>, S extends Space> e
|
||||
.add(Param.optional(List.of("workload", "yaml"), String.class, "location of workload yaml file"))
|
||||
.add(Param.optional("driver", String.class))
|
||||
.add(Param.defaultTo("dryrun", "none").setRegex("(op|jsonnet|emit|none)"))
|
||||
.add(Param.defaultTo("advisor", "none").setRegex("(validate|enforce|none)"))
|
||||
.add(Param.optional("maxtries", Integer.class))
|
||||
.asReadOnly();
|
||||
}
|
||||
|
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.nb.api.errors;
|
||||
|
||||
public class ProcessingEarlyExit extends RuntimeException {
|
||||
private final String message;
|
||||
private final int exitCode;
|
||||
|
||||
public ProcessingEarlyExit(String message, int exitCode) {
|
||||
this.message = message;
|
||||
this.exitCode = exitCode;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
final String helpmsg = """
|
||||
'ARG'.
|
||||
"""
|
||||
.replaceAll("ARG", this.message);
|
||||
return helpmsg;
|
||||
}
|
||||
|
||||
public int getExitCode() {
|
||||
return this.exitCode;
|
||||
}
|
||||
}
|
@ -136,12 +136,12 @@ public class NBCLI implements Function<String[], Integer>, NBLabeledElement {
|
||||
break;
|
||||
}
|
||||
|
||||
final String error = NBCLIErrorHandler.handle(e, showStackTraces, NBCLI.version);
|
||||
final int result = NBCLIErrorHandler.handle(e, showStackTraces, NBCLI.version);
|
||||
// Commented for now, as the above handler should do everything needed.
|
||||
if (null != error) System.err.println("Scenario stopped due to error. See logs for details.");
|
||||
System.err.println("Stopped. See logs for details.");
|
||||
System.err.flush();
|
||||
System.out.flush();
|
||||
return NBCLI.EXIT_ERROR;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ package io.nosqlbench.engine.api.activityimpl;
|
||||
|
||||
public enum Dryrun {
|
||||
/**
|
||||
* Ops are executed normally, no change to the dispenser behavior
|
||||
* Ops are executed normally, no change to the dispenser behavior.
|
||||
*/
|
||||
none,
|
||||
/**
|
||||
@ -32,5 +32,12 @@ public enum Dryrun {
|
||||
* Ops will print the toString version of their result to stdout.
|
||||
* This is done by wrapping the synthesized op in a post-emit facade.
|
||||
*/
|
||||
emit
|
||||
emit,
|
||||
/**
|
||||
* Jsonnet evaluation is a one time dry-run and then exit.
|
||||
* With this value the run should exit after the first evaluation of jsonnet
|
||||
* and Ops are not executed, but should processing fall through then processing
|
||||
* will proceed as for none.
|
||||
*/
|
||||
jsonnet
|
||||
}
|
||||
|
@ -43,6 +43,7 @@ public class OpWrappers {
|
||||
case none -> dispenser;
|
||||
case op -> new DryCycleOpDispenserWrapper(adapter, pop, dispenser);
|
||||
case emit -> new EmitterCycleOpDispenserWrapper(adapter, pop, dispenser);
|
||||
case jsonnet -> dispenser;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -45,6 +45,7 @@ public class INFO_run extends NBCommandInfo {
|
||||
|
||||
Diagnostic Options
|
||||
* dryrun enable dryrun diagnostics at different levels
|
||||
* advisor enable advisor for command validation and enforcement
|
||||
|
||||
Metrics Options
|
||||
* alias name the activity so that you can observer or modify it concurrently
|
||||
|
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.engine.core.lifecycle.process;
|
||||
|
||||
public enum NBAdvisor {
|
||||
/**
|
||||
* Do not analyze arguments, scenarios, activities, and workloads
|
||||
*/
|
||||
none,
|
||||
/**
|
||||
* Provide advice about invalid, incorrect, and unused ops
|
||||
*/
|
||||
validate,
|
||||
/**
|
||||
* Only allow correct operations
|
||||
*/
|
||||
enforce
|
||||
}
|
@ -17,6 +17,7 @@
|
||||
package io.nosqlbench.engine.core.lifecycle.process;
|
||||
|
||||
import io.nosqlbench.nb.api.errors.BasicError;
|
||||
import io.nosqlbench.nb.api.errors.ProcessingEarlyExit;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.graalvm.polyglot.PolyglotException;
|
||||
@ -43,7 +44,7 @@ public class NBCLIErrorHandler {
|
||||
|
||||
private final static Logger logger = LogManager.getLogger("ERRORHANDLER");
|
||||
|
||||
public static String handle(Throwable t, boolean wantsStackTraces, String version) {
|
||||
public static int handle(Throwable t, boolean wantsStackTraces, String version) {
|
||||
|
||||
if (wantsStackTraces) {
|
||||
StackTraceElement[] st = Thread.currentThread().getStackTrace();
|
||||
@ -63,6 +64,9 @@ public class NBCLIErrorHandler {
|
||||
} else if (t instanceof BasicError) {
|
||||
logger.trace("Handling basic error: " + t);
|
||||
return handleBasicError((BasicError) t, wantsStackTraces, version);
|
||||
} else if (t instanceof ProcessingEarlyExit) {
|
||||
logger.trace("Handle processing early exit: " + t);
|
||||
return handleProcessingEarlyExit((ProcessingEarlyExit) t, wantsStackTraces, version);
|
||||
} else if (t instanceof Exception) {
|
||||
logger.trace("Handling general exception: " + t);
|
||||
return handleInternalError((Exception) t, wantsStackTraces, version);
|
||||
@ -72,7 +76,7 @@ public class NBCLIErrorHandler {
|
||||
}
|
||||
}
|
||||
|
||||
private static String handleInternalError(Exception e, boolean wantsStackTraces, String version) {
|
||||
private static int handleInternalError(Exception e, boolean wantsStackTraces, String version) {
|
||||
String prefix = "internal error(" + version + "):";
|
||||
if (e.getCause() != null && !e.getCause().getClass().getCanonicalName().contains("io.nosqlbench")) {
|
||||
prefix = "Error from driver or included library(" + version + "):";
|
||||
@ -87,10 +91,10 @@ public class NBCLIErrorHandler {
|
||||
logger.error(e.getMessage());
|
||||
logger.error("for the full stack trace, run with --show-stacktraces");
|
||||
}
|
||||
return e.getMessage();
|
||||
return 2;
|
||||
}
|
||||
|
||||
private static String handleScriptException(ScriptException e, boolean wantsStackTraces, String version) {
|
||||
private static int handleScriptException(ScriptException e, boolean wantsStackTraces, String version) {
|
||||
Throwable cause = e.getCause();
|
||||
if (cause instanceof PolyglotException) {
|
||||
Throwable hostException = ((PolyglotException) cause).asHostException();
|
||||
@ -107,17 +111,22 @@ public class NBCLIErrorHandler {
|
||||
logger.error("for the full stack trace, run with --show-stacktraces");
|
||||
}
|
||||
}
|
||||
return e.getMessage();
|
||||
return 2;
|
||||
}
|
||||
|
||||
private static String handleBasicError(BasicError e, boolean wantsStackTraces, String version) {
|
||||
private static int handleBasicError(BasicError e, boolean wantsStackTraces, String version) {
|
||||
if (wantsStackTraces) {
|
||||
logger.error(e.getMessage(), e);
|
||||
} else {
|
||||
logger.error(e.getMessage());
|
||||
logger.error("for the full stack trace, run with --show-stacktraces");
|
||||
}
|
||||
return e.getMessage();
|
||||
return 2;
|
||||
}
|
||||
|
||||
private static int handleProcessingEarlyExit(ProcessingEarlyExit e, boolean wantsStackTraces, String version) {
|
||||
logger.info(e.toString());
|
||||
return e.getExitCode();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ class ExitStatusIntegrationTests {
|
||||
);
|
||||
assertThat(result.exception).isNull();
|
||||
String stderr = String.join("\n", result.getStderrData());
|
||||
assertThat(stderr).contains("Scenario stopped due to error");
|
||||
assertThat(stderr).contains("Stopped. See logs for details");
|
||||
assertThat(result.exitStatus).isEqualTo(2);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user