The Codex of Business Writing Software for Real-World Solutions 2.pptx
Smarter internet of things with stream and event processing virtual io_t_meetup_20170920
1. Smarter Internet of Things with
Stream and Event Processing
Virtual IoT Meetup
September 20, 2017
András Jankó, István Papp, István Ráth
IncQuery Labs
https://www.meetup.com/Virtual-IoT/events/238648625/
2. TL; DR
• IoT / Smart home and stream / event processing 101
• IncQuery Labs Smarthome CEP demonstrator
• “CEP on the edge of the smart home”
• Educational technology showcase
• Eclipse Smarthome / OpenHAB2 - middleware
• Drools – control logic
• HomeIO – smart home simulator
• Open source (EPL v1):
https://github.com/IncQueryLabs/smarthome-cep-demonstrator
3. IoT and stream processing
Devices Data publishers
Service
platforms
Data
consumers
Collect AnalyzeStream
React
Embedded,
smart
Gateways
(Kura, …)
MQTT, Kafka,
deepstreamHub,
...
Low-level
protocols
Cloud,
enterprise,
...
Storage,
analytics, …
OR real-time
stream or event
processing
4. (Event) Stream processing vs CEP
(Event) Stream processing CEP
Data centric: aggregates, trends Event centric: “find the needle in the haystack”
Imperative to “SQL-like” languages “SQL-like” to Rule / pattern based languages
Priority: speed Priority: expressiveness
Constrained data model, simple temporal
operators (time windows)
Relaxed data model, advanced temporal
operators (before, meets, overlaps, includes,
starts, coincides)
Distributed by design, easy to scale Harder to scale
Apache Spark, Apache Storm, Apache Flink,
Heron, Kinesis, Sybase ESP, Oracle EP, TIBCO
Streambase, …
WSO2 Siddhi, Esper, Drools, IBM WS Studio
Business Events, …
Streaming analytics, monitoring, data fusion… Surveillance, predictive maintenance, Smart
manufacturing, …
5. Eclipse Smarthome and OpenHAB
Eclipse
SmartHome
Communication
IO
Config
Model
Gateway
OpenHAB
Automation
Addons
Persistence
UI
https://eclipse.org/smarthome/https://www.openhab.org/ https://www.meetup.com/Virtual-IoT/events/238648474/
6. IncQuery Labs Smart home CEP demonstrator
Drools
Fusion
Simulator
(HomeIO)
OpenHAB2
Dashboard
Complex event
processing
UI
Communication
Open source (EPL v1): https://github.com/IncQueryLabs/smarthome-cep-demonstrator
7. Motivation
• Simulator
• Make it easier to develop smart home applications
• Architecture allows for hybrid setups (simulator AND physical devices together)
• Rule-based programs
• Discrete rules, each applying to a subset of the problem focus on the essence
• Simple and flexible – best for often changing logic (e.g. quick prototyping)
• Drools Fusion - http://drools.jboss.org/drools-fusion.html
• ESH / OpenHAB2 support only simple rules by default
Drools Fusion is much more powerful
• Fits “relatively well” into the ESH / OSGi world Retains the benefits of the cloudless
smart home architecture
• Low latency, Offline operation Avoid security and privacy concerns
• Integrates easily with Java reuse components, integrate with local & remote services
• Pre-filter data on the gateway edge computing
8. Drools - ESH integration
Inference engine
Pattern matcher
Agenda
Execution
engine
Working
memory
Rule
specifications
Input
Output
Runtime model:
• ESH Item registry
save RAM by object reuse
• extended event bus
Java code
9. Smart home Hello world with Drools
rule "Example Lights Switch"
when
$item : Item( name == "Example_Light", $state : state)
ItemStateChangedEvent( name == "Example_Switch", newState ==
OPEN)
then
if ($state == ON) {
openhab.postCommand($item, OFF);
} else {
openhab.postCommand($item, ON);
}
end
ESH Item
instance with
pattern
constraints
Event bus info
– encodes
state changes
OpenHAB
helper classes
11. Summary
• Demonstrator features
• HomeIO - MQTT adapter (with OpenHAB translator)
• Extended event bus for ESH
• Drools – OSGi integration
• Case study sample rules, docs on the wiki
• JUnit tests & ESH mock
• Build with Maven+Tycho
• Plans for the future
• Support open source simulators (OpenSHS) and other CEP engines (Esper, BeepBeep3)
• Developer tools enhancements
(Oomph, Drools debugger, project & code generation with VIATRA)
• Eclipse.org contributions – if there is interest
• + your favorite enhancement – looking for contributors!
• Next presentation @ EclipseCon Europe 2017 IoT Day:
• https://www.eclipsecon.org/europe2017/session/iot-day-lightning-talks