use of io.nosqlbench.engine.api.activityapi.core.ActivityType in project nosqlbench by nosqlbench.
the class ActivityTypeLoader method getDriverAdapter.
private Optional<ActivityType> getDriverAdapter(String activityTypeName, ActivityDef activityDef) {
Optional<DriverAdapter> oda = DRIVERADAPTER_SPI_FINDER.getOptionally(activityTypeName);
if (oda.isPresent()) {
DriverAdapter<?, ?> driverAdapter = oda.get();
activityDef.getParams().remove("driver");
if (driverAdapter instanceof NBConfigurable) {
NBConfigModel cfgModel = ((NBConfigurable) driverAdapter).getConfigModel();
Optional<String> op_yaml_loc = activityDef.getParams().getOptionalString("yaml", "workload");
if (op_yaml_loc.isPresent()) {
Map<String, Object> disposable = new LinkedHashMap<>(activityDef.getParams());
StmtsDocList workload = StatementsLoader.loadPath(logger, op_yaml_loc.get(), disposable, "activities");
cfgModel = cfgModel.add(workload.getConfigModel());
}
NBConfiguration cfg = cfgModel.apply(activityDef.getParams());
((NBConfigurable) driverAdapter).applyConfig(cfg);
}
ActivityType activityType = new StandardActivityType<>(driverAdapter, activityDef);
return Optional.of(activityType);
} else {
return Optional.empty();
}
}
use of io.nosqlbench.engine.api.activityapi.core.ActivityType in project nosqlbench by nosqlbench.
the class ActivityTypeLoader method load.
public Optional<ActivityType> load(ActivityDef activityDef) {
final String driverName = activityDef.getParams().getOptionalString("driver", "type").orElseThrow(() -> new BasicError("The parameter 'driver=' is required."));
activityDef.getParams().getOptionalString("jar").map(jar -> {
Set<URL> urls = NBIO.local().search(jar).list().stream().map(Content::getURL).collect(Collectors.toSet());
return urls;
}).ifPresent(this::extendClassLoader);
return this.getDriverAdapter(driverName, activityDef).or(() -> ACTIVITYTYPE_SPI_FINDER.getOptionally(driverName));
}
use of io.nosqlbench.engine.api.activityapi.core.ActivityType in project nosqlbench by nosqlbench.
the class MetricsMapper method metricsDetail.
public static String metricsDetail(String activitySpec) {
// StringBuilder metricsDetail = new StringBuilder();
List<String> metricsDetails = new ArrayList<>();
ActivityDef activityDef = ActivityDef.parseActivityDef(activitySpec);
logger.info("introspecting metric names for " + activitySpec);
Optional<ActivityType> activityType = new ActivityTypeLoader().load(activityDef);
if (!activityType.isPresent()) {
throw new RuntimeException("Activity type '" + activityDef.getActivityType() + "' does not exist in this runtime.");
}
Activity activity = activityType.get().getAssembledActivity(activityDef, new HashMap<>());
PolyglotMetricRegistryBindings nashornMetricRegistryBindings = new PolyglotMetricRegistryBindings(ActivityMetrics.getMetricRegistry());
activity.initActivity();
activity.getInputDispenserDelegate().getInput(0);
activity.getActionDispenserDelegate().getAction(0);
activity.getMotorDispenserDelegate().getMotor(activityDef, 0);
Map<String, Metric> metricMap = nashornMetricRegistryBindings.getMetrics();
for (Map.Entry<String, Metric> metricEntry : metricMap.entrySet()) {
String metricName = metricEntry.getKey();
Metric metricValue = metricEntry.getValue();
Map<String, String> getterSummary = getGetterSummary(metricValue);
// details.put(metricName,getterSummary);
List<String> methodDetails = getterSummary.entrySet().stream().map(es -> metricName + es.getKey() + " " + es.getValue()).collect(Collectors.toList());
methodDetails.sort(String::compareTo);
String getterText = methodDetails.stream().collect(Collectors.joining("\n"));
metricsDetails.add(metricName + "\n" + getterText);
}
return metricsDetails.stream().collect(Collectors.joining("\n"));
}
Aggregations