Class RichAsyncFunction<IN,​OUT>

  • Type Parameters:
    IN - The type of the input elements.
    OUT - The type of the returned elements.
    All Implemented Interfaces:
    Serializable, org.apache.flink.api.common.functions.Function, org.apache.flink.api.common.functions.RichFunction, AsyncFunction<IN,​OUT>

    @PublicEvolving
    public abstract class RichAsyncFunction<IN,​OUT>
    extends org.apache.flink.api.common.functions.AbstractRichFunction
    implements AsyncFunction<IN,​OUT>
    Rich variant of the AsyncFunction. As a RichFunction, it gives access to the RuntimeContext and provides setup and teardown methods: RichFunction.open(OpenContext) and RichFunction.close().

    State related apis in RuntimeContext are not supported yet because the key may get changed while accessing states in the working thread.

    IterationRuntimeContext.getIterationAggregator(String) is not supported since the aggregator may be modified by multiple threads.

    See Also:
    Serialized Form
    • Constructor Detail

      • RichAsyncFunction

        public RichAsyncFunction()
    • Method Detail

      • setRuntimeContext

        public void setRuntimeContext​(org.apache.flink.api.common.functions.RuntimeContext runtimeContext)
        Specified by:
        setRuntimeContext in interface org.apache.flink.api.common.functions.RichFunction
        Overrides:
        setRuntimeContext in class org.apache.flink.api.common.functions.AbstractRichFunction
      • asyncInvoke

        public abstract void asyncInvoke​(IN input,
                                         ResultFuture<OUT> resultFuture)
                                  throws Exception
        Description copied from interface: AsyncFunction
        Trigger async operation for each stream input.
        Specified by:
        asyncInvoke in interface AsyncFunction<IN,​OUT>
        Parameters:
        input - element coming from an upstream task
        resultFuture - to be completed with the result data
        Throws:
        Exception - in case of a user code error. An exception will make the task fail and trigger fail-over process.