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, org.apache.flink.api.common.functions.Function, org.apache.flink.api.common.functions.RichFunction, SinkFunction<IN>

@Internal public class SocketClientSink<IN> extends RichSinkFunction<IN>
Deprecated.
This interface will be removed in future versions. Use the new Sink 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:
  • 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, org.apache.flink.api.common.serialization.SerializationSchema<IN> schema)
    Deprecated.
    Creates a new SocketClientSink.
    SocketClientSink(String hostName, int port, org.apache.flink.api.common.serialization.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, org.apache.flink.api.common.serialization.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

    Modifier and Type
    Method
    Description
    void
    Deprecated.
    Closes the connection with the Socket server.
    int
    Deprecated.
     
    void
    invoke(IN value)
    Deprecated.
    Called when new data arrives to the sink, and forwards it to Socket.
    void
    open(org.apache.flink.api.common.functions.OpenContext openContext)
    Deprecated.
     

    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 Details

    • SocketClientSink

      public SocketClientSink(String hostName, int port, org.apache.flink.api.common.serialization.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, org.apache.flink.api.common.serialization.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, org.apache.flink.api.common.serialization.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 Details

    • open

      public void open(org.apache.flink.api.common.functions.OpenContext openContext) throws Exception
      Deprecated.
      Specified by:
      open in interface org.apache.flink.api.common.functions.RichFunction
      Overrides:
      open in class org.apache.flink.api.common.functions.AbstractRichFunction
      Throws:
      Exception
    • 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 interface org.apache.flink.api.common.functions.RichFunction
      Overrides:
      close in class org.apache.flink.api.common.functions.AbstractRichFunction
      Throws:
      Exception
    • getCurrentNumberOfRetries

      @VisibleForTesting public int getCurrentNumberOfRetries()
      Deprecated.