quarks.topology

Interface Topology

  • All Superinterfaces:
    TopologyElement
    All Known Implementing Classes:
    quarks.topology.spi.AbstractTopology, DirectTopology, quarks.topology.spi.graph.GraphTopology


    public interface Topology
    extends TopologyElement
    A declaration of a topology of streaming data. This class provides some fundamental generic methods to create source streams, such as source, poll, strings.
    • Method Detail

      • source

        <T> TStream<T> source(Supplier<java.lang.Iterable<T>> data)
        Declare a new source stream that iterates over the return of Iterable<T> get() from data. Once all the tuples from data.get() have been submitted on the stream, no more tuples are submitted.
        The returned stream will be endless if the iterator returned from the Iterable never completes.

        If data implements AutoCloseable, its close() method will be called when the topology's execution is terminated.

        Parameters:
        data - Function that produces that data for the stream.
        Returns:
        New stream containing the tuples from the iterator returned by data.get().
        See Also:
        Quarks Source Streams
      • generate

        <T> TStream<T> generate(Supplier<T> data)
        Declare an endless source stream. data.get() will be called repeatably. Each non-null returned value will be present on the stream.

        If data implements AutoCloseable, its close() method will be called when the topology's execution is terminated.

        Parameters:
        data - Supplier of the tuples.
        Returns:
        New stream containing the tuples from calls to data.get() .
        See Also:
        Quarks Source Streams
      • poll

        <T> TStream<T> poll(Supplier<T> data,
                            long period,
                            java.util.concurrent.TimeUnit unit)
        Declare a new source stream that calls data.get() periodically. Each non-null value returned will appear on the returned stream. Thus each call to {code data.get()} will result in zero tuples or one tuple on the stream.

        If data implements AutoCloseable, its close() method will be called when the topology's execution is terminated.

        Parameters:
        data - Function that produces that data for the stream.
        period - Approximate period {code data.get()} will be called.
        unit - Time unit of period.
        Returns:
        New stream containing the tuples returned by data.get().
        See Also:
        Quarks Source Streams
      • events

        <T> TStream<T> events(Consumer<Consumer<T>> eventSetup)
        Declare a stream populated by an event system. At startup eventSetup.accept(eventSubmitter)) is called by the runtime with eventSubmitter being a Consumer<T>. Calling eventSubmitter.accept(t) results in t being present on the returned stream if it is not null. If t is null then no action is taken.
        It is expected that eventSubmitter is called from the event handler callback registered with the event system.

        Downstream processing is isolated from the event source to ensure that event listener is not blocked by a long or slow processing flow.

        If eventSetup implements AutoCloseable, its close() method will be called when the topology's execution is terminated.

        Parameters:
        eventSetup - handler to receive the eventSubmitter
        Returns:
        New stream containing the tuples added by eventSubmitter.accept(t).
        See Also:
        PlumbingStreams.pressureReliever(TStream, quarks.function.Function, int), Quarks Source Streams
      • strings

        TStream<java.lang.String> strings(java.lang.String... strings)
        Declare a stream of strings.
        Parameters:
        strings - Strings that will be present on the stream.
        Returns:
        Stream containing all values in strings.
      • of

        <T> TStream<T> of(T... values)
        Declare a stream of objects.
        Parameters:
        values - Values that will be present on the stream.
        Returns:
        Stream containing all values in values.
      • collection

        <T> TStream<T> collection(java.util.Collection<T> tuples)
        Declare a stream of constants from a collection. The returned stream will contain all the tuples in tuples.
        Parameters:
        tuples - Tuples that will be present on the stream.
        Returns:
        Stream containing all values in tuples.
      • getTester

        Tester getTester()
        Get the tester for this topology.
        Returns:
        tester for this topology.
      • graph

        Graph graph()
        Get the underlying graph.
        Returns:
        the underlying graph.
      • getRuntimeServiceSupplier

        Supplier<RuntimeServices> getRuntimeServiceSupplier()
        Return a function that at execution time will return a RuntimeServices instance a stream function can use.
        Returns:
        Function that at execution time will return a RuntimeServices instance

Copyright IBM 2015,2016 - 2f6ad0e-20160307-0902