blob: b84834face3442896ef044babee4d125f4cbd3c0 [file] [log] [blame]
vinayakb38b7ca42012-03-05 05:44:15 +00001#!/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
10BASEDIR=`pwd`/$(dirname $0)
11echo "Base dir: " ${BASEDIR}
12
13ASTERIX_BIN=${BASEDIR}/asterix/asterix-app.zip
14HYRACKS_SERVER_BIN=${BASEDIR}/hyracks-server/bin
15HYRACKS_CLI_BIN=${BASEDIR}/hyracks-cli/bin
16
17CONFIG_DIR=${BASEDIR}/config
18LOG_DIR=${BASEDIR}/log
19
20mkdir ${LOG_DIR} ${CONFIG_DIR}
21
22CONFIG_NAME=local-autogen.properties # name of config file to generate
23
24# check existence of directories
25dirs=($HYRACKS_SERVER_BIN $HYRACKS_CLI_BIN $LOG_DIR $CONFIG_DIR)
26for i in "${dirs[@]}"
27do
28 if [ ! -d "$i" ]
29 then
30 printf "Error: invalid directory layout -- can't access $i\n" >&2
31 exit 2
32 fi
33done
34
35# set number of node controllers to load
36if [ "$1" == "" ]
37then
38 numnc=1
39else
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
47fi
48
49# generate a suitable config file
50echo "generating config file..."
51printf "MetadataNode=nc1\nNewUniverse=true\n" > $CONFIG_DIR/$CONFIG_NAME
52for ((i=1;i<=$numnc;i++)); do
53 echo "nc$i.stores=/tmp/nc$i/" >> $CONFIG_DIR/$CONFIG_NAME
54done
55echo "OutputDir=/tmp/asterix_output/" >> $CONFIG_DIR/$CONFIG_NAME
56
57# point to the config file and give java some extra memory
58export CLASSPATH_PREFIX=$CONFIG_DIR
59export JAVA_OPTS="-DAsterixConfigFileName=$CONFIG_NAME -Xms256m -Xmx512m"
60
61echo "cluster controller starting..."
62sh $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
65sleep 3
66
67# start the node controllers
68for ((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
75done
76
77# deploy the asterix application to hyracks
78echo "connect to \"localhost\";create application asterix \"$ASTERIX_BIN\";" > $CONFIG_DIR/deploy.hcli
79cat $CONFIG_DIR/deploy.hcli | sh $HYRACKS_CLI_BIN/hyrackscli