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<T>
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)
Initialize the connection with the Socket in the server.
|
getIterationRuntimeContext, getRuntimeContext, setRuntimeContext
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
invoke
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.public void open(Configuration parameters) throws Exception
open
in interface RichFunction
open
in class AbstractRichFunction
parameters
- Configuration.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.Configuration
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–2020 The Apache Software Foundation. All rights reserved.