├── Cometd
├── src
│ └── main
│ │ ├── resources
│ │ └── docker-config.yml
│ │ ├── docker
│ │ └── docker-assembly.xml
│ │ └── java
│ │ └── com
│ │ └── hortonworks
│ │ └── iot
│ │ └── cometd
│ │ └── Main.java
├── .gitignore
├── .DS_Store
├── .settings
│ └── .gitignore
├── .project
├── .classpath
└── pom.xml
├── MapUI
├── src
│ ├── main
│ │ ├── resources
│ │ │ └── docker-config.yml
│ │ ├── webapp
│ │ │ ├── WEB-INF
│ │ │ │ ├── .gitignore
│ │ │ │ └── web.xml
│ │ │ ├── .DS_Store
│ │ │ ├── images
│ │ │ │ ├── car.png
│ │ │ │ ├── 487632108.png
│ │ │ │ ├── greenMarker.png
│ │ │ │ ├── hospitalRed.png
│ │ │ │ ├── redMarker.png
│ │ │ │ ├── stb_alert.png
│ │ │ │ ├── stb_normal.png
│ │ │ │ ├── hospitalGreen.png
│ │ │ │ ├── stb_alert_25.png
│ │ │ │ ├── stb_normal_25.png
│ │ │ │ ├── hortonworks-logo-new.png
│ │ │ │ └── hortonworks-logo-green.png
│ │ │ └── css
│ │ │ │ └── mapStyle.css
│ │ ├── .DS_Store
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── hortonworks
│ │ │ │ └── iot
│ │ │ │ └── mapui
│ │ │ │ ├── MapUIMain.java
│ │ │ │ └── MapUI.java
│ │ └── docker
│ │ │ └── docker-assembly.xml
│ └── .DS_Store
├── .gitignore
├── .DS_Store
├── .settings
│ └── .gitignore
├── .classpath
├── .project
└── pom.xml
├── DeviceMonitor
├── .gitignore
├── .settings
│ └── .gitignore
├── .DS_Store
├── src
│ ├── .DS_Store
│ └── main
│ │ ├── .DS_Store
│ │ └── java
│ │ ├── .DS_Store
│ │ └── com
│ │ ├── .DS_Store
│ │ └── hortonworks
│ │ ├── .DS_Store
│ │ ├── events
│ │ ├── ExternalRequest.java
│ │ ├── DeviceStatus.java
│ │ ├── TechnicianDestination.java
│ │ ├── TechnicianDetails.java
│ │ ├── STBStatus.java
│ │ ├── DeviceAlert.java
│ │ └── TechnicianStatus.java
│ │ ├── bolts
│ │ ├── PrintDeviceAlert.java
│ │ ├── PrintDeviceStatus.java
│ │ ├── PublishAlert.java
│ │ ├── PublishTechnicianLocation.java
│ │ ├── PublishDeviceStatus.java
│ │ ├── RouteTechnician.java
│ │ ├── PersistTechnicianLocation.java
│ │ ├── IncidentDetector.java
│ │ ├── EnrichDeviceStatus.java
│ │ └── RecommendTechnician.java
│ │ ├── util
│ │ ├── DeviceEventJSONScheme.java
│ │ ├── TechnicianEventJSONScheme.java
│ │ └── Constants.java
│ │ └── iot
│ │ └── topology
│ │ └── DeviceMonitorTopology.java
├── .project
├── .classpath
└── pom.xml
├── DeviceMonitorNostradamus
├── .gitignore
├── .settings
│ └── .gitignore
├── .DS_Store
├── src
│ ├── .DS_Store
│ └── main
│ │ ├── .DS_Store
│ │ └── java
│ │ ├── .DS_Store
│ │ └── com
│ │ └── hortonworks
│ │ └── iot
│ │ ├── events
│ │ ├── DeviceStatus.java
│ │ └── STBStatus.java
│ │ └── util
│ │ └── Constants.java
├── .project
├── .classpath
└── pom.xml
├── Model
├── nostradamusSVMModel.zip
└── device_manager_svm.xml
├── screenshot
└── DeviceManagerScreenShot.png
├── stopSimulation.sh
├── Nifi
└── config
│ ├── nifi-ambari-config.json
│ ├── nifi-env.json
│ ├── nifi-flow-env.json
│ ├── nifi-bootstrap-env.json
│ ├── nifi-logback-env.json
│ └── nifi-properties-env.json
├── DEVICE_MANAGER_DEMO_CONTROL
├── package
│ └── scripts
│ │ ├── params.py
│ │ └── master.py
├── quicklinks
│ └── quicklinks.json
├── configuration
│ └── control-config.xml
└── metainfo.xml
├── SliderConfig
├── resources.json
├── appConfig.json
└── metainfo.json
├── DEVICE_MANAGER_DEMO_CONTROL_SAM
├── quicklinks
│ └── quicklinks.json
├── package
│ └── scripts
│ │ ├── params.py
│ │ └── master.py
├── configuration
│ └── control-config.xml
└── metainfo.xml
├── startSimulation.sh
├── Zeppelin
└── notebook
│ └── 2B75QB4J1
│ └── note.json
├── README.md
├── DeviceMonitorNostradamusScala
├── pom.xml
└── src
│ └── main
│ └── scala
│ └── com
│ └── hortonworks
│ └── iot
│ └── spark
│ └── streaming
│ └── SparkNostradamus.scala
└── redeployApplication.sh
/Cometd/src/main/resources/docker-config.yml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/MapUI/src/main/resources/docker-config.yml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/Cometd/.gitignore:
--------------------------------------------------------------------------------
1 | /target/
2 | /classes/
3 |
--------------------------------------------------------------------------------
/DeviceMonitor/.gitignore:
--------------------------------------------------------------------------------
1 | /target/
2 | /classes/
3 |
--------------------------------------------------------------------------------
/DeviceMonitorNostradamus/.gitignore:
--------------------------------------------------------------------------------
1 | /target/
2 | /classes/
3 |
--------------------------------------------------------------------------------
/MapUI/.gitignore:
--------------------------------------------------------------------------------
1 | /classes/
2 | /target/
3 | /tomcat.8090/
4 |
--------------------------------------------------------------------------------
/MapUI/src/main/webapp/WEB-INF/.gitignore:
--------------------------------------------------------------------------------
1 | /lib/
2 | /classes/
3 |
--------------------------------------------------------------------------------
/Cometd/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vvaks0/DeviceManagerDemo/HEAD/Cometd/.DS_Store
--------------------------------------------------------------------------------
/Cometd/.settings/.gitignore:
--------------------------------------------------------------------------------
1 | /org.eclipse.jdt.core.prefs
2 | /org.eclipse.m2e.core.prefs
3 |
--------------------------------------------------------------------------------
/MapUI/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vvaks0/DeviceManagerDemo/HEAD/MapUI/.DS_Store
--------------------------------------------------------------------------------
/DeviceMonitor/.settings/.gitignore:
--------------------------------------------------------------------------------
1 | /org.eclipse.jdt.core.prefs
2 | /org.eclipse.m2e.core.prefs
3 |
--------------------------------------------------------------------------------
/MapUI/src/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vvaks0/DeviceManagerDemo/HEAD/MapUI/src/.DS_Store
--------------------------------------------------------------------------------
/DeviceMonitor/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vvaks0/DeviceManagerDemo/HEAD/DeviceMonitor/.DS_Store
--------------------------------------------------------------------------------
/MapUI/src/main/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vvaks0/DeviceManagerDemo/HEAD/MapUI/src/main/.DS_Store
--------------------------------------------------------------------------------
/DeviceMonitorNostradamus/.settings/.gitignore:
--------------------------------------------------------------------------------
1 | /org.eclipse.jdt.core.prefs
2 | /org.eclipse.m2e.core.prefs
3 |
--------------------------------------------------------------------------------
/DeviceMonitor/src/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vvaks0/DeviceManagerDemo/HEAD/DeviceMonitor/src/.DS_Store
--------------------------------------------------------------------------------
/Model/nostradamusSVMModel.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vvaks0/DeviceManagerDemo/HEAD/Model/nostradamusSVMModel.zip
--------------------------------------------------------------------------------
/MapUI/src/main/webapp/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vvaks0/DeviceManagerDemo/HEAD/MapUI/src/main/webapp/.DS_Store
--------------------------------------------------------------------------------
/DeviceMonitor/src/main/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vvaks0/DeviceManagerDemo/HEAD/DeviceMonitor/src/main/.DS_Store
--------------------------------------------------------------------------------
/DeviceMonitorNostradamus/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vvaks0/DeviceManagerDemo/HEAD/DeviceMonitorNostradamus/.DS_Store
--------------------------------------------------------------------------------
/MapUI/.settings/.gitignore:
--------------------------------------------------------------------------------
1 | /org.eclipse.jdt.core.prefs
2 | /org.eclipse.m2e.core.prefs
3 | /org.eclipse.wst.validation.prefs
4 |
--------------------------------------------------------------------------------
/MapUI/src/main/webapp/images/car.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vvaks0/DeviceManagerDemo/HEAD/MapUI/src/main/webapp/images/car.png
--------------------------------------------------------------------------------
/DeviceMonitor/src/main/java/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vvaks0/DeviceManagerDemo/HEAD/DeviceMonitor/src/main/java/.DS_Store
--------------------------------------------------------------------------------
/DeviceMonitorNostradamus/src/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vvaks0/DeviceManagerDemo/HEAD/DeviceMonitorNostradamus/src/.DS_Store
--------------------------------------------------------------------------------
/screenshot/DeviceManagerScreenShot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vvaks0/DeviceManagerDemo/HEAD/screenshot/DeviceManagerScreenShot.png
--------------------------------------------------------------------------------
/DeviceMonitor/src/main/java/com/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vvaks0/DeviceManagerDemo/HEAD/DeviceMonitor/src/main/java/com/.DS_Store
--------------------------------------------------------------------------------
/DeviceMonitorNostradamus/src/main/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vvaks0/DeviceManagerDemo/HEAD/DeviceMonitorNostradamus/src/main/.DS_Store
--------------------------------------------------------------------------------
/MapUI/src/main/webapp/images/487632108.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vvaks0/DeviceManagerDemo/HEAD/MapUI/src/main/webapp/images/487632108.png
--------------------------------------------------------------------------------
/MapUI/src/main/webapp/images/greenMarker.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vvaks0/DeviceManagerDemo/HEAD/MapUI/src/main/webapp/images/greenMarker.png
--------------------------------------------------------------------------------
/MapUI/src/main/webapp/images/hospitalRed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vvaks0/DeviceManagerDemo/HEAD/MapUI/src/main/webapp/images/hospitalRed.png
--------------------------------------------------------------------------------
/MapUI/src/main/webapp/images/redMarker.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vvaks0/DeviceManagerDemo/HEAD/MapUI/src/main/webapp/images/redMarker.png
--------------------------------------------------------------------------------
/MapUI/src/main/webapp/images/stb_alert.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vvaks0/DeviceManagerDemo/HEAD/MapUI/src/main/webapp/images/stb_alert.png
--------------------------------------------------------------------------------
/MapUI/src/main/webapp/images/stb_normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vvaks0/DeviceManagerDemo/HEAD/MapUI/src/main/webapp/images/stb_normal.png
--------------------------------------------------------------------------------
/MapUI/src/main/webapp/images/hospitalGreen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vvaks0/DeviceManagerDemo/HEAD/MapUI/src/main/webapp/images/hospitalGreen.png
--------------------------------------------------------------------------------
/MapUI/src/main/webapp/images/stb_alert_25.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vvaks0/DeviceManagerDemo/HEAD/MapUI/src/main/webapp/images/stb_alert_25.png
--------------------------------------------------------------------------------
/MapUI/src/main/webapp/images/stb_normal_25.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vvaks0/DeviceManagerDemo/HEAD/MapUI/src/main/webapp/images/stb_normal_25.png
--------------------------------------------------------------------------------
/DeviceMonitorNostradamus/src/main/java/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vvaks0/DeviceManagerDemo/HEAD/DeviceMonitorNostradamus/src/main/java/.DS_Store
--------------------------------------------------------------------------------
/DeviceMonitor/src/main/java/com/hortonworks/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vvaks0/DeviceManagerDemo/HEAD/DeviceMonitor/src/main/java/com/hortonworks/.DS_Store
--------------------------------------------------------------------------------
/MapUI/src/main/webapp/images/hortonworks-logo-new.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vvaks0/DeviceManagerDemo/HEAD/MapUI/src/main/webapp/images/hortonworks-logo-new.png
--------------------------------------------------------------------------------
/MapUI/src/main/webapp/images/hortonworks-logo-green.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vvaks0/DeviceManagerDemo/HEAD/MapUI/src/main/webapp/images/hortonworks-logo-green.png
--------------------------------------------------------------------------------
/stopSimulation.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | kill -9 `cat STB_1000_Sim.pid`
4 | kill -9 `cat STB_2000_Sim.pid`
5 | kill -9 `cat STB_3000_Sim.pid`
6 |
7 | kill -9 `cat Technician_1000_Sim.pid`
8 | kill -9 `cat Technician_2000_Sim.pid`
9 | kill -9 `cat Technician_3000_Sim.pid`
10 |
--------------------------------------------------------------------------------
/Nifi/config/nifi-ambari-config.json:
--------------------------------------------------------------------------------
1 | "properties" : {
2 | "nifi.ambari_reporting_frequency" : "1 mins",
3 | "nifi.initial_mem" : "512m",
4 | "nifi.install_dir" : "/opt",
5 | "nifi.max_mem" : "512m",
6 | "nifi.node.protocol.port" : "9088",
7 | "nifi.port" : "9090",
8 | "nifi.setup_prebuilt" : "true"
9 | }
10 |
--------------------------------------------------------------------------------
/Nifi/config/nifi-env.json:
--------------------------------------------------------------------------------
1 | "properties" : {
2 | "content" : "\n#!/bin/sh\n\n# The java implementation to use.\nexport JAVA_HOME={{jdk64_home}}\n\nexport NIFI_HOME={{nifi_dir}}\n\n#The directory for the NiFi pid file\nexport NIFI_PID_DIR=\"{{nifi_pid_dir}}\"\n\n#The directory for NiFi log files\nexport NIFI_LOG_DIR=\"{{nifi_log_dir}}\""
3 | }
--------------------------------------------------------------------------------
/MapUI/src/main/webapp/WEB-INF/web.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/DEVICE_MANAGER_DEMO_CONTROL/package/scripts/params.py:
--------------------------------------------------------------------------------
1 |
2 | #!/usr/bin/env python
3 | from resource_management import *
4 |
5 | # server configurations
6 | config = Script.get_config()
7 |
8 | install_dir = config['configurations']['control-config']['democontrol.install_dir']
9 | download_url = config['configurations']['control-config']['democontrol.download_url']
10 | nifi_host_ip = config['configurations']['control-config']['democontrol.nifi_host_ip']
11 |
--------------------------------------------------------------------------------
/SliderConfig/resources.json:
--------------------------------------------------------------------------------
1 | {
2 | "schema": "http://example.org/specification/v2.0.0",
3 | "metadata": { },
4 | "global": { },
5 | "components": {"slider-appmaster": { },
6 | "MAPUI": {
7 | "yarn.role.priority": "1",
8 | "yarn.component.instances": "1",
9 | "yarn.memory": "256"
10 | },
11 | "COMETD": {
12 | "yarn.role.priority": "2",
13 | "yarn.component.instances": "1",
14 | "yarn.memory": "256"
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/MapUI/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/MapUI/src/main/java/com/hortonworks/iot/mapui/MapUIMain.java:
--------------------------------------------------------------------------------
1 | package com.hortonworks.iot.mapui;
2 |
3 | import org.apache.catalina.startup.Tomcat;
4 |
5 | public class MapUIMain{
6 | public static void main(String [] args) throws Exception {
7 | //String contextPath = "/";
8 | String appBase = ".";
9 |
10 | Tomcat tomcat = new Tomcat();
11 | tomcat.setPort(Integer.parseInt("8090"));
12 | tomcat.getHost().setAppBase(appBase);
13 | tomcat.addWebapp("/MapUI", appBase);
14 |
15 | tomcat.start();
16 | tomcat.getServer().await();
17 | }
18 | }
--------------------------------------------------------------------------------
/DEVICE_MANAGER_DEMO_CONTROL/quicklinks/quicklinks.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "default",
3 | "description": "default quick links configuration",
4 | "configuration": {
5 | "protocol":
6 | {
7 | "type":"http",
8 | "checks":[]
9 | },
10 |
11 | "links": [
12 | {
13 | "name": "device_manager_map_ui",
14 | "label": "Device Manager Map UI",
15 | "requires_user_name": "false",
16 | "component_name": "NIFI_MASTER",
17 | "url":"%@://%@:%@/MapUI/DeviceMap",
18 | "port":{
19 | "http_default_port": "8090"
20 | }
21 | }
22 | ]
23 | }
24 | }
--------------------------------------------------------------------------------
/DEVICE_MANAGER_DEMO_CONTROL_SAM/quicklinks/quicklinks.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "default",
3 | "description": "default quick links configuration",
4 | "configuration": {
5 | "protocol":
6 | {
7 | "type":"http",
8 | "checks":[]
9 | },
10 |
11 | "links": [
12 | {
13 | "name": "device_manager_map_ui",
14 | "label": "Device Manager Map UI",
15 | "requires_user_name": "false",
16 | "component_name": "NIFI_MASTER",
17 | "url":"%@://%@:%@/MapUI/DeviceMap",
18 | "port":{
19 | "http_default_port": "8090"
20 | }
21 | }
22 | ]
23 | }
24 | }
--------------------------------------------------------------------------------
/Cometd/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | Cometd
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.m2e.core.maven2Builder
15 |
16 |
17 |
18 |
19 |
20 | org.eclipse.jdt.core.javanature
21 | org.eclipse.m2e.core.maven2Nature
22 |
23 |
24 |
--------------------------------------------------------------------------------
/DeviceMonitor/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | DeviceMonitor
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.m2e.core.maven2Builder
15 |
16 |
17 |
18 |
19 |
20 | org.eclipse.jdt.core.javanature
21 | org.eclipse.m2e.core.maven2Nature
22 |
23 |
24 |
--------------------------------------------------------------------------------
/MapUI/src/main/docker/docker-assembly.xml:
--------------------------------------------------------------------------------
1 |
3 | ${project.artifactId}
4 |
5 |
6 | target/MapUI-jar-with-dependencies.jar
7 | /
8 |
9 |
10 | src/main/resources/docker-config.yml
11 | /
12 |
13 |
14 |
--------------------------------------------------------------------------------
/Cometd/src/main/docker/docker-assembly.xml:
--------------------------------------------------------------------------------
1 |
3 | ${project.artifactId}
4 |
5 |
6 | target/Cometd-jar-with-dependencies.jar
7 | /
8 |
9 |
10 | src/main/resources/docker-config.yml
11 | /
12 |
13 |
14 |
--------------------------------------------------------------------------------
/DeviceMonitorNostradamus/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | DeviceMonitorNostradamus
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.m2e.core.maven2Builder
15 |
16 |
17 |
18 |
19 |
20 | org.eclipse.jdt.core.javanature
21 | org.eclipse.m2e.core.maven2Nature
22 |
23 |
24 |
--------------------------------------------------------------------------------
/SliderConfig/appConfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "schema": "http://example.org/specification/v2.0.0",
3 | "metadata": {},
4 | "global": {},
5 | "components": {
6 | "MAPUI": {
7 | "mapui.commandPath": "/usr/bin/docker",
8 | "mapui.options":"-d --net=host",
9 | "mapui.statusCommand":"docker inspect -f {{.State.Running}} ${CONTAINER_ID} | grep true"
10 | },
11 | "COMETD": {
12 | "cometd.commandPath": "/usr/bin/docker",
13 | "cometd.options":"-d --net=host",
14 | "cometd.statusCommand":"docker inspect -f {{.State.Running}} ${CONTAINER_ID} | grep true"
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/DeviceMonitor/src/main/java/com/hortonworks/events/ExternalRequest.java:
--------------------------------------------------------------------------------
1 | package com.hortonworks.events;
2 |
3 | import java.io.Serializable;
4 |
5 | public class ExternalRequest implements Serializable {
6 | private static final long serialVersionUID = 1L;
7 | private String serialNumber;
8 | private String command;
9 |
10 | public ExternalRequest() {}
11 |
12 | public void setDeviceSerialNumber(String value){
13 | serialNumber = value;
14 | }
15 |
16 | public String getDeviceSerialNumber(){
17 | return serialNumber;
18 | }
19 |
20 | public void setCommand(String value){
21 | command = value;
22 | }
23 |
24 | public String getCommand(){
25 | return command;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/DEVICE_MANAGER_DEMO_CONTROL_SAM/package/scripts/params.py:
--------------------------------------------------------------------------------
1 |
2 | #!/usr/bin/env python
3 | from resource_management import *
4 |
5 | # server configurations
6 | config = Script.get_config()
7 |
8 | install_dir = config['configurations']['control-config']['democontrol.install.dir']
9 | simulator_download_url = config['configurations']['control-config']['democontrol.simulator.git.url']
10 | device_manager_download_url = config['configurations']['control-config']['democontrol.device.manager.git.url']
11 | sam_extentions_download_url = config['configurations']['control-config']['democontrol.sam.extentions.git.url']
12 | google_api_key = config['configurations']['control-config']['democontrol.google.api.key']
13 |
14 | nifi_host = str(config['clusterHostInfo']['nifi_master_hosts'][0])
15 | nifi_port = '9090'
16 |
17 |
--------------------------------------------------------------------------------
/DeviceMonitor/src/main/java/com/hortonworks/events/DeviceStatus.java:
--------------------------------------------------------------------------------
1 | package com.hortonworks.events;
2 |
3 | import java.io.Serializable;
4 |
5 | public class DeviceStatus implements Serializable {
6 | private static final long serialVersionUID = 1L;
7 | private String serialNumber;
8 | private String status;
9 | private String state;
10 |
11 | public void setSerialNumber(String value){
12 | serialNumber = value;
13 | }
14 | public void setState(String value){
15 | state = value;
16 | }
17 | public void setStatus(String value){
18 | status = value;
19 | }
20 |
21 | public String getSerialNumber(){
22 | return serialNumber;
23 | }
24 | public String getState(){
25 | return state;
26 | }
27 | public String getStatus(){
28 | return status;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/DeviceMonitor/src/main/java/com/hortonworks/events/TechnicianDestination.java:
--------------------------------------------------------------------------------
1 | package com.hortonworks.events;
2 |
3 | public class TechnicianDestination extends TechnicianStatus {
4 | private static final long serialVersionUID = 1L;
5 | private Double destinationLatitude;
6 | private Double destinationLongitude;
7 |
8 | public TechnicianDestination() {
9 | super();
10 | }
11 |
12 | public void setDestinationLongitude(Double value){
13 | destinationLongitude = value;
14 | }
15 | public void setDestinationLatitude(Double value){
16 | destinationLatitude = value;
17 | }
18 |
19 | public Double getDestinationLongitude(){
20 | return destinationLongitude;
21 | }
22 | public Double getDestinationLatitude(){
23 | return destinationLatitude;
24 | }
25 | }
--------------------------------------------------------------------------------
/MapUI/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | MapUI
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.wst.common.project.facet.core.builder
15 |
16 |
17 |
18 |
19 | org.eclipse.m2e.core.maven2Builder
20 |
21 |
22 |
23 |
24 |
25 | org.eclipse.jdt.core.javanature
26 | org.eclipse.m2e.core.maven2Nature
27 | org.eclipse.wst.common.project.facet.core.nature
28 |
29 |
30 |
--------------------------------------------------------------------------------
/DeviceMonitorNostradamus/src/main/java/com/hortonworks/iot/events/DeviceStatus.java:
--------------------------------------------------------------------------------
1 | package com.hortonworks.iot.events;
2 |
3 | import java.io.Serializable;
4 |
5 | public class DeviceStatus implements Serializable {
6 | private static final long serialVersionUID = 1L;
7 | private String serialNumber;
8 | private String status;
9 | private String state;
10 |
11 | public void setSerialNumber(String value){
12 | serialNumber = value;
13 | }
14 | public void setState(String value){
15 | state = value;
16 | }
17 | public void setStatus(String value){
18 | status = value;
19 | }
20 |
21 | public String getSerialNumber(){
22 | return serialNumber;
23 | }
24 | public String getState(){
25 | return state;
26 | }
27 | public String getStatus(){
28 | return status;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/DEVICE_MANAGER_DEMO_CONTROL/configuration/control-config.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | democontrol.install_dir
8 | /root
9 | Directory under which demo control utility will be installed
10 |
11 |
12 |
13 |
14 | democontrol.download_url
15 | https://github.com/vakshorton/DataSimulators.git
16 | Online location to download Simulator package
17 |
18 |
19 |
20 | democontrol.nifi_host_ip
21 |
22 | IP address of host where Nifi is listening
23 |
24 |
--------------------------------------------------------------------------------
/DeviceMonitor/src/main/java/com/hortonworks/events/TechnicianDetails.java:
--------------------------------------------------------------------------------
1 | package com.hortonworks.events;
2 |
3 | import java.io.Serializable;
4 |
5 | //import java.util.HashMap;
6 | //import java.util.Map;
7 |
8 | public class TechnicianDetails extends TechnicianStatus implements Serializable {
9 | private static final long serialVersionUID = 1L;
10 | private Integer yearsExperience;
11 | private Integer rating;
12 | //private Map parts = new HashMap();
13 | public TechnicianDetails() {
14 | super();
15 | }
16 |
17 | public Integer getYearsExperience(){
18 | return yearsExperience;
19 | }
20 | public Integer getRating(){
21 | return rating;
22 | }
23 | public void setYearsExperience(Integer value){
24 | yearsExperience = value;
25 | }
26 | public void setRating(Integer value){
27 | rating = value;
28 | }
29 | }
--------------------------------------------------------------------------------
/SliderConfig/metainfo.json:
--------------------------------------------------------------------------------
1 | {
2 | "schemaVersion": "2.1",
3 | "application": {
4 | "name": "MAPUI",
5 | "components": [
6 | {
7 | "name": "MAPUI",
8 | "type": "docker",
9 | "dockerContainers": [
10 | {
11 | "name": "mapui",
12 | "commandPath": "/usr/bin/docker",
13 | "image": "vvaks/mapui",
14 | "ports": [{"containerPort" : "8090"}]
15 | }
16 | ]
17 | },
18 | {
19 | "name": "COMETD",
20 | "type": "docker",
21 | "dockerContainers": [
22 | {
23 | "name": "cometd",
24 | "commandPath": "/usr/bin/docker",
25 | "image": "vvaks/cometd",
26 | "ports": [{"containerPort" : "8091"}]
27 | }
28 | ]
29 | }
30 | ]
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/Nifi/config/nifi-flow-env.json:
--------------------------------------------------------------------------------
1 | "properties" : {
2 | "content" : "\n\n 10\n 5\n \n 7c84501d-d10c-407c-b9f3-1d80e38fe36a\n NiFi Flow\n \n \n \n \n \n \n 3b80ba0f-a6c0-48db-b721-4dbc04cef28e\n AmbariReportingTask\n \n org.apache.nifi.reporting.ambari.AmbariReportingTask\n {{nifi_ambari_reporting_frequency}}\n RUNNING\n TIMER_DRIVEN\n \n Metrics Collector URL\n ${ambari.metrics.collector.url}\n \n \n Application ID\n ${ambari.application.id}\n \n \n Hostname\n ${hostname(true)}\n \n \n \n"
3 | }
--------------------------------------------------------------------------------
/Cometd/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/DeviceMonitor/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/DeviceMonitor/src/main/java/com/hortonworks/events/STBStatus.java:
--------------------------------------------------------------------------------
1 | package com.hortonworks.events;
2 |
3 | import java.io.Serializable;
4 |
5 | import com.hortonworks.events.DeviceStatus;
6 |
7 | public class STBStatus extends DeviceStatus implements Serializable {
8 | private static final long serialVersionUID = 1L;
9 | private String deviceModel;
10 | private Integer internalTemp;
11 | private Integer signalStrength;
12 | private Double latitude;
13 | private Double longitude;
14 |
15 | public void setDeviceModel(String value){
16 | deviceModel = value;
17 | }
18 | public void setInternalTemp(Integer value){
19 | internalTemp = value;
20 | }
21 | public void setSignalStrength(Integer value){
22 | signalStrength = value;
23 | }
24 | public void setLatitude(Double value){
25 | latitude = value;
26 | }
27 | public void setLongitude(Double value){
28 | longitude = value;
29 | }
30 |
31 | public String getDeviceModel(){
32 | return deviceModel;
33 | }
34 | public Integer getInternalTemp(){
35 | return internalTemp;
36 | }
37 | public Integer getSignalStrength(){
38 | return signalStrength;
39 | }
40 | public Double getLatitude(){
41 | return latitude;
42 | }
43 | public Double getLongitude(){
44 | return longitude;
45 | }
46 | }
--------------------------------------------------------------------------------
/DeviceMonitorNostradamus/src/main/java/com/hortonworks/iot/events/STBStatus.java:
--------------------------------------------------------------------------------
1 | package com.hortonworks.iot.events;
2 |
3 | import java.io.Serializable;
4 |
5 | import com.hortonworks.iot.events.DeviceStatus;
6 |
7 | public class STBStatus extends DeviceStatus implements Serializable {
8 | private static final long serialVersionUID = 1L;
9 | private String deviceModel;
10 | private Integer internalTemp;
11 | private Integer signalStrength;
12 | private Double latitude;
13 | private Double longitude;
14 |
15 | public void setDeviceModel(String value){
16 | deviceModel = value;
17 | }
18 | public void setInternalTemp(Integer value){
19 | internalTemp = value;
20 | }
21 | public void setSignalStrength(Integer value){
22 | signalStrength = value;
23 | }
24 | public void setLatitude(Double value){
25 | latitude = value;
26 | }
27 | public void setLongitude(Double value){
28 | longitude = value;
29 | }
30 |
31 | public String getDeviceModel(){
32 | return deviceModel;
33 | }
34 | public Integer getInternalTemp(){
35 | return internalTemp;
36 | }
37 | public Integer getSignalStrength(){
38 | return signalStrength;
39 | }
40 | public Double getLatitude(){
41 | return latitude;
42 | }
43 | public Double getLongitude(){
44 | return longitude;
45 | }
46 | }
--------------------------------------------------------------------------------
/DeviceMonitor/src/main/java/com/hortonworks/events/DeviceAlert.java:
--------------------------------------------------------------------------------
1 | package com.hortonworks.events;
2 |
3 | import java.io.Serializable;
4 |
5 | public class DeviceAlert implements Serializable {
6 | private static final long serialVersionUID = 1L;
7 | private String serialNumber;
8 | private String deviceModel;
9 | private String alertDescription;
10 | private Double longitude;
11 | private Double latitude;
12 |
13 | public DeviceAlert() {}
14 |
15 | public void setSerialNumber(String value){
16 | serialNumber = value;
17 | }
18 | public void setDeviceModel(String value){
19 | deviceModel = value;
20 | }
21 | public void setAlertDescription(String value){
22 | alertDescription = value;
23 | }
24 | public void setLongitude(Double value){
25 | longitude = value;
26 | }
27 | public void setLatitude(Double value){
28 | latitude = value;
29 | }
30 |
31 | public String getSerialNumber(){
32 | return serialNumber;
33 | }
34 | public String getDeviceModel(){
35 | return deviceModel;
36 | }
37 | public String getAlertDescription(){
38 | return alertDescription;
39 | }
40 | public Double getLongitude(){
41 | return longitude;
42 | }
43 | public Double getLatitude(){
44 | return latitude;
45 | }
46 | }
--------------------------------------------------------------------------------
/DeviceMonitorNostradamus/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/DEVICE_MANAGER_DEMO_CONTROL_SAM/configuration/control-config.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | democontrol.install.dir
8 | /root
9 | Directory under which demo control utility will be installed
10 |
11 |
12 |
13 | democontrol.device.manager.git.url
14 | https://github.com/vakshorton/DeviceManagerDemo.git
15 | Online location to download Device Manager Application
16 |
17 |
18 |
19 | democontrol.sam.extentions.git.url
20 | https://github.com/vakshorton/sam-custom-extensions.git
21 | Online location to download SAM custom extentions
22 |
23 |
24 |
25 | democontrol.simulator.git.url
26 | https://github.com/vakshorton/DataSimulators.git
27 | Online location to download Simulator package
28 |
29 |
30 |
31 | democontrol.google.api.key
32 |
33 | PASSWORD
34 | Google API Key used to enable Map in Device Manager UI
35 |
36 | password
37 |
38 |
39 |
--------------------------------------------------------------------------------
/DEVICE_MANAGER_DEMO_CONTROL/metainfo.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 2.0
4 |
5 |
6 | DEVICE_MANAGER_DEMO_CONTROL
7 | Device Manager Demo Control
8 | Utility to start and stop Device and Technician event generator for the Device Manager Demo
9 | 0.1.0
10 |
11 |
12 | DEVICE_MANAGER_DEMO_CONTROL
13 | Device Manager Demo Control
14 | MASTER
15 | 1
16 |
17 |
18 | PYTHON
19 | 600
20 |
21 |
22 |
23 |
24 |
25 | any
26 |
27 |
28 |
29 | control-config
30 |
31 | false
32 |
33 |
34 | quicklinks.json
35 | true
36 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/DEVICE_MANAGER_DEMO_CONTROL_SAM/metainfo.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 2.0
4 |
5 |
6 | DEVICE_MANAGER_DEMO_CONTROL
7 | Device Manager Demo Control
8 | Utility to start and stop Device and Technician event generator for the Device Manager Demo
9 | 0.1.0
10 |
11 |
12 | DEVICE_MANAGER_DEMO_CONTROL
13 | Device Manager Demo Control
14 | MASTER
15 | 1
16 |
17 |
18 | PYTHON
19 | 600
20 |
21 |
22 |
23 |
24 |
25 | any
26 |
27 |
28 |
29 | control-config
30 |
31 | false
32 |
33 |
34 | quicklinks.json
35 | true
36 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/DeviceMonitor/src/main/java/com/hortonworks/events/TechnicianStatus.java:
--------------------------------------------------------------------------------
1 | package com.hortonworks.events;
2 |
3 | import java.io.Serializable;
4 |
5 | public class TechnicianStatus implements Serializable {
6 | private static final long serialVersionUID = 1L;
7 | private String technicianId;
8 | private Double longitude;
9 | private Double latitude;
10 | private String status;
11 | private String ipaddress;
12 | private String port;
13 | private String eventType;
14 |
15 | public TechnicianStatus() {}
16 |
17 | public void setTechnicianId(String value){
18 | technicianId = value;
19 | }
20 | public void setLongitude(Double value){
21 | longitude = value;
22 | }
23 | public void setLatitude(Double value){
24 | latitude = value;
25 | }
26 | public void setStatus(String value){
27 | status = value;
28 | }
29 | public void setIpAddress(String value){
30 | ipaddress = value;
31 | }
32 | public void setPort(String value){
33 | port = value;
34 | }
35 | public void setEventType(String value){
36 | eventType = value;
37 | }
38 | public String getTechnicianId(){
39 | return technicianId;
40 | }
41 | public Double getLongitude(){
42 | return longitude;
43 | }
44 | public Double getLatitude(){
45 | return latitude;
46 | }
47 | public String getStatus(){
48 | return status;
49 | }
50 | public String getIpAddress(){
51 | return ipaddress;
52 | }
53 | public String getPort(){
54 | return port;
55 | }
56 | public String getEventType(){
57 | return eventType;
58 | }
59 | }
--------------------------------------------------------------------------------
/DeviceMonitor/src/main/java/com/hortonworks/bolts/PrintDeviceAlert.java:
--------------------------------------------------------------------------------
1 | package com.hortonworks.bolts;
2 |
3 | import java.util.Map;
4 |
5 | import com.hortonworks.events.DeviceAlert;
6 |
7 | import org.apache.storm.task.OutputCollector;
8 | import org.apache.storm.task.TopologyContext;
9 | import org.apache.storm.topology.OutputFieldsDeclarer;
10 | import org.apache.storm.topology.base.BaseRichBolt;
11 | import org.apache.storm.tuple.Fields;
12 | import org.apache.storm.tuple.Tuple;
13 | import org.apache.storm.tuple.Values;
14 |
15 | /*
16 | import backtype.storm.task.OutputCollector;
17 | import backtype.storm.task.TopologyContext;
18 | import backtype.storm.topology.OutputFieldsDeclarer;
19 | import backtype.storm.topology.base.BaseRichBolt;
20 | import backtype.storm.tuple.Fields;
21 | import backtype.storm.tuple.Tuple;
22 | import backtype.storm.tuple.Values;
23 | */
24 |
25 | public class PrintDeviceAlert extends BaseRichBolt {
26 | private static final long serialVersionUID = 1L;
27 | private OutputCollector collector;
28 |
29 | public void execute(Tuple tuple) {
30 | DeviceAlert deviceAlert = (DeviceAlert) tuple.getValueByField("DeviceAlert");
31 | System.out.println("ALERT******");
32 | System.out.println("Device Serial Number: " + deviceAlert.getSerialNumber());
33 | System.out.println("Device Model: " + deviceAlert.getDeviceModel());
34 | System.out.println("Incident Description: " + deviceAlert.getAlertDescription());
35 | System.out.println("Device Lat: " + deviceAlert.getLatitude());
36 | System.out.println("Device Lng: " + deviceAlert.getLongitude());
37 |
38 | collector.emit(tuple, new Values((DeviceAlert)deviceAlert));
39 | collector.ack(tuple);
40 | }
41 |
42 | public void prepare(Map arg0, TopologyContext arg1, OutputCollector collector) {
43 | this.collector = collector;
44 | }
45 |
46 | public void declareOutputFields(OutputFieldsDeclarer declarer) {
47 | declarer.declare(new Fields("DeviceAlert"));
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/DeviceMonitor/src/main/java/com/hortonworks/bolts/PrintDeviceStatus.java:
--------------------------------------------------------------------------------
1 | package com.hortonworks.bolts;
2 |
3 | import java.util.Map;
4 |
5 | import com.hortonworks.events.STBStatus;
6 |
7 | import org.apache.storm.task.OutputCollector;
8 | import org.apache.storm.task.TopologyContext;
9 | import org.apache.storm.topology.OutputFieldsDeclarer;
10 | import org.apache.storm.topology.base.BaseRichBolt;
11 | import org.apache.storm.tuple.Fields;
12 | import org.apache.storm.tuple.Tuple;
13 | import org.apache.storm.tuple.Values;
14 |
15 | /*
16 | import backtype.storm.task.OutputCollector;
17 | import backtype.storm.task.TopologyContext;
18 | import backtype.storm.topology.OutputFieldsDeclarer;
19 | import backtype.storm.topology.base.BaseRichBolt;
20 | import backtype.storm.tuple.Fields;
21 | import backtype.storm.tuple.Tuple;
22 | import backtype.storm.tuple.Values;
23 | */
24 |
25 | public class PrintDeviceStatus extends BaseRichBolt {
26 | private static final long serialVersionUID = 1L;
27 | private OutputCollector collector;
28 |
29 | public void execute(Tuple tuple) {
30 | STBStatus deviceStatus = (STBStatus) tuple.getValueByField("DeviceStatus");
31 | System.out.println("Device Serial Number: " + deviceStatus.getSerialNumber());
32 | System.out.println("State: " + deviceStatus.getState());
33 | System.out.println("Status: " + deviceStatus.getStatus());
34 | System.out.println("Internal Temp: " + deviceStatus.getInternalTemp());
35 | System.out.println("Signal Strength: " + deviceStatus.getSignalStrength());
36 | System.out.println("Device Model: " + deviceStatus.getDeviceModel());
37 | System.out.println("Latitude: " + deviceStatus.getLatitude());
38 | System.out.println("Longitude: " + deviceStatus.getLongitude());
39 | //collector.emit(tuple, new Values((DeviceStatus)deviceStatus));
40 | collector.ack(tuple);
41 | }
42 |
43 | public void prepare(Map arg0, TopologyContext arg1, OutputCollector collector) {
44 | this.collector = collector;
45 | }
46 |
47 | public void declareOutputFields(OutputFieldsDeclarer declarer) {
48 | declarer.declare(new Fields("DeviceStatus"));
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/startSimulation.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | export AMBARI_HOST=$(hostname -f)
4 |
5 | export CLUSTER_NAME=$(curl -u admin:admin -X GET http://$AMBARI_HOST:8080/api/v1/clusters |grep cluster_name|grep -Po ': "(.+)'|grep -Po '[a-zA-Z0-9!$\-]+')
6 |
7 | if [[ -z $CLUSTER_NAME ]]; then
8 | echo "Could not connect to Ambari Server. Please run this script on the same host where Ambari Server is installed."
9 | exit 1
10 | else
11 | echo "*********************************CLUSTER NAME IS: $CLUSTER_NAME"
12 | fi
13 |
14 | getNifiHost () {
15 | NIFI_HOST=$(curl -u admin:admin -X GET http://$AMBARI_HOST:8080/api/v1/clusters/$CLUSTER_NAME/services/NIFI/components/NIFI_MASTER|grep "host_name"|grep -Po ': "([a-zA-Z0-9\-_!?.]+)'|grep -Po '([a-zA-Z0-9\-_!?.]+)')
16 |
17 | echo $NIFI_HOST
18 | }
19 |
20 | NIFI_HOST=$(getNifiHost)
21 | NIFI_HOST_IP=$(getent hosts $NIFI_HOST | awk '{ print $1 }')
22 |
23 | echo "*********************************NIFI HOST: $NIFI_HOST"
24 | echo "*********************************NIFI HOST IP: $NIFI_HOST_IP"
25 |
26 | echo "*********************************Starting Set Top Box Simulations..."
27 | nohup java -jar DeviceSimulator-0.0.1-SNAPSHOT-jar-with-dependencies.jar STB 1000 Simulation $NIFI_HOST_IP > STB_1000_Sim.log 2>&1&
28 | echo $! > STB_1000_Sim.pid
29 |
30 | nohup java -jar DeviceSimulator-0.0.1-SNAPSHOT-jar-with-dependencies.jar STB 2000 Simulation $NIFI_HOST_IP > STB_2000_Sim.log 2>&1&
31 | echo $! > STB_2000_Sim.pid
32 |
33 | nohup java -jar DeviceSimulator-0.0.1-SNAPSHOT-jar-with-dependencies.jar STB 3000 Simulation $NIFI_HOST_IP > STB_3000_Sim.log 2>&1&
34 | echo $! > STB_3000_Sim.pid
35 |
36 | echo "*********************************Starting Technician Simulations..."
37 | nohup java -jar DeviceSimulator-0.0.1-SNAPSHOT-jar-with-dependencies.jar Technician 1000 Simulation $NIFI_HOST_IP > Technician_1000_Sim.log 2>&1&
38 | echo $! > Technician_1000_Sim.pid
39 |
40 | nohup java -jar DeviceSimulator-0.0.1-SNAPSHOT-jar-with-dependencies.jar Technician 2000 Simulation $NIFI_HOST_IP > Technician_2000_Sim.log 2>&1&
41 | echo $! > Technician_2000_Sim.pid
42 |
43 | nohup java -jar DeviceSimulator-0.0.1-SNAPSHOT-jar-with-dependencies.jar Technician 3000 Simulation $NIFI_HOST_IP > Technician_3000_Sim.log 2>&1&
44 | echo $! > Technician_3000_Sim.pid
45 |
46 | exit 0
--------------------------------------------------------------------------------
/Cometd/src/main/java/com/hortonworks/iot/cometd/Main.java:
--------------------------------------------------------------------------------
1 | package com.hortonworks.iot.cometd;
2 |
3 | import java.util.Map;
4 |
5 | import org.cometd.bayeux.server.BayeuxServer;
6 | import org.cometd.bayeux.server.ConfigurableServerChannel;
7 | import org.cometd.bayeux.server.ServerChannel;
8 | import org.cometd.server.CometDServlet;
9 | import org.eclipse.jetty.server.Server;
10 | import org.eclipse.jetty.servlet.ServletContextHandler;
11 | import org.eclipse.jetty.servlet.ServletHolder;
12 |
13 | public class Main {
14 |
15 | public static void main(String[] args) throws Exception {
16 | // Configure Jetty
17 | Integer cometdListenPort = 8091;
18 | Map env = System.getenv();
19 | System.out.println("********************** ENV: " + env);
20 | if(env.get("COMETD_PORT") != null){
21 | cometdListenPort = Integer.valueOf((String)env.get("COMETD_PORT"));
22 | }
23 |
24 | System.out.println("********************** Cometd Port: " + cometdListenPort);
25 | Server server = new Server(cometdListenPort);
26 |
27 | ServletContextHandler webAppContext = new ServletContextHandler(ServletContextHandler.SESSIONS);
28 | webAppContext.setContextPath("/");
29 |
30 | System.out.println("Loading Cometd PubSub.....");
31 | // Configure Cometd
32 | CometDServlet cometdServlet = new CometDServlet();
33 | webAppContext.addServlet(new ServletHolder(cometdServlet), "/cometd/*");
34 | server.setHandler(webAppContext);
35 |
36 | System.out.println("Starting Jetty Server.....");
37 | // Start Jetty
38 | server.start();
39 |
40 | System.out.println("Creating PubSub Topics.....");
41 | // Create channels to publish on
42 | BayeuxServer bayeux = cometdServlet.getBayeux();
43 | createChannel(bayeux, "/devicestatus");
44 | createChannel(bayeux, "/technicianstatus");
45 | createChannel(bayeux, "/alert");
46 | createChannel(bayeux, "/prediction");
47 | createChannel(bayeux, "/fraudAlert");
48 | createChannel(bayeux, "/incomingTransactions");
49 | createChannel(bayeux, "/accountStatusUpdate");
50 | createChannel(bayeux, "/bioReactorStatus");
51 | createChannel(bayeux, "/filtrationStatus");
52 | createChannel(bayeux, "/sentiment");
53 | //final ServerChannel channel = bayeux.getChannel("");
54 |
55 | server.join();
56 | }
57 |
58 | public static void createChannel(BayeuxServer bayeux, String channelName){
59 | bayeux.createChannelIfAbsent(channelName, new ServerChannel.Initializer()
60 | {
61 | public void configureChannel(ConfigurableServerChannel channel)
62 | {
63 | channel.setPersistent(true);
64 | System.out.println(channel.getChannelId());
65 | }
66 | });
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/Zeppelin/notebook/2B75QB4J1/note.json:
--------------------------------------------------------------------------------
1 | {
2 | "paragraphs": [
3 | {
4 | "text": "%dep\nz.load(\"org.apache.spark:spark-streaming-kafka_2.10:1.5.2\")",
5 | "dateUpdated": "Dec 16, 2015 10:48:58 PM",
6 | "config": {
7 | "colWidth": 12.0,
8 | "graph": {
9 | "mode": "table",
10 | "height": 300.0,
11 | "optionOpen": false,
12 | "keys": [],
13 | "values": [],
14 | "groups": [],
15 | "scatter": {}
16 | },
17 | "editorMode": "ace/mode/scala"
18 | },
19 | "settings": {
20 | "params": {},
21 | "forms": {}
22 | },
23 | "jobName": "paragraph_1450305854262_-641518226",
24 | "id": "20151216-224414_1407033887",
25 | "result": {
26 | "code": "SUCCESS",
27 | "type": "TEXT",
28 | "msg": "res0: org.apache.zeppelin.spark.dep.Dependency \u003d org.apache.zeppelin.spark.dep.Dependency@299aef85\n"
29 | },
30 | "dateCreated": "Dec 16, 2015 10:44:14 PM",
31 | "dateStarted": "Dec 16, 2015 10:48:58 PM",
32 | "dateFinished": "Dec 16, 2015 10:49:37 PM",
33 | "status": "FINISHED",
34 | "progressUpdateIntervalMs": 500
35 | },
36 | {
37 | "text": "import org.apache.spark.streaming.kafka._\n \nval kafkaStream \u003d KafkaUtils.createStream(streamingContext, \"localhost:2181\", [consumer group id], [per-topic number of Kafka partitions to consume])",
38 | "dateUpdated": "Dec 16, 2015 10:52:37 PM",
39 | "config": {
40 | "colWidth": 12.0,
41 | "graph": {
42 | "mode": "table",
43 | "height": 300.0,
44 | "optionOpen": false,
45 | "keys": [],
46 | "values": [],
47 | "groups": [],
48 | "scatter": {}
49 | },
50 | "editorMode": "ace/mode/scala"
51 | },
52 | "settings": {
53 | "params": {},
54 | "forms": {}
55 | },
56 | "jobName": "paragraph_1450305904843_828699266",
57 | "id": "20151216-224504_2103656662",
58 | "dateCreated": "Dec 16, 2015 10:45:04 PM",
59 | "status": "READY",
60 | "progressUpdateIntervalMs": 500
61 | }
62 | ],
63 | "name": "Device Management Spark Streaming",
64 | "id": "2B75QB4J1",
65 | "angularObjects": {
66 | "2B9EDS7RX": [],
67 | "2B8V224NM": [],
68 | "2B5YUQKT8": [],
69 | "2B8JH2674": [],
70 | "2B8AE3SQC": [],
71 | "2B8RDV9CU": [],
72 | "2B6XJD72P": [],
73 | "2B889XZ5W": [],
74 | "2B5SJ7RSF": [],
75 | "2B8WH294Q": [],
76 | "2B7K5YMG2": [],
77 | "2B7Y9ZUR6": [],
78 | "2B5Y3SDHE": [],
79 | "2B8B5C112": []
80 | },
81 | "config": {},
82 | "info": {}
83 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # DeviceManagerDemo
2 | The Device Manager Demo is designed to demonstrate a fully functioning modern Data/IoT application.
3 | It is a Lambda architecture built using the Hortonworks Data Platform and Hortonworks Data Flow.
4 | The demo shows how a Telecom can manage customer device outages using predictive maintenance and a connected workforce.
5 |
6 | # Install DeviceManagerDemo
7 | Download and Import Hortonworks Sandbox 2.4 for Virtual Box.
8 |
9 | Should work with VMWare but has not been tested.
10 |
11 | Modify local hosts file so that sandbox.hortonworks.com resolves to 127.0.0.1 (This is important and may break the simulator and UI)
12 |
13 | Configure Virtual Box Port Forward
14 |
15 | 8082 – HDF_HTTP_Ingest
16 |
17 | 8090 - MapUI
18 |
19 | 8091 - Cometd
20 |
21 | 9090 – HDF_Studio
22 |
23 | Start Sandbox, SSH to Sandbox (ssh root@sandbox.hortonworks.com -p 2222)
24 |
25 | Wait for Sandbox to fully boot up, all service need to finish starting
26 |
27 | Change Ambari password to "admin" (ambari-admin-password-reset)
28 |
29 | (!!!!!!!!!!!!!AMBARI PASSWORD MUST BE SET TO "admin" (no quotes)!!!!!!)
30 |
31 | cd /root (use the /root directory to begin the install)
32 |
33 | git clone https://github.com/vakshorton/DeviceManagerDemo.git
34 |
35 | (make sure that git cloned to /root/DeviceManagerDemo)
36 |
37 | cd DeviceManagerDemo
38 |
39 | ./install.sh
40 |
41 | Install script reboot once complete. This is required to refresh session configuration.
42 |
43 | Wait for Sandbox to fully reboot
44 |
45 | Log back in via SSH (ssh root@sandbox.hortonworks.com -p 2222)
46 |
47 | # Start Demo
48 | The script to start demo services should be located in the /root/DeviceManagerDemo directory
49 |
50 | ./startDemoServices.sh
51 |
52 | Slider will download the servlet (UI) docker containers from the docker hub so it may take a few minutes for the application server to start
53 |
54 | Bring up the UI in a Browser: http://sandbox.hortonworks.com:8090/MapUI/DeviceMap
55 |
56 | Start Simulation:
57 |
58 | The Simulator should be located in the DeviceManagerDemo directory
59 |
60 | java -jar DeviceSimulator-0.0.1-SNAPSHOT-jar-with-dependencies.jar Technician 1000 Simulation
61 |
62 | java -jar DeviceSimulator-0.0.1-SNAPSHOT-jar-with-dependencies.jar STB 1000 Simulation
63 |
64 | USAGE:
65 |
66 | java -jar simulator.jar arg1=Simulator-Type{BioReactor|FiltrationSystem} arg2=EntityId{1000} arg3={Simulation|Training}
67 |
68 | Example:
69 |
70 | java -jar DeviceSimulator-0.0.1-SNAPSHOT-jar-with-dependencies.jar Technician 1000 Simulation
71 |
72 | java -jar DeviceSimulator-0.0.1-SNAPSHOT-jar-with-dependencies.jar STB 1000 Simulation
73 |
74 | # MAP UI
75 | 
76 |
77 |
78 |
--------------------------------------------------------------------------------
/Nifi/config/nifi-bootstrap-env.json:
--------------------------------------------------------------------------------
1 | "properties" : {
2 | "content" : "\n# Java command to use when running NiFi\njava=java\n\n# Username to use when running NiFi. This value will be ignored on Windows.\nrun.as={{nifi_user}}\n\n# Configure where NiFi's lib and conf directories live\nlib.dir=./lib\nconf.dir=./conf\n\n# How long to wait after telling NiFi to shutdown before explicitly killing the Process\ngraceful.shutdown.seconds=20\n\n# Disable JSR 199 so that we can use JSP's without running a JDK\njava.arg.1=-Dorg.apache.jasper.compiler.disablejsr199=true\n\n# JVM memory settings\njava.arg.2=-Xms{{nifi_initial_mem}}\njava.arg.3=-Xmx{{nifi_max_mem}}\n\n# Enable Remote Debugging\n#java.arg.debug=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000\n\njava.arg.4=-Djava.net.preferIPv4Stack=true\n\n# allowRestrictedHeaders is required for Cluster/Node communications to work properly\njava.arg.5=-Dsun.net.http.allowRestrictedHeaders=true\njava.arg.6=-Djava.protocol.handler.pkgs=sun.net.www.protocol\n\n# Java 7 and below have issues with Code Cache. The following lines allow us to run well even with\n# many classes loaded in the JVM.\n#java.arg.7=-XX:ReservedCodeCacheSize=256m\n#java.arg.8=-XX:CodeCacheFlushingMinimumFreeSpace=10m\n#java.arg.9=-XX:+UseCodeCacheFlushing\n#java.arg.11=-XX:PermSize=128M\n#java.arg.12=-XX:MaxPermSize=128M\n\n# The G1GC is still considered experimental but has proven to be very advantageous in providing great\n# performance without significant \"stop-the-world\" delays.\n#java.arg.13=-XX:+UseG1GC\n\n#Set headless mode by default\njava.arg.14=-Djava.awt.headless=true\n\n#Ambari Metrics Collector URL - passed in to flow.xml for AmbariReportingTask\njava.arg.15=-Dambari.metrics.collector.url=http://{{metrics_collector_host}}:{{metrics_collector_port}}/ws/v1/timeline/metrics\n\n#Application ID - used in flow.xml - passed into flow.xml for AmbariReportingTask \njava.arg.16=-Dambari.application.id=nifi\n\n\n###\n# Notification Services for notifying interested parties when NiFi is stopped, started, dies\n###\n\n# XML File that contains the definitions of the notification services\nnotification.services.file=./conf/bootstrap-notification-services.xml\n\n# In the case that we are unable to send a notification for an event, how many times should we retry?\nnotification.max.attempts=5\n\n# Comma-separated list of identifiers that are present in the notification.services.file; which services should be used to notify when NiFi is started?\n#nifi.start.notification.services=email-notification\n\n# Comma-separated list of identifiers that are present in the notification.services.file; which services should be used to notify when NiFi is stopped?\n#nifi.stop.notification.services=email-notification\n\n# Comma-separated list of identifiers that are present in the notification.services.file; which services should be used to notify when NiFi dies?\n#nifi.dead.notification.services=email-notification",
3 | "nifi_group" : "nifi",
4 | "nifi_log_dir" : "/var/log/nifi",
5 | "nifi_pid_dir" : "/var/run/nifi",
6 | "nifi_user" : "nifi"
7 | }
--------------------------------------------------------------------------------
/Model/device_manager_svm.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/DeviceMonitor/src/main/java/com/hortonworks/bolts/PublishAlert.java:
--------------------------------------------------------------------------------
1 | package com.hortonworks.bolts;
2 |
3 | import java.util.HashMap;
4 | import java.util.Map;
5 |
6 | import org.cometd.client.BayeuxClient;
7 | import org.cometd.client.transport.ClientTransport;
8 | import org.cometd.client.transport.LongPollingTransport;
9 | import org.eclipse.jetty.client.HttpClient;
10 |
11 | import com.hortonworks.events.DeviceAlert;
12 | import com.hortonworks.util.Constants;
13 |
14 | import org.apache.storm.task.OutputCollector;
15 | import org.apache.storm.task.TopologyContext;
16 | import org.apache.storm.topology.OutputFieldsDeclarer;
17 | import org.apache.storm.topology.base.BaseRichBolt;
18 | import org.apache.storm.tuple.Fields;
19 | import org.apache.storm.tuple.Tuple;
20 | import org.apache.storm.tuple.Values;
21 |
22 | /*
23 | import backtype.storm.task.OutputCollector;
24 | import backtype.storm.task.TopologyContext;
25 | import backtype.storm.topology.OutputFieldsDeclarer;
26 | import backtype.storm.topology.base.BaseRichBolt;
27 | import backtype.storm.tuple.Fields;
28 | import backtype.storm.tuple.Tuple;
29 | import backtype.storm.tuple.Values;
30 | */
31 |
32 | public class PublishAlert extends BaseRichBolt {
33 | private String pubSubUrl;
34 | private String alertChannel;
35 | private BayeuxClient bayuexClient;
36 | private OutputCollector collector;
37 | private Constants constants;
38 |
39 | public void execute(Tuple tuple) {
40 | DeviceAlert deviceAlert = (DeviceAlert) tuple.getValueByField("DeviceAlert");
41 |
42 | Map data = new HashMap();
43 | data.put("deviceSerialNumber", deviceAlert.getSerialNumber());
44 | data.put("alertDescription", deviceAlert.getAlertDescription());
45 | data.put("deviceModel", deviceAlert.getDeviceModel());
46 | data.put("latitude", deviceAlert.getLatitude());
47 | data.put("longitude", deviceAlert.getLongitude());
48 | bayuexClient.getChannel(alertChannel).publish(data);
49 |
50 | collector.emit(tuple, new Values((DeviceAlert)deviceAlert));
51 | collector.ack(tuple);
52 | }
53 |
54 | public void prepare(Map arg0, TopologyContext arg1, OutputCollector collector) {
55 | this.collector = collector;
56 | this.constants = new Constants();
57 | pubSubUrl = constants.getPubSubUrl();
58 | alertChannel = constants.getAlertChannel();
59 |
60 | HttpClient httpClient = new HttpClient();
61 | try {
62 | httpClient.start();
63 | } catch (Exception e) {
64 | e.printStackTrace();
65 | }
66 |
67 | // Prepare the transport
68 | Map options = new HashMap();
69 | ClientTransport transport = new LongPollingTransport(options, httpClient);
70 |
71 | // Create the BayeuxClient
72 | bayuexClient = new BayeuxClient(pubSubUrl, transport);
73 |
74 | bayuexClient.handshake();
75 | boolean handshaken = bayuexClient.waitFor(3000, BayeuxClient.State.CONNECTED);
76 | if (handshaken)
77 | {
78 | System.out.println("Connected to Cometd Http PubSub Platform");
79 | }
80 | else{
81 | System.out.println("Could not connect to Cometd Http PubSub Platform");
82 | }
83 | }
84 |
85 | public void declareOutputFields(OutputFieldsDeclarer declarer) {
86 | declarer.declare(new Fields("DeviceAlert"));
87 | }
88 | }
--------------------------------------------------------------------------------
/DeviceMonitor/src/main/java/com/hortonworks/bolts/PublishTechnicianLocation.java:
--------------------------------------------------------------------------------
1 | package com.hortonworks.bolts;
2 |
3 | import java.io.IOException;
4 | import java.util.HashMap;
5 | import java.util.Map;
6 |
7 | import org.cometd.client.BayeuxClient;
8 | import org.cometd.client.transport.ClientTransport;
9 | import org.cometd.client.transport.LongPollingTransport;
10 | import org.eclipse.jetty.client.HttpClient;
11 |
12 | import com.hortonworks.events.TechnicianStatus;
13 | import com.hortonworks.util.Constants;
14 |
15 | import org.apache.storm.task.OutputCollector;
16 | import org.apache.storm.task.TopologyContext;
17 | import org.apache.storm.topology.OutputFieldsDeclarer;
18 | import org.apache.storm.topology.base.BaseRichBolt;
19 | import org.apache.storm.tuple.Fields;
20 | import org.apache.storm.tuple.Tuple;
21 | import org.apache.storm.tuple.Values;
22 |
23 | /*
24 | import backtype.storm.task.OutputCollector;
25 | import backtype.storm.task.TopologyContext;
26 | import backtype.storm.topology.OutputFieldsDeclarer;
27 | import backtype.storm.topology.base.BaseRichBolt;
28 | import backtype.storm.tuple.Fields;
29 | import backtype.storm.tuple.Tuple;
30 | import backtype.storm.tuple.Values;
31 | */
32 |
33 | public class PublishTechnicianLocation extends BaseRichBolt {
34 | private String pubSubUrl;
35 | private String techChannel;
36 | private BayeuxClient bayuexClient;
37 | private OutputCollector collector;
38 | private Constants constants;
39 |
40 | public void execute(Tuple tuple) {
41 | TechnicianStatus technicianStatus = (TechnicianStatus) tuple.getValueByField("TechnicianStatus");
42 | Map data = new HashMap();
43 | data.put("technicianId", technicianStatus.getTechnicianId());
44 | data.put("latitude", technicianStatus.getLatitude());
45 | data.put("longitude", technicianStatus.getLongitude());
46 | data.put("status", technicianStatus.getStatus());
47 | data.put("eventType", technicianStatus.getEventType());
48 | bayuexClient.getChannel(techChannel).publish(data);
49 |
50 | collector.emit(tuple, new Values((TechnicianStatus)technicianStatus));
51 | collector.ack(tuple);
52 | }
53 |
54 | public void prepare(Map arg0, TopologyContext arg1, OutputCollector collector) {
55 | this.collector = collector;
56 | constants = new Constants();
57 | pubSubUrl = constants.getPubSubUrl();
58 | techChannel = constants.getTechnicianChannel();
59 |
60 | HttpClient httpClient = new HttpClient();
61 | try {
62 | httpClient.start();
63 | } catch (Exception e) {
64 | e.printStackTrace();
65 | }
66 |
67 | // Prepare the transport
68 | Map options = new HashMap();
69 | ClientTransport transport = new LongPollingTransport(options, httpClient);
70 |
71 | // Create the BayeuxClient
72 | bayuexClient = new BayeuxClient(pubSubUrl, transport);
73 |
74 | bayuexClient.handshake();
75 | boolean handshaken = bayuexClient.waitFor(1000, BayeuxClient.State.CONNECTED);
76 | if (handshaken)
77 | {
78 | System.out.println("Connected to Cometd Http PubSub Platform");
79 | }
80 | else{
81 | System.out.println("Could not connect to Cometd Http PubSub Platform");
82 | }
83 | }
84 |
85 | public void declareOutputFields(OutputFieldsDeclarer declarer) {
86 | declarer.declare(new Fields("TechnicianStatus"));
87 | }
88 | }
--------------------------------------------------------------------------------
/DeviceMonitor/src/main/java/com/hortonworks/bolts/PublishDeviceStatus.java:
--------------------------------------------------------------------------------
1 | package com.hortonworks.bolts;
2 |
3 | import java.util.HashMap;
4 | import java.util.Map;
5 |
6 | import org.cometd.client.BayeuxClient;
7 | import org.cometd.client.transport.ClientTransport;
8 | import org.cometd.client.transport.LongPollingTransport;
9 | import org.eclipse.jetty.client.HttpClient;
10 |
11 | import com.hortonworks.events.DeviceStatus;
12 | import com.hortonworks.events.STBStatus;
13 | import com.hortonworks.util.Constants;
14 |
15 | import org.apache.storm.task.OutputCollector;
16 | import org.apache.storm.task.TopologyContext;
17 | import org.apache.storm.topology.OutputFieldsDeclarer;
18 | import org.apache.storm.topology.base.BaseRichBolt;
19 | import org.apache.storm.tuple.Fields;
20 | import org.apache.storm.tuple.Tuple;
21 | import org.apache.storm.tuple.Values;
22 |
23 | /*
24 | import backtype.storm.task.OutputCollector;
25 | import backtype.storm.task.TopologyContext;
26 | import backtype.storm.topology.OutputFieldsDeclarer;
27 | import backtype.storm.topology.base.BaseRichBolt;
28 | import backtype.storm.tuple.Fields;
29 | import backtype.storm.tuple.Tuple;
30 | import backtype.storm.tuple.Values;
31 | */
32 |
33 | public class PublishDeviceStatus extends BaseRichBolt {
34 | private String pubSubUrl;
35 | private String deviceChannel;
36 | private BayeuxClient bayuexClient;
37 | private OutputCollector collector;
38 | private Constants constants;
39 |
40 | public void execute(Tuple tuple) {
41 | STBStatus deviceStatus = (STBStatus) tuple.getValueByField("DeviceStatus");
42 |
43 | Map data = new HashMap();
44 | data.put("deviceSerialNumber", deviceStatus.getSerialNumber());
45 | data.put("internalTemp", deviceStatus.getInternalTemp());
46 | data.put("signalStrength", deviceStatus.getSignalStrength());
47 | data.put("deviceModel", deviceStatus.getDeviceModel());
48 | data.put("latitude", deviceStatus.getLatitude());
49 | data.put("longitude", deviceStatus.getLongitude());
50 | data.put("status", deviceStatus.getStatus());
51 | data.put("state", deviceStatus.getState());
52 | bayuexClient.getChannel(deviceChannel).publish(data);
53 |
54 | collector.emit(tuple, new Values((DeviceStatus)deviceStatus));
55 | collector.ack(tuple);
56 | }
57 |
58 | public void prepare(Map arg0, TopologyContext arg1, OutputCollector collector) {
59 | this.collector = collector;
60 | this.constants = new Constants();
61 | pubSubUrl = constants.getPubSubUrl();
62 | deviceChannel = constants.getDeviceChannel();
63 |
64 | HttpClient httpClient = new HttpClient();
65 | try {
66 | httpClient.start();
67 | } catch (Exception e) {
68 | e.printStackTrace();
69 | }
70 |
71 | // Prepare the transport
72 | Map options = new HashMap();
73 | ClientTransport transport = new LongPollingTransport(options, httpClient);
74 |
75 | // Create the BayeuxClient
76 | bayuexClient = new BayeuxClient(pubSubUrl, transport);
77 |
78 | bayuexClient.handshake();
79 | boolean handshaken = bayuexClient.waitFor(3000, BayeuxClient.State.CONNECTED);
80 | if (handshaken)
81 | {
82 | System.out.println("Connected to Cometd Http PubSub Platform");
83 | }
84 | else{
85 | System.out.println("Could not connect to Cometd Http PubSub Platform");
86 | }
87 | }
88 |
89 | public void declareOutputFields(OutputFieldsDeclarer declarer) {
90 | declarer.declare(new Fields("DeviceStatus"));
91 | }
92 | }
--------------------------------------------------------------------------------
/DeviceMonitor/src/main/java/com/hortonworks/bolts/RouteTechnician.java:
--------------------------------------------------------------------------------
1 | package com.hortonworks.bolts;
2 |
3 | import java.io.IOException;
4 | import java.io.OutputStream;
5 | import java.net.HttpURLConnection;
6 | import java.net.URL;
7 | import java.util.HashMap;
8 | import java.util.Map;
9 |
10 | import org.codehaus.jackson.JsonGenerationException;
11 | import org.codehaus.jackson.map.JsonMappingException;
12 | import org.codehaus.jackson.map.ObjectMapper;
13 |
14 | import com.hortonworks.events.TechnicianDestination;
15 | import com.hortonworks.util.Constants;
16 |
17 | import org.apache.storm.task.OutputCollector;
18 | import org.apache.storm.task.TopologyContext;
19 | import org.apache.storm.topology.OutputFieldsDeclarer;
20 | import org.apache.storm.topology.base.BaseRichBolt;
21 | import org.apache.storm.tuple.Fields;
22 | import org.apache.storm.tuple.Tuple;
23 | import org.apache.storm.tuple.Values;
24 |
25 | /*
26 | import backtype.storm.task.OutputCollector;
27 | import backtype.storm.task.TopologyContext;
28 | import backtype.storm.topology.OutputFieldsDeclarer;
29 | import backtype.storm.topology.base.BaseRichBolt;
30 | import backtype.storm.tuple.Fields;
31 | import backtype.storm.tuple.Tuple;
32 | import backtype.storm.tuple.Values;
33 | */
34 |
35 | public class RouteTechnician extends BaseRichBolt {
36 | static final long serialVersionUID = 1L;
37 | private TechnicianDestination technicianDestination;
38 | private OutputCollector collector;
39 | private Constants constants;
40 |
41 | public RouteTechnician() {
42 | super();
43 | }
44 |
45 | public void execute(Tuple tuple) {
46 | technicianDestination = (TechnicianDestination)tuple.getValueByField("TechnicianDestination");
47 | try{
48 | URL url = new URL("http://" + constants.getNameNodeHost() +":8084/contentListener");
49 | HttpURLConnection conn = (HttpURLConnection) url.openConnection();
50 | conn.setDoOutput(true);
51 | conn.setRequestMethod("POST");
52 | conn.setRequestProperty("Content-Type", "application/json");
53 |
54 | System.out.println("To String: " + convertPOJOToJSON(technicianDestination));
55 |
56 | OutputStream os = conn.getOutputStream();
57 | os.write(convertPOJOToJSON(technicianDestination).getBytes());
58 | os.flush();
59 |
60 | if (conn.getResponseCode() != 200) {
61 | throw new RuntimeException("Failed : HTTP error code : "
62 | + conn.getResponseCode());
63 | }
64 |
65 | } catch (Exception e) {
66 | e.printStackTrace();
67 | }
68 | collector.ack(tuple);
69 | }
70 |
71 | public void prepare(Map arg0, TopologyContext arg1, OutputCollector collector) {
72 | this.collector = collector;
73 | this.constants = new Constants();
74 | }
75 |
76 | public void declareOutputFields(OutputFieldsDeclarer declarer) {
77 | declarer.declare(new Fields("TechnicianDestination"));
78 | }
79 |
80 | public String convertPOJOToJSON(Object pojo) {
81 | String jsonString = "";
82 | ObjectMapper mapper = new ObjectMapper();
83 |
84 | try {
85 | jsonString = mapper.writeValueAsString(pojo);
86 | } catch (JsonGenerationException e) {
87 | e.printStackTrace();
88 | } catch (JsonMappingException e) {
89 | e.printStackTrace();
90 | } catch (IOException e) {
91 | e.printStackTrace();
92 | }
93 | return jsonString;
94 | }
95 | }
--------------------------------------------------------------------------------
/DEVICE_MANAGER_DEMO_CONTROL/package/scripts/master.py:
--------------------------------------------------------------------------------
1 | import sys, os, pwd, signal, time, shutil
2 | from subprocess import *
3 | from resource_management import *
4 |
5 | class DemoControl(Script):
6 | def install(self, env):
7 | self.configure(env)
8 | import params
9 |
10 | if not os.path.exists(params.install_dir):
11 | os.makedirs(params.install_dir)
12 | os.chdir(params.install_dir)
13 | Execute('git clone ' + params.download_url)
14 | os.chdir(params.install_dir+'/DataSimulators/DeviceSimulator')
15 | Execute('mvn clean package')
16 | os.chdir(params.install_dir+'/DataSimulators/DeviceSimulator/target')
17 | shutil.copy('DeviceSimulator-0.0.1-SNAPSHOT-jar-with-dependencies.jar', params.install_dir)
18 |
19 | def start(self, env):
20 | self.configure(env)
21 | import params
22 | Execute('echo Start Simulation')
23 | Execute('nohup java -jar '+params.install_dir+'/DeviceSimulator-0.0.1-SNAPSHOT-jar-with-dependencies.jar STB 1000 Simulation '+params.nifi_host_ip+' > '+params.install_dir+'/STB_1000_Sim.log 2>&1 & echo $! > /var/run/STB_1000_Sim.pid')
24 | Execute('nohup java -jar '+params.install_dir+'/DeviceSimulator-0.0.1-SNAPSHOT-jar-with-dependencies.jar STB 2000 Simulation '+params.nifi_host_ip+' > '+params.install_dir+'/STB_2000_Sim.log 2>&1 & echo $! > /var/run/STB_2000_Sim.pid')
25 | Execute('nohup java -jar '+params.install_dir+'/DeviceSimulator-0.0.1-SNAPSHOT-jar-with-dependencies.jar STB 3000 Simulation '+params.nifi_host_ip+' > '+params.install_dir+'/STB_3000_Sim.log 2>&1 & echo $! > /var/run/STB_3000_Sim.pid')
26 |
27 | Execute('nohup java -jar '+params.install_dir+'/DeviceSimulator-0.0.1-SNAPSHOT-jar-with-dependencies.jar Technician 1000 Simulation '+params.nifi_host_ip+' > '+params.install_dir+'/Technician_1000_Sim.log 2>&1 & echo $! > /var/run/Technician_1000_Sim.pid')
28 | Execute('nohup java -jar '+params.install_dir+'/DeviceSimulator-0.0.1-SNAPSHOT-jar-with-dependencies.jar Technician 2000 Simulation '+params.nifi_host_ip+' > '+params.install_dir+'/Technician_2000_Sim.log 2>&1 & echo $! > /var/run/Technician_2000_Sim.pid')
29 | Execute('nohup java -jar '+params.install_dir+'/DeviceSimulator-0.0.1-SNAPSHOT-jar-with-dependencies.jar Technician 3000 Simulation '+params.nifi_host_ip+' > '+params.install_dir+'/Technician_3000_Sim.log 2>&1 & echo $! > /var/run/Technician_3000_Sim.pid')
30 |
31 | def stop(self, env):
32 | self.configure(env)
33 | import params
34 | Execute('echo Stop Simulation')
35 | Execute (format('kill -9 `cat /var/run/STB_1000_Sim.pid` >/dev/null 2>&1'))
36 | Execute (format('kill -9 `cat /var/run/STB_2000_Sim.pid` >/dev/null 2>&1'))
37 | Execute (format('kill -9 `cat /var/run/STB_3000_Sim.pid` >/dev/null 2>&1'))
38 | Execute (format('kill -9 `cat /var/run/Technician_1000_Sim.pid` >/dev/null 2>&1'))
39 | Execute (format('kill -9 `cat /var/run/Technician_2000_Sim.pid` >/dev/null 2>&1'))
40 | Execute (format('kill -9 `cat /var/run/Technician_3000_Sim.pid` >/dev/null 2>&1'))
41 |
42 | Execute ('rm -f /var/run/STB_1000_Sim.pid')
43 | Execute ('rm -f /var/run/STB_2000_Sim.pid')
44 | Execute ('rm -f /var/run/STB_3000_Sim.pid')
45 | Execute ('rm -f /var/run/Technician_1000_Sim.pid')
46 | Execute ('rm -f /var/run/Technician_2000_Sim.pid')
47 | Execute ('rm -f /var/run/Technician_3000_Sim.pid')
48 |
49 | def status(self, env):
50 | import params
51 | env.set_params(params)
52 | check_process_status('/var/run/STB_1000_Sim.pid')
53 |
54 | def configure(self, env):
55 | import params
56 | env.set_params(params)
57 |
58 | if __name__ == "__main__":
59 | DemoControl().execute()
60 |
--------------------------------------------------------------------------------
/DeviceMonitor/src/main/java/com/hortonworks/util/DeviceEventJSONScheme.java:
--------------------------------------------------------------------------------
1 | package com.hortonworks.util;
2 |
3 | import java.io.IOException;
4 | import java.nio.ByteBuffer;
5 | import java.nio.charset.Charset;
6 | import java.util.List;
7 |
8 | import org.apache.storm.kafka.KeyValueScheme;
9 | import org.apache.storm.kafka.StringScheme;
10 | import org.apache.storm.tuple.Fields;
11 | import org.apache.storm.tuple.Values;
12 | import org.codehaus.jackson.JsonParseException;
13 | import org.codehaus.jackson.map.JsonMappingException;
14 | import org.codehaus.jackson.map.ObjectMapper;
15 |
16 | import com.hortonworks.events.STBStatus;
17 |
18 | /*
19 | import backtype.storm.spout.Scheme;
20 | import backtype.storm.tuple.Fields;
21 | import backtype.storm.tuple.Values;
22 | import storm.kafka.KeyValueScheme;
23 | */
24 |
25 | /**
26 | * Encodes a byte array into a single UTF-8 string. Very useful for testing and passing raw JSON messages around without
27 | * proper deserialization.
28 | */
29 | public class DeviceEventJSONScheme implements KeyValueScheme {
30 | private static final long serialVersionUID = 1L;
31 | private static final Charset UTF8 = Charset.forName("UTF-8");
32 |
33 | public List