Class CollectSink<IN>

    • Constructor Detail

      • CollectSink

        public CollectSink​(InetAddress hostIp,
                           int port,
                           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​(OpenContext openContext)
                  throws Exception
        Initialize the connection with the Socket in the server.
        Specified by:
        open in interface RichFunction
        Overrides:
        open in class AbstractRichFunction
        Parameters:
        openContext - the context.
        Throws:
        Exception - Implementations may forward exceptions, which are caught by the runtime. When the runtime catches an exception, it aborts the task and lets the fail-over logic decide whether to retry the task execution.
      • close

        public void close()
                   throws Exception
        Closes the connection with the Socket server.
        Specified by:
        close in interface RichFunction
        Overrides:
        close in class AbstractRichFunction
        Throws:
        Exception - Implementations may forward exceptions, which are caught by the runtime. When the runtime catches an exception, it aborts the task and lets the fail-over logic decide whether to retry the task execution.