congrats Icon
New! Announcing our next generation AI code completions
Read here
Tabnine Logo
StreamExecutionEnvironment.socketTextStream
Code IndexAdd Tabnine to your IDE (free)

How to use
socketTextStream
method
in
org.apache.flink.streaming.api.environment.StreamExecutionEnvironment

Best Java code snippets using org.apache.flink.streaming.api.environment.StreamExecutionEnvironment.socketTextStream (Showing top 20 results out of 315)

origin: apache/flink

/**
 * Creates a new data stream that contains the strings received infinitely from a socket. Received strings are
 * decoded by the system's default character set. The reader is terminated immediately when the socket is down.
 *
 * @param hostname
 *         The host name which a server socket binds
 * @param port
 *         The port number which a server socket binds. A port number of 0 means that the port number is automatically
 *         allocated.
 * @param delimiter
 *         A character which splits received strings into records
 * @return A data stream containing the strings received from the socket
 *
 * @deprecated Use {@link #socketTextStream(String, int, String)} instead.
 */
@Deprecated
@SuppressWarnings("deprecation")
public DataStreamSource<String> socketTextStream(String hostname, int port, char delimiter) {
  return socketTextStream(hostname, port, delimiter, 0);
}
origin: apache/flink

/**
 * Creates a new data stream that contains the strings received infinitely from a socket. Received strings are
 * decoded by the system's default character set. On the termination of the socket server connection retries can be
 * initiated.
 *
 * <p>Let us note that the socket itself does not report on abort and as a consequence retries are only initiated when
 * the socket was gracefully terminated.
 *
 * @param hostname
 *         The host name which a server socket binds
 * @param port
 *         The port number which a server socket binds. A port number of 0 means that the port number is automatically
 *         allocated.
 * @param delimiter
 *         A character which splits received strings into records
 * @param maxRetry
 *         The maximal retry interval in seconds while the program waits for a socket that is temporarily down.
 *         Reconnection is initiated every second. A number of 0 means that the reader is immediately terminated,
 *         while
 *         a    negative value ensures retrying forever.
 * @return A data stream containing the strings received from the socket
 *
 * @deprecated Use {@link #socketTextStream(String, int, String, long)} instead.
 */
@Deprecated
public DataStreamSource<String> socketTextStream(String hostname, int port, char delimiter, long maxRetry) {
  return socketTextStream(hostname, port, String.valueOf(delimiter), maxRetry);
}
origin: apache/flink

/**
 * Creates a new data stream that contains the strings received infinitely from a socket. Received strings are
 * decoded by the system's default character set, using"\n" as delimiter. The reader is terminated immediately when
 * the socket is down.
 *
 * @param hostname
 *         The host name which a server socket binds
 * @param port
 *         The port number which a server socket binds. A port number of 0 means that the port number is automatically
 *         allocated.
 * @return A data stream containing the strings received from the socket
 */
@PublicEvolving
public DataStreamSource<String> socketTextStream(String hostname, int port) {
  return socketTextStream(hostname, port, "\n");
}
origin: apache/flink

/**
 * Creates a new data stream that contains the strings received infinitely from a socket. Received strings are
 * decoded by the system's default character set. The reader is terminated immediately when the socket is down.
 *
 * @param hostname
 *         The host name which a server socket binds
 * @param port
 *         The port number which a server socket binds. A port number of 0 means that the port number is automatically
 *         allocated.
 * @param delimiter
 *         A string which splits received strings into records
 * @return A data stream containing the strings received from the socket
 */
@PublicEvolving
public DataStreamSource<String> socketTextStream(String hostname, int port, String delimiter) {
  return socketTextStream(hostname, port, delimiter, 0);
}
origin: apache/flink

/**
 * A thin wrapper layer over {@link StreamExecutionEnvironment#socketTextStream(java.lang.String, int)}.
 *
 * @param host The host name which a server socket binds
 * @param port The port number which a server socket binds. A port number of 0 means that the port number is automatically
 * allocated.
 * @return A python data stream containing the strings received from the socket
 */
public PythonDataStream socket_text_stream(String host, int port) {
  return new PythonDataStream<>(env.socketTextStream(host, port).map(new AdapterMap<String>()));
}
origin: apache/flink

DataStream<String> text = env.socketTextStream(hostname, port, "\n");
origin: org.apache.flink/flink-streaming-java_2.11

/**
 * Creates a new data stream that contains the strings received infinitely from a socket. Received strings are
 * decoded by the system's default character set. The reader is terminated immediately when the socket is down.
 *
 * @param hostname
 *         The host name which a server socket binds
 * @param port
 *         The port number which a server socket binds. A port number of 0 means that the port number is automatically
 *         allocated.
 * @param delimiter
 *         A character which splits received strings into records
 * @return A data stream containing the strings received from the socket
 *
 * @deprecated Use {@link #socketTextStream(String, int, String)} instead.
 */
@Deprecated
@SuppressWarnings("deprecation")
public DataStreamSource<String> socketTextStream(String hostname, int port, char delimiter) {
  return socketTextStream(hostname, port, delimiter, 0);
}
origin: org.apache.flink/flink-streaming-java_2.10

/**
 * Creates a new data stream that contains the strings received infinitely from a socket. Received strings are
 * decoded by the system's default character set. The reader is terminated immediately when the socket is down.
 *
 * @param hostname
 *         The host name which a server socket binds
 * @param port
 *         The port number which a server socket binds. A port number of 0 means that the port number is automatically
 *         allocated.
 * @param delimiter
 *         A character which splits received strings into records
 * @return A data stream containing the strings received from the socket
 *
 * @deprecated Use {@link #socketTextStream(String, int, String)} instead.
 */
@Deprecated
@SuppressWarnings("deprecation")
public DataStreamSource<String> socketTextStream(String hostname, int port, char delimiter) {
  return socketTextStream(hostname, port, delimiter, 0);
}
origin: org.apache.flink/flink-streaming-java

/**
 * Creates a new data stream that contains the strings received infinitely from a socket. Received strings are
 * decoded by the system's default character set. The reader is terminated immediately when the socket is down.
 *
 * @param hostname
 *         The host name which a server socket binds
 * @param port
 *         The port number which a server socket binds. A port number of 0 means that the port number is automatically
 *         allocated.
 * @param delimiter
 *         A character which splits received strings into records
 * @return A data stream containing the strings received from the socket
 *
 * @deprecated Use {@link #socketTextStream(String, int, String)} instead.
 */
@Deprecated
@SuppressWarnings("deprecation")
public DataStreamSource<String> socketTextStream(String hostname, int port, char delimiter) {
  return socketTextStream(hostname, port, delimiter, 0);
}
origin: DTStack/flinkx

/**
 * Creates a new data stream that contains the strings received infinitely from a socket. Received strings are
 * decoded by the system's default character set. The reader is terminated immediately when the socket is down.
 *
 * @param hostname
 *         The host name which a server socket binds
 * @param port
 *         The port number which a server socket binds. A port number of 0 means that the port number is automatically
 *         allocated.
 * @param delimiter
 *         A character which splits received strings into records
 * @return A data stream containing the strings received from the socket
 *
 * @deprecated Use {@link #socketTextStream(String, int, String)} instead.
 */
@Deprecated
@SuppressWarnings("deprecation")
public DataStreamSource<String> socketTextStream(String hostname, int port, char delimiter) {
  return socketTextStream(hostname, port, delimiter, 0);
}
origin: DTStack/flinkx

/**
 * Creates a new data stream that contains the strings received infinitely from a socket. Received strings are
 * decoded by the system's default character set, using"\n" as delimiter. The reader is terminated immediately when
 * the socket is down.
 *
 * @param hostname
 *         The host name which a server socket binds
 * @param port
 *         The port number which a server socket binds. A port number of 0 means that the port number is automatically
 *         allocated.
 * @return A data stream containing the strings received from the socket
 */
@PublicEvolving
public DataStreamSource<String> socketTextStream(String hostname, int port) {
  return socketTextStream(hostname, port, "\n");
}
origin: org.apache.flink/flink-streaming-java

/**
 * Creates a new data stream that contains the strings received infinitely from a socket. Received strings are
 * decoded by the system's default character set, using"\n" as delimiter. The reader is terminated immediately when
 * the socket is down.
 *
 * @param hostname
 *         The host name which a server socket binds
 * @param port
 *         The port number which a server socket binds. A port number of 0 means that the port number is automatically
 *         allocated.
 * @return A data stream containing the strings received from the socket
 */
@PublicEvolving
public DataStreamSource<String> socketTextStream(String hostname, int port) {
  return socketTextStream(hostname, port, "\n");
}
origin: org.apache.flink/flink-streaming-java_2.11

/**
 * Creates a new data stream that contains the strings received infinitely from a socket. Received strings are
 * decoded by the system's default character set, using"\n" as delimiter. The reader is terminated immediately when
 * the socket is down.
 *
 * @param hostname
 *         The host name which a server socket binds
 * @param port
 *         The port number which a server socket binds. A port number of 0 means that the port number is automatically
 *         allocated.
 * @return A data stream containing the strings received from the socket
 */
@PublicEvolving
public DataStreamSource<String> socketTextStream(String hostname, int port) {
  return socketTextStream(hostname, port, "\n");
}
origin: org.apache.flink/flink-streaming-java_2.11

/**
 * Creates a new data stream that contains the strings received infinitely from a socket. Received strings are
 * decoded by the system's default character set. The reader is terminated immediately when the socket is down.
 *
 * @param hostname
 *         The host name which a server socket binds
 * @param port
 *         The port number which a server socket binds. A port number of 0 means that the port number is automatically
 *         allocated.
 * @param delimiter
 *         A string which splits received strings into records
 * @return A data stream containing the strings received from the socket
 */
@PublicEvolving
public DataStreamSource<String> socketTextStream(String hostname, int port, String delimiter) {
  return socketTextStream(hostname, port, delimiter, 0);
}
origin: org.apache.flink/flink-streaming-java_2.10

/**
 * Creates a new data stream that contains the strings received infinitely from a socket. Received strings are
 * decoded by the system's default character set, using"\n" as delimiter. The reader is terminated immediately when
 * the socket is down.
 *
 * @param hostname
 *         The host name which a server socket binds
 * @param port
 *         The port number which a server socket binds. A port number of 0 means that the port number is automatically
 *         allocated.
 * @return A data stream containing the strings received from the socket
 */
@PublicEvolving
public DataStreamSource<String> socketTextStream(String hostname, int port) {
  return socketTextStream(hostname, port, "\n");
}
origin: org.apache.flink/flink-streaming-java

/**
 * Creates a new data stream that contains the strings received infinitely from a socket. Received strings are
 * decoded by the system's default character set. The reader is terminated immediately when the socket is down.
 *
 * @param hostname
 *         The host name which a server socket binds
 * @param port
 *         The port number which a server socket binds. A port number of 0 means that the port number is automatically
 *         allocated.
 * @param delimiter
 *         A string which splits received strings into records
 * @return A data stream containing the strings received from the socket
 */
@PublicEvolving
public DataStreamSource<String> socketTextStream(String hostname, int port, String delimiter) {
  return socketTextStream(hostname, port, delimiter, 0);
}
origin: DTStack/flinkx

/**
 * Creates a new data stream that contains the strings received infinitely from a socket. Received strings are
 * decoded by the system's default character set. The reader is terminated immediately when the socket is down.
 *
 * @param hostname
 *         The host name which a server socket binds
 * @param port
 *         The port number which a server socket binds. A port number of 0 means that the port number is automatically
 *         allocated.
 * @param delimiter
 *         A string which splits received strings into records
 * @return A data stream containing the strings received from the socket
 */
@PublicEvolving
public DataStreamSource<String> socketTextStream(String hostname, int port, String delimiter) {
  return socketTextStream(hostname, port, delimiter, 0);
}
origin: org.apache.flink/flink-streaming-java_2.10

/**
 * Creates a new data stream that contains the strings received infinitely from a socket. Received strings are
 * decoded by the system's default character set. The reader is terminated immediately when the socket is down.
 *
 * @param hostname
 *         The host name which a server socket binds
 * @param port
 *         The port number which a server socket binds. A port number of 0 means that the port number is automatically
 *         allocated.
 * @param delimiter
 *         A string which splits received strings into records
 * @return A data stream containing the strings received from the socket
 */
@PublicEvolving
public DataStreamSource<String> socketTextStream(String hostname, int port, String delimiter) {
  return socketTextStream(hostname, port, delimiter, 0);
}
origin: uk.gov.gchq.gaffer/flink-library

  @Override
  public Object doOperation(final AddElementsFromSocket op, final Context context, final Store store) throws OperationException {
    final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
    if (null != op.getParallelism()) {
      env.setParallelism(op.getParallelism());
    }

    final DataStream<Element> builder =
        env.socketTextStream(op.getHostname(), op.getPort(), op.getDelimiter())
            .flatMap(new GafferMapFunction(String.class, op.getElementGenerator()));

    if (Boolean.parseBoolean(op.getOption(FlinkConstants.SKIP_REBALANCING))) {
      builder.addSink(new GafferSink(op, store));
    } else {
      builder.rebalance().addSink(new GafferSink(op, store));
    }

    try {
      env.execute(op.getClass().getSimpleName() + "-" + op.getHostname() + ":" + op.getPort());
    } catch (final Exception e) {
      throw new OperationException("Failed to add elements from port: " + op.getPort(), e);
    }

    return null;
  }
}
origin: wuchong/my-flink-project

  public static void main(String[] args) throws Exception {

    // 创建 execution environment
    StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

    // 通过连接 socket 获取输入数据,这里连接到本地9000端口,如果9000端口已被占用,请换一个端口
    DataStream<String> text = env.socketTextStream("localhost", 9000, "\n");

    // 解析数据,按 word 分组,开窗,聚合
    DataStream<Tuple2<String, Integer>> windowCounts = text
        .flatMap(new FlatMapFunction<String, Tuple2<String, Integer>>() {
          @Override
          public void flatMap(String value, Collector<Tuple2<String, Integer>> out) {
            for (String word : value.split("\\s")) {
              out.collect(Tuple2.of(word, 1));
            }
          }
        })
        .keyBy(0)
        .timeWindow(Time.seconds(5))
        .sum(1);

    // 将结果打印到控制台,注意这里使用的是单线程打印,而非多线程
    windowCounts.print().setParallelism(1);

    env.execute("Socket Window WordCount");
  }
}
org.apache.flink.streaming.api.environmentStreamExecutionEnvironmentsocketTextStream

Javadoc

Creates a new data stream that contains the strings received infinitely from a socket. Received strings are decoded by the system's default character set, using"\n" as delimiter. The reader is terminated immediately when the socket is down.

Popular methods of StreamExecutionEnvironment

  • execute
  • getExecutionEnvironment
    Creates an execution environment that represents the context in which the program is currently execu
  • addSource
    Ads a data source with a custom type information thus opening a DataStream. Only in very special cas
  • getConfig
    Gets the config object.
  • enableCheckpointing
    Enables checkpointing for the streaming job. The distributed state of the streaming dataflow will be
  • setStreamTimeCharacteristic
    Sets the time characteristic for all streams create from this environment, e.g., processing time, ev
  • setParallelism
    Sets the parallelism for operations executed through this environment. Setting a parallelism of x he
  • fromElements
    Creates a new data stream that contains the given elements. The elements must all be of the same typ
  • setStateBackend
    Sets the state backend that describes how to store and checkpoint operator state. It defines both wh
  • createLocalEnvironment
    Creates a LocalStreamEnvironment. The local execution environment will run the program in a multi-th
  • fromCollection
    Creates a data stream from the given iterator.Because the iterator will remain unmodified until the
  • getCheckpointConfig
    Gets the checkpoint config, which defines values like checkpoint interval, delay between checkpoints
  • fromCollection,
  • getCheckpointConfig,
  • getParallelism,
  • getStreamGraph,
  • setRestartStrategy,
  • readTextFile,
  • generateSequence,
  • clean,
  • getStreamTimeCharacteristic

Popular in Java

  • Making http post requests using okhttp
  • onCreateOptionsMenu (Activity)
  • notifyDataSetChanged (ArrayAdapter)
  • setRequestProperty (URLConnection)
  • BufferedReader (java.io)
    Wraps an existing Reader and buffers the input. Expensive interaction with the underlying reader is
  • ArrayList (java.util)
    ArrayList is an implementation of List, backed by an array. All optional operations including adding
  • JList (javax.swing)
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • Runner (org.openjdk.jmh.runner)
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble
  • Top 17 PhpStorm Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now