Class CountNewsClicks
- java.lang.Object
-
- org.apache.flink.streaming.examples.dsv2.eventtime.CountNewsClicks
-
public class CountNewsClicks extends Object
This example illustrates how to count the number of clicks on each news at 1 hour after news publication.The input consists of a series of
CountNewsClicks.NewsEvents, which fall into two categories: news publish and news click. EachCountNewsClicks.NewsEventcontains three components: the event type, the news ID and the timestamp. Notably, there is only one event of typeCountNewsClicks.NewsEventType.PUBLISHfor each news.Usage:
--output <path>The output directory where the Job will write the results. If no output path is provided, the Job will print the results tostdout.
This example shows how to:
- Usage of Event Time extension in DataStream API V2
Please note that if you intend to run this example in an IDE, you must first add the following VM options: "--add-opens=java.base/java.util=ALL-UNNAMED". This is necessary because the module system in JDK 17+ restricts some reflection operations.
Please note that the DataStream API V2 is a new set of APIs, to gradually replace the original DataStream API. It is currently in the experimental stage and is not fully available for production.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCountNewsClicks.CountNewsClicksProcessFunctionThis process function will consumeCountNewsClicks.NewsEventand count the number of clicks within 1 hour of the news publication and send the resultsCountNewsClicks.NewsClicksto the output.static classCountNewsClicks.NewsClicksTheCountNewsClicks.NewsClicksrepresents the number of clicks on news within one hour following its publication.static classCountNewsClicks.NewsEventTheCountNewsClicks.NewsEventrepresents an event on news, containing the event type, news id and the timestamp.static classCountNewsClicks.NewsEventTypeThe type ofCountNewsClicks.NewsEvent, note that only one event of typeCountNewsClicks.NewsEventType.PUBLISHfor each news.
-
Constructor Summary
Constructors Constructor Description CountNewsClicks()
-