Repository: hadoop
Updated Branches:
  refs/heads/docker-hadoop-runner 578ad9c28 -> 2a89d85e2


HDDS-839. Wait for other services in the started script of hadoop-runner base 
docker image
Contributed by Elek, Marton.


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/2a89d85e
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/2a89d85e
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/2a89d85e

Branch: refs/heads/docker-hadoop-runner
Commit: 2a89d85e22f808ae7eb514e9ce00c47d08f46ba0
Parents: 578ad9c
Author: Anu Engineer <[email protected]>
Authored: Tue Nov 27 17:59:50 2018 -0800
Committer: Anu Engineer <[email protected]>
Committed: Tue Nov 27 17:59:50 2018 -0800

----------------------------------------------------------------------
 Dockerfile         |  2 +-
 scripts/starter.sh | 39 ++++++++++++++++++++++++++++++++-------
 2 files changed, 33 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/2a89d85e/Dockerfile
----------------------------------------------------------------------
diff --git a/Dockerfile b/Dockerfile
index dd7dc00..4627be9 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -15,7 +15,7 @@
 # limitations under the License.
 
 FROM openjdk:8-jdk
-RUN apt-get update && apt-get install -y jq curl python python-pip sudo && 
apt-get clean
+RUN apt-get update && apt-get install -y jq curl python python-pip sudo netcat 
&& apt-get clean
 RUN pip install robotframework
 RUN wget -O /usr/local/bin/dumb-init 
https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64
 RUN chmod +x /usr/local/bin/dumb-init

http://git-wip-us.apache.org/repos/asf/hadoop/blob/2a89d85e/scripts/starter.sh
----------------------------------------------------------------------
diff --git a/scripts/starter.sh b/scripts/starter.sh
index 5b898e7..0b07bba 100755
--- a/scripts/starter.sh
+++ b/scripts/starter.sh
@@ -18,9 +18,6 @@
 ##
 set -e
 
-#To avoid docker volume permission problems
-sudo chmod o+rwx /data
-
 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
 
 $DIR/envtoconf.py --destination /opt/hadoop/etc/hadoop
@@ -30,6 +27,38 @@ if [ -n "$SLEEP_SECONDS" ]; then
    sleep $SLEEP_SECONDS
 fi
 
+#
+# You can wait for an other TCP port with these settings.
+#
+# Example:
+#
+# export WAITFOR=localhost:9878
+#
+# With an optional parameter, you can also set the maximum 
+# time of waiting with (in seconds) with WAITFOR_TIMEOUT.
+# (The default is 300 seconds / 5 minutes.)
+if [ ! -z "$WAITFOR" ]; then
+  echo "Waiting for the service $WAITFOR"
+  WAITFOR_HOST=$(printf "%s\n" "$WAITFOR"| cut -d : -f 1)
+  WAITFOR_PORT=$(printf "%s\n" "$WAITFOR"| cut -d : -f 2)
+  for i in `seq ${WAITFOR_TIMEOUT:-300} -1 0` ; do
+    set +e
+    nc -z "$WAITFOR_HOST" "$WAITFOR_PORT" > /dev/null 2>&1
+    result=$?
+    set -e
+    if [ $result -eq 0 ] ; then
+      break
+    fi
+    sleep 1
+  done
+  if [ "$i" -eq 0 ]; then
+     echo "Waiting for service $WAITFOR is timed out." >&2
+     exit 1
+  f
+  fi
+fi
+
+
 if [ -n "$KERBEROS_ENABLED" ]; then
        echo "Setting up kerberos!!"
        KERBEROS_SERVER=${KERBEROS_SERVER:-krb5}
@@ -87,10 +116,6 @@ fi
 
 if [ -n "$ENSURE_OM_INITIALIZED" ]; then
    if [ ! -f "$ENSURE_OM_INITIALIZED" ]; then
-      # To make sure SCM is running in dockerized environment we will sleep
-      # Could be removed after HDFS-13203
-      echo "Waiting 15 seconds for SCM startup"
-      sleep 15
       # Improve om and scm start up options
       /opt/hadoop/bin/ozone om --init || /opt/hadoop/bin/ozone om 
-createObjectStore
    fi


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to