bigtop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ofle...@apache.org
Subject [47/51] [abbrv] bigtop git commit: BIGTOP-2273. Add exec command into docker-hadoop.sh
Date Fri, 29 Jul 2016 17:03:28 GMT
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/a15d8f93
Tree: http://git-wip-us.apache.org/repos/asf/bigtop/tree/a15d8f93
Diff: http://git-wip-us.apache.org/repos/asf/bigtop/diff/a15d8f93

Branch: refs/heads/BIGTOP-2253
Commit: a15d8f9338c285f6f7f573b236e36c27bdd5de83
Parents: 9ea5150
Author: Evans Ye <evansye@apache.org>
Authored: Sun Jan 24 13:49:36 2016 +0800
Committer: Olaf Flebbe <o.flebbe@science-computing.de>
Committed: Fri Jul 22 20:54:48 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/a15d8f93/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/a15d8f93/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;;


Mime
View raw message