Revert "Add NBAdvisor Framework"

This reverts commit f2f448ffc3.
This commit is contained in:
Dave Fisher 2024-11-05 14:14:06 -08:00
parent f2f448ffc3
commit 8048402b88
11 changed files with 130 additions and 108 deletions

View File

@ -0,0 +1,115 @@
<!--
~ 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>

View File

@ -20,7 +20,6 @@ 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;
@ -130,10 +129,10 @@ public class OpsLoader {
System.err.println(stderrOutput);
if (resultStatus==0 && stderrOutput.isEmpty()) {
logger.info("no errors detected during jsonnet evaluation.");
throw new ProcessingEarlyExit("dryrun=jsonnet: No errors detected.", 0);
System.exit(0);
} else {
logger.error("ERRORS detected during jsonnet evaluation:\n" + stderrOutput);
throw new ProcessingEarlyExit("dryrun=jsonnet: Errors detected.", 2);
System.exit(2);
}
}
if (!stderrOutput.isEmpty()) {

View File

@ -178,7 +178,6 @@ 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();
}

View File

@ -1,40 +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.
*/
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;
}
}

View File

@ -136,12 +136,12 @@ public class NBCLI implements Function<String[], Integer>, NBLabeledElement {
break;
}
final int result = NBCLIErrorHandler.handle(e, showStackTraces, NBCLI.version);
final String error = NBCLIErrorHandler.handle(e, showStackTraces, NBCLI.version);
// Commented for now, as the above handler should do everything needed.
System.err.println("Stopped. See logs for details.");
if (null != error) System.err.println("Scenario stopped due to error. See logs for details.");
System.err.flush();
System.out.flush();
return result;
return NBCLI.EXIT_ERROR;
}
}

View File

@ -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,12 +32,5 @@ 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,
/**
* 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
emit
}

View File

@ -43,7 +43,6 @@ public class OpWrappers {
case none -> dispenser;
case op -> new DryCycleOpDispenserWrapper(adapter, pop, dispenser);
case emit -> new EmitterCycleOpDispenserWrapper(adapter, pop, dispenser);
case jsonnet -> dispenser;
};
}
}

View File

@ -45,7 +45,6 @@ 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

View File

@ -1,33 +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.
*/
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
}

View File

@ -17,7 +17,6 @@
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;
@ -44,7 +43,7 @@ public class NBCLIErrorHandler {
private final static Logger logger = LogManager.getLogger("ERRORHANDLER");
public static int handle(Throwable t, boolean wantsStackTraces, String version) {
public static String handle(Throwable t, boolean wantsStackTraces, String version) {
if (wantsStackTraces) {
StackTraceElement[] st = Thread.currentThread().getStackTrace();
@ -64,9 +63,6 @@ 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);
@ -76,7 +72,7 @@ public class NBCLIErrorHandler {
}
}
private static int handleInternalError(Exception e, boolean wantsStackTraces, String version) {
private static String 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 + "):";
@ -91,10 +87,10 @@ public class NBCLIErrorHandler {
logger.error(e.getMessage());
logger.error("for the full stack trace, run with --show-stacktraces");
}
return 2;
return e.getMessage();
}
private static int handleScriptException(ScriptException e, boolean wantsStackTraces, String version) {
private static String handleScriptException(ScriptException e, boolean wantsStackTraces, String version) {
Throwable cause = e.getCause();
if (cause instanceof PolyglotException) {
Throwable hostException = ((PolyglotException) cause).asHostException();
@ -111,22 +107,17 @@ public class NBCLIErrorHandler {
logger.error("for the full stack trace, run with --show-stacktraces");
}
}
return 2;
return e.getMessage();
}
private static int handleBasicError(BasicError e, boolean wantsStackTraces, String version) {
private static String 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 2;
}
private static int handleProcessingEarlyExit(ProcessingEarlyExit e, boolean wantsStackTraces, String version) {
logger.info(e.toString());
return e.getExitCode();
return e.getMessage();
}
}

View File

@ -40,7 +40,7 @@ class ExitStatusIntegrationTests {
);
assertThat(result.exception).isNull();
String stderr = String.join("\n", result.getStderrData());
assertThat(stderr).contains("Stopped. See logs for details");
assertThat(stderr).contains("Scenario stopped due to error");
assertThat(result.exitStatus).isEqualTo(2);
}