Skip to content
This repository was archived by the owner on Mar 24, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion IoT-Dashboard/config/environments/production.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"baseUrl": "http://23.92.235.246:8080"
"baseUrl": "http://33.33.164.176:8080"
}
2 changes: 1 addition & 1 deletion IoT-Dashboard/src/main/resources/public/scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ angular

angular.module('services.config', [])
.constant('configuration', {
baseUrl: 'http://23.92.235.246:8080'
baseUrl: 'http://33.33.164.176:8080'
});

'use strict';
Expand Down
6 changes: 3 additions & 3 deletions IoT-DataScience/PythonModel/Configuration/default.conf
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[Directories]
dir_rawdata: hdfs://sandbox:9000/data/Dallas-Drives/simulated_data/*.out
dir_storedmodel: /IoT-ConnectedCar/data/model/
dir_clusters: /IoT-ConnectedCar/data/model/
logfile: /IoT-ConnectedCar/data/stream_predict.log
dir_storedmodel: /opt/pivotal/IoT-ConnectedCar/data/model/
dir_clusters: /opt/pivotal/IoT-ConnectedCar/data/model/
logfile: /opt/pivotal/IoT-ConnectedCar/data/stream_predict.log

[Batch]
cluster_class_file: KMeans
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ private Double toDouble(Object value) {

@SuppressWarnings("unchecked")
public CarPosition(Map<String, Object> values) {
this.journeyId = (String) values.get("journey_id");
this.journeyId = String.valueOf(values.get("journey_id"));
this.absoluteThrottlePosB = toDouble(values.get("absolute_throttle_pos_b"));
this.acceleration = toDouble(values.get("acceleration"));
this.acceleratorThrottlePosD = toDouble(values.get("accelerator_throttle_pos_d"));
Expand Down Expand Up @@ -186,7 +186,7 @@ public CarPosition(Map<String, Object> values) {
this.longitude = toDouble(values.get("longitude"));
this.mafAirflow = toDouble(values.get("maf_airflow"));
this.mpgInstantaneous = toDouble(values.get("mpg_instantaneous"));
this.obdStandards = Integer.parseInt((String) values.get("obd_standards"));
this.obdStandards = Integer.parseInt(String.valueOf(values.get("obd_standards")));
this.relativeThrottlePos = toDouble(values.get("relative_throttle_pos"));
this.rpm = toDouble(values.get("rpm"));
this.shortTermFuel = toDouble(values.get("short_term_fuel"));
Expand Down Expand Up @@ -214,7 +214,7 @@ else if(vehicleSpeed instanceof Double){
this.vehicleSpeed = (Double) vehicleSpeed;
}
else {
this.vehicleSpeed = Double.parseDouble((String) vehicleSpeed);
this.vehicleSpeed = Double.parseDouble(String.valueOf(vehicleSpeed));
}
}

Expand Down
10 changes: 5 additions & 5 deletions IoT-Scripts/start_simulator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
function printOptions {
echo "You are currently at home, the Renaissance Hotel."
echo "Where do you want to go?"
echo "1) Work - Omni Hotel"
echo "1) Home - Prom"
echo "2) Flying Saucer Resturant"
echo "3) Babe's Chicken Dinner House"
echo "4) Sandy Lake Amusement Park"
Expand Down Expand Up @@ -35,16 +35,16 @@ function selectInputFile {

case $selection in
1)
inputfile="/opt/pivotal/data/Dallas-Drives/Ren-Omni-75.out"
inputfile="/opt/pivotal/IoT-ConnectedCar/data/Chicago_Drives/Home-Prom.out"
;;
2)
inputfile="/opt/pivotal/data/Dallas-Drives/Ren-Fly-BeltlineRoute.out"
inputfile="/opt/pivotal/IoT-ConnectedCar/data/Dallas-Drives/Ren-Fly-BeltlineRoute.out"
;;
3)
inputfile="/opt/pivotal/data/Dallas-Drives/Ren-Babes-JupiterCampbellRoute.out"
inputfile="/opt/pivotal/IoT-ConnectedCar/data/Dallas-Drives/Ren-Babes-JupiterCampbellRoute.out"
;;
4)
inputfile="/opt/pivotal/data/Dallas-Drives/Ren-Sandy-GBTollwayRoute.out"
inputfile="/opt/pivotal/IoT-ConnectedCar/data/Dallas-Drives/Ren-Sandy-GBTollwayRoute.out"
;;
esac

Expand Down
2 changes: 1 addition & 1 deletion IoT-Scripts/start_xd-shell.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Pivotal 2014 #

source /etc/profile.d/pivotal.sh
sudo $XD_HOME/../shell/bin/xd-shell
sudo HADOOP_USER_NAME=hdfs $XD_HOME/../shell/bin/xd-shell --hadoopDistro hdp22

set retcode = $?
#read -p "Done. Press [Enter] to close."
Expand Down
4 changes: 2 additions & 2 deletions IoT-Scripts/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ gemfire-server $GEMFIRE_IOT_CONF_DIR/iot-demo.xml &
sleep 10;

# Load the journeys into GemFire
java -jar /opt/pivotal/IoT-ConnectedCar/IoT-GemFireLoader/build/libs/IoT-GemFireLoader.jar /opt/pivotal/data/model/clusters.json
java -jar /opt/pivotal/IoT-ConnectedCar/IoT-GemFireLoader/build/libs/IoT-GemFireLoader.jar /opt/pivotal/IoT-ConnectedCar/data/model/clusters.json

# Start XD Singlenode
sudo $XD_HOME/bin/xd-singlenode
sudo HADOOP_USER_NAME=hdfs $XD_HOME/bin/xd-singlenode --hadoopDistro hdp22

set retcode = $?
read -p "Done. Press [Enter] to close."
Expand Down
2 changes: 1 addition & 1 deletion IoT-Scripts/stream-create.xd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Create the initial stream to take HTTP data and enrich it and store it to a local file
stream create --name IoT-HTTP --definition "http | filter --script=file:/opt/pivotal/IoT-ConnectedCar/IoT-DataFilter/src/main/resources/DataFilter.groovy | acmeenrich | shell --inputType=application/json --command='/opt/pivotal/anaconda/bin/python ./StreamPredict.py' --workingDir=/opt/pivotal/IoT-ConnectedCar/IoT-DataScience/PythonModel/ | hdfs" --deploy
stream create --name IoT-HTTP --definition "http | filter --script=file:/opt/pivotal/IoT-ConnectedCar/IoT-DataFilter/src/main/resources/DataFilter.groovy | acmeenrich | shell --inputType=application/json --command='/home/vagrant/anaconda2/bin/python ./StreamPredict.py' --workingDir=/opt/pivotal/IoT-ConnectedCar/IoT-DataScience/PythonModel/ | hdfs" --deploy

// Create a tap that reads the transformed json data into gemfire
stream create --name IoT-Gemfire --definition "tap:stream:IoT-HTTP.shell > typeconversiontransformer | gemfire-server --regionName=car-position --keyExpression=payload.vin" --deploy
40 changes: 40 additions & 0 deletions Vagrant.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
## Setting up the development environment
**Sample data:**
Extract https://s3.amazonaws.com/iot.connected.car/opt_pivotal_data.tar.gz to root of the IoT-ConnectedCar project


**Download and Install Hortonworks**
- Download the Hortonworks VirtualBox OVA from http://hortonworks.com/products/hortonworks-sandbox/#install
- Open VirtualBox and go to File -> Import Appliance and import the Hortonworks OVA
- Open the Settings panel for Hortonworks and go to the Network tab
- Disable Adapter 1 and Enable Adapter 2 as a Bridged Adapter
- Start Hortonworks VM
- Get the IP of the Hortonworks box by running `VBoxManage guestproperty get "Hortonworks Sandbox with HDP 2.3.2" "/VirtualBox/GuestInfo/Net/0/V4/IP"`
- You should be able to see Ambari at `<HORTONWORKS_BRIDGED_IP>:8080`


**Building the project**
- `vagrant up`
- `vagrant ssh`
- `sudo vim $XD_HOME/config/servers.yml` and modify `spring: hadoop: fsUri: hdfs://<HORTONWORKS_BRIDGED_IP>:8020` with the IP of the Hortonworks box
- `sudo vim $XD_HOME/config/hadoop.properties`: and modify `fs.default.name=hdfs://<HORTONWORKS_BRIDGED_IP>:8020` with the IP of the Hortonworks box
- `cp $XD_HOME/../python/src/springxd/stream.py $IOT_HOME/IoT-DataScience/PythonModel`
- `cd $IOT_HOME/IoT-Dashboard` and run `npm install && bower install && grunt clean build`
- `cd $IOT_HOME` and run `./gradlew clean build`


## Running from the VM
- `cd $IOT_HOME/IoT-Scripts`
- Run `./startup.sh`
- Once startup has finished loading(reached 'scheduling deployments to new containers in 15000 ms'), open another tab
- In the new tab run `./start_xd-shell.sh`
- From inside the Spring XD shell, execute these commands:
- `module upload --type processor --name acmeenrich --file /opt/pivotal/IoT-ConnectedCar/IoT-EnrichmentTransformer/build/libs/IoT-EnrichmentTransformer.jar`
- `module upload --type processor --name typeconversiontransformer --file /opt/pivotal/IoT-ConnectedCar/IoT-GemFireTransformer/build/libs/IoT-GemFireTransformer.jar`
- `script --file /opt/pivotal/IoT-ConnectedCar/IoT-Scripts/stream-create.xd`
- Note that the modules only need to added the first time but the stream command will need to be re-run each time the project is launched
- In another terminal run `./start_restapi.sh`
- In another terminal run `./start_dashboard.sh`
- In another terminal run `./start_simulator.sh`
- Once the simulator has started select option 1
- Open `33.33.164.176:9889` in your browser
22 changes: 22 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
$domain_name = "IoT-ConnectedCar"
$vagrant_ip = "33.33.164.176"
$box_name = "IoT-ConnectedCar.box"
$box_path = "http://devops.cloudspace.com/images/iot-connected/"
$cpus = 4
$memory = 4096

Vagrant.configure(2) do |config|
org = $domain_name
config.vm.box = $box_name
config.vm.box_url = File.join($box_path, $box_name)
config.ssh.forward_agent = true
config.ssh.username = "vagrant"
config.ssh.password = "vagrant"
config.vm.network "private_network", ip: $vagrant_ip
config.vm.network "public_network", bridge: "en0: Wi-Fi (AirPort)"
config.vm.synced_folder "./", "/opt/pivotal/#{org}", :nfs => { :mount_options => ["dmode=777","fmode=777"] }

config.vm.provider "virtualbox" do |v|
v.customize ["modifyvm", :id, "--memory", $memory, "--name", $domain_name,"--cpus", $cpus]
end
end