Big data: Stream of configuring flink under Windows
What developers want most is to test in windows and then run the debugged program in a cluster. Write a Socket below, which is a local monitoring port to extract data in real time. For partners who get Chinese files and complete videos, please add QQ group: 947967114
Here is a piece of code:
Import org.apache.flink.api.java.utils.ParameterToolimport org.apache.flink.streaming.api.scala._import org.apache.flink.streaming.api.windowing.time.Timeobject SocketWindowWordCount {def main (args: Array [String]): Unit = {val port:Int=try {ParameterTool.fromArgs (args) .getInt ("port")} catch {case eVision return} val env:StreamExecutionEnvironment=StreamExecutionEnvironment.getExecutionEnvironment val text=env.socketTextStream ("localhost", port) '\ n') val windowWordCount=text.flatMap {w = > w.split ("\ s +")} .map {w = > WordWithCount (wMagne1)}. KeyBy ("word") .timewindow (Time.seconds (5), Time.seconds (1)). Sum ("count") windowWordCount.print (). SetParallelism (1) env.execute ("Socket Window WordCount")}} case class WordWithCount (word: String, count: Long) {}
There are several things to pay attention to in this program. The first org.apache.flink.streaming.api.windowing.time.Time is the use of this time package. The second is that org.apache.flink.streaming.api.scala._, should not be introduced directly into org.apache.flink.streaming.api.scala.StreamExecutionEnvironment.
Configure the nc port of windows and download nc.exe (https://eternallybored.org/misc/netcat/)) on the Internet
Select version: unzip it and put it in a specified directory. Then enter this directory in the cmd environment. For partners who get Chinese files and complete videos, please add QQ group: 947967114
Use the command to start nc to set port 9000 (nc-L-p 9000-v)
Set the input parameters in IDEA:
Specify the port-port 9000, and then run
Enter data in the Cmd port, and you can see the real-time cloud computing results in flink:
At this point, a stream configuration of flink in windows is complete. For partners who get Chinese files and complete videos, please add QQ group: 947967114