Class SocketClientSink<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.api.functions.sink.legacy.SocketClientSink<IN>
-
- Type Parameters:
IN
- data to be written into the Socket.
- All Implemented Interfaces:
Serializable
,Function
,RichFunction
,SinkFunction<IN>
@Internal public class SocketClientSink<IN> extends RichSinkFunction<IN>
Deprecated.This interface will be removed in future versions. Use the newSink
interface instead.Socket client that acts as a streaming sink. The data is sent to a Socket as a byte array.The sink can be set to retry message sends after the sending failed.
The sink can be set to 'autoflush', in which case the socket stream is flushed after every message. This significantly reduced throughput, but also decreases message latency.
- 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 SocketClientSink(String hostName, int port, SerializationSchema<IN> schema)
Deprecated.Creates a new SocketClientSink.SocketClientSink(String hostName, int port, SerializationSchema<IN> schema, int maxNumRetries)
Deprecated.Creates a new SocketClientSink that retries connections upon failure up to a given number of times.SocketClientSink(String hostName, int port, SerializationSchema<IN> schema, int maxNumRetries, boolean autoflush)
Deprecated.Creates a new SocketClientSink that retries connections upon failure up to a given number of times.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
close()
Deprecated.Closes the connection with the Socket server.int
getCurrentNumberOfRetries()
Deprecated.void
invoke(IN value)
Deprecated.Called when new data arrives to the sink, and forwards it to Socket.void
open(OpenContext openContext)
Deprecated.Initialization method for the function.-
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
-
SocketClientSink
public SocketClientSink(String hostName, int port, SerializationSchema<IN> schema)
Deprecated.Creates a new SocketClientSink. The sink will not attempt to retry connections upon failure and will not auto-flush the stream.- Parameters:
hostName
- Hostname of the server to connect to.port
- Port of the server.schema
- Schema used to serialize the data into bytes.
-
SocketClientSink
public SocketClientSink(String hostName, int port, SerializationSchema<IN> schema, int maxNumRetries)
Deprecated.Creates a new SocketClientSink that retries connections upon failure up to a given number of times. A value of -1 for the number of retries will cause the system to retry an infinite number of times. The sink will not auto-flush the stream.- Parameters:
hostName
- Hostname of the server to connect to.port
- Port of the server.schema
- Schema used to serialize the data into bytes.maxNumRetries
- The maximum number of retries after a message send failed.
-
SocketClientSink
public SocketClientSink(String hostName, int port, SerializationSchema<IN> schema, int maxNumRetries, boolean autoflush)
Deprecated.Creates a new SocketClientSink that retries connections upon failure up to a given number of times. A value of -1 for the number of retries will cause the system to retry an infinite number of times.- Parameters:
hostName
- Hostname of the server to connect to.port
- Port of the server.schema
- Schema used to serialize the data into bytes.maxNumRetries
- The maximum number of retries after a message send failed.autoflush
- Flag to indicate whether the socket stream should be flushed after each message.
-
-
Method Detail
-
open
public void open(OpenContext openContext) throws Exception
Deprecated.Description copied from interface:RichFunction
Initialization method for the function. It is called before the actual working methods (like map or join) and thus suitable for one time setup work. For functions that are part of an iteration, this method will be invoked at the beginning of each iteration superstep.The openContext object passed to the function can be used for configuration and initialization. The openContext contains some necessary information that were configured on the function in the program composition.
public class MyFilter extends RichFilterFunction<String> { private String searchString; public void open(OpenContext openContext) { // initialize the value of searchString } public boolean filter(String value) { return value.equals(searchString); } }
- Specified by:
open
in interfaceRichFunction
- Overrides:
open
in classAbstractRichFunction
- Parameters:
openContext
- The context containing information about the context in which the function is opened.- 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.
-
invoke
public void invoke(IN value) throws Exception
Deprecated.Called when new data arrives to the sink, and forwards it to Socket.- Parameters:
value
- The value to write to the socket.- Throws:
Exception
-
close
public void close() throws Exception
Deprecated.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.
-
getCurrentNumberOfRetries
@VisibleForTesting public int getCurrentNumberOfRetries()
Deprecated.
-
-