use of com.ibm.streamsx.topology.generator.spl.GraphUtilities.VisitController in project streamsx.topology by IBMStreams.
the class GraphBuilder method isInLowLatencyRegion.
public boolean isInLowLatencyRegion(BOperator... operators) {
// handle nested low latency regions
JSONObject graph = complete();
final VisitController visitController = new VisitController(Direction.UPSTREAM);
final int[] openRegionCount = { 0 };
for (BOperator operator : operators) {
JSONObject jop = operator.complete();
GraphUtilities.visitOnce(visitController, Collections.singleton(JSON4JUtilities.gson(jop)), JSON4JUtilities.gson(graph), new Consumer<JsonObject>() {
private static final long serialVersionUID = 1L;
@Override
public void accept(JsonObject jo) {
String kind = GsonUtilities.jstring(jo, "kind");
if (LOW_LATENCY.kind().equals(kind)) {
if (openRegionCount[0] <= 0)
visitController.setStop();
else
openRegionCount[0]--;
} else if (END_LOW_LATENCY.kind().equals(kind))
openRegionCount[0]++;
}
});
if (visitController.stopped() || openRegionCount[0] > 0)
return true;
}
return false;
}
Aggregations