aboutsummaryrefslogtreecommitdiffstats
path: root/aai-resources/src
diff options
context:
space:
mode:
authorVenkata Harish K Kajur <vk250x@att.com>2017-10-03 22:22:00 +0000
committerVenkata Harish K Kajur <vk250x@att.com>2017-10-04 05:01:06 +0000
commitb55d5b3b17177a4a8ed8b890216aa35eebf08969 (patch)
treef58c3ed39ad1939c65f13ad505b5e1108358d5fe /aai-resources/src
parent41c0b3995a3db07950e8e27726f15e7d46e323a0 (diff)
Change the init chef to wait until hbase is up
When vm1 and vm2 are deployed independently the vm1 needs to manually check the port on hbase container and see if the hbase is open when the port is open, wait a couple of seconds and then start the create db schema script Issue-ID: AAI-411 Change-Id: I329cb15de73fecd6c4057c6ee2c406bbf03a0272 Signed-off-by: Venkata Harish K Kajur <vk250x@att.com>
Diffstat (limited to 'aai-resources/src')
-rw-r--r--aai-resources/src/main/resources/docker/init-chef.sh39
1 files changed, 39 insertions, 0 deletions
diff --git a/aai-resources/src/main/resources/docker/init-chef.sh b/aai-resources/src/main/resources/docker/init-chef.sh
index 4c49a27..416c25f 100644
--- a/aai-resources/src/main/resources/docker/init-chef.sh
+++ b/aai-resources/src/main/resources/docker/init-chef.sh
@@ -59,6 +59,45 @@ chef-solo \
-j /var/chef/aai-config/cookbooks/runlist-aai-resources.json \
-E ${AAI_CHEF_ENV};
+TITAN_REALTIME="/opt/app/aai-resources/bundleconfig/etc/appprops/titan-realtime.properties";
+
+if [ ! -f ${TITAN_REALTIME} ]; then
+ echo "Unable to find the titan realtime file";
+ exit 1;
+fi
+
+HBASE_HOSTNAME=$(grep "storage.hostname" ${TITAN_REALTIME} | cut -d"=" -f2-);
+HBASE_PORT="${HBASE_PORT:-2181}";
+NUM_OF_RETRIES=${NUM_OF_RETRIES:-200};
+retry=0;
+
+# Tries to connect to hbase on port 2181 until success
+# or until the number of retries by default 500 times
+# with each time giving a sleep of 5 seconds between
+# each time it pings the port on that host
+
+while ! nc -z ${HBASE_HOSTNAME} ${HBASE_PORT} ;
+do
+ if [ $retry -eq $NUM_OF_RETRIES ]; then
+ echo "Unable to connect to hbase after $NUM_OF_RETRIES retries, please check if hbase server is properly configured and be able to connect";
+ exit 1;
+ fi;
+
+ echo "Waiting for hbase to be up";
+ sleep 5;
+
+ retry=$((retry + 1));
+done
+
+HBASE_STARTUP_ARTIFICIAL_DELAY=${HBASE_STARTUP_ARTIFICIAL_DELAY:-50};
+
+# By default the artificial delay will be introduced
+# the user can override it by set DISABLE_HBASE_STARTUP_ARTIFICIAL_DELAY to some string
+
+if [ -z "${DISABLE_HBASE_STARTUP_ARTIFICIAL_DELAY}" ]; then
+ sleep ${HBASE_STARTUP_ARTIFICIAL_DELAY};
+fi;
+
/opt/app/aai-resources/bin/createDBSchema.sh || {
echo "Error: Unable to create the db schema, please check if the hbase host is configured and up";
exit 1;