allow pre-use verification of command availability

This commit is contained in:
Jonathan Shook
2024-01-18 00:23:07 -06:00
parent 6f06846a35
commit add366a73b
4 changed files with 27 additions and 2 deletions

View File

@@ -53,5 +53,15 @@ public class NBAutoScriptResolver implements NBInvokableResolver {
} }
} }
@Override
public boolean verify(Cmd cmd) {
return NBIO.local()
.searchPrefixes("scripts/auto")
.pathname(cmd.getArgValue("_impl"))
.extensionSet("js")
.first()
.isPresent();
}
} }

View File

@@ -45,6 +45,16 @@ public class NBCoreInvokableResolver implements NBInvokableResolver {
return null; return null;
} }
@Override
public boolean verify(Cmd cmd) {
for (NBInvokableResolver resolver : getResolvers().values()) {
if (resolver.verify(cmd)) {
return true;
}
}
return false;
}
private SequencedMap<String, NBInvokableResolver> getResolvers() { private SequencedMap<String, NBInvokableResolver> getResolvers() {
if (this.resolvers == null || this.resolvers.isEmpty()) { if (this.resolvers == null || this.resolvers.isEmpty()) {
SequencedMap<String,NBInvokableResolver> resolverMap = new LinkedHashMap<>(); SequencedMap<String,NBInvokableResolver> resolverMap = new LinkedHashMap<>();

View File

@@ -21,6 +21,8 @@ import io.nosqlbench.engine.core.lifecycle.scenario.container.NBBufferedContaine
import io.nosqlbench.engine.core.lifecycle.scenario.execution.NBInvokableCommand; import io.nosqlbench.engine.core.lifecycle.scenario.execution.NBInvokableCommand;
public interface NBInvokableResolver { public interface NBInvokableResolver {
NBInvokableCommand resolve(Cmd cmd, NBBufferedContainer parent, String phaseName); NBInvokableCommand resolve(Cmd cmd, NBBufferedContainer parent, String stepname);
boolean verify(Cmd cmd);
} }

View File

@@ -37,5 +37,8 @@ public class NBScriptCommandResolver implements NBInvokableResolver {
}; };
} }
@Override
public boolean verify(Cmd cmd) {
return true;
}
} }