aboutsummaryrefslogtreecommitdiffstats
path: root/aai-resources/src
diff options
context:
space:
mode:
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;