IN
- data to be written into the Socket.@PublicEvolving public class SocketClientSink<IN> extends RichSinkFunction<IN>
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.
SinkFunction.Context
Constructor and Description |
---|
SocketClientSink(String hostName,
int port,
SerializationSchema<IN> schema)
Creates a new SocketClientSink.
|
SocketClientSink(String hostName,
int port,
SerializationSchema<IN> schema,
int maxNumRetries)
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)
Creates a new SocketClientSink that retries connections upon failure up to a given number of
times.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the connection with the Socket server.
|
void |
invoke(IN value)
Called when new data arrives to the sink, and forwards it to Socket.
|
void |
open(Configuration parameters)
Deprecated.
This method is deprecated since Flink 1.19. The users are recommended to
implement
open(OpenContext openContext) and override open(Configuration
parameters) with an empty body instead. 1. If you implement open(OpenContext
openContext) , the open(OpenContext openContext) will be invoked and the open(Configuration parameters) won't be invoked. 2. If you don't implement open(OpenContext openContext) , the open(Configuration parameters) will be
invoked in the default implementation of the open(OpenContext openContext) . |
getIterationRuntimeContext, getRuntimeContext, setRuntimeContext
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
finish, invoke, writeWatermark
open
public SocketClientSink(String hostName, int port, SerializationSchema<IN> schema)
hostName
- Hostname of the server to connect to.port
- Port of the server.schema
- Schema used to serialize the data into bytes.public SocketClientSink(String hostName, int port, SerializationSchema<IN> schema, int maxNumRetries)
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.public SocketClientSink(String hostName, int port, SerializationSchema<IN> schema, int maxNumRetries, boolean autoflush)
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.@Deprecated public void open(Configuration parameters) throws Exception
open(OpenContext openContext)
and override open(Configuration
parameters)
with an empty body instead. 1. If you implement open(OpenContext
openContext)
, the open(OpenContext openContext)
will be invoked and the open(Configuration parameters)
won't be invoked. 2. If you don't implement open(OpenContext openContext)
, the open(Configuration parameters)
will be
invoked in the default implementation of the open(OpenContext openContext)
.open
in interface RichFunction
open
in class AbstractRichFunction
parameters
- The configuration containing the parameters attached to the contract.Exception
- if an error happens.public void invoke(IN value) throws Exception
value
- The value to write to the socket.Exception
public void close() throws Exception
close
in interface RichFunction
close
in class AbstractRichFunction
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.Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.