Search in sources :

Example 1 with SPLGenerator

use of com.ibm.streamsx.topology.generator.spl.SPLGenerator in project streamsx.topology by IBMStreams.

the class ToolkitRemoteContext method generateSPL.

private void generateSPL(File toolkitRoot, JsonObject jsonGraph) throws IOException {
    // Create the SPL file, and save a copy of the JSON file.
    SPLGenerator generator = new SPLGenerator();
    createNamespaceFile(toolkitRoot, jsonGraph, "spl", generator.generateSPL(jsonGraph));
    createNamespaceFile(toolkitRoot, jsonGraph, "json", jsonGraph.toString());
}
Also used : SPLGenerator(com.ibm.streamsx.topology.generator.spl.SPLGenerator)

Example 2 with SPLGenerator

use of com.ibm.streamsx.topology.generator.spl.SPLGenerator in project streamsx.topology by IBMStreams.

the class LowLatencyTest method threadedPortTest.

@Test
public void threadedPortTest() throws Exception {
    assumeTrue(isMainRun());
    Topology topology = newTopology("lowLatencyTest");
    // Construct topology
    TStream<String> ss = topology.strings("hello").lowLatency();
    TStream<String> ss1 = ss.transform(getContainerId());
    TStream<String> ss2 = ss1.transform(getContainerId()).endLowLatency();
    SPLGenerator generator = new SPLGenerator();
    JSONObject graph = topology.builder().complete();
    JsonObject ggraph = JSON4JUtilities.gson(graph);
    generator.generateSPL(ggraph);
    GsonUtilities.objectArray(ggraph, "operators", op -> {
        String lowLatencyTag = null;
        JsonObject placement = object(op, CONFIG, PLACEMENT);
        if (placement != null)
            lowLatencyTag = jstring(placement, PLACEMENT_LOW_LATENCY_REGION_ID);
        String kind = jstring(op, "kind");
        JsonObject queue = object(op, "queue");
        if (queue != null && (lowLatencyTag == null || lowLatencyTag.equals(""))) {
            throw new IllegalStateException("Operator has threaded port when it shouldn't.");
        }
        if (queue != null && kind.equals("com.ibm.streamsx.topology.functional.java::FunctionTransform")) {
            throw new IllegalStateException("Transform operator expecting threaded port; none found.");
        }
    });
}
Also used : JSONObject(com.ibm.json.java.JSONObject) JsonObject(com.google.gson.JsonObject) Topology(com.ibm.streamsx.topology.Topology) TestTopology(com.ibm.streamsx.topology.test.TestTopology) SPLGenerator(com.ibm.streamsx.topology.generator.spl.SPLGenerator) Test(org.junit.Test)

Aggregations

SPLGenerator (com.ibm.streamsx.topology.generator.spl.SPLGenerator)2 JsonObject (com.google.gson.JsonObject)1 JSONObject (com.ibm.json.java.JSONObject)1 Topology (com.ibm.streamsx.topology.Topology)1 TestTopology (com.ibm.streamsx.topology.test.TestTopology)1 Test (org.junit.Test)1