Skip to content

Commit

Permalink
Improve context data loading speed.
Browse files Browse the repository at this point in the history
  • Loading branch information
jason-fox committed Jan 23, 2020
1 parent fc94e05 commit a82b41e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 30 deletions.
29 changes: 11 additions & 18 deletions import-data
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,12 @@

set -e


curl () {
docker run --network fiware_default --rm appropriate/curl -s -o /dev/null \
"$@"
printf "."
}

printf "⏳ Loading context data "

#
# Create four Store Entities in various locations across Berlin
#
curl -X POST \
curl -s -o /dev/null -X POST \
'http://orion:1026/v2/op/update' \
-H 'Content-Type: application/json' \
-g -d '{
Expand Down Expand Up @@ -53,7 +46,7 @@ curl -X POST \
#
# Add Weather and Twitter Responses for Store 1 using random values
#
curl -X POST \
curl -s -o /dev/null -X POST \
http://orion:1026/v2/registrations \
-H 'Content-Type: application/json' \
-d '{
Expand All @@ -78,7 +71,7 @@ curl -X POST \
"status": "active"
}'

curl -X POST \
curl -s -o /dev/null -X POST \
http://orion:1026/v2/registrations \
-H 'Content-Type: application/json' \
-d '{
Expand Down Expand Up @@ -106,7 +99,7 @@ curl -X POST \

# Add Weather and Twitter Responses for Store 2 using real sources
#
# curl -X POST \
# curl -s -o /dev/null -X POST \
# 'http://orion:1026/v2/registrations' \
# -H 'Content-Type: application/json' \
# -d '{
Expand All @@ -131,7 +124,7 @@ curl -X POST \
# }
# }'

# curl -X POST \
# curl -s -o /dev/null -X POST \
# 'http://orion:1026/v2/registrations' \
# -H 'Content-Type: application/json' \
# -d '{
Expand Down Expand Up @@ -159,7 +152,7 @@ curl -X POST \
# Create a series of Shelf Entities and place the in each Store.
# Each shelf is designed to hold one product.
#
curl -X POST \
curl -s -o /dev/null -X POST \
'http://orion:1026/v2/op/update' \
-H 'Content-Type: application/json' \
-g -d '{
Expand Down Expand Up @@ -242,7 +235,7 @@ curl -X POST \
# Create a series of Product Entities.
# These are a series of alcoholc and non-alcoholic drinks which are available to sell.
#
curl -X POST \
curl -s -o /dev/null -X POST \
'http://orion:1026/v2/op/update' \
-H 'Content-Type: application/json' \
-d '{
Expand Down Expand Up @@ -310,7 +303,7 @@ curl -X POST \
# Create a series of InventoryItems Entities.
# These the drinks on order in Store:001
#
curl -X POST \
curl -s -o /dev/null -X POST \
'http://orion:1026/v2/op/update' \
-H 'Content-Type: application/json' \
-d '{
Expand Down Expand Up @@ -347,7 +340,7 @@ curl -X POST \
# Create a series of InventoryItems Entities.
# These the drinks on order in Store:002
#
curl -X POST \
curl -s -o /dev/null -X POST \
'http://orion:1026/v2/op/update' \
-H 'Content-Type: application/json' \
-d '{
Expand Down Expand Up @@ -376,7 +369,7 @@ curl -X POST \
# These the drinks on order in Store:003
# Note that Shelf Unit009 is currently unused
#
curl -X POST \
curl -s -o /dev/null -X POST \
'http://orion:1026/v2/op/update' \
-H 'Content-Type: application/json' \
-d '{
Expand Down Expand Up @@ -413,7 +406,7 @@ curl -X POST \
# Create a series of InventoryItems Entities.
# These the drinks on order in Store:004
#
curl -X POST \
curl -s -o /dev/null -X POST \
'http://orion:1026/v2/op/update' \
-H 'Content-Type: application/json' \
-d '{
Expand Down
16 changes: 6 additions & 10 deletions provision-devices
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@
set -e


curl () {
docker run --network fiware_default --rm appropriate/curl -s -o /dev/null \
"$@"
printf "."
}



printf "⏳ Provisioning IoT devices "
Expand All @@ -21,7 +17,7 @@ printf "⏳ Provisioning IoT devices "
# Create a service groups for all UltraLight IoT devices
#

curl -X POST \
curl -s -o /dev/null -X POST \
'http://iot-agent:4041/iot/services' \
-H 'Content-Type: application/json' \
-H 'fiware-service: openiot' \
Expand Down Expand Up @@ -124,7 +120,7 @@ curl -X POST \
# Provision sensors for Store 001
#

curl -X POST \
curl -s -o /dev/null -X POST \
'http://iot-agent:4041/iot/devices' \
-H 'Content-Type: application/json' \
-H 'fiware-service: openiot' \
Expand Down Expand Up @@ -176,7 +172,7 @@ curl -X POST \
# Provision sensors for Store 002
#

curl -X POST \
curl -s -o /dev/null -X POST \
'http://iot-agent:4041/iot/devices' \
-H 'Content-Type: application/json' \
-H 'fiware-service: openiot' \
Expand Down Expand Up @@ -232,7 +228,7 @@ curl -X POST \
# Provision sensors for Store 3
#

curl -X POST \
curl -s -o /dev/null -X POST \
'http://iot-agent:4041/iot/devices' \
-H 'Content-Type: application/json' \
-H 'fiware-service: openiot' \
Expand Down Expand Up @@ -287,7 +283,7 @@ curl -X POST \
# Provision sensors for Store 4
#

curl -X POST \
curl -s -o /dev/null -X POST \
'http://iot-agent:4041/iot/devices' \
-H 'Content-Type: application/json' \
-H 'fiware-service: openiot' \
Expand Down
8 changes: 6 additions & 2 deletions services
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@ if (( $# != 1 )); then
fi

loadData () {
./import-data
docker run --rm -v $(pwd)/import-data:/import-data \
--network fiware_default \
--entrypoint /bin/ash curlimages/curl import-data
waitForIoTAgent
./provision-devices
docker run --rm -v $(pwd)/provision-devices:/provision-devices \
--network fiware_default \
--entrypoint /bin/ash curlimages/curl provision-devices
echo ""
}

Expand Down

0 comments on commit a82b41e

Please sign in to comment.