aboutsummaryrefslogtreecommitdiff
path: root/provisioner
diff options
context:
space:
mode:
authorEvans Ye <evansye@apache.org>2016-01-24 13:49:36 +0800
committerOlaf Flebbe <of@oflebbe.de>2016-08-09 20:26:21 +0200
commitfb08b15ae1c37c4e8cba93eff21393de96ff3d02 (patch)
treee3bc99847218150d5117d1e68fb60e0e7ed2b7a0 /provisioner
parentd5415743973e6b4db707dbc5ed9d4be458eaf40e (diff)
BIGTOP-2273. Add exec command into docker-hadoop.sh
Diffstat (limited to 'provisioner')
-rw-r--r--provisioner/docker/README.md25
-rwxr-xr-xprovisioner/docker/docker-hadoop.sh33
2 files changed, 49 insertions, 9 deletions
diff --git a/provisioner/docker/README.md b/provisioner/docker/README.md
index 51bac857..fbc82b4c 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
```
diff --git a/provisioner/docker/docker-hadoop.sh b/provisioner/docker/docker-hadoop.sh
index e8bd767e..d8392baa 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;;