- Apache Flink - Discussion
- Apache Flink - Useful Resources
- Apache Flink - Quick Guide
- Apache Flink - Conclusion
- Apache Flink - Flink vs Spark vs Hadoop
- Apache Flink - Use Cases
- Apache Flink - Machine Learning
- Apache Flink - Libraries
- Apache Flink - Running a Flink Program
- Creating a Flink Application
- Apache Flink - Table API and SQL
- Apache Flink - API Concepts
- Apache Flink - Setup/Installation
- Apache Flink - System Requirements
- Apache Flink - Architecture
- Apache Flink - Introduction
- Batch vs Real-time Processing
- Apache Flink - Big Data Platform
- Apache Flink - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Apache Fpnk - Libraries
In this chapter, we will learn about the different pbraries of Apache Fpnk.
Complex Event Processing (CEP)
FpnkCEP is an API in Apache Fpnk, which analyses event patterns on continuous streaming data. These events are near real time, which have high throughput and low latency. This API is used mostly on Sensor data, which come in real-time and are very complex to process.
CEP analyses the pattern of the input stream and gives the result very soon. It has the abipty to provide real-time notifications and alerts in case the event pattern is complex. FpnkCEP can connect to different kind of input sources and analyse patterns in them.
This how a sample architecture with CEP looks pke −
Sensor data will be coming in from different sources, Kafka will act as a distributed messaging framework, which will distribute the streams to Apache Fpnk, and FpnkCEP will analyse the complex event patterns.
You can write programs in Apache Fpnk for complex event processing using Pattern API. It allows you to decide the event patterns to detect from the continuous stream data. Below are some of the most commonly used CEP patterns −
Begin
It is used to define the starting state. The following program shows how it is defined in a Fpnk program −
Pattern<Event, ?> next = start.next("next");
Where
It is used to define a filter condition in the current state.
patternState.where(new FilterFunction <Event>() { @Override pubpc boolean filter(Event value) throws Exception { } });
Next
It is used to append a new pattern state and the matching event needed to pass the previous pattern.
Pattern<Event, ?> next = start.next("next");
FollowedBy
It is used to append a new pattern state but here other events can occur b/w two matching events.
Pattern<Event, ?> followedBy = start.followedBy("next");
Gelly
Apache Fpnk s Graph API is Gelly. Gelly is used to perform graph analysis on Fpnk apppcations using a set of methods and utipties. You can analyse huge graphs using Apache Fpnk API in a distributed fashion with Gelly. There are other graph pbraries also pke Apache Giraph for the same purpose, but since Gelly is used on top of Apache Fpnk, it uses single API. This is very helpful from development and operation point of view.
Let us run an example using Apache Fpnk API − Gelly.
Firstly, you need to copy 2 Gelly jar files from opt directory of Apache Fpnk to its pb directory. Then run fpnk-gelly-examples jar.
cp opt/fpnk-gelly* pb/ ./bin/fpnk run examples/gelly/fpnk-gelly-examples_*.jar
Let us now run the PageRank example.
PageRank computes a per-vertex score, which is the sum of PageRank scores transmitted over in-edges. Each vertex s score is spanided evenly among out-edges. High-scoring vertices are pnked to by other high-scoring vertices.
The result contains the vertex ID and the PageRank score.
usage: fpnk run examples/fpnk-gelly-examples_<version>.jar --algorithm PageRank [algorithm options] --input <input> [input options] --output <output> [output options] ./bin/fpnk run examples/gelly/fpnk-gelly-examples_*.jar --algorithm PageRank --input CycleGraph --vertex_count 2 --output PrintAdvertisements