mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2024-12-22 15:13:41 -06:00
fix method naming to expected behavior in service selector
This commit is contained in:
parent
87aa9d1dec
commit
3a54725d66
@ -68,17 +68,23 @@ public class StandardActivity<R extends Op, S> extends SimpleActivity implements
|
||||
|
||||
ServiceLoader<DriverAdapter> adapterLoader = ServiceLoader.load(DriverAdapter.class);
|
||||
Optional<DriverAdapter> defaultAdapter = activityDef.getParams().getOptionalString("driver")
|
||||
.map(s -> ServiceSelector.of(s, adapterLoader).getOne());
|
||||
.flatMap(s -> ServiceSelector.of(s, adapterLoader).get());
|
||||
|
||||
List<OpTemplate> opTemplates = loadOpTemplates(defaultAdapter);
|
||||
|
||||
|
||||
List<ParsedOp> pops = new ArrayList<>();
|
||||
List<DriverAdapter> adapterlist = new ArrayList<>();
|
||||
for (OpTemplate ot : opTemplates) {
|
||||
String driverName = ot.getOptionalStringParam("driver")
|
||||
ParsedOp incompleteOpDef = new ParsedOp(ot, NBConfiguration.empty(), List.of());
|
||||
String driverName = incompleteOpDef.takeOptionalStaticValue("driver",String.class)
|
||||
.or(() -> activityDef.getParams().getOptionalString("driver"))
|
||||
.orElseThrow(() -> new OpConfigError("Unable to identify driver name for op template:\n" + ot));
|
||||
|
||||
// String driverName = ot.getOptionalStringParam("driver")
|
||||
// .or(() -> activityDef.getParams().getOptionalString("driver"))
|
||||
// .orElseThrow(() -> new OpConfigError("Unable to identify driver name for op template:\n" + ot));
|
||||
|
||||
if (!adapters.containsKey(driverName)) {
|
||||
DriverAdapter adapter = ServiceSelector.of(driverName, adapterLoader).get().orElseThrow(
|
||||
() -> new OpConfigError("Unable to load driver adapter for name '" + driverName + "'")
|
||||
@ -98,13 +104,15 @@ public class StandardActivity<R extends Op, S> extends SimpleActivity implements
|
||||
}
|
||||
|
||||
DriverAdapter adapter = adapters.get(driverName);
|
||||
adapterlist.add(adapter);
|
||||
ParsedOp pop = new ParsedOp(ot,adapter.getConfiguration(),List.of(adapter.getPreprocessor()));
|
||||
Optional<String> discard = pop.takeOptionalStaticValue("driver", String.class);
|
||||
pops.add(pop);
|
||||
}
|
||||
|
||||
try {
|
||||
boolean strict = activityDef.getParams().getOptionalBoolean("strict").orElse(false);
|
||||
sequence = createOpSourceFromParsedOps(adapters, mappers, pops);
|
||||
sequence = createOpSourceFromParsedOps(adapters, mappers, adapterlist, pops);
|
||||
} catch (Exception e) {
|
||||
if (e instanceof OpConfigError) {
|
||||
throw e;
|
||||
|
@ -64,8 +64,12 @@ public class ServiceSelector<T> implements Predicate<ServiceLoader.Provider<? ex
|
||||
if (services.size() == 0) {
|
||||
throw new RuntimeException("You requested exactly one instance of a service by name '" + name + "', but got " +
|
||||
(services.stream().map(s -> s.getClass().getSimpleName())).collect(Collectors.joining(",")) + " (" + services.stream().count() + ")");
|
||||
} else if (services.size()==1) {
|
||||
return services.get(0);
|
||||
}
|
||||
return services.get(0);
|
||||
throw new RuntimeException("You requested exactly one instance of a service by name '" + name + "', but got " +
|
||||
(services.stream().map(s -> s.getClass().getSimpleName())).collect(Collectors.joining(",")) + " (" + services.stream().count() + ")");
|
||||
|
||||
}
|
||||
|
||||
public List<? extends T> getAll() {
|
||||
@ -91,13 +95,8 @@ public class ServiceSelector<T> implements Predicate<ServiceLoader.Provider<? ex
|
||||
List<? extends T> services = getAll();
|
||||
if (services.size() == 1) {
|
||||
return Optional.of(services.get(0));
|
||||
} else {
|
||||
return Optional.empty();
|
||||
}
|
||||
if (services.size()==0) {
|
||||
throw new RuntimeException("No services were found for '" + name + "'.");
|
||||
}
|
||||
throw new RuntimeException("You requested exactly one instance of a service by name '" + name + "', but got " +
|
||||
(services.stream().map(s -> s.getClass().getSimpleName())).collect(Collectors.joining(",")) + " (" + services.stream().count() + ")");
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user