You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bigtop.apache.org by of...@apache.org on 2016/08/09 18:28:46 UTC

[6/9] bigtop git commit: BIGTOP-2273. Add exec command into docker-hadoop.sh

BIGTOP-2273. Add exec command into docker-hadoop.sh


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

Branch: refs/heads/master
Commit: fb08b15ae1c37c4e8cba93eff21393de96ff3d02
Parents: d541574
Author: Evans Ye <ev...@apache.org>
Authored: Sun Jan 24 13:49:36 2016 +0800
Committer: Olaf Flebbe <of...@oflebbe.de>
Committed: Tue Aug 9 20:26:21 2016 +0200

----------------------------------------------------------------------
 provisioner/docker/README.md        | 25 +++++++++++++++++++-----
 provisioner/docker/docker-hadoop.sh | 33 ++++++++++++++++++++++++++++----
 2 files changed, 49 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/bigtop/blob/fb08b15a/provisioner/docker/README.md
----------------------------------------------------------------------
diff --git a/provisioner/docker/README.md b/provisioner/docker/README.md
index 51bac85..fbc82b4 100644
--- a/provisioner/docker/README.md
+++ b/provisioner/docker/README.md
@@ -60,19 +60,31 @@ service docker start
 ./docker-hadoop.sh --destroy
 ```
 
-3) Update your cluster after doing configuration changes on ./config. (re-run puppet apply)
+3) Get into the first container (the master)
+
+```
+./docker-hadoop.sh --exec 1 bash
+```
+
+4) Execute a command on the second container
+
+```
+./docker-hadoop.sh --exec 2 hadoop fs -ls /
+```
+
+5) Update your cluster after doing configuration changes on ./config. (re-run puppet apply)
 
 ```
 ./docker-hadoop.sh --provision
 ```
 
-4) Run Bigtop smoke tests
+6) Run Bigtop smoke tests
 
 ```
 ./docker-hadoop.sh --smoke-tests
 ```
 
-5) Chain your operations with-in one command.
+7) Chain your operations with-in one command.
 
 ```
 ./docker-hadoop.sh --create 5 --smoke-tests --destroy
@@ -84,7 +96,7 @@ Commands will be executed by following order:
 create 5 node cluster => run smoke tests => destroy the cluster
 ```
 
-6) See helper message:
+8) See helper message:
 
 ```
 ./docker-hadoop.sh -h
@@ -92,9 +104,12 @@ usage: docker-hadoop.sh [-C file ] args
        -C file                                   Use alternate file for config.yaml
   commands:
        -c NUM_INSTANCES, --create=NUM_INSTANCES  Create a Docker based Bigtop Hadoop cluster
+       -d, --destroy                             Destroy the cluster
+       -e, --exec INSTANCE_NO|INSTANCE_NAME      Execute command on a specific instance. Instance can be specified by name or number.
+                                                 For example: docker-hadoop.sh --exec 1 bash
+                                                              docker-hadoop.sh --exec docker_bigtop_1 bash
        -p, --provision                           Deploy configuration changes
        -s, --smoke-tests                         Run Bigtop smoke tests
-       -d, --destroy                             Destroy the cluster
        -h, --help
 ```
 

http://git-wip-us.apache.org/repos/asf/bigtop/blob/fb08b15a/provisioner/docker/docker-hadoop.sh
----------------------------------------------------------------------
diff --git a/provisioner/docker/docker-hadoop.sh b/provisioner/docker/docker-hadoop.sh
index e8bd767..d8392ba 100755
--- a/provisioner/docker/docker-hadoop.sh
+++ b/provisioner/docker/docker-hadoop.sh
@@ -22,9 +22,12 @@ usage() {
     echo "       -C file                                   Use alternate file for config.yaml"
     echo "  commands:"
     echo "       -c NUM_INSTANCES, --create=NUM_INSTANCES  Create a Docker based Bigtop Hadoop cluster"
+    echo "       -d, --destroy                             Destroy the cluster"
+    echo "       -e, --exec INSTANCE_NO|INSTANCE_NAME      Execute command on a specific instance. Instance can be specified by name or number."
+    echo "                                                 For example: $PROG --exec 1 bash"
+    echo "                                                              $PROG --exec docker_bigtop_1 bash"
     echo "       -p, --provision                           Deploy configuration changes"
     echo "       -s, --smoke-tests                         Run Bigtop smoke tests"
-    echo "       -d, --destroy                             Destroy the cluster"
     echo "       -h, --help"
     exit 1
 }
@@ -137,6 +140,20 @@ get-yaml-config() {
     cat ${yamlconf} | $RUBY_EXE -ryaml -e "$RUBY_SCRIPT" | tr -d '\r'
 }
 
+execute() {
+    re='^[0-9]+$'
+    if [[ $1 =~ $re ]] ; then
+        no=$1
+        shift
+        nodes=(`docker-compose ps -q`)
+        docker exec -ti ${nodes[$((no-1))]} $@
+    else
+        name=$1
+        shift
+        docker exec -ti $name $@
+    fi
+}
+
 PROG=`basename $0`
 
 if [ $# -eq 0 ]; then
@@ -160,15 +177,23 @@ while [ $# -gt 0 ]; do
         fi
 	yamlconf=$2
         shift 2;;
+    -d|--destroy)
+        destroy
+        shift;;
+    -e|--exec)
+        if [ $# -lt 3 ]; then
+          echo "exec command takes 2 parameters: 1) instance no 2) command to be executed" 1>&2
+          usage
+        fi
+        shift
+        execute $@
+        shift $#;;
     -p|--provision)
         provision
         shift;;
     -s|--smoke-tests)
         smoke-tests
         shift;;
-    -d|--destroy)
-        destroy
-        shift;;
     -h|--help)
         usage
         shift;;