blob: e062d7d3797cb8dbefeb1b6d1991690fc923d1be [file] [log] [blame]
Lusheng Jid6d409f2018-03-22 23:25:45 -04001#!/bin/bash
2# ================================================================================
Vijay Venkatesh Kumar2cabee92020-01-13 20:50:28 +00003# Copyright (c) 2018-2020 AT&T Intellectual Property. All rights reserved.
Lusheng Jid6d409f2018-03-22 23:25:45 -04004# ================================================================================
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16# ============LICENSE_END=========================================================
17
18set -e
19
20CDAP_HOST='localhost'
21CDAP_PORT='11015'
22TCA_NAMESPACE='cdap_tca_hi_lo'
23TCA_APPNAME='dcae-tca'
24
25TCA_ARTIFACT='dcae-analytics-cdap-tca'
Lusheng Jid6d409f2018-03-22 23:25:45 -040026TCA_FILE_PATH='/opt/tca'
Lusheng Ji1dd7a992018-05-10 23:54:18 -040027TCA_JAR="$(ls -1r ${TCA_FILE_PATH}/${TCA_ARTIFACT}*.jar | head -1)"
28TCA_ARTIFACT_VERSION=$(echo "$TCA_JAR" |rev |cut -f 2-4 -d '.' |rev)
Lusheng Jid6d409f2018-03-22 23:25:45 -040029TCA_APP_CONF="${TCA_FILE_PATH}/tca_app_config.json"
30TCA_CONF="${TCA_FILE_PATH}/tca_config.json"
31TCA_PREF="${TCA_FILE_PATH}/tca_app_preferences.json"
32TCA_CONF_TEMP='/tmp/tca_config.json'
33TCA_APP_CONF_TEMP='/tmp/tca_app_config.json'
34TCA_PREF_TEMP='/tmp/tca_preferences.json'
35
36TCA_PATH_APP="${CDAP_HOST}:${CDAP_PORT}/v3/namespaces/${TCA_NAMESPACE}/apps/${TCA_APPNAME}"
37TCA_PATH_ARTIFACT="${CDAP_HOST}:${CDAP_PORT}/v3/namespaces/${TCA_NAMESPACE}/artifacts"
38
Lusheng Jie380f6b2018-05-14 22:45:56 -040039MR_WATCHDOG_PATH="${TCA_FILE_PATH}/mr-watchdog.sh"
40
41
42WORKER_COUNT='0'
Lusheng Jid6d409f2018-03-22 23:25:45 -040043
Vijay Venkatesh Kumar2cabee92020-01-13 20:50:28 +000044# Remove consul dependency for CBS lookup (DCAEGEN2-2021)
45# CBS Host and port are set to CBS K8S service name and port identified on CBS deployment via Helm
46CBS_HOST=${CBS_HOST:-config-binding-service}
47CBS_PORT=${CBS_PORT:-10000}
Lusheng Ji3622f7a2018-04-04 21:51:34 -040048
Vijay Venkatesh Kumar2cabee92020-01-13 20:50:28 +000049#CONSUL_HOST=${CONSUL_HOST:-consul}
50#CONSUL_PORT=${CONSUL_PORT:-8500}
51#CONFIG_BINDING_SERVICE=${CONFIG_BINDING_SERVICE:-config_binding_service}
52CBS_SERVICE_NAME=${CBS_SERVICE_NAME:-config_binding_service}
Lusheng Ji3622f7a2018-04-04 21:51:34 -040053
vagrant61c202d2018-04-05 20:34:40 +000054#Changing to HOSTNAME parameter for consistency with k8s deploy
55MY_NAME=${HOSTNAME:-tca}
Lusheng Ji3622f7a2018-04-04 21:51:34 -040056
Lusheng Ji3622f7a2018-04-04 21:51:34 -040057
58echo "Generting preference file"
Lusheng Jie380f6b2018-05-14 22:45:56 -040059DMAAPSUBGROUP=${DMAAPSUBGROUP:-OpenDCAEc12}
60DMAAPSUBID=${DMAAPSUBID:=c12}
Lusheng Ji3622f7a2018-04-04 21:51:34 -040061sed -i 's/{{DMAAPHOST}}/'"${DMAAPHOST}"'/g' ${TCA_PREF}
62sed -i 's/{{DMAAPPORT}}/'"${DMAAPPORT}"'/g' ${TCA_PREF}
63sed -i 's/{{DMAAPPUBTOPIC}}/'"${DMAAPPUBTOPIC}"'/g' ${TCA_PREF}
64sed -i 's/{{DMAAPSUBTOPIC}}/'"${DMAAPSUBTOPIC}"'/g' ${TCA_PREF}
Lusheng Jie380f6b2018-05-14 22:45:56 -040065sed -i 's/{{DMAAPSUBGROUP}}/'"${DMAAPSUBGROUP}"'/g' ${TCA_PREF}
66sed -i 's/{{DMAAPSUBID}}/'"${DMAAPSUBID}"'/g' ${TCA_PREF}
Lusheng Ji3622f7a2018-04-04 21:51:34 -040067sed -i 's/{{AAIHOST}}/'"${AAIHOST}"'/g' ${TCA_PREF}
68sed -i 's/{{AAIPORT}}/'"${AAIPORT}"'/g' ${TCA_PREF}
Lusheng Ji1dd7a992018-05-10 23:54:18 -040069if [ -z "$REDISHOSTPORT" ]; then
Lusheng Ji3622f7a2018-04-04 21:51:34 -040070 sed -i 's/{{REDISHOSTPORT}}/NONE/g' ${TCA_PREF}
71 sed -i 's/{{REDISCACHING}}/false/g' ${TCA_PREF}
72else
73 sed -i 's/{{REDISHOSTPORT}}/'"${REDISHOSTPORT}"'/g' ${TCA_PREF}
74 sed -i 's/{{REDISCACHING}}/true/g' ${TCA_PREF}
75fi
Lusheng Jid6d409f2018-03-22 23:25:45 -040076
77function tca_stop {
78 # stop programs
79 echo
80 echo "Stopping TCADMaaPMRPublisherWorker, TCADMaaPMRSubscriberWorker, and TCAVESCollectorFlow ..."
81 echo
82 curl -s -X POST "http://${TCA_PATH_APP}/workers/TCADMaaPMRPublisherWorker/stop"
83 curl -s -X POST "http://${TCA_PATH_APP}/workers/TCADMaaPMRSubscriberWorker/stop"
84 curl -s -X POST "http://${TCA_PATH_APP}/flows/TCAVESCollectorFlow/stop"
85 echo "done"
86 echo
87}
88
89function tca_load_artifact {
90 echo
Lusheng Ji3622f7a2018-04-04 21:51:34 -040091 echo "Loading artifact ${TCA_JAR} to http://${TCA_PATH_ARTIFACT}/${TCA_ARTIFACT}..."
Lusheng Jid6d409f2018-03-22 23:25:45 -040092 curl -s -X POST --data-binary @"${TCA_JAR}" "http://${TCA_PATH_ARTIFACT}/${TCA_ARTIFACT}"
93 echo
94}
95
96function tca_load_conf {
97 echo
Lusheng Ji3622f7a2018-04-04 21:51:34 -040098 echo "Loading configuration ${TCA_APP_CONF} to http://${TCA_PATH_APP}"
Lusheng Jid6d409f2018-03-22 23:25:45 -040099 curl -s -X PUT -d @${TCA_APP_CONF} http://${TCA_PATH_APP}
100 echo
101
102 # load preferences
103 echo
Lusheng Ji3622f7a2018-04-04 21:51:34 -0400104 echo "Loading preferences ${TCA_PREF} to http://${TCA_PATH_APP}/preferences"
Lusheng Jid6d409f2018-03-22 23:25:45 -0400105 curl -s -X PUT -d @${TCA_PREF} http://${TCA_PATH_APP}/preferences
106 echo
107}
108
109
110function tca_delete {
111 echo
Lusheng Ji3622f7a2018-04-04 21:51:34 -0400112 echo "Deleting application dcae-tca http://${TCA_PATH_APP}"
Lusheng Jid6d409f2018-03-22 23:25:45 -0400113 curl -s -X DELETE http://${TCA_PATH_APP}
114 echo
115
116 # delete artifact
117 echo
Lusheng Ji3622f7a2018-04-04 21:51:34 -0400118 echo "Deleting artifact http://${TCA_PATH_ARTIFACT}/${TCA_ARTIFACT}/versions/${TCA_ARTIFACT_VERSION} ..."
Lusheng Jid6d409f2018-03-22 23:25:45 -0400119 curl -s -X DELETE "http://${TCA_PATH_ARTIFACT}/${TCA_ARTIFACT}/versions/${TCA_ARTIFACT_VERSION}"
120 echo
121}
122
123function tca_start {
124 echo
125 echo "Starting TCADMaaPMRPublisherWorker, TCADMaaPMRSubscriberWorker, and TCAVESCollectorFlow ..."
126 curl -s -X POST "http://${TCA_PATH_APP}/workers/TCADMaaPMRPublisherWorker/start"
127 curl -s -X POST "http://${TCA_PATH_APP}/workers/TCADMaaPMRSubscriberWorker/start"
128 curl -s -X POST "http://${TCA_PATH_APP}/flows/TCAVESCollectorFlow/start"
129 echo
130}
131
132
133function tca_status {
Lusheng Jie380f6b2018-05-14 22:45:56 -0400134 WORKER_COUNT='0'
Lusheng Jid6d409f2018-03-22 23:25:45 -0400135 echo
Lusheng Jie380f6b2018-05-14 22:45:56 -0400136 STATUS=$(curl -s "http://${TCA_PATH_APP}/workers/TCADMaaPMRPublisherWorker/status")
137 echo "TCADMaaPMRPublisherWorker status: $STATUS"
138 INC=$(echo "$STATUS" | jq . |grep RUNNING |wc -l)
139 WORKER_COUNT=$((WORKER_COUNT+INC))
140
141 STATUS=$(curl -s "http://${TCA_PATH_APP}/workers/TCADMaaPMRSubscriberWorker/status")
142 echo "TCADMaaPMRSubscriberWorker status: $STATUS"
143 INC=$(echo "$STATUS" | jq . |grep RUNNING |wc -l)
144 WORKER_COUNT=$((WORKER_COUNT+INC))
145
146 STATUS=$(curl -s "http://${TCA_PATH_APP}/flows/TCAVESCollectorFlow/status")
147 echo "TCAVESCollectorFlow status: $STATUS"
148 INC=$(echo "$STATUS" | jq . |grep RUNNING |wc -l)
149 WORKER_COUNT=$((WORKER_COUNT+INC))
Lusheng Jid6d409f2018-03-22 23:25:45 -0400150 echo
Lusheng Jid6d409f2018-03-22 23:25:45 -0400151}
152
153
Lusheng Jie380f6b2018-05-14 22:45:56 -0400154function tca_restart {
155 MR_HOST=$(jq .subscriberHostName ${TCA_PREF} |sed -e 's/\"//g')
156 MR_PORT=$(jq .subscriberHostPort ${TCA_PREF} |sed -e 's/\"//g')
157 MR_TOPIC=$(jq .subscriberTopicName ${TCA_PREF} |sed -e 's/\"//g')
158 echo "Verifying DMaaP topic: ${MR_TOPIC}@${MR_HOST}:${MR_PORT} (will block until topic ready)"
159 "${MR_WATCHDOG_PATH}" "${MR_HOST}" "${MR_PORT}" "${MR_TOPIC}"
160 tca_stop
161 tca_delete
162 tca_load_artifact
163 tca_load_conf
164 tca_start
165 sleep 5
166 tca_status
167}
168
Lusheng Jid6d409f2018-03-22 23:25:45 -0400169function tca_poll_policy {
Lusheng Jie134c822018-04-23 23:16:32 -0400170 URL0="${CBS_HOST}:${CBS_PORT}/service_component_all/${MY_NAME}"
Lusheng Ji1dd7a992018-05-10 23:54:18 -0400171 echo "tca_poll_policy: Retrieving all-in-one config at ${URL0}"
Lusheng Jie134c822018-04-23 23:16:32 -0400172 HTTP_RESPONSE=$(curl --silent --write-out "HTTPSTATUS:%{http_code}" "$URL0")
Lusheng Ji1dd7a992018-05-10 23:54:18 -0400173 HTTP_BODY=$(echo "$HTTP_RESPONSE" | sed -e 's/HTTPSTATUS\:.*//g')
174 HTTP_STATUS=$(echo "$HTTP_RESPONSE" | tr -d '\n' | sed -e 's/.*HTTPSTATUS://')
Lusheng Jiac864ce2018-04-05 12:02:52 -0400175
Lusheng Jiac864ce2018-04-05 12:02:52 -0400176 if [ "$HTTP_STATUS" != "200" ]; then
Lusheng Ji1dd7a992018-05-10 23:54:18 -0400177 echo "tca_poll_policy: Retrieving all-in-one config failed with status $HTTP_STATUS"
Lusheng Jie134c822018-04-23 23:16:32 -0400178 URL1="${CBS_HOST}:${CBS_PORT}/service_component/${MY_NAME}"
Lusheng Ji1dd7a992018-05-10 23:54:18 -0400179 echo "tca_poll_policy: Retrieving app config only at ${URL1}"
Lusheng Jie134c822018-04-23 23:16:32 -0400180 HTTP_RESPONSE1=$(curl --silent --write-out "HTTPSTATUS:%{http_code}" "$URL1")
Lusheng Ji1dd7a992018-05-10 23:54:18 -0400181 HTTP_BODY1=$(echo "$HTTP_RESPONSE1" | sed -e 's/HTTPSTATUS\:.*//g')
182 HTTP_STATUS1=$(echo "$HTTP_RESPONSE1" | tr -d '\n' | sed -e 's/.*HTTPSTATUS://')
Lusheng Jie134c822018-04-23 23:16:32 -0400183 if [ "$HTTP_STATUS1" != "200" ]; then
Lusheng Ji1dd7a992018-05-10 23:54:18 -0400184 echo "tca_poll_policy: Retrieving app config only failed with status $HTTP_STATUS1"
Lusheng Jie134c822018-04-23 23:16:32 -0400185 return
186 fi
187
188 URL2="$URL1:preferences"
Lusheng Ji1dd7a992018-05-10 23:54:18 -0400189 echo "tca_poll_policy: Retrieving app preferences only at ${URL2}"
Lusheng Jie134c822018-04-23 23:16:32 -0400190 HTTP_RESPONSE2=$(curl --silent --write-out "HTTPSTATUS:%{http_code}" "$URL2")
Lusheng Ji1dd7a992018-05-10 23:54:18 -0400191 HTTP_BODY2=$(echo "$HTTP_RESPONSE2" | sed -e 's/HTTPSTATUS\:.*//g')
192 HTTP_STATUS2=$(echo "$HTTP_RESPONSE2" | tr -d '\n' | sed -e 's/.*HTTPSTATUS://')
Lusheng Jie134c822018-04-23 23:16:32 -0400193 if [ "$HTTP_STATUS2" != "200" ]; then
Lusheng Ji1dd7a992018-05-10 23:54:18 -0400194 echo "tca_poll_policy: Retrieving app preferences only failed with status $HTTP_STATUS2"
195 return
196 fi
197
198 if [[ "$CONFIG" == "null" || "$PREF" == "null" ]]; then
199 echo "tca_poll_policy: either app config or app preferences being empty, config not applicable"
Lusheng Jie134c822018-04-23 23:16:32 -0400200 return
201 fi
202
Lusheng Ji1dd7a992018-05-10 23:54:18 -0400203 echo "$HTTP_BODY1" | jq . --sort-keys > "${TCA_CONF_TEMP}"
204 echo "$HTTP_BODY2" | jq . --sort-keys > "${TCA_PREF_TEMP}"
Lusheng Jie134c822018-04-23 23:16:32 -0400205 else
Lusheng Ji1dd7a992018-05-10 23:54:18 -0400206 CONFIG=$(echo "$HTTP_BODY" | jq .config.app_config)
207 PREF=$(echo "$HTTP_BODY" | jq .config.app_preferences)
Vijay Venkatesh Kumar290fe202019-04-24 12:49:48 +0000208 POLICY=$(echo "$HTTP_BODY" | jq .policies.items[0].config.tca_policy)
vagrantb51fd792018-05-01 08:21:11 +0000209
vagrantb51fd792018-05-01 08:21:11 +0000210
Lusheng Ji1dd7a992018-05-10 23:54:18 -0400211 if [[ "$CONFIG" == "null" || "$PREF" == "null" ]]; then
212 echo "tca_poll_policy: CONFIG received is parsed to be empty, trying to parse using R1 format"
213 CONFIG=$(echo "$HTTP_BODY" | jq .config)
214 NEWPREF=$(echo "$HTTP_BODY" | jq .preferences)
215
216 #echo "CONFIG is [$CONFIG]"
217 #echo "NEWPREF is [$NEWPREF]"
vagrantb51fd792018-05-01 08:21:11 +0000218 else
Lusheng Ji1dd7a992018-05-10 23:54:18 -0400219 echo "tca_poll_policy: CONFIG is [${CONFIG}], PREF is [${PREF}], POLICY is [${POLICY}]"
220 ## Check if policy content under tca_policy is returned null
221 ## null indicates no active policy flow; hence use configuration loaded
222 ## from blueprint
223 if [ "$POLICY" == "null" ]; then
224 # tca_policy through blueprint
225 NEWPREF=${PREF}
226 else
227 # tca_policy through active policy flow through PH
228 NEWPREF=$(echo "$PREF" | jq --arg tca_policy "$POLICY" '. + {$tca_policy}')
229 fi
230 NEWPREF=$(echo "$NEWPREF" | sed 's/\\n//g')
vagrantb51fd792018-05-01 08:21:11 +0000231 fi
Lusheng Ji1dd7a992018-05-10 23:54:18 -0400232
233 if [[ "$CONFIG" == "null" || "$NEWPREF" == "null" ]]; then
234 echo "tca_poll_policy: either app config or app preferences being empty, config not applicable"
235 return
236 fi
237
238 echo "$CONFIG" | jq . --sort-keys > "${TCA_CONF_TEMP}"
239 echo "$NEWPREF" | jq . --sort-keys > "${TCA_PREF_TEMP}"
Lusheng Jiac864ce2018-04-05 12:02:52 -0400240 fi
Lusheng Jid6d409f2018-03-22 23:25:45 -0400241
242 if [ ! -e "${TCA_CONF_TEMP}" ] || [ "$(ls -sh ${TCA_CONF_TEMP} |cut -f1 -d' ' |sed -e 's/[^0-9]//g')" -lt "1" ]; then
243 echo "Fail to receive configuration"
244 return
245 fi
246 if [ ! -e "${TCA_PREF_TEMP}" ] || [ "$(ls -sh ${TCA_PREF_TEMP} |cut -f1 -d' ' |sed -e 's/[^0-9]//g')" -lt "1" ]; then
247 echo "Fail to receive preferences"
248 return
249 fi
250
251 CONF_CHANGED=""
252 # extract only the config section from APP CONF (which has both artifact and config sections)
253 jq .config --sort-keys ${TCA_APP_CONF} > ${TCA_CONF}
254 if ! diff ${TCA_CONF} ${TCA_CONF_TEMP} ; then
255 echo "TCA config changed"
256 # generating the new app conf using current app conf's artifact section and the new downloaded config
257 jq --argfile CONFVALUE ${TCA_CONF_TEMP} '.config = $CONFVALUE' <${TCA_APP_CONF} > ${TCA_APP_CONF_TEMP}
258
259 mv ${TCA_APP_CONF_TEMP} ${TCA_APP_CONF}
260 CONF_CHANGED=1
261 fi
262
263 PERF_CHANGED=""
264 # update the subscriber ConsumerID, if not already unique,
265 # so replicas appear as different consumers in the consumer group
266 HOSTID=$(head -1 /etc/hostname | rev |cut -f1-2 -d'-' |rev)
267 CONSUMERID=$(jq .subscriberConsumerId ${TCA_PREF_TEMP} |sed -e 's/\"//g')
268 if ! (echo "$CONSUMERID" |grep "$HOSTID"); then
269 CONSUMERID="${CONSUMERID}-${HOSTID}"
Lusheng Ji1dd7a992018-05-10 23:54:18 -0400270 jq --arg CID "${CONSUMERID}" '.subscriberConsumerId = $CID' < "${TCA_PREF_TEMP}" > "${TCA_PREF_TEMP}2"
Lusheng Jid6d409f2018-03-22 23:25:45 -0400271 mv "${TCA_PREF_TEMP}2" "${TCA_PREF_TEMP}"
272 fi
273 if ! diff ${TCA_PREF} ${TCA_PREF_TEMP} ; then
274 echo "TCA preference updated"
275 mv ${TCA_PREF_TEMP} ${TCA_PREF}
276 PERF_CHANGED=1
277 fi
278
Lusheng Ji1dd7a992018-05-10 23:54:18 -0400279 if [[ "$PERF_CHANGED" == "1" || "$CONF_CHANGED" == "1" ]]; then
280 echo "Newly received configuration/preference differ from the running instance's. reload confg"
Lusheng Jie380f6b2018-05-14 22:45:56 -0400281 tca_restart
282 else
283 echo "Newly received configuration/preference identical from the running instance's"
Lusheng Jid6d409f2018-03-22 23:25:45 -0400284 fi
285}
286
287
288export PATH=${PATH}:/opt/cdap/sdk/bin
289
Lusheng Ji1dd7a992018-05-10 23:54:18 -0400290
291echo "Starting TCA-CDAP in standalone mode"
292
Lusheng Jid6d409f2018-03-22 23:25:45 -0400293# starting CDAP SDK in background
294cdap sdk start
295
Lusheng Jie380f6b2018-05-14 22:45:56 -0400296echo "CDAP Started, waiting CDAP ready on ${CDAP_HOST}:${CDAP_PORT} ..."
Lusheng Jid6d409f2018-03-22 23:25:45 -0400297while ! nc -z ${CDAP_HOST} ${CDAP_PORT}; do
Lusheng Jie380f6b2018-05-14 22:45:56 -0400298 sleep 1 # wait for 1 second before check again
Lusheng Jid6d409f2018-03-22 23:25:45 -0400299done
Lusheng Jid6d409f2018-03-22 23:25:45 -0400300
301echo "Creating namespace cdap_tca_hi_lo ..."
302curl -s -X PUT "http://${CDAP_HOST}:${CDAP_PORT}/v3/namespaces/cdap_tca_hi_lo"
303
Lusheng Jid6d409f2018-03-22 23:25:45 -0400304# stop programs
305tca_stop
Lusheng Jid6d409f2018-03-22 23:25:45 -0400306# delete application
307tca_delete
Lusheng Jid6d409f2018-03-22 23:25:45 -0400308# load artifact
309tca_load_artifact
310tca_load_conf
Lusheng Jid6d409f2018-03-22 23:25:45 -0400311# start programs
312tca_start
313
Lusheng Jid6d409f2018-03-22 23:25:45 -0400314# get status of programs
315tca_status
316
Lusheng Jie380f6b2018-05-14 22:45:56 -0400317echo "TCA-CDAP standalone mode initialization completed, with $WORKER_COUNT / 3 up"
Lusheng Jid6d409f2018-03-22 23:25:45 -0400318
319
Lusheng Ji1dd7a992018-05-10 23:54:18 -0400320
321#Changing to HOSTNAME parameter for consistency with k8s deploy
322MY_NAME=${HOSTNAME:-tca}
323
Vijay Venkatesh Kumar2cabee92020-01-13 20:50:28 +0000324echo "TCA environment: I am ${MY_NAME}, CBS K8S Service Name and port is ${CBS_HOST}:${CBS_PORT}"
Lusheng Ji1dd7a992018-05-10 23:54:18 -0400325
326while echo
Lusheng Jid6d409f2018-03-22 23:25:45 -0400327do
Lusheng Jie380f6b2018-05-14 22:45:56 -0400328 echo "======================================================> $(date)"
329 tca_status
330
331 while [ "$WORKER_COUNT" != "3" ]; do
332 echo "Status checking: worker count is $WORKER_COUNT, needs a reset"
333 sleep 5
334
335 tca_restart
336 echo "TCA restarted"
337 done
338
339
Vijay Venkatesh Kumar2cabee92020-01-13 20:50:28 +0000340#Below commented to remove consul lookup and use k8s servicename for CBS (DCAEGEN2-2021)
341# if [[ -z "$CBS_HOST" || -z "$CBS_PORT" ]]; then
342# echo "Retrieving host and port for ${CBS_SERVICE_NAME} from ${CONSUL_HOST}:${CONSUL_PORT}"
343# sleep 2
344# CBS_HOST=$(curl -s "${CONSUL_HOST}:${CONSUL_PORT}/v1/catalog/service/${CBS_SERVICE_NAME}" |jq .[0].ServiceAddress |sed -e 's/\"//g')
345# CBS_PORT=$(curl -s "${CONSUL_HOST}:${CONSUL_PORT}/v1/catalog/service/${CBS_SERVICE_NAME}" |jq .[0].ServicePort |sed -e 's/\"//g')
346# echo "CBS discovered to be at ${CBS_HOST}:${CBS_PORT}"
347# fi
Lusheng Ji1dd7a992018-05-10 23:54:18 -0400348
349 if [ ! -z "$CBS_HOST" ] && [ ! -z "$CBS_PORT" ]; then
350 tca_poll_policy
351 fi
Lusheng Jid6d409f2018-03-22 23:25:45 -0400352 sleep 30
353done