Search in sources :

Example 1 with StreamHandler

use of com.ibm.streams.flow.handlers.StreamHandler in project streamsx.topology by IBMStreams.

the class TupleCollection method setupEmbeddedTestHandlers.

public void setupEmbeddedTestHandlers(JavaTestableGraph tg) throws Exception {
    for (TStream<?> stream : handlers.keySet()) {
        Set<StreamHandler<Tuple>> streamHandlers = handlers.get(stream);
        for (StreamHandler<Tuple> streamHandler : streamHandlers) {
            BOutput output = stream.output();
            if (output instanceof BOutputPort) {
                BOutputPort outputPort = (BOutputPort) output;
                tg.registerStreamHandler(outputPort.port(), streamHandler);
            }
        // tg.registerStreamHandler(stream.getPort(), streamHandler);
        }
    }
}
Also used : BOutput(com.ibm.streamsx.topology.builder.BOutput) StreamHandler(com.ibm.streams.flow.handlers.StreamHandler) BOutputPort(com.ibm.streamsx.topology.builder.BOutputPort) OutputTuple(com.ibm.streams.operator.OutputTuple) Tuple(com.ibm.streams.operator.Tuple)

Example 2 with StreamHandler

use of com.ibm.streams.flow.handlers.StreamHandler 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);
        }
    }
}
Also used : TStream(com.ibm.streamsx.topology.TStream) BOutput(com.ibm.streamsx.topology.builder.BOutput) StreamHandler(com.ibm.streams.flow.handlers.StreamHandler) OutputPortDeclaration(com.ibm.streams.flow.declare.OutputPortDeclaration) JavaTestableGraph(com.ibm.streams.flow.javaprimitives.JavaTestableGraph) Tuple(com.ibm.streams.operator.Tuple) HashSet(java.util.HashSet)

Aggregations

StreamHandler (com.ibm.streams.flow.handlers.StreamHandler)2 Tuple (com.ibm.streams.operator.Tuple)2 BOutput (com.ibm.streamsx.topology.builder.BOutput)2 OutputPortDeclaration (com.ibm.streams.flow.declare.OutputPortDeclaration)1 JavaTestableGraph (com.ibm.streams.flow.javaprimitives.JavaTestableGraph)1 OutputTuple (com.ibm.streams.operator.OutputTuple)1 TStream (com.ibm.streamsx.topology.TStream)1 BOutputPort (com.ibm.streamsx.topology.builder.BOutputPort)1 HashSet (java.util.HashSet)1