Class CollectSink<IN>
- java.lang.Object
-
- org.apache.flink.api.common.functions.AbstractRichFunction
-
- org.apache.flink.streaming.api.functions.sink.legacy.RichSinkFunction<IN>
-
- org.apache.flink.streaming.experimental.CollectSink<IN>
-
- All Implemented Interfaces:
Serializable
,Function
,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
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.flink.streaming.api.functions.sink.legacy.SinkFunction
SinkFunction.Context
-
-
Constructor Summary
Constructors Constructor Description CollectSink(InetAddress hostIp, int port, TypeSerializer<IN> serializer)
Creates a CollectSink that will send the data to the specified host.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes the connection with the Socket server.void
invoke(IN value, SinkFunction.Context context)
Writes the given value to the sink.void
open(OpenContext openContext)
Initialize the connection with the Socket in the server.-
Methods inherited from class org.apache.flink.api.common.functions.AbstractRichFunction
getIterationRuntimeContext, getRuntimeContext, setRuntimeContext
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.flink.streaming.api.functions.sink.legacy.SinkFunction
finish, invoke, writeWatermark
-
-
-
-
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 adefault
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 interfaceRichFunction
- Overrides:
open
in classAbstractRichFunction
- 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 interfaceRichFunction
- Overrides:
close
in classAbstractRichFunction
- 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.
-
-