Class AsyncDataStream


  • @PublicEvolving
    public class AsyncDataStream
    extends Object
    A helper class to apply AsyncFunction to a data stream.
    
     DataStream<String> input = ...
     AsyncFunction<String, Tuple<String, String>> asyncFunc = ...
    
     AsyncDataStream.orderedWait(input, asyncFunc, timeout, TimeUnit.MILLISECONDS, 100);
     
    • Constructor Detail

      • AsyncDataStream

        public AsyncDataStream()
    • Method Detail

      • unorderedWait

        public static <IN,​OUT> SingleOutputStreamOperator<OUT> unorderedWait​(DataStream<IN> in,
                                                                                   AsyncFunction<IN,​OUT> func,
                                                                                   long timeout,
                                                                                   TimeUnit timeUnit,
                                                                                   int capacity)
        Adds an AsyncWaitOperator. The order of output stream records may be reordered.
        Type Parameters:
        IN - Type of input record
        OUT - Type of output record
        Parameters:
        in - Input DataStream
        func - AsyncFunction
        timeout - for the asynchronous operation to complete
        timeUnit - of the given timeout
        capacity - The max number of async i/o operation that can be triggered
        Returns:
        A new SingleOutputStreamOperator.
      • orderedWait

        public static <IN,​OUT> SingleOutputStreamOperator<OUT> orderedWait​(DataStream<IN> in,
                                                                                 AsyncFunction<IN,​OUT> func,
                                                                                 long timeout,
                                                                                 TimeUnit timeUnit,
                                                                                 int capacity)
        Adds an AsyncWaitOperator. The order to process input records is guaranteed to be the same as input ones.
        Type Parameters:
        IN - Type of input record
        OUT - Type of output record
        Parameters:
        in - Input DataStream
        func - AsyncFunction
        timeout - for the asynchronous operation to complete
        timeUnit - of the given timeout
        capacity - The max number of async i/o operation that can be triggered
        Returns:
        A new SingleOutputStreamOperator.
      • orderedWait

        public static <IN,​OUT> SingleOutputStreamOperator<OUT> orderedWait​(DataStream<IN> in,
                                                                                 AsyncFunction<IN,​OUT> func,
                                                                                 long timeout,
                                                                                 TimeUnit timeUnit)
        Adds an AsyncWaitOperator. The order to process input records is guaranteed to be the same as input ones.
        Type Parameters:
        IN - Type of input record
        OUT - Type of output record
        Parameters:
        in - Input DataStream
        func - AsyncFunction
        timeout - for the asynchronous operation to complete
        timeUnit - of the given timeout
        Returns:
        A new SingleOutputStreamOperator.
      • unorderedWaitWithRetry

        public static <IN,​OUT> SingleOutputStreamOperator<OUT> unorderedWaitWithRetry​(DataStream<IN> in,
                                                                                            AsyncFunction<IN,​OUT> func,
                                                                                            long timeout,
                                                                                            TimeUnit timeUnit,
                                                                                            AsyncRetryStrategy<OUT> asyncRetryStrategy)
        Adds an AsyncWaitOperator with an AsyncRetryStrategy to support retry of AsyncFunction. The order of output stream records may be reordered.
        Type Parameters:
        IN - Type of input record
        OUT - Type of output record
        Parameters:
        in - Input DataStream
        func - AsyncFunction
        timeout - from first invoke to final completion of asynchronous operation, may include multiple retries, and will be reset in case of restart
        timeUnit - of the given timeout
        asyncRetryStrategy - The strategy of reattempt async i/o operation that can be triggered
        Returns:
        A new SingleOutputStreamOperator.
      • unorderedWaitWithRetry

        public static <IN,​OUT> SingleOutputStreamOperator<OUT> unorderedWaitWithRetry​(DataStream<IN> in,
                                                                                            AsyncFunction<IN,​OUT> func,
                                                                                            long timeout,
                                                                                            TimeUnit timeUnit,
                                                                                            int capacity,
                                                                                            AsyncRetryStrategy<OUT> asyncRetryStrategy)
        Adds an AsyncWaitOperator with an AsyncRetryStrategy to support retry of AsyncFunction. The order of output stream records may be reordered.
        Type Parameters:
        IN - Type of input record
        OUT - Type of output record
        Parameters:
        in - Input DataStream
        func - AsyncFunction
        timeout - from first invoke to final completion of asynchronous operation, may include multiple retries, and will be reset in case of restart
        timeUnit - of the given timeout
        capacity - The max number of async i/o operation that can be triggered
        asyncRetryStrategy - The strategy of reattempt async i/o operation that can be triggered
        Returns:
        A new SingleOutputStreamOperator.
      • orderedWaitWithRetry

        public static <IN,​OUT> SingleOutputStreamOperator<OUT> orderedWaitWithRetry​(DataStream<IN> in,
                                                                                          AsyncFunction<IN,​OUT> func,
                                                                                          long timeout,
                                                                                          TimeUnit timeUnit,
                                                                                          AsyncRetryStrategy<OUT> asyncRetryStrategy)
        Adds an AsyncWaitOperator with an AsyncRetryStrategy to support retry of AsyncFunction. The order to process input records is guaranteed to be the same as * input ones.
        Type Parameters:
        IN - Type of input record
        OUT - Type of output record
        Parameters:
        in - Input DataStream
        func - AsyncFunction
        timeout - from first invoke to final completion of asynchronous operation, may include multiple retries, and will be reset in case of restart
        timeUnit - of the given timeout
        asyncRetryStrategy - The strategy of reattempt async i/o operation that can be triggered
        Returns:
        A new SingleOutputStreamOperator.
      • orderedWaitWithRetry

        public static <IN,​OUT> SingleOutputStreamOperator<OUT> orderedWaitWithRetry​(DataStream<IN> in,
                                                                                          AsyncFunction<IN,​OUT> func,
                                                                                          long timeout,
                                                                                          TimeUnit timeUnit,
                                                                                          int capacity,
                                                                                          AsyncRetryStrategy<OUT> asyncRetryStrategy)
        Adds an AsyncWaitOperator with an AsyncRetryStrategy to support retry of AsyncFunction. The order to process input records is guaranteed to be the same as * input ones.
        Type Parameters:
        IN - Type of input record
        OUT - Type of output record
        Parameters:
        in - Input DataStream
        func - AsyncFunction
        timeout - from first invoke to final completion of asynchronous operation, may include multiple retries, and will be reset in case of restart
        timeUnit - of the given timeout
        capacity - The max number of async i/o operation that can be triggered
        asyncRetryStrategy - The strategy of reattempt async i/o operation that can be triggered
        Returns:
        A new SingleOutputStreamOperator.