Search in sources :

Example 1 with JSONArray

use of com.ibm.json.java.JSONArray in project streamsx.topology by IBMStreams.

the class PlaceableTest method getResourceTags.

private static Set<String> getResourceTags(BOperator bop) {
    JSONObject placement = JOperatorConfig.getJSONItem(bop.json(), PLACEMENT);
    if (placement == null)
        return null;
    JSONArray jat = (JSONArray) placement.get(com.ibm.streamsx.topology.generator.operator.OpProperties.PLACEMENT_RESOURCE_TAGS);
    if (jat == null)
        return null;
    Set<String> tags = new HashSet<>();
    for (Object rt : jat) tags.add(rt.toString());
    return tags;
}
Also used : JSONObject(com.ibm.json.java.JSONObject) JSONArray(com.ibm.json.java.JSONArray) JSONObject(com.ibm.json.java.JSONObject) HashSet(java.util.HashSet)

Example 2 with JSONArray

use of com.ibm.json.java.JSONArray in project streamsx.topology by IBMStreams.

the class BInputPort method complete.

/**
     * Add this port information and its connections to output ports, by name.
     */
@Override
public JSONObject complete() {
    final JSONObject json = json();
    BUtils.addPortInfo(json, port);
    JSONArray conns = new JSONArray();
    for (StreamConnection c : port().getConnections()) {
        conns.add(c.getOutput().getName());
    }
    json.put("connections", conns);
    return json;
}
Also used : JSONObject(com.ibm.json.java.JSONObject) JSONArray(com.ibm.json.java.JSONArray) StreamConnection(com.ibm.streams.flow.declare.StreamConnection)

Example 3 with JSONArray

use of com.ibm.json.java.JSONArray in project streamsx.topology by IBMStreams.

the class BOperator method complete.

@Override
public JSONObject complete() {
    JSONObject json = super.complete();
    if (regions != null) {
        JSONArray ra = new JSONArray();
        ra.addAll(regions);
        json.put("regions", ra);
    }
    return json;
}
Also used : JSONObject(com.ibm.json.java.JSONObject) JSONArray(com.ibm.json.java.JSONArray)

Example 4 with JSONArray

use of com.ibm.json.java.JSONArray in project streamsx.topology by IBMStreams.

the class BOutputPort method complete.

@Override
public JSONObject complete() {
    final JSONObject json = json();
    BUtils.addPortInfo(json, port);
    JSONArray conns = new JSONArray();
    for (StreamConnection c : port().getConnections()) {
        conns.add(c.getInput().getName());
    }
    json.put("connections", conns);
    return json;
}
Also used : JSONObject(com.ibm.json.java.JSONObject) JSONArray(com.ibm.json.java.JSONArray) StreamConnection(com.ibm.streams.flow.declare.StreamConnection)

Example 5 with JSONArray

use of com.ibm.json.java.JSONArray in project streamsx.topology by IBMStreams.

the class BOperatorInvocation method complete.

@Override
public JSONObject complete() {
    final JSONObject json = super.complete();
    if (outputs != null) {
        JSONArray oa = new JSONArray(outputs.size());
        for (BOutputPort output : outputs) {
            oa.add(output.complete());
        }
        json.put("outputs", oa);
    }
    if (inputs != null) {
        JSONArray ia = new JSONArray(inputs.size());
        for (BInputPort input : inputs) {
            ia.add(input.complete());
        }
        json.put("inputs", ia);
    }
    return json;
}
Also used : JSONObject(com.ibm.json.java.JSONObject) JSONArray(com.ibm.json.java.JSONArray)

Aggregations

JSONArray (com.ibm.json.java.JSONArray)15 JSONObject (com.ibm.json.java.JSONObject)14 Topology (com.ibm.streamsx.topology.Topology)5 Test (org.junit.Test)5 TestTopology (com.ibm.streamsx.topology.test.TestTopology)4 StreamConnection (com.ibm.streams.flow.declare.StreamConnection)2 ArrayList (java.util.ArrayList)2 JsonObject (com.google.gson.JsonObject)1 OrderedJSONObject (com.ibm.json.java.OrderedJSONObject)1 StreamSchema (com.ibm.streams.operator.StreamSchema)1 Tuple (com.ibm.streams.operator.Tuple)1 BInputPort (com.ibm.streamsx.topology.builder.BInputPort)1 BOperatorInvocation (com.ibm.streamsx.topology.builder.BOperatorInvocation)1 BOutput (com.ibm.streamsx.topology.builder.BOutput)1 KeyFunctionHasher (com.ibm.streamsx.topology.internal.logic.KeyFunctionHasher)1 SPLStream (com.ibm.streamsx.topology.spl.SPLStream)1 PythonFunctionalOperatorsTest (com.ibm.streamsx.topology.test.splpy.PythonFunctionalOperatorsTest)1 Tester (com.ibm.streamsx.topology.tester.Tester)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1