- set -x
- cd $CONFIGMAP_ROOT
- pwd
- # order is important in this next list
- for uri in dmaap dcaeLocations mr_clusters topics mr_clients dr_nodes feeds dr_pubs dr_subs
- do
- if [ -d ${uri} ]
- then
- for j in `ls ${uri}/*.json`
- do
- echo "POST $j to $uri"
- dopost $j $uri
- done
- fi
- done
- set +x
+function do_http_post() {
+ RETRY_TIME=60
+ if [ -n "$RESP_CACHE" ]; then
+ RESP="$RESP_CACHE"/"$(echo "${1##*/}" | cut -d "." -f1)"-resp.json
+ fi
+ while true; do
+ if [ "$2" != "feeds" -a "$2" != "topics" ]; then
+ req_body=$(cat "${1}" | envsubst)
+ rc=$(xcurl -o "$RESP" -d "$req_body" "${URL}${2}")
+ if [ "$rc" = "200" -o "$rc" = "201" -o "$rc" = "409" ]; then
+ echo "Http Post request is successful with response code=$rc"
+ break
+ fi
+ else
+ rc=$(xcurl -o "$RESP" -d @"${1}" "${URL}${2}"/?"${PARAM}")
+ if [ "$rc" = "200" -o "$rc" = "201" -o "$rc" = "409" ]; then
+ echo "Http Post request for feed creation is successful with response code=$rc"
+ break
+ fi
+ fi
+ echo "$(date): Http Response code=$rc. Will retry after $RETRY_TIME seconds.."
+ sleep "$RETRY_TIME"
+ done