Class CollectSink<IN>

  • All Implemented Interfaces:
    Serializable, org.apache.flink.api.common.functions.Function, org.apache.flink.api.common.functions.RichFunction, SinkFunction<IN>

    @Experimental
    public class CollectSink<IN>
    extends RichSinkFunction<IN>
    A specialized data sink to be used by DataStreamUtils.collect().

    This experimental class is relocated from flink-streaming-contrib. Please see package-info.java for more information.

    See Also:
    Serialized Form
    • Constructor Detail

      • CollectSink

        public CollectSink​(InetAddress hostIp,
                           int port,
                           org.apache.flink.api.common.typeutils.TypeSerializer<IN> serializer)
        Creates a CollectSink that will send the data to the specified host.
        Parameters:
        hostIp - IP address of the Socket server.
        port - Port of the Socket server.
        serializer - A serializer for the data.
    • Method Detail

      • invoke

        public void invoke​(IN value,
                           SinkFunction.Context context)
                    throws Exception
        Description copied from interface: SinkFunction
        Writes the given value to the sink. This function is called for every record.

        You have to override this method when implementing a SinkFunction, this is a default method for backward compatibility with the old-style method only.

        Parameters:
        value - The input record.
        context - Additional context about the input record.
        Throws:
        Exception - This method may throw exceptions. Throwing an exception will cause the operation to fail and may trigger recovery.
      • open

        public void open​(org.apache.flink.api.common.functions.OpenContext openContext)
                  throws Exception
        Initialize the connection with the Socket in the server.
        Parameters:
        openContext - the context.
        Throws:
        Exception
      • close

        public void close()
                   throws Exception
        Closes the connection with the Socket server.
        Specified by:
        close in interface org.apache.flink.api.common.functions.RichFunction
        Overrides:
        close in class org.apache.flink.api.common.functions.AbstractRichFunction
        Throws:
        Exception