vinayakb | 38b7ca4 | 2012-03-05 05:44:15 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # Logging output for the CC and NCs is directed to their appropriately named |
| 4 | # files in LOG_HOME |
| 5 | # |
| 6 | # Example usage: ./runasterix.sh 4 |
| 7 | # Loads 1 CC, 4 NCs (nc0, nc1, nc2, and nc3) |
| 8 | # |
| 9 | |
| 10 | BASEDIR=`pwd`/$(dirname $0) |
| 11 | echo "Base dir: " ${BASEDIR} |
| 12 | |
| 13 | ASTERIX_BIN=${BASEDIR}/asterix/asterix-app.zip |
| 14 | HYRACKS_SERVER_BIN=${BASEDIR}/hyracks-server/bin |
| 15 | HYRACKS_CLI_BIN=${BASEDIR}/hyracks-cli/bin |
| 16 | |
| 17 | CONFIG_DIR=${BASEDIR}/config |
| 18 | LOG_DIR=${BASEDIR}/log |
| 19 | |
| 20 | mkdir ${LOG_DIR} ${CONFIG_DIR} |
| 21 | |
| 22 | CONFIG_NAME=local-autogen.properties # name of config file to generate |
| 23 | |
| 24 | # check existence of directories |
| 25 | dirs=($HYRACKS_SERVER_BIN $HYRACKS_CLI_BIN $LOG_DIR $CONFIG_DIR) |
| 26 | for i in "${dirs[@]}" |
| 27 | do |
| 28 | if [ ! -d "$i" ] |
| 29 | then |
| 30 | printf "Error: invalid directory layout -- can't access $i\n" >&2 |
| 31 | exit 2 |
| 32 | fi |
| 33 | done |
| 34 | |
| 35 | # set number of node controllers to load |
| 36 | if [ "$1" == "" ] |
| 37 | then |
| 38 | numnc=1 |
| 39 | else |
| 40 | if echo $1 | egrep -q '^[0-9]+$'; then |
| 41 | numnc=$1 |
| 42 | else |
| 43 | printf "Error: $1 is not a number.\n" >&2 |
| 44 | printf "usage: %s [number_of_ncs]\n" $(basename $0) >&2 |
| 45 | exit 2 |
| 46 | fi |
| 47 | fi |
| 48 | |
| 49 | # generate a suitable config file |
| 50 | echo "generating config file..." |
| 51 | printf "MetadataNode=nc1\nNewUniverse=true\n" > $CONFIG_DIR/$CONFIG_NAME |
| 52 | for ((i=1;i<=$numnc;i++)); do |
| 53 | echo "nc$i.stores=/tmp/nc$i/" >> $CONFIG_DIR/$CONFIG_NAME |
| 54 | done |
| 55 | echo "OutputDir=/tmp/asterix_output/" >> $CONFIG_DIR/$CONFIG_NAME |
| 56 | |
| 57 | # point to the config file and give java some extra memory |
| 58 | export CLASSPATH_PREFIX=$CONFIG_DIR |
| 59 | export JAVA_OPTS="-DAsterixConfigFileName=$CONFIG_NAME -Xms256m -Xmx512m" |
| 60 | |
| 61 | echo "cluster controller starting..." |
| 62 | sh $HYRACKS_SERVER_BIN/hyrackscc -cc-root localhost -client-net-ip-address 127.0.0.1 -cluster-net-ip-address 127.0.0.1 &> $LOG_DIR/cc.log & |
| 63 | |
| 64 | # for some reason this helps against getting a socket error |
| 65 | sleep 3 |
| 66 | |
| 67 | # start the node controllers |
| 68 | for ((i=1;i<=$numnc;i++)); do |
| 69 | echo "node controller (nc$i) starting..." |
| 70 | sh $HYRACKS_SERVER_BIN/hyracksnc -cc-host localhost -cluster-net-ip-address 127.0.0.1 -data-ip-address 127.0.0.1 -node-id "nc$i" \ |
| 71 | &> $LOG_DIR/nc$i.log & |
| 72 | |
| 73 | # avoid socket error |
| 74 | sleep .5 |
| 75 | done |
| 76 | |
| 77 | # deploy the asterix application to hyracks |
| 78 | echo "connect to \"localhost\";create application asterix \"$ASTERIX_BIN\";" > $CONFIG_DIR/deploy.hcli |
| 79 | cat $CONFIG_DIR/deploy.hcli | sh $HYRACKS_CLI_BIN/hyrackscli |