use of com.ibm.streams.flow.declare.OutputPortDeclaration in project streamsx.topology by IBMStreams.
the class BOperatorInvocation method addOutput.
public BOutputPort addOutput(StreamSchema schema) {
if (outputs == null)
outputs = new ArrayList<>();
final OutputPortDeclaration port = op.addOutput(schema);
final BOutputPort stream = new BOutputPort(this, port);
outputs.add(stream);
return stream;
}
use of com.ibm.streams.flow.declare.OutputPortDeclaration in project streamsx.topology by IBMStreams.
the class EmbeddedGraph method declareOutputs.
private void declareOutputs(OperatorInvocation<? extends Operator> opDecl, JsonArray outputs) {
if (GsonUtilities.jisEmpty(outputs))
return;
// Ensure we deal with them in port order.
JsonObject[] ports = new JsonObject[outputs.size()];
for (JsonElement e : outputs) {
JsonObject output = e.getAsJsonObject();
ports[output.get("index").getAsInt()] = output;
}
for (JsonObject output : ports) {
String name = jstring(output, "name");
StreamSchema schema = Type.Factory.getTupleType(jstring(output, "type")).getTupleSchema();
OutputPortDeclaration port = opDecl.addOutput(name, schema);
assert !outputPorts.containsKey(name);
outputPorts.put(name, port);
}
}
use of com.ibm.streams.flow.declare.OutputPortDeclaration in project streamsx.topology by IBMStreams.
the class EmbeddedGraph method declareOpConnections.
private void declareOpConnections(JsonObject json) {
JsonArray outputs = json.getAsJsonArray("outputs");
if (jisEmpty(outputs))
return;
for (JsonElement e : outputs) {
JsonObject output = e.getAsJsonObject();
String name = jstring(output, "name");
JsonArray conns = output.getAsJsonArray("connections");
if (jisEmpty(conns))
continue;
OutputPortDeclaration port = requireNonNull(outputPorts.get(name));
for (JsonElement c : conns) {
String iname = c.getAsString();
InputPortDeclaration iport = requireNonNull(inputPorts.get(iname));
port.connect(iport);
}
}
}
use of com.ibm.streams.flow.declare.OutputPortDeclaration in project streamsx.topology by IBMStreams.
the class EmbeddedTesterRuntime method setupEmbeddedTestHandlers.
private void setupEmbeddedTestHandlers(EmbeddedGraph eg) throws Exception {
// Embedded does not support a StreamHandler against
// a connected stream. In that case add a no-op intermediate stream.
Set<TStream<?>> adds = new HashSet<>();
// Find all that are connected.
for (TStream<?> stream : handlers.keySet()) {
if (stream.output().isConnected())
adds.add(stream);
}
// Insert a filter for the handler.
for (TStream<?> stream : adds) {
TStream<?> filter = stream.filter(t -> true);
Set<StreamHandler<Tuple>> handler = handlers.get(stream);
handlers.remove(stream);
handlers.put(filter, handler);
}
final JavaTestableGraph tg = eg.getExecutionGraph();
for (TStream<?> stream : handlers.keySet()) {
Set<StreamHandler<Tuple>> streamHandlers = handlers.get(stream);
final BOutput output = stream.output();
final OutputPortDeclaration portDecl = eg.getOutputPort(output.name());
for (StreamHandler<Tuple> streamHandler : streamHandlers) {
tg.registerStreamHandler(portDecl, streamHandler);
}
}
}
Aggregations