use of io.nosqlbench.engine.api.activityapi.core.Activity 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"));
}
use of io.nosqlbench.engine.api.activityapi.core.Activity in project nosqlbench by nosqlbench.
the class ScenarioController method stop.
/**
* Stop an activity, given the name by which it is known already in the scenario. This causes the
* activity to stop all threads, but keeps the thread objects handy for starting again. This can be useful
* for certain testing scenarios in which you want to stop some workloads and start others based on other conditions.
*
* Alternately, you can provide one or more aliases in the same command, and all matching names will be stopped.
*
* @param spec The name of the activity that is already known to the scenario
*/
public synchronized void stop(String spec) {
logger.debug("request->STOP '" + spec + "'");
List<String> aliases = Arrays.asList(spec.split("[,; ]"));
List<String> matched = aliases.stream().map(String::trim).filter(s -> !s.isEmpty()).flatMap(aspec -> getMatchingAliases(aspec).stream()).collect(Collectors.toList());
for (String alias : matched) {
ActivityDef adef = aliasToDef(alias);
scenariologger.debug("STOP " + adef.getAlias());
stop(adef);
}
}
use of io.nosqlbench.engine.api.activityapi.core.Activity in project nosqlbench by nosqlbench.
the class CoreServices method getOutputDispenser.
public static <A extends Activity> Optional<OutputDispenser> getOutputDispenser(A activity) {
OutputDispenser outputDispenser = new SimpleConfig(activity, "output").getString("type").flatMap(OutputType.FINDER::get).map(mt -> mt.getOutputDispenser(activity)).orElse(null);
if (outputDispenser == null) {
return Optional.empty();
}
Optional<Predicate<ResultReadable>> outputFilterDispenser = getOutputFilter(activity);
if (outputFilterDispenser.isPresent()) {
outputDispenser = new FilteringOutputDispenser(outputDispenser, outputFilterDispenser.get());
}
return Optional.ofNullable(outputDispenser);
}
Aggregations