From a82b41ecbc296d55826868e68745f201bf60fd5e Mon Sep 17 00:00:00 2001 From: Jason Fox Date: Thu, 23 Jan 2020 16:06:37 +0100 Subject: [PATCH] Improve context data loading speed. --- import-data | 29 +++++++++++------------------ provision-devices | 16 ++++++---------- services | 8 ++++++-- 3 files changed, 23 insertions(+), 30 deletions(-) diff --git a/import-data b/import-data index 65b96d9..c8e3db0 100755 --- a/import-data +++ b/import-data @@ -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 '{ @@ -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 '{ @@ -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 '{ @@ -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 '{ @@ -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 '{ @@ -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 '{ @@ -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 '{ @@ -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 '{ @@ -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 '{ @@ -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 '{ @@ -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 '{ diff --git a/provision-devices b/provision-devices index 11a2a9f..8f56142 100755 --- a/provision-devices +++ b/provision-devices @@ -7,11 +7,7 @@ set -e -curl () { - docker run --network fiware_default --rm appropriate/curl -s -o /dev/null \ - "$@" - printf "." -} + printf "⏳ Provisioning IoT devices " @@ -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' \ @@ -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' \ @@ -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' \ @@ -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' \ @@ -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' \ diff --git a/services b/services index d41e725..4a6c929 100755 --- a/services +++ b/services @@ -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 "" }