Search in sources :

Example 11 with ActivityDef

use of io.engineblock.activityimpl.ActivityDef in project engineblock by engineblock.

the class ScenarioController method run.

public synchronized void run(int timeout, Map<String, String> activityDefMap) {
    ActivityDef ad = new ActivityDef(new ParameterMap(activityDefMap));
    run(timeout, ad);
}
Also used : ActivityDef(io.engineblock.activityimpl.ActivityDef) ParameterMap(io.engineblock.activityimpl.ParameterMap)

Example 12 with ActivityDef

use of io.engineblock.activityimpl.ActivityDef in project engineblock by engineblock.

the class EBCLIScriptAssembly method assembleScript.

public static String assembleScript(EBCLIOptions options) {
    StringBuilder sb = new StringBuilder();
    for (EBCLIOptions.Cmd cmd : options.getCommands()) {
        switch(cmd.cmdType) {
            case script:
                String scriptData = loadScript(cmd);
                sb.append("// from CLI as ").append(cmd).append("\n");
                sb.append(scriptData);
                break;
            // start activity
            case start:
            case // run activity
            run:
                // Sanity check that this can parse before using it
                ActivityDef activityDef = ActivityDef.parseActivityDef(cmd.cmdSpec);
                sb.append("// from CLI as ").append(cmd).append("\n").append("scenario.").append(cmd.cmdType.toString()).append("(\"").append(cmd.cmdSpec).append("\");\n");
                break;
            case // await activity
            await:
                sb.append("// from CLI as ").append(cmd).append("\n");
                sb.append("scenario.awaitActivity(\"").append(cmd.cmdSpec).append("\");\n");
                break;
            case // stop activity
            stop:
                sb.append("// from CLI as ").append(cmd).append("\n");
                sb.append("scenario.stop(\"").append(cmd.cmdSpec).append("\");\n");
                break;
            case waitmillis:
                sb.append("// from CLI as ").append(cmd).append("\n");
                sb.append("scenario.waitMillis(").append(cmd.cmdSpec).append(");\n");
                break;
        }
    }
    return sb.toString();
}
Also used : ActivityDef(io.engineblock.activityimpl.ActivityDef)

Example 13 with ActivityDef

use of io.engineblock.activityimpl.ActivityDef in project engineblock by engineblock.

the class ExceptionCountMetrics method count.

public void count(Throwable e) {
    Counter c = counters.get(e.getClass());
    if (c == null) {
        synchronized (counters) {
            c = counters.computeIfAbsent(e.getClass(), k -> ActivityMetrics.counter(activityDef, "errorcounts." + e.getClass().getSimpleName()));
        }
    }
    c.inc();
}
Also used : Counter(com.codahale.metrics.Counter) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ActivityDef(io.engineblock.activityimpl.ActivityDef) Counter(com.codahale.metrics.Counter)

Example 14 with ActivityDef

use of io.engineblock.activityimpl.ActivityDef in project engineblock by engineblock.

the class ExceptionHistoMetrics method update.

public void update(Throwable e, long magnitude) {
    Histogram h = counters.get(e.getClass());
    if (h == null) {
        synchronized (counters) {
            h = counters.computeIfAbsent(e.getClass(), k -> ActivityMetrics.histogram(activityDef, "errorhistos." + e.getClass().getSimpleName()));
        }
    }
    h.update(magnitude);
}
Also used : Histogram(com.codahale.metrics.Histogram) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ActivityDef(io.engineblock.activityimpl.ActivityDef) Histogram(com.codahale.metrics.Histogram)

Example 15 with ActivityDef

use of io.engineblock.activityimpl.ActivityDef in project engineblock by engineblock.

the class ExceptionMeterMetrics method count.

public void count(Exception e) {
    Meter c = meters.get(e.getClass());
    if (c == null) {
        synchronized (meters) {
            c = meters.computeIfAbsent(e.getClass(), k -> ActivityMetrics.meter(activityDef, "exceptions." + e.getClass().getSimpleName()));
        }
    }
    c.mark();
}
Also used : Meter(com.codahale.metrics.Meter) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ActivityDef(io.engineblock.activityimpl.ActivityDef) Meter(com.codahale.metrics.Meter)

Aggregations

ActivityDef (io.engineblock.activityimpl.ActivityDef)15 Test (org.testng.annotations.Test)5 ParameterMap (io.engineblock.activityimpl.ParameterMap)3 SimpleActivity (io.engineblock.activityimpl.SimpleActivity)3 CoreMotorDispenser (io.engineblock.activityimpl.motor.CoreMotorDispenser)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 Histogram (com.codahale.metrics.Histogram)2 Action (io.engineblock.activityapi.core.Action)2 ActionDispenser (io.engineblock.activityapi.core.ActionDispenser)2 InputDispenser (io.engineblock.activityapi.input.InputDispenser)2 OutputDispenser (io.engineblock.activityapi.output.OutputDispenser)2 CoreActionDispenser (io.engineblock.activityimpl.action.CoreActionDispenser)2 CoreInputDispenser (io.engineblock.activityimpl.input.CoreInputDispenser)2 com.codahale.metrics (com.codahale.metrics)1 Counter (com.codahale.metrics.Counter)1 Meter (com.codahale.metrics.Meter)1 Activity (io.engineblock.activityapi.core.Activity)1 ActivityType (io.engineblock.activityapi.core.ActivityType)1 Input (io.engineblock.activityapi.input.Input)1 TargetRateInput (io.engineblock.activityimpl.input.TargetRateInput)1