In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
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
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.