Search in sources :

Example 1 with ActivityDef

use of io.nosqlbench.engine.api.activityimpl.ActivityDef in project nosqlbench by nosqlbench.

the class ExceptionCountMetrics method count.

public void count(String name) {
    Counter c = counters.get(name);
    if (c == null) {
        synchronized (counters) {
            c = counters.computeIfAbsent(name, k -> ActivityMetrics.counter(activityDef, "errorcounts." + name));
        }
    }
    c.inc();
}
Also used : List(java.util.List) ActivityDef(io.nosqlbench.engine.api.activityimpl.ActivityDef) Counter(com.codahale.metrics.Counter) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ArrayList(java.util.ArrayList) Counter(com.codahale.metrics.Counter)

Example 2 with ActivityDef

use of io.nosqlbench.engine.api.activityimpl.ActivityDef in project nosqlbench by nosqlbench.

the class ExceptionTimerMetrics method update.

public void update(String name, long nanosDuration) {
    Timer timer = timers.get(name);
    if (timer == null) {
        synchronized (timers) {
            timer = timers.computeIfAbsent(name, k -> ActivityMetrics.timer(activityDef, "exceptions." + name));
        }
    }
    timer.update(nanosDuration, TimeUnit.NANOSECONDS);
}
Also used : TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) ActivityDef(io.nosqlbench.engine.api.activityimpl.ActivityDef) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Timer(com.codahale.metrics.Timer) ArrayList(java.util.ArrayList) Timer(com.codahale.metrics.Timer)

Example 3 with ActivityDef

use of io.nosqlbench.engine.api.activityimpl.ActivityDef in project nosqlbench by nosqlbench.

the class ActivityExecutorTest method getActivityMotorFactory.

private MotorDispenser<?> getActivityMotorFactory(final ActivityDef ad, Action lc, final Input ls) {
    MotorDispenser<?> cmf = new MotorDispenser<>() {

        @Override
        public Motor getMotor(ActivityDef activityDef, int slotId) {
            Activity activity = new SimpleActivity(activityDef);
            Motor<?> cm = new CoreMotor(activity, slotId, ls);
            cm.setAction(lc);
            return cm;
        }
    };
    return cmf;
}
Also used : SimpleActivity(io.nosqlbench.engine.api.activityimpl.SimpleActivity) CoreMotorDispenser(io.nosqlbench.engine.api.activityimpl.motor.CoreMotorDispenser) SimpleActivity(io.nosqlbench.engine.api.activityimpl.SimpleActivity) ActivityDef(io.nosqlbench.engine.api.activityimpl.ActivityDef) CoreMotor(io.nosqlbench.engine.api.activityimpl.motor.CoreMotor)

Example 4 with ActivityDef

use of io.nosqlbench.engine.api.activityimpl.ActivityDef 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));
}
Also used : NBConfigModel(io.nosqlbench.nb.api.config.standard.NBConfigModel) java.util(java.util) DriverAdapter(io.nosqlbench.engine.api.activityimpl.uniform.DriverAdapter) ActivityDef(io.nosqlbench.engine.api.activityimpl.ActivityDef) Maturity(io.nosqlbench.nb.annotations.Maturity) MalformedURLException(java.net.MalformedURLException) Files(java.nio.file.Files) StandardActivityType(io.nosqlbench.engine.api.activityimpl.uniform.StandardActivityType) URL(java.net.URL) Content(io.nosqlbench.nb.api.content.Content) Collectors(java.util.stream.Collectors) NBIO(io.nosqlbench.nb.api.content.NBIO) BasicError(io.nosqlbench.nb.api.errors.BasicError) URLClassLoader(java.net.URLClassLoader) Logger(org.apache.logging.log4j.Logger) StmtsDocList(io.nosqlbench.engine.api.activityconfig.yaml.StmtsDocList) StatementsLoader(io.nosqlbench.engine.api.activityconfig.StatementsLoader) NBConfiguration(io.nosqlbench.nb.api.config.standard.NBConfiguration) LogManager(org.apache.logging.log4j.LogManager) Path(java.nio.file.Path) ActivityType(io.nosqlbench.engine.api.activityapi.core.ActivityType) NBEnvironment(io.nosqlbench.nb.api.NBEnvironment) NBConfigurable(io.nosqlbench.nb.api.config.standard.NBConfigurable) SimpleServiceLoader(io.nosqlbench.nb.api.spi.SimpleServiceLoader) Content(io.nosqlbench.nb.api.content.Content) BasicError(io.nosqlbench.nb.api.errors.BasicError)

Example 5 with ActivityDef

use of io.nosqlbench.engine.api.activityimpl.ActivityDef in project nosqlbench by nosqlbench.

the class ScenarioController method start.

/**
 * Start an activity, given a map which holds the activity definition for it. The activity will be known in
 * the scenario by the alias parameter.
 *
 * @param activityDefMap A map containing the activity definition
 */
public synchronized void start(Map<String, String> activityDefMap) {
    ActivityDef ad = new ActivityDef(new ParameterMap(activityDefMap));
    start(ad);
}
Also used : ActivityDef(io.nosqlbench.engine.api.activityimpl.ActivityDef) ParameterMap(io.nosqlbench.engine.api.activityimpl.ParameterMap)

Aggregations

ActivityDef (io.nosqlbench.engine.api.activityimpl.ActivityDef)39 Test (org.junit.jupiter.api.Test)25 NBConfiguration (io.nosqlbench.nb.api.config.standard.NBConfiguration)18 SimpleActivity (io.nosqlbench.engine.api.activityimpl.SimpleActivity)6 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)6 Histogram (com.codahale.metrics.Histogram)4 ParameterMap (io.nosqlbench.engine.api.activityimpl.ParameterMap)4 CoreMotorDispenser (io.nosqlbench.engine.api.activityimpl.motor.CoreMotorDispenser)4 ActivityMetrics (io.nosqlbench.engine.api.metrics.ActivityMetrics)4 ActivityTypeLoader (io.nosqlbench.engine.core.lifecycle.ActivityTypeLoader)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 Counter (com.codahale.metrics.Counter)3 Timer (com.codahale.metrics.Timer)3 Action (io.nosqlbench.engine.api.activityapi.core.Action)3 ActionDispenser (io.nosqlbench.engine.api.activityapi.core.ActionDispenser)3 ActivityType (io.nosqlbench.engine.api.activityapi.core.ActivityType)3 InputDispenser (io.nosqlbench.engine.api.activityapi.input.InputDispenser)3 OutputDispenser (io.nosqlbench.engine.api.activityapi.output.OutputDispenser)3 CoreActionDispenser (io.nosqlbench.engine.api.activityimpl.action.CoreActionDispenser)3