mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
improve error for driver adapter not found
This commit is contained in:
parent
a6df79c322
commit
a05dbc834a
@ -26,6 +26,7 @@ import io.nosqlbench.engine.core.annotation.Annotators;
|
||||
import io.nosqlbench.nb.annotations.Maturity;
|
||||
import io.nosqlbench.nb.api.annotations.Annotation;
|
||||
import io.nosqlbench.nb.api.annotations.Layer;
|
||||
import io.nosqlbench.nb.api.config.standard.ConfigSuggestions;
|
||||
import io.nosqlbench.nb.api.errors.BasicError;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@ -323,7 +324,12 @@ public class ScenarioController {
|
||||
.setMaturity(this.minMaturity)
|
||||
.load(activityDef)
|
||||
.orElseThrow(
|
||||
() -> new RuntimeException("Driver for '" + activityDef + "' was not found.")
|
||||
() -> new RuntimeException("Driver for '" + activityDef + "' was not found." +
|
||||
"\nYou can use --list-drivers to see what drivers are supported in this runtime." +
|
||||
ConfigSuggestions.suggestAlternates(
|
||||
new ActivityTypeLoader().getAllSelectors(),activityDef.getActivityType(),4)
|
||||
.orElse("")
|
||||
)
|
||||
);
|
||||
|
||||
executor = new ActivityExecutor(
|
||||
|
@ -37,8 +37,34 @@ public class ConfigSuggestions {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
private static Optional<String> suggestAlternates(ConfigModel model, String param, int maxDistance) {
|
||||
public static Optional<String> suggestAlternates(Set<String> candidates, String provided, int maxDistance) {
|
||||
Set<String>[] sorted = new Set[maxDistance+1];
|
||||
for (int i = 0; i < sorted.length; i++) {
|
||||
sorted[i]=new HashSet<String>();
|
||||
}
|
||||
for (String candidate : candidates) {
|
||||
int distance = LevenshteinDistance.getDefaultInstance().apply(provided, candidate);
|
||||
if (distance<=maxDistance) {
|
||||
sorted[distance].add(candidate);
|
||||
}
|
||||
}
|
||||
for (Set<String> set : sorted) {
|
||||
if (set.size()>1) {
|
||||
return Optional.of(" Did you mean one of '" + String.join("','", set) + "' ?");
|
||||
} else if (set.size()==1) {
|
||||
return Optional.of(" Did you mean '" + set.stream().findFirst().get() + "' ?");
|
||||
}
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
private static Optional<String> suggestAlternates(
|
||||
ConfigModel model,
|
||||
String param,
|
||||
int maxDistance
|
||||
) {
|
||||
Map<Integer, Set<String>> suggestions = new HashMap<>();
|
||||
|
||||
for (String candidate : model.getNamedParams().keySet()) {
|
||||
try {
|
||||
Integer distance = LevenshteinDistance.getDefaultInstance().apply(param, candidate);
|
||||
|
Loading…
Reference in New Issue
Block a user