use of com.ociweb.pronghorn.stage.scheduling.ScriptedNonThreadScheduler 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();
}
use of com.ociweb.pronghorn.stage.scheduling.ScriptedNonThreadScheduler in project GreenLightning by oci-pronghorn.
the class GreenRuntime method testUntilShutdownRequested.
public static boolean testUntilShutdownRequested(GreenApp app, long timeoutMS) {
GreenRuntime runtime = new GreenRuntime(app.getClass().getSimpleName());
ScriptedNonThreadScheduler s = test(app, runtime);
long limit = System.nanoTime() + (timeoutMS * 1_000_000L);
boolean result = true;
s.startup();
while (!ScriptedNonThreadScheduler.isShutdownRequested(s)) {
s.run();
if (System.nanoTime() > limit) {
System.err.println("exit due to timeout");
result = false;
break;
}
}
return result;
}
use of com.ociweb.pronghorn.stage.scheduling.ScriptedNonThreadScheduler in project FogLight-Examples by oci-pronghorn.
the class AppTest method testApp.
@Test
public void testApp() {
FogRuntime runtime = FogRuntime.test(new IoTApp(false));
TestHardware hardware = (TestHardware) runtime.getHardware();
TestI2CBacking backing = (TestI2CBacking) hardware.getI2CBacking();
ScriptedNonThreadScheduler scheduler = (ScriptedNonThreadScheduler) runtime.getScheduler();
scheduler.startup();
hardware.clearI2CWriteCount();
hardware.write(IoTApp.ANGLE_SENSOR_PORT, 512);
hardware.write(IoTApp.LIGHT_SENSOR_PORT, 300);
// scheduler.run();
//
// int i = hardware.getI2CWriteCount();
// while (i>0) {
//
// hardware.outputLastI2CWrite(System.out,i--);
//
// }
// need ring of commands so it can be checked.
// assertEquals(Grove_LCD_RGB.RGB_ADDRESS, backing.lastWriteAddress);
// TODO: must ask I2C LCD for its brightness.
// test application here
}
use of com.ociweb.pronghorn.stage.scheduling.ScriptedNonThreadScheduler in project FogLight-Examples by oci-pronghorn.
the class AppTest method testApp.
// no longer supported use of Paho.
@Ignore
public void testApp() {
FogRuntime runtime = FogRuntime.test(new IoTApp());
ScriptedNonThreadScheduler scheduler = (ScriptedNonThreadScheduler) runtime.getScheduler();
scheduler.startup();
TestHardware hardware = (TestHardware) runtime.getHardware();
int iterations = 10;
while (--iterations >= 0) {
scheduler.run();
// test application here
}
}
use of com.ociweb.pronghorn.stage.scheduling.ScriptedNonThreadScheduler in project FogLight-Examples by oci-pronghorn.
the class AppTest method testApp.
@Test
public void testApp() {
FogRuntime runtime = FogRuntime.test(new IoTApp());
ScriptedNonThreadScheduler scheduler = (ScriptedNonThreadScheduler) runtime.getScheduler();
scheduler.startup();
TestHardware hardware = (TestHardware) runtime.getHardware();
int iterations = 10;
while (--iterations >= 0) {
scheduler.run();
// test application here
}
}
Aggregations