本文整理汇总了Java中org.apache.flink.streaming.api.functions.sink.SocketClientSink类的典型用法代码示例。如果您正苦于以下问题:Java SocketClientSink类的具体用法?Java SocketClientSink怎么用?Java SocketClientSink使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SocketClientSink类属于org.apache.flink.streaming.api.functions.sink包,在下文中一共展示了SocketClientSink类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeToSocket
import org.apache.flink.streaming.api.functions.sink.SocketClientSink; //导入依赖的package包/类
/**
* Writes the DataStream to a socket as a byte array. The format of the
* output is specified by a {@link SerializationSchema}.
*
* @param hostName
* host of the socket
* @param port
* port of the socket
* @param schema
* schema for serialization
* @return the closed DataStream
*/
@PublicEvolving
public DataStreamSink<T> writeToSocket(String hostName, int port, SerializationSchema<T> schema) {
DataStreamSink<T> returnStream = addSink(new SocketClientSink<>(hostName, port, schema, 0));
returnStream.setParallelism(1); // It would not work if multiple instances would connect to the same port
return returnStream;
}