Search in sources :

Example 1 with StageVisitor

use of com.ociweb.pronghorn.stage.scheduling.StageVisitor in project GreenLightning by oci-pronghorn.

the class GreenRuntime method test.

private static ScriptedNonThreadScheduler test(GreenApp app, GreenRuntime runtime) {
    // force hardware to TestHardware regardless of where or what platform its run on.
    // this is done because this is the test() method and must behave the same everywhere.
    runtime.builder = new BuilderImpl(runtime.gm, runtime.args);
    // lowered for tests, we want tests to run faster, tests probably run on bigger systems.
    runtime.builder.setDefaultRate(10_000);
    app.declareConfiguration(runtime.builder);
    GraphManager.addDefaultNota(runtime.gm, GraphManager.SCHEDULE_RATE, runtime.builder.getDefaultSleepRateNS());
    runtime.declareBehavior(app);
    runtime.builder.buildStages(runtime);
    runtime.logStageScheduleRates();
    TelemetryConfig telemetryConfig = runtime.builder.getTelemetryConfig();
    if (telemetryConfig != null) {
        runtime.gm.enableTelemetry(telemetryConfig.getPort());
    }
    // exportGraphDotFile();
    boolean reverseOrder = false;
    StageVisitor badPlayers = new StageVisitor() {

        byte[] seen = new byte[GraphManager.countStages(runtime.gm) + 1];

        @Override
        public void visit(PronghornStage stage) {
            if (0 == seen[stage.stageId]) {
                seen[stage.stageId] = 1;
                logger.warn("Slow or blocking stage detected, investigation required: {}", stage);
            }
        }
    };
    runtime.setScheduler(new ScriptedNonThreadScheduler(runtime.gm, reverseOrder, badPlayers, null));
    return (ScriptedNonThreadScheduler) runtime.getScheduler();
}
Also used : BuilderImpl(com.ociweb.gl.impl.BuilderImpl) ScriptedNonThreadScheduler(com.ociweb.pronghorn.stage.scheduling.ScriptedNonThreadScheduler) StageVisitor(com.ociweb.pronghorn.stage.scheduling.StageVisitor) PronghornStage(com.ociweb.pronghorn.stage.PronghornStage)

Aggregations

BuilderImpl (com.ociweb.gl.impl.BuilderImpl)1 PronghornStage (com.ociweb.pronghorn.stage.PronghornStage)1 ScriptedNonThreadScheduler (com.ociweb.pronghorn.stage.scheduling.ScriptedNonThreadScheduler)1 StageVisitor (com.ociweb.pronghorn.stage.scheduling.StageVisitor)1