blob: 574c2238c338d68b2d533b1d920d4c8da1a1ed46 [file] [log] [blame]
Naoki Shiota4e463182014-03-21 15:13:24 -07001#!/bin/bash
Naoki Shiota4e463182014-03-21 15:13:24 -07002
Naoki Shiota590c18d2014-03-31 17:52:59 -07003### Env vars used by this script. (default value) ###
4# $ONOS_HOME : path of root directory of ONOS repository (this script's dir)
5# $ONOS_CONF_DIR : path of ONOS config directory (~/ONOS/conf)
Naoki Shiota9a1e6d12014-04-03 14:47:12 -07006# $ONOS_CONF : path of ONOS node config file (~/ONOS/conf/onos_node.`hostname`.conf or onos_node.conf)
Naoki Shiota590c18d2014-03-31 17:52:59 -07007# $ONOS_PROPS : path of ONOS properties file (~/ONOS/conf/onos.properties)
8# $ONOS_LOGBACK : path of logback config file (~/ONOS/conf/logback.`hostname`.xml)
Naoki Shiotad8ea71a2014-04-23 17:04:51 -07009# $ONOS_LOGDIR : path of log output directory (~/ONOS/onos-logs)
10# $ONOS_LOGBASE : base name of log output file (onos.`hostname`)
Praseed Balakrishnan418c7b22014-06-16 13:33:53 -070011# $ONOS_DEBUG : option to enable debugger for ONOS (false)
Naoki Shiota590c18d2014-03-31 17:52:59 -070012# $RAMCLOUD_HOME : path of root directory of RAMCloud repository (~/ramcloud)
13# $RAMCLOUD_BRANCH : branch name of RAMCloud to use (master)
Yuta HIGUCHIfb1905a2014-06-09 14:07:34 -070014# $ZK_HOME : path of root directory of ZooKeeper (~/zookeeper-3.4.6)
Naoki Shiota72209722014-04-08 14:32:17 -070015# $ZK_LIB_DIR : path of ZooKeeper library (/var/lib/zookeeper)
Naoki Shiotad8ea71a2014-04-23 17:04:51 -070016# $ZK_LOG_DIR : path of ZooKeeper log output directory (~/ONOS/onos-logs/zk-`hostname`)
Praseed Balakrishnan418c7b22014-06-16 13:33:53 -070017# $JVM_OPTS : JVM options to add when starting ONOS
18# $JVM_DEBUG_PORT : port to use for remote debugging ONOS process, when $ONOS_DEBUG is enabled (22007)
Naoki Shiotab7eb55d2014-04-21 18:21:36 -070019# $ZK_CONF : path of ZooKeeper config file (~/ONOS/conf/zoo.cfg)
20# $HC_CONF : path of Hazelcast config file (~/ONOS/conf/hazelcast.xml)
21# $RAMCLOUD_CONF : path of RAMCloud config file (~/ONOS/conf/ramcloud.conf)
Naoki Shiota590c18d2014-03-31 17:52:59 -070022#####################################################
23
Naoki Shiota590c18d2014-03-31 17:52:59 -070024ONOS_HOME=${ONOS_HOME:-$(cd `dirname $0`; pwd)}
Naoki Shiota9df15d32014-03-27 14:26:20 -070025ONOS_CONF_DIR=${ONOS_CONF_DIR:-${ONOS_HOME}/conf}
Naoki Shiota9a1e6d12014-04-03 14:47:12 -070026ONOS_CONF=${ONOS_CONF:-${ONOS_CONF_DIR}/onos_node.`hostname`.conf}
Naoki Shiota590c18d2014-03-31 17:52:59 -070027
Naoki Shiotab7eb55d2014-04-21 18:21:36 -070028source ${ONOS_HOME}/scripts/common/utils.sh
29
Yuta HIGUCHIe748ecc2014-05-28 13:55:03 -070030confirm-if-root
31
Naoki Shiota590c18d2014-03-31 17:52:59 -070032if [ ! -f ${ONOS_CONF} ]; then
Naoki Shiota9a1e6d12014-04-03 14:47:12 -070033 # falling back to default config file
34 ONOS_CONF=${ONOS_CONF_DIR}/onos_node.conf
35 if [ ! -f ${ONOS_CONF} ]; then
36 echo "${ONOS_CONF} not found."
37 exit 1
38 fi
Naoki Shiota590c18d2014-03-31 17:52:59 -070039fi
Naoki Shiota4e928512014-04-03 15:49:35 -070040
Naoki Shiota4e928512014-04-03 15:49:35 -070041### Variables read from ONOS config file ###
Yuta HIGUCHI85de40d2014-06-12 14:06:41 -070042ONOS_CLUSTER_NAME=$(read-conf ${ONOS_CONF} onos.cluster.name "onos")
Naoki Shiota4e928512014-04-03 15:49:35 -070043ONOS_HOST_NAME=$(read-conf ${ONOS_CONF} host.name `hostname`)
44ONOS_HOST_IP=$(read-conf ${ONOS_CONF} host.ip)
45ONOS_HOST_ROLE=$(read-conf ${ONOS_CONF} host.role)
46ONOS_HOST_BACKEND=$(read-conf ${ONOS_CONF} host.backend)
47ZK_HOSTS=$(read-conf ${ONOS_CONF} zookeeper.hosts ${ONOS_HOST_NAME})
Yuta HIGUCHI5f1ce1c2014-07-20 22:43:54 -070048ZK_CLIENTPORT=$(read-conf ${ONOS_CONF} zookeeper.clientPort 2181)
49ZK_PORTS=$(read-conf ${ONOS_CONF} zookeeper.ports 2888:3888)
Naoki Shiota4e928512014-04-03 15:49:35 -070050RC_COORD_PROTOCOL=$(read-conf ${ONOS_CONF} ramcloud.coordinator.protocol "fast+udp")
51RC_COORD_IP=$(read-conf ${ONOS_CONF} ramcloud.coordinator.ip ${ONOS_HOST_IP})
52RC_COORD_PORT=$(read-conf ${ONOS_CONF} ramcloud.coordinator.port 12246)
53RC_SERVER_PROTOCOL=$(read-conf ${ONOS_CONF} ramcloud.server.protocol "fast+udp")
54RC_SERVER_IP=$(read-conf ${ONOS_CONF} ramcloud.server.ip ${ONOS_HOST_IP})
55RC_SERVER_PORT=$(read-conf ${ONOS_CONF} ramcloud.server.port 12242)
Naoki Shiotab7eb55d2014-04-21 18:21:36 -070056HC_HOST_PORT=$(read-conf ${ONOS_CONF} hazelcast.host.port 5701)
Naoki Shiota4e928512014-04-03 15:49:35 -070057HC_TCPIP_MEMBERS=$(read-conf ${ONOS_CONF} hazelcast.tcp-ip.members)
58HC_MULTICAST_GROUP=$(read-conf ${ONOS_CONF} hazelcast.multicast.group "224.2.2.3")
59HC_MULTICAST_PORT=$(read-conf ${ONOS_CONF} hazelcast.multicast.port 54327)
Naoki Shiota590c18d2014-03-31 17:52:59 -070060############################################
61
62
63############## Other variables #############
Naoki Shiota4e928512014-04-03 15:49:35 -070064ONOS_TEMPLATE_DIR=${ONOS_CONF_DIR}/template
65
Naoki Shiota4e463182014-03-21 15:13:24 -070066LOGDIR=${ONOS_LOGDIR:-${ONOS_HOME}/onos-logs}
67
Yuta HIGUCHIfb1905a2014-06-09 14:07:34 -070068ZK_HOME=${ZK_HOME:-~/zookeeper-3.4.6}
Naoki Shiotab7eb55d2014-04-21 18:21:36 -070069ZK_CONF=${ZK_CONF:-${ONOS_CONF_DIR}/zoo.cfg}
Naoki Shiota4e928512014-04-03 15:49:35 -070070ZK_CONF_TEMPLATE=${ONOS_TEMPLATE_DIR}/zoo.cfg.template
Yuta HIGUCHI13d1dbf2014-04-17 20:51:38 -070071# Adding ONOS_HOST_NAME dir since file name (zookeeper.out) cannot be controlled.
Naoki Shiotad8ea71a2014-04-23 17:04:51 -070072ZK_LOG_DIR=${ZK_LOG_DIR:-${ONOS_HOME}/onos-logs/zk-${ONOS_HOST_NAME}}
Naoki Shiota72209722014-04-08 14:32:17 -070073ZK_LIB_DIR=${ZK_LIB_DIR:-/var/lib/zookeeper}
Naoki Shiota9df15d32014-03-27 14:26:20 -070074ZK_MY_ID=${ZK_LIB_DIR}/myid
Naoki Shiota4e463182014-03-21 15:13:24 -070075
Naoki Shiotab7eb55d2014-04-21 18:21:36 -070076HC_CONF=${HC_CONF:-${ONOS_CONF_DIR}/hazelcast.xml}
Naoki Shiota4e928512014-04-03 15:49:35 -070077HC_CONF_TEMPLATE=${ONOS_TEMPLATE_DIR}/hazelcast.xml.template
78
Naoki Shiota4e463182014-03-21 15:13:24 -070079RAMCLOUD_HOME=${RAMCLOUD_HOME:-~/ramcloud}
Naoki Shiota590c18d2014-03-31 17:52:59 -070080RAMCLOUD_COORD_LOG=${LOGDIR}/ramcloud.coordinator.${ONOS_HOST_NAME}.log
81RAMCLOUD_SERVER_LOG=${LOGDIR}/ramcloud.server.${ONOS_HOST_NAME}.log
Naoki Shiota4e463182014-03-21 15:13:24 -070082RAMCLOUD_BRANCH=${RAMCLOUD_BRANCH:-master}
Naoki Shiotab7eb55d2014-04-21 18:21:36 -070083RAMCLOUD_CONF=${RAMCLOUD_CONF:-${ONOS_CONF_DIR}/ramcloud.conf}
Naoki Shiota4e463182014-03-21 15:13:24 -070084
Yuta HIGUCHI13d1dbf2014-04-17 20:51:38 -070085export LD_LIBRARY_PATH=${ONOS_HOME}/lib:${RAMCLOUD_HOME}/obj.${RAMCLOUD_BRANCH}:$LD_LIBRARY_PATH
Naoki Shiota4e463182014-03-21 15:13:24 -070086
87## Because the script change dir to $ONOS_HOME, we can set ONOS_LOGBACK and LOGDIR relative to $ONOS_HOME
Naoki Shiota590c18d2014-03-31 17:52:59 -070088ONOS_LOGBACK=${ONOS_LOGBACK:-${ONOS_CONF_DIR}/logback.${ONOS_HOST_NAME}.xml}
Naoki Shiota9df15d32014-03-27 14:26:20 -070089ONOS_LOGBACK_BACKUP=${ONOS_LOGBACK}.bak
Naoki Shiota4e928512014-04-03 15:49:35 -070090ONOS_LOGBACK_TEMPLATE=${ONOS_TEMPLATE_DIR}/logback.xml.template
Naoki Shiota4e463182014-03-21 15:13:24 -070091LOGDIR=${ONOS_LOGDIR:-${ONOS_HOME}/onos-logs}
Naoki Shiota590c18d2014-03-31 17:52:59 -070092LOGBASE=${ONOS_LOGBASE:-onos.${ONOS_HOST_NAME}}
Naoki Shiota4e463182014-03-21 15:13:24 -070093ONOS_LOG="${LOGDIR}/${LOGBASE}.log"
Yuta HIGUCHI04713972014-05-30 11:01:17 -070094ONOS_LOG_ROLLING_PATTERN="${LOGDIR}/${LOGBASE}.%i.log.gz"
95ONOS_STDOUT_LOG="${LOGDIR}/${LOGBASE}.stdout"
96ONOS_STDERR_LOG="${LOGDIR}/${LOGBASE}.stderr"
Naoki Shiota4e463182014-03-21 15:13:24 -070097PCAP_LOG="${LOGDIR}/${LOGBASE}.pcap"
Yuta HIGUCHI04713972014-05-30 11:01:17 -070098LOGS="$ONOS_LOG $ONOS_STDOUT_LOG $ONOS_STDERR_LOG $PCAP_LOG"
Naoki Shiota4e463182014-03-21 15:13:24 -070099
Naoki Shiota9df15d32014-03-27 14:26:20 -0700100ONOS_PROPS=${ONOS_PROPS:-${ONOS_CONF_DIR}/onos.properties}
Naoki Shiota4e463182014-03-21 15:13:24 -0700101JMX_PORT=${JMX_PORT:-7189}
Praseed Balakrishnan418c7b22014-06-16 13:33:53 -0700102JVM_DEBUG_PORT=${JVM_DEBUG_PORT:-22007}
Naoki Shiota4e463182014-03-21 15:13:24 -0700103
104# Set JVM options
105JVM_OPTS="${JVM_OPTS:-}"
Naoki Shiota4e463182014-03-21 15:13:24 -0700106JVM_OPTS="$JVM_OPTS -server -d64"
107#JVM_OPTS="$JVM_OPTS -XX:+TieredCompilation -XX:InitialCodeCacheSize=512m -XX:ReservedCodeCacheSize=512m"
Yuta HIGUCHI18354592014-04-01 13:53:42 -0700108
109# Uncomment or specify appropriate value as JVM_OPTS environment variables.
110#JVM_OPTS="$JVM_OPTS -Xmx4g -Xms4g -Xmn800m"
Naoki Shiota4e463182014-03-21 15:13:24 -0700111#JVM_OPTS="$JVM_OPTS -Xmx2g -Xms2g -Xmn800m"
112#JVM_OPTS="$JVM_OPTS -Xmx1g -Xms1g -Xmn800m"
Yuta HIGUCHI18354592014-04-01 13:53:42 -0700113
114#JVM_OPTS="$JVM_OPTS -XX:+UseParallelGC"
115JVM_OPTS="$JVM_OPTS -XX:+UseConcMarkSweepGC"
116JVM_OPTS="$JVM_OPTS -XX:+AggressiveOpts"
117
118# We may want to remove UseFastAccessorMethods option: http://bugs.java.com/view_bug.do?bug_id=6385687
119JVM_OPTS="$JVM_OPTS -XX:+UseFastAccessorMethods"
120
121JVM_OPTS="$JVM_OPTS -XX:MaxInlineSize=8192"
122JVM_OPTS="$JVM_OPTS -XX:FreqInlineSize=8192"
123JVM_OPTS="$JVM_OPTS -XX:CompileThreshold=1500"
124
Naoki Shiota4e463182014-03-21 15:13:24 -0700125JVM_OPTS="$JVM_OPTS -XX:OnError=crash-logger" ;# For dumping core
Yuta HIGUCHI18354592014-04-01 13:53:42 -0700126
Praseed Balakrishnan4fe80812014-07-24 11:29:19 -0700127# This option tells the VM to generate a heap dump when memory allocation cannot be satisfied.
128# http://www.oracle.com/technetwork/java/javase/clopts-139448.html#gbzrr
129JVM_OPTS="$JVM_OPTS -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=${ONOS_HOME}"
130
Yuta HIGUCHI18354592014-04-01 13:53:42 -0700131# Workaround for Thread Priority http://tech.stolsvik.com/2010/01/linux-java-thread-priorities-workaround.html
132JVM_OPTS="$JVM_OPTS -XX:+UseThreadPriorities -XX:ThreadPriorityPolicy=42"
133
134JVM_OPTS="$JVM_OPTS -XX:+UseCompressedOops"
135
136JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.port=$JMX_PORT"
137JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.ssl=false"
138JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.authenticate=false"
139
Yuta HIGUCHI6bcaf982014-07-30 15:49:58 -0700140JVM_OPTS="$JVM_OPTS -Dhazelcast.logging.type=slf4j -Dhazelcast.jmx=true -Dhazelcast.jmx.detailed=true"
Naoki Shiota4e463182014-03-21 15:13:24 -0700141
Yuta HIGUCHIc248d0d2014-07-30 16:14:18 -0700142# TODO revisit HZ related magic numbers
143# HZ Default:1000000
144JVM_OPTS="$JVM_OPTS -Dhazelcast.event.queue.capacity=4000000"
145# HZ Default:32 (KB)
146JVM_OPTS="$JVM_OPTS -Dhazelcast.socket.receive.buffer.size=4096"
147# HZ Default:32 (KB)
148JVM_OPTS="$JVM_OPTS -Dhazelcast.socket.send.buffer.size=4096"
149
150
Yuta HIGUCHI18354592014-04-01 13:53:42 -0700151# Uncomment to dump final JVM flags to stdout
152#JVM_OPTS="$JVM_OPTS -XX:+PrintFlagsFinal"
153
Naoki Shiota4e463182014-03-21 15:13:24 -0700154# Set ONOS core main class
Jonathan Hart51f6f5b2014-04-03 10:32:10 -0700155MAIN_CLASS="net.onrc.onos.core.main.Main"
Naoki Shiota4e463182014-03-21 15:13:24 -0700156
157MVN=${MVN:-mvn -o}
Naoki Shiota590c18d2014-03-31 17:52:59 -0700158############################################
Naoki Shiota4e463182014-03-21 15:13:24 -0700159
Naoki Shiota9df15d32014-03-27 14:26:20 -0700160
Naoki Shiota590c18d2014-03-31 17:52:59 -0700161############# Common functions #############
162function print_usage {
Naoki Shiota05721b32014-04-29 14:41:12 -0700163 local scriptname=`basename $0`
Naoki Shiota590c18d2014-03-31 17:52:59 -0700164 local filename=`basename ${ONOS_CONF}`
165 local usage="Usage: setup/start/stop ONOS on this server.
Naoki Shiota05721b32014-04-29 14:41:12 -0700166 \$ ${scriptname} setup [-f]
Pavlin Radoslavovd8f30d92014-04-18 13:03:09 -0700167 Set up ONOS node using ${ONOS_CONF} .
Naoki Shiota590c18d2014-03-31 17:52:59 -0700168 - generate and replace config file of ZooKeeper.
169 - create myid in ZooKeeper datadir.
Yuta HIGUCHI13d1dbf2014-04-17 20:51:38 -0700170 - generate and replace config file for Hazelcast.
171 - generate and replace config file for RAMCloud.
Naoki Shiota590c18d2014-03-31 17:52:59 -0700172 - generate and replace logback.${ONOS_HOST_NAME}.xml
173 If -f option is used, all existing files will be overwritten without confirmation.
Naoki Shiota05721b32014-04-29 14:41:12 -0700174 \$ ${scriptname} start [single-node|coord-node|server-node|coord-and-server-node]
Naoki Shiota590c18d2014-03-31 17:52:59 -0700175 Start ONOS node with specific RAMCloud entities
176 - single-node: start ONOS with stand-alone RAMCloud
177 - coord-node : start ONOS with RAMCloud coordinator
178 - server-node: start ONOS with RAMCloud server
179 - coord-and-server-node: start ONOS with RAMCloud coordinator and server
180 * Default behavior can be defined by ${filename}
Naoki Shiota05721b32014-04-29 14:41:12 -0700181 \$ ${scriptname} stop
Naoki Shiota590c18d2014-03-31 17:52:59 -0700182 Stop all ONOS-related processes
Naoki Shiota05721b32014-04-29 14:41:12 -0700183 \$ ${scriptname} restart
Naoki Shiota590c18d2014-03-31 17:52:59 -0700184 Stop and start currently running ONOS-related processes
Naoki Shiota05721b32014-04-29 14:41:12 -0700185 \$ ${scriptname} status
Naoki Shiota590c18d2014-03-31 17:52:59 -0700186 Show status of ONOS-related processes
Naoki Shiota05721b32014-04-29 14:41:12 -0700187 \$ ${scriptname} {zk|rc-coord|rc-server|core} {start|stop|restart|status}
Naoki Shiota9109a1e2014-05-13 11:11:01 -0700188 Control specific ONOS-related process
189 \$ ${scriptname} rc deldb
190 Delete data in RAMCloud"
Naoki Shiota590c18d2014-03-31 17:52:59 -0700191
Yuta HIGUCHId150ece2014-04-29 16:25:36 -0700192 echo "${usage}"
Naoki Shiota4e463182014-03-21 15:13:24 -0700193}
194
Yuta HIGUCHIb138a8c2014-06-19 11:07:20 -0700195# rotate-log [log-filename] [max rotations]
196# Example:
197# foobar.log -> foobar.log.1
198# foobar.log.1 -> foobar.log.2
199# foobar.log.gz -> foobar.log.1.gz
Naoki Shiota4e463182014-03-21 15:13:24 -0700200function rotate-log {
Naoki Shiota4e928512014-04-03 15:49:35 -0700201 local logfile=$1
202 local nr_max=${2:-10}
203 if [ -f $logfile ]; then
Yuta HIGUCHIb138a8c2014-06-19 11:07:20 -0700204 # TODO treating only .gz now. probably want more generic solution
205 local basename=${logfile%%.gz}
206 local append=""
207 if [ "$basename" != "$logfile" ]; then
208 append=".gz"
209 fi
Naoki Shiota4e928512014-04-03 15:49:35 -0700210 for i in `seq $(expr $nr_max - 1) -1 1`; do
Yuta HIGUCHIb138a8c2014-06-19 11:07:20 -0700211 if [ -f ${basename}.${i}${append} ]; then
212 mv -f ${basename}.${i}${append} ${basename}.`expr $i + 1`${append}
Naoki Shiota4e928512014-04-03 15:49:35 -0700213 fi
214 done
Yuta HIGUCHIb138a8c2014-06-19 11:07:20 -0700215 mv ${basename}${append} ${basename}.1${append}
Naoki Shiota4e928512014-04-03 15:49:35 -0700216 fi
Naoki Shiota4e463182014-03-21 15:13:24 -0700217}
218
219# kill-processes {module-name} {array of pids}
220function kill-processes {
221 # Kill the existing processes
222 local pids=$2
Naoki Shiota9df15d32014-03-27 14:26:20 -0700223 if [ ! -z "$pids" ]; then
Naoki Shiota4e463182014-03-21 15:13:24 -0700224 echo -n "Stopping $1 ... "
225 fi
226 for p in ${pids}; do
227 if [ x$p != "x" ]; then
Naoki Shiota4b355762014-05-27 11:46:43 -0700228 # Check if target process is accesible from current user
229 kill -0 $p
230 if [ "$?" -ne 0 ]; then
231 # Error exit code here means "failed to send signal".
232 # Supposedly because of permission error.
233 echo "Failed to kill process (pid: $p)."
234 echo "Check if current user is the same as process owner."
235 exit 1
236 fi
237
Yuta HIGUCHId150ece2014-04-29 16:25:36 -0700238 (
239 # Ask process with SIGTERM first, if that did not kill the process
240 # wait 1s and if process still exist, force process to be killed.
241 kill -TERM $p && kill -0 $p && sleep 1 && kill -0 $p && kill -KILL $p
242 ) 2> /dev/null
Naoki Shiota4b355762014-05-27 11:46:43 -0700243
244 # Ensure process is killed.
245 kill -0 $p 2> /dev/null
246 if [ "$?" -ne 0 ]; then
247 # Error exit code here means "process not found", i.e. "kill succeeded".
248 echo "Killed existing process (pid: $p)"
249 else
250 # Process still exists. Some unexpected error occurs.
251 echo "Failed to kill process (pid: $p)."
252 echo "Unexpected error occurs during process termination."
253 exit 1
254 fi
Naoki Shiota4e463182014-03-21 15:13:24 -0700255 fi
256 done
257}
258
Naoki Shiota9a1e6d12014-04-03 14:47:12 -0700259function handle-error {
260 set -e
261
262 revert-confs
263
264 set +e
265
266 exit 1
267}
268
Naoki Shiota4e928512014-04-03 15:49:35 -0700269# revert-confs [error message]
270function revert-confs {
Naoki Shiota9df15d32014-03-27 14:26:20 -0700271 echo -n "ERROR occurred ... "
Naoki Shiota9df15d32014-03-27 14:26:20 -0700272
Naoki Shiota4e928512014-04-03 15:49:35 -0700273 revert-file `basename ${ZK_CONF}`
274 revert-file `basename ${HC_CONF}`
Naoki Shiota9df15d32014-03-27 14:26:20 -0700275
276 echo "EXIT"
277
278 if [ ! -z "$1" ]; then
279 echo $1
280 fi
Naoki Shiota9df15d32014-03-27 14:26:20 -0700281}
282
Naoki Shiota590c18d2014-03-31 17:52:59 -0700283function create-zk-conf {
Naoki Shiota9df15d32014-03-27 14:26:20 -0700284 echo -n "Creating ${ZK_CONF} ... "
Naoki Shiotab7eb55d2014-04-21 18:21:36 -0700285
Pavlin Radoslavovd8f30d92014-04-18 13:03:09 -0700286 # Create the ZooKeeper lib directory
Yuta HIGUCHIb3983b12014-06-12 14:21:09 -0700287 if [[ ! ( -w ${ZK_LIB_DIR} && -d ${ZK_LIB_DIR} ) ]]; then
Naoki Shiota7f495cf2014-05-21 17:23:25 -0700288 local SUDO=${SUDO:-sudo}
Pavlin Radoslavovd8f30d92014-04-18 13:03:09 -0700289 local whoami=`whoami`
290 {
Yuta HIGUCHIb3983b12014-06-12 14:21:09 -0700291 ${SUDO} mkdir -p ${ZK_LIB_DIR}
Pavlin Radoslavovd8f30d92014-04-18 13:03:09 -0700292 ${SUDO} chown ${whoami} ${ZK_LIB_DIR}
293 } || {
294 echo "FAILED"
295 echo "[ERROR] Failed to create directory ${ZK_LIB_DIR}."
296 echo "[ERROR] Please retry after setting \"env SUDO=sudo\""
297 exit 1
298 }
299 fi
300
301 # creation of ZooKeeper config
Naoki Shiotab7eb55d2014-04-21 18:21:36 -0700302 local temp_zk=`begin-conf-creation ${ZK_CONF}`
Naoki Shiota9df15d32014-03-27 14:26:20 -0700303
Naoki Shiota4e928512014-04-03 15:49:35 -0700304 hostarr=`echo ${ZK_HOSTS} | tr "," " "`
Naoki Shiota9df15d32014-03-27 14:26:20 -0700305
306 local i=1
307 local myid=
308 for host in ${hostarr}; do
Naoki Shiota9a1e6d12014-04-03 14:47:12 -0700309 if [ "${host}" = "${ONOS_HOST_NAME}" -o "${host}" = "${ONOS_HOST_IP}" ]; then
Naoki Shiota9df15d32014-03-27 14:26:20 -0700310 myid=$i
311 break
312 fi
313 i=`expr $i + 1`
314 done
315
316 if [ -z "${myid}" ]; then
Naoki Shiota590c18d2014-03-31 17:52:59 -0700317 local filename=`basename ${ONOS_CONF}`
Naoki Shiota35f8d5c2014-04-08 11:13:18 -0700318 revert-confs "[ERROR] In ${filename}, zookeeper.hosts must have hostname \"${ONOS_HOST_NAME}\" or IP address"
Naoki Shiota9df15d32014-03-27 14:26:20 -0700319 fi
320
Yuta HIGUCHI69450892014-04-16 09:10:55 -0700321 if [ -f "${ZK_MY_ID}" ]; then
Naoki Shiotab7eb55d2014-04-21 18:21:36 -0700322 # sudo will be needed if ZK_MY_ID is already created by other (old) script
Yuta HIGUCHI69450892014-04-16 09:10:55 -0700323 local SUDO=${SUDO:-}
324 {
325 ${SUDO} mv -f ${ZK_MY_ID} ${ZK_MY_ID}.old
326 } || {
327 echo "FAILED"
328 echo "[ERROR] Failed to rename ${ZK_MY_ID}."
Pavlin Radoslavovd8f30d92014-04-18 13:03:09 -0700329 echo "[ERROR] Please retry after setting \"env SUDO=sudo\""
Yuta HIGUCHI69450892014-04-16 09:10:55 -0700330 exit 1
331 }
332 fi
333
Naoki Shiota9df15d32014-03-27 14:26:20 -0700334 echo ${myid} > ${ZK_MY_ID}
335
336 echo -n "myid is assigned to ${myid} ... "
337
338 while read line; do
339 if [[ $line =~ ^__HOSTS__$ ]]; then
340 i=1
341 for host in ${hostarr}; do
Yuta HIGUCHI5f1ce1c2014-07-20 22:43:54 -0700342 # TODO: ZK ports should be configurable per host
343 local hostline="server.${i}=${host}:${ZK_PORTS}"
Naoki Shiotab7eb55d2014-04-21 18:21:36 -0700344 echo $hostline
Naoki Shiota9df15d32014-03-27 14:26:20 -0700345 i=`expr $i + 1`
346 done
347 elif [[ $line =~ __DATADIR__ ]]; then
Naoki Shiotab7eb55d2014-04-21 18:21:36 -0700348 echo $line | sed -e "s|__DATADIR__|${ZK_LIB_DIR}|"
Naoki Shiota9df15d32014-03-27 14:26:20 -0700349 else
Naoki Shiotab7eb55d2014-04-21 18:21:36 -0700350 echo $line
Naoki Shiota9df15d32014-03-27 14:26:20 -0700351 fi
Naoki Shiotab7eb55d2014-04-21 18:21:36 -0700352 done < ${ZK_CONF_TEMPLATE} > ${temp_zk}
Yuta HIGUCHI5f1ce1c2014-07-20 22:43:54 -0700353 sed -e "s|__CLIENTPORT__|${ZK_CLIENTPORT}|" -i "" ${temp_zk}
Naoki Shiotab7eb55d2014-04-21 18:21:36 -0700354
355 end-conf-creation ${ZK_CONF}
Naoki Shiota9df15d32014-03-27 14:26:20 -0700356
357 echo "DONE"
Naoki Shiota590c18d2014-03-31 17:52:59 -0700358}
Naoki Shiota9df15d32014-03-27 14:26:20 -0700359
Naoki Shiota4e928512014-04-03 15:49:35 -0700360function create-hazelcast-conf {
361 echo -n "Creating ${HC_CONF} ... "
362
Naoki Shiotab7eb55d2014-04-21 18:21:36 -0700363 local temp_hc=`begin-conf-creation ${HC_CONF}`
Naoki Shiota4e928512014-04-03 15:49:35 -0700364
365 # To keep indent of XML file, change IFS
366 local IFS=''
367 while read line; do
368 if [[ $line =~ __HC_NETWORK__ ]]; then
369 if [ ! -z "${HC_TCPIP_MEMBERS}" ]; then
370 # temporary change
371 IFS=' '
372 local memberarr=`echo ${HC_TCPIP_MEMBERS} | tr "," " "`
373 echo '<multicast enabled="false" />'
374 echo '<tcp-ip enabled="true">'
375 for member in ${memberarr}; do
376 echo " <member>${member}</member>"
377 done
378 echo '</tcp-ip>'
379 IFS=''
380 else
381 echo '<multicast enabled="true">'
382 echo " <multicast-group>${HC_MULTICAST_GROUP}</multicast-group>"
383 echo " <multicast-port>${HC_MULTICAST_PORT}</multicast-port>"
384 echo '</multicast>'
385 echo '<tcp-ip enabled="false" />'
386 fi
Naoki Shiotab7eb55d2014-04-21 18:21:36 -0700387 elif [[ $line =~ __HC_PORT__ ]]; then
388 echo $line | sed -e "s|__HC_PORT__|${HC_HOST_PORT}|"
Yuta HIGUCHI85de40d2014-06-12 14:06:41 -0700389 elif [[ $line =~ __HC_CLUSTER__ ]]; then
390 echo $line | sed -e "s|__HC_CLUSTER__|${ONOS_CLUSTER_NAME}|"
Naoki Shiota4e928512014-04-03 15:49:35 -0700391 else
392 echo "${line}"
393 fi
394 done < ${HC_CONF_TEMPLATE} > ${temp_hc}
395
Naoki Shiotab7eb55d2014-04-21 18:21:36 -0700396 end-conf-creation ${HC_CONF}
Naoki Shiota4e928512014-04-03 15:49:35 -0700397
398 echo "DONE"
399}
400
Yuta HIGUCHI13d1dbf2014-04-17 20:51:38 -0700401function create-ramcloud-conf {
402 echo -n "Creating ${RAMCLOUD_CONF} ... "
403
Naoki Shiotab7eb55d2014-04-21 18:21:36 -0700404 local temp_rc=`begin-conf-creation ${RAMCLOUD_CONF}`
Yuta HIGUCHId150ece2014-04-29 16:25:36 -0700405
Yuta HIGUCHI5f1ce1c2014-07-20 22:43:54 -0700406 local rc_locator=`echo "${ZK_HOSTS}" | sed -e "s/,/:${ZK_CLIENTPORT},/g"`
407 rc_locator+=":${ZK_CLIENTPORT}"
408
Yuta HIGUCHI85de40d2014-06-12 14:06:41 -0700409 local rc_cluster_name=$(read-conf ${ONOS_CONF} ramcloud.clusterName ${ONOS_CLUSTER_NAME})
Yuta HIGUCHId150ece2014-04-29 16:25:36 -0700410
Yuta HIGUCHI5f1ce1c2014-07-20 22:43:54 -0700411 echo "ramcloud.locator=zk:localhost:2181,${rc_locator}" > ${temp_rc}
Yuta HIGUCHId150ece2014-04-29 16:25:36 -0700412 echo "ramcloud.clusterName=${rc_cluster_name}" >> ${temp_rc}
Yuta HIGUCHI13d1dbf2014-04-17 20:51:38 -0700413
Naoki Shiotab7eb55d2014-04-21 18:21:36 -0700414 end-conf-creation ${RAMCLOUD_CONF}
Yuta HIGUCHI13d1dbf2014-04-17 20:51:38 -0700415
416 echo "DONE"
417}
418
Naoki Shiota590c18d2014-03-31 17:52:59 -0700419function create-logback-conf {
Naoki Shiota9df15d32014-03-27 14:26:20 -0700420 echo -n "Creating ${ONOS_LOGBACK} ... "
Naoki Shiota590c18d2014-03-31 17:52:59 -0700421
Naoki Shiota9df15d32014-03-27 14:26:20 -0700422 # creation of logback config
Naoki Shiotab7eb55d2014-04-21 18:21:36 -0700423 local temp_lb=`begin-conf-creation ${ONOS_LOGBACK}`
Yuta HIGUCHI04713972014-05-30 11:01:17 -0700424
425 sed -e "s|__FILENAME__|${ONOS_LOG}|" \
426 -e "s|__ROLLING_PATTERN__|${ONOS_LOG_ROLLING_PATTERN}|" ${ONOS_LOGBACK_TEMPLATE} > ${temp_lb}
Naoki Shiotab7eb55d2014-04-21 18:21:36 -0700427
428 end-conf-creation ${ONOS_LOGBACK}
Naoki Shiota590c18d2014-03-31 17:52:59 -0700429
Naoki Shiota9df15d32014-03-27 14:26:20 -0700430 echo "DONE"
Naoki Shiota9df15d32014-03-27 14:26:20 -0700431}
432
Naoki Shiota4e928512014-04-03 15:49:35 -0700433function create-confs {
434 local key
435 local filename
436
Naoki Shiota9a1e6d12014-04-03 14:47:12 -0700437 trap handle-error ERR
Naoki Shiota4e928512014-04-03 15:49:35 -0700438
Naoki Shiotab7eb55d2014-04-21 18:21:36 -0700439 echo "Config file : ${ONOS_CONF}"
440
Naoki Shiota4e928512014-04-03 15:49:35 -0700441 if [ "$1" == "-f" ]; then
442 create-zk-conf
443 create-hazelcast-conf
Yuta HIGUCHI13d1dbf2014-04-17 20:51:38 -0700444 create-ramcloud-conf
Naoki Shiota4e928512014-04-03 15:49:35 -0700445 create-logback-conf
446 else
447 create-conf-interactive ${ZK_CONF} create-zk-conf
448 create-conf-interactive ${HC_CONF} create-hazelcast-conf
Yuta HIGUCHI13d1dbf2014-04-17 20:51:38 -0700449 create-conf-interactive ${RAMCLOUD_CONF} create-ramcloud-conf
Naoki Shiota4e928512014-04-03 15:49:35 -0700450 create-conf-interactive ${ONOS_LOGBACK} create-logback-conf
451 fi
Naoki Shiota590c18d2014-03-31 17:52:59 -0700452
453 trap - ERR
454}
455############################################
Naoki Shiota4e463182014-03-21 15:13:24 -0700456
Naoki Shiota590c18d2014-03-31 17:52:59 -0700457
458###### Functions related to ZooKeeper ######
Naoki Shiota4e463182014-03-21 15:13:24 -0700459function zk {
460 case "$1" in
461 start)
462 start-zk
463 ;;
464 stop)
465 stop-zk
466 ;;
467 stat*) # <- status
468 status-zk
469 ;;
470 re*) # <- restart
471 stop-zk
472 start-zk
473 ;;
474 *)
Naoki Shiota590c18d2014-03-31 17:52:59 -0700475 print_usage
Naoki Shiota4e463182014-03-21 15:13:24 -0700476 exit 1
477 esac
478}
479
Naoki Shiotab7eb55d2014-04-21 18:21:36 -0700480function load-zk-cfg {
481 if [ -f "${ZK_CONF}" ]; then
482 local filename=`basename ${ZK_CONF}`
483 local dirname=`dirname ${ZK_CONF}`
484
485 # Run ZooKeeper with our configuration
486 export ZOOCFG=${filename}
487 export ZOOCFGDIR=${dirname}
488 fi
489}
490
Naoki Shiota4e463182014-03-21 15:13:24 -0700491function start-zk {
Pavlin Radoslavovd8f30d92014-04-18 13:03:09 -0700492 echo -n "Starting ZooKeeper ... "
Naoki Shiota9df15d32014-03-27 14:26:20 -0700493
Naoki Shiota4e928512014-04-03 15:49:35 -0700494 export ZOO_LOG_DIR=${ZK_LOG_DIR}
Yuta HIGUCHI13d1dbf2014-04-17 20:51:38 -0700495 mkdir -p ${ZK_LOG_DIR}
Naoki Shiotab7eb55d2014-04-21 18:21:36 -0700496
497 load-zk-cfg
Yuta HIGUCHIf66cf212014-05-29 23:16:44 -0700498
499 # log4j.properties is read from classpath if not found in CWD.
500 # Using the ZooKeeper supplied default in ZooKeeper conf dir.
501 # TODO: To explicitly specify our customized log4j config file:
502 # export SERVER_JVMFLAGS="-Dlog4j.configuration=${ZK_LOG4J}"
503 env CLASSPATH="${ZK_HOME}/conf:${CLASSPATH}" ${ZK_HOME}/bin/zkServer.sh start
Naoki Shiota4e463182014-03-21 15:13:24 -0700504}
505
506function stop-zk {
Yuta HIGUCHI7c708362014-06-02 23:15:13 -0700507 echo -n "Stopping ZooKeeper ... "
508 load-zk-cfg
509
510 ${ZK_HOME}/bin/zkServer.sh stop
Naoki Shiota4e463182014-03-21 15:13:24 -0700511}
512
513function status-zk {
Naoki Shiotab7eb55d2014-04-21 18:21:36 -0700514 load-zk-cfg
Naoki Shiota9df15d32014-03-27 14:26:20 -0700515
Naoki Shiota72209722014-04-08 14:32:17 -0700516 ${ZK_HOME}/bin/zkServer.sh status
Naoki Shiota4e463182014-03-21 15:13:24 -0700517}
Yuta HIGUCHId150ece2014-04-29 16:25:36 -0700518
519function check-zk {
520 # assumption here is that ZK status script is the last command in status-zk.
521 status-zk &> /dev/null
522 local zk_status=$?
523 if [ "$zk_status" -ne 0 ]; then
524 return 1;
525 fi
526 return 0
527}
528
Yuta HIGUCHI7873c932014-06-02 23:16:18 -0700529function check-and-start-zk {
530 check-zk
531 local zk_status=$?
532 if [ "$zk_status" -ne 0 ]; then
533 start-zk
534 fi
535}
536
Yuta HIGUCHId150ece2014-04-29 16:25:36 -0700537# wait-zk-or-die {timeout-sec}
538function wait-zk-or-die {
Yuta HIGUCHI7873c932014-06-02 23:16:18 -0700539 local retries=${1:-5}
Yuta HIGUCHId150ece2014-04-29 16:25:36 -0700540 # do-while retries >= 0
541 while true; do
542 check-zk
543 local zk_status=$?
544 if [ "$zk_status" -eq 0 ]; then
545 return 0
546 fi
547 sleep 1;
548 ((retries -= 1))
549 (( retries >= 0 )) || break
550 done
551 echo "ZooKeeper is not running."
552 exit 1
553}
554
Naoki Shiota590c18d2014-03-31 17:52:59 -0700555############################################
Naoki Shiota4e463182014-03-21 15:13:24 -0700556
557
Naoki Shiota590c18d2014-03-31 17:52:59 -0700558####### Functions related to RAMCloud ######
Yuta HIGUCHI259b79a2014-06-04 12:21:22 -0700559
560# Check if this host should be running RAMCloud coordinator:
561function is-coord-role {
562 if [ "${ONOS_HOST_BACKEND}" = "ramcloud" ]; then
563 case "${ONOS_HOST_ROLE}" in
564 single-node)
565 echo "true"
566 return 0
567 ;;
568 coord-node)
569 echo "true"
570 return 0
571 ;;
572 server-node)
573 echo "false"
574 return 1
575 ;;
576 coord-and-server-node)
577 echo "true"
578 return 0
579 ;;
580 *)
581 echo "false"
582 return 1
583 ;;
584 esac
585 else
586 echo "false"
587 return 1
588 fi
589}
590
591# Check if this host should be running RAMCloud server:
592function is-server-role {
593 if [ "${ONOS_HOST_BACKEND}" = "ramcloud" ]; then
594 case "${ONOS_HOST_ROLE}" in
595 single-node)
596 echo "true"
597 return 0
598 ;;
599 coord-node)
600 echo "false"
601 return 1
602 ;;
603 server-node)
604 echo "true"
605 return 0
606 ;;
607 coord-and-server-node)
608 echo "true"
609 return 0
610 ;;
611 *)
612 echo "false"
613 return 1
614 ;;
615 esac
616 else
617 echo "false"
618 return 1
619 fi
620}
621
Naoki Shiota9df15d32014-03-27 14:26:20 -0700622function start-backend {
623 if [ "${ONOS_HOST_BACKEND}" = "ramcloud" ]; then
Naoki Shiota590c18d2014-03-31 17:52:59 -0700624 if [ $1 == "coord" ]; then
625 rc-coord startifdown
626 elif [ $1 == "server" ]; then
627 rc-server startifdown
628 fi
Naoki Shiota9df15d32014-03-27 14:26:20 -0700629 fi
630}
631
632function stop-backend {
633 rcsn=`pgrep -f obj.${RAMCLOUD_BRANCH}/server | wc -l`
634 if [ $rcsn != 0 ]; then
635 rc-server stop
636 fi
637
Naoki Shiota590c18d2014-03-31 17:52:59 -0700638 rccn=`pgrep -f obj.${RAMCLOUD_BRANCH}/coordinator | wc -l`
Naoki Shiota9df15d32014-03-27 14:26:20 -0700639 if [ $rccn != 0 ]; then
640 rc-coord stop
641 fi
642}
643
Naoki Shiota590c18d2014-03-31 17:52:59 -0700644
Naoki Shiota4e463182014-03-21 15:13:24 -0700645### Functions related to RAMCloud coordinator
Naoki Shiota9df15d32014-03-27 14:26:20 -0700646function rc-coord-addr {
Naoki Shiota9109a1e2014-05-13 11:11:01 -0700647 local host=${RC_COORD_IP}
648 if [ -z "${host}" ]; then
649 # falling back to 0.0.0.0
650 host="0.0.0.0"
651 fi
652 echo "${RC_COORD_PROTOCOL}:host=${host},port=${RC_COORD_PORT}"
Naoki Shiota9df15d32014-03-27 14:26:20 -0700653}
654
655function rc-server-addr {
Naoki Shiota9109a1e2014-05-13 11:11:01 -0700656 local host=${RC_SERVER_IP}
657 if [ -z "${host}" ]; then
658 # falling back to 0.0.0.0
659 host="0.0.0.0"
660 fi
661 echo "${RC_SERVER_PROTOCOL}:host=${host},port=${RC_SERVER_PORT}"
Naoki Shiota9df15d32014-03-27 14:26:20 -0700662}
663
Naoki Shiota4e463182014-03-21 15:13:24 -0700664function rc-coord {
665 case "$1" in
666 start)
Naoki Shiota4e463182014-03-21 15:13:24 -0700667 stop-coord
668 start-coord
669 ;;
670 startifdown)
Naoki Shiota590c18d2014-03-31 17:52:59 -0700671 local n=`pgrep -f obj.${RAMCLOUD_BRANCH}/coordinator | wc -l`
Naoki Shiota4e463182014-03-21 15:13:24 -0700672 if [ $n == 0 ]; then
673 start-coord
674 else
675 echo "$n instance of RAMCloud coordinator running"
676 fi
677 ;;
678 stop)
679 stop-coord
680 ;;
Yuta HIGUCHId150ece2014-04-29 16:25:36 -0700681 deldb)
682 stop-backend
683 del-coord-info
684 ;;
Naoki Shiota4e463182014-03-21 15:13:24 -0700685 stat*) # <- status
686 local n=`pgrep -f obj.${RAMCLOUD_BRANCH}/coordinator | wc -l`
687 echo "$n RAMCloud coordinator running"
688 ;;
689 *)
Naoki Shiota590c18d2014-03-31 17:52:59 -0700690 print_usage
Naoki Shiota4e463182014-03-21 15:13:24 -0700691 exit 1
692 esac
693}
694
695function start-coord {
Yuta HIGUCHI7873c932014-06-02 23:16:18 -0700696 check-and-start-zk
697 wait-zk-or-die
Yuta HIGUCHId150ece2014-04-29 16:25:36 -0700698
Naoki Shiota4e463182014-03-21 15:13:24 -0700699 if [ ! -d ${LOGDIR} ]; then
700 mkdir -p ${LOGDIR}
701 fi
702 if [ -f $RAMCLOUD_COORD_LOG ]; then
703 rotate-log $RAMCLOUD_COORD_LOG
704 fi
Naoki Shiota9df15d32014-03-27 14:26:20 -0700705
706 local coord_addr=`rc-coord-addr`
Naoki Shiota4e463182014-03-21 15:13:24 -0700707
Yuta HIGUCHId082b962014-06-02 11:42:22 -0700708 # TODO Make ONOS_CONF readable from ONOS process then eliminate RAMCLOUD_CONF
709
710 # Configuration for ZK address, port
711 local rc_locator=$(read-conf ${RAMCLOUD_CONF} ramcloud.locator "zk:localhost:2181")
712
Yuta HIGUCHId150ece2014-04-29 16:25:36 -0700713 # RAMCloud cluster name
Yuta HIGUCHI85de40d2014-06-12 14:06:41 -0700714 local rc_cluster_name=$(read-conf ${RAMCLOUD_CONF} ramcloud.clusterName ${ONOS_CLUSTER_NAME})
Yuta HIGUCHId082b962014-06-02 11:42:22 -0700715
Yuta HIGUCHIea7eba02014-05-14 11:13:52 -0700716 # RAMCloud transport timeout
717 local rc_timeout=$(read-conf ${ONOS_CONF} ramcloud.timeout 1000)
Yuta HIGUCHId150ece2014-04-29 16:25:36 -0700718 # RAMCloud option deadServerTimeout
719 # (note RC default is 250ms, setting relaxed ONOS default to 1000ms)
720 local rc_coord_deadServerTimeout=$(read-conf ${ONOS_CONF} ramcloud.coordinator.deadServerTimeout 1000)
721
722 # NOTE RAMCloud document suggests to use -L to specify listen address:port,
723 # but actual RAMCloud code only uses -C argument now.
724 # (FYI: -C is documented to be deprecated in the document)
725
726 local coord_args="-C ${coord_addr}"
Yuta HIGUCHId082b962014-06-02 11:42:22 -0700727 coord_args="${coord_args} --externalStorage ${rc_locator}"
Yuta HIGUCHId150ece2014-04-29 16:25:36 -0700728 coord_args="${coord_args} --clusterName ${rc_cluster_name}"
Yuta HIGUCHIea7eba02014-05-14 11:13:52 -0700729 coord_args="${coord_args} --timeout ${rc_timeout}"
Yuta HIGUCHId150ece2014-04-29 16:25:36 -0700730 coord_args="${coord_args} --deadServerTimeout ${rc_coord_deadServerTimeout}"
731
732 # Read environment variables if set
733 coord_args="${coord_args} ${RC_COORDINATOR_OPTS}"
734
735 if [ "${ONOS_HOST_ROLE}" == "single-node" ]; then
736 # Note: Following reset is required, since RC restart is considered node failure,
737 # and tries recovery of server, which will never succeed after restart.
738 echo "Role configured to single-node mode. RAMCloud cluster will be reset on each start-up."
739 coord_args="${coord_args} --reset"
740 fi
741
Naoki Shiota4e463182014-03-21 15:13:24 -0700742 # Run ramcloud
743 echo -n "Starting RAMCloud coordinator ... "
Yuta HIGUCHId150ece2014-04-29 16:25:36 -0700744 ${RAMCLOUD_HOME}/obj.${RAMCLOUD_BRANCH}/coordinator ${coord_args} > $RAMCLOUD_COORD_LOG 2>&1 &
Naoki Shiota4e463182014-03-21 15:13:24 -0700745 echo "STARTED"
746}
747
Yuta HIGUCHId150ece2014-04-29 16:25:36 -0700748function del-coord-info {
Yuta HIGUCHI7873c932014-06-02 23:16:18 -0700749 check-and-start-zk
750 wait-zk-or-die
Yuta HIGUCHId150ece2014-04-29 16:25:36 -0700751
752 if [ ! -d ${LOGDIR} ]; then
753 mkdir -p ${LOGDIR}
754 fi
755 if [ -f $RAMCLOUD_COORD_LOG ]; then
756 rotate-log $RAMCLOUD_COORD_LOG
757 fi
758
759 local coord_addr=`rc-coord-addr`
760
Yuta HIGUCHId082b962014-06-02 11:42:22 -0700761 # Configuration for ZK address, port
762 local rc_locator=$(read-conf ${RAMCLOUD_CONF} ramcloud.locator "zk:localhost:2181")
Yuta HIGUCHId150ece2014-04-29 16:25:36 -0700763 # RAMCloud cluster name
Yuta HIGUCHI85de40d2014-06-12 14:06:41 -0700764 local rc_cluster_name=$(read-conf ${RAMCLOUD_CONF} ramcloud.clusterName ${ONOS_CLUSTER_NAME})
Yuta HIGUCHId150ece2014-04-29 16:25:36 -0700765 # RAMCloud option deadServerTimeout
766 # (note RC default is 250ms, setting relaxed ONOS default to 1000ms)
767 local rc_coord_deadServerTimeout=$(read-conf ${ONOS_CONF} ramcloud.coordinator.deadServerTimeout 1000)
768
769 # NOTE RAMCloud document suggests to use -L to specify listen address:port,
770 # but actual RAMCloud code only uses -C argument now.
771 # (FYI: -C is documented to be deprecated in the document)
772
773 local coord_args="-C ${coord_addr}"
Yuta HIGUCHId082b962014-06-02 11:42:22 -0700774 coord_args="${coord_args} --externalStorage ${rc_locator}"
Yuta HIGUCHId150ece2014-04-29 16:25:36 -0700775 coord_args="${coord_args} --clusterName ${rc_cluster_name}"
776
777 # Note: --reset will reset ZK stored info and start running as acoordinator.
778 echo -n "Deleting RAMCloud cluster coordination info ... "
779 ${RAMCLOUD_HOME}/obj.${RAMCLOUD_BRANCH}/coordinator ${coord_args} --reset &> $RAMCLOUD_COORD_LOG &
780
Yuta HIGUCHIcd44eb32014-05-24 16:51:31 -0700781 # TODO Assuming 5 sec is enough. To be sure monitor log?
782 sleep 5
783 # kill coordinator
Yuta HIGUCHIce9f3ee2014-05-14 09:48:40 -0700784 (pkill -f ${RAMCLOUD_HOME}/obj.${RAMCLOUD_BRANCH}/coordinator &> /dev/null)
Yuta HIGUCHId150ece2014-04-29 16:25:36 -0700785
786 echo "DONE"
787}
Naoki Shiota4e463182014-03-21 15:13:24 -0700788
789function stop-coord {
Yuta HIGUCHId150ece2014-04-29 16:25:36 -0700790 kill-processes "RAMCloud coordinator" `pgrep -f ${RAMCLOUD_HOME}/obj.${RAMCLOUD_BRANCH}/coordinator`
Naoki Shiota4e463182014-03-21 15:13:24 -0700791}
792
Naoki Shiota4e463182014-03-21 15:13:24 -0700793### Functions related to RAMCloud server
794function rc-server {
795 case "$1" in
796 start)
Naoki Shiota4e463182014-03-21 15:13:24 -0700797 stop-server
798 start-server
799 ;;
800 startifdown)
Yuta HIGUCHId150ece2014-04-29 16:25:36 -0700801 local n=`pgrep -f ${RAMCLOUD_HOME}/obj.${RAMCLOUD_BRANCH}/server | wc -l`
Naoki Shiota4e463182014-03-21 15:13:24 -0700802 if [ $n == 0 ]; then
803 start-server
804 else
805 echo "$n instance of RAMCloud server running"
806 fi
807 ;;
808 stop)
809 stop-server
810 ;;
Yuta HIGUCHId150ece2014-04-29 16:25:36 -0700811 deldb)
812 stop-server
813 del-server-backup
814 ;;
Naoki Shiota4e463182014-03-21 15:13:24 -0700815 stat*) # <- status
Yuta HIGUCHId150ece2014-04-29 16:25:36 -0700816 n=`pgrep -f ${RAMCLOUD_HOME}/obj.${RAMCLOUD_BRANCH}/server | wc -l`
Naoki Shiota4e463182014-03-21 15:13:24 -0700817 echo "$n RAMCloud server running"
818 ;;
819 *)
Naoki Shiota590c18d2014-03-31 17:52:59 -0700820 print_usage
Naoki Shiota4e463182014-03-21 15:13:24 -0700821 exit 1
822 esac
823}
824
825function start-server {
Yuta HIGUCHI7873c932014-06-02 23:16:18 -0700826 check-and-start-zk
827 wait-zk-or-die
Yuta HIGUCHId150ece2014-04-29 16:25:36 -0700828
Naoki Shiota4e463182014-03-21 15:13:24 -0700829 if [ ! -d ${LOGDIR} ]; then
830 mkdir -p ${LOGDIR}
831 fi
832 if [ -f $RAMCLOUD_SERVER_LOG ]; then
833 rotate-log $RAMCLOUD_SERVER_LOG
834 fi
Naoki Shiota9df15d32014-03-27 14:26:20 -0700835
836 local coord_addr=`rc-coord-addr`
837 local server_addr=`rc-server-addr`
Naoki Shiota4e463182014-03-21 15:13:24 -0700838
Yuta HIGUCHId150ece2014-04-29 16:25:36 -0700839 local masterServiceThreads=$(read-conf ${ONOS_CONF} ramcloud.server.masterServiceThreads 5)
840 local logCleanerThreads=$(read-conf ${ONOS_CONF} ramcloud.server.logCleanerThreads 1)
Yuta HIGUCHI52efcbb2014-05-16 09:30:33 -0700841 local detectFailures=$(read-conf ${ONOS_CONF} ramcloud.server.detectFailures 0)
Yuta HIGUCHId150ece2014-04-29 16:25:36 -0700842
Yuta HIGUCHId082b962014-06-02 11:42:22 -0700843 # Configuration for ZK address, port
844 local rc_locator=$(read-conf ${RAMCLOUD_CONF} ramcloud.locator "zk:localhost:2181")
Yuta HIGUCHId150ece2014-04-29 16:25:36 -0700845 # RAMCloud cluster name
Yuta HIGUCHI85de40d2014-06-12 14:06:41 -0700846 local rc_cluster_name=$(read-conf ${RAMCLOUD_CONF} ramcloud.clusterName ${ONOS_CLUSTER_NAME})
Yuta HIGUCHIea7eba02014-05-14 11:13:52 -0700847 # RAMCloud transport timeout
848 local rc_timeout=$(read-conf ${ONOS_CONF} ramcloud.timeout 1000)
Yuta HIGUCHId150ece2014-04-29 16:25:36 -0700849 # replication factor (-r) config
850 local rc_replicas=$(read-conf ${ONOS_CONF} ramcloud.server.replicas 0)
851 # backup file path (-f) config
852 local rc_datafile=$(read-conf ${ONOS_CONF} ramcloud.server.file "/var/tmp/ramclouddata/backup.${ONOS_HOST_NAME}.log")
853 mkdir -p `dirname ${rc_datafile}`
854
855 local server_args="-L ${server_addr}"
Yuta HIGUCHId082b962014-06-02 11:42:22 -0700856 server_args="${server_args} --externalStorage ${rc_locator}"
Yuta HIGUCHId150ece2014-04-29 16:25:36 -0700857 server_args="${server_args} --clusterName ${rc_cluster_name}"
Yuta HIGUCHIea7eba02014-05-14 11:13:52 -0700858 server_args="${server_args} --timeout ${rc_timeout}"
Yuta HIGUCHId150ece2014-04-29 16:25:36 -0700859 server_args="${server_args} --masterServiceThreads ${masterServiceThreads}"
860 server_args="${server_args} --logCleanerThreads ${logCleanerThreads}"
861 server_args="${server_args} --detectFailures ${detectFailures}"
862 server_args="${server_args} --replicas ${rc_replicas}"
863 server_args="${server_args} --file ${rc_datafile}"
864
865 # Read environment variables if set
866 server_args="${server_args} ${RC_SERVER_OPTS}"
Yuta HIGUCHI45bc3cf2014-04-19 18:12:15 -0700867
Naoki Shiota4e463182014-03-21 15:13:24 -0700868 # Run ramcloud
869 echo -n "Starting RAMCloud server ... "
Yuta HIGUCHId150ece2014-04-29 16:25:36 -0700870 ${RAMCLOUD_HOME}/obj.${RAMCLOUD_BRANCH}/server ${server_args} > $RAMCLOUD_SERVER_LOG 2>&1 &
Naoki Shiota4e463182014-03-21 15:13:24 -0700871 echo "STARTED"
872}
873
Yuta HIGUCHId150ece2014-04-29 16:25:36 -0700874function del-server-backup {
Naoki Shiota9109a1e2014-05-13 11:11:01 -0700875 echo -n "Delete RAMCloud backup server data [y/N]? "
876 while [ 1 ]; do
877 read key
878 if [ "${key}" == "Y" -o "${key}" == "y" ]; then
879 break
880 elif [ -z "${key}" -o "${key}" == "N" -o "${key}" == "n" ]; then
881 echo "Cancelled."
882 return
883 fi
884 echo "[y/N]? "
885 done
886
Yuta HIGUCHId150ece2014-04-29 16:25:36 -0700887 echo -n "Removing RAMCloud backup server data ... "
888 local rc_datafile=$(read-conf ${ONOS_CONF} ramcloud.server.file "/var/tmp/ramclouddata/backup.${ONOS_HOST_NAME}.log")
889 rm -f ${rc_datafile}
890 echo "DONE"
891}
892
Naoki Shiota4e463182014-03-21 15:13:24 -0700893function stop-server {
Yuta HIGUCHId150ece2014-04-29 16:25:36 -0700894 kill-processes "RAMCloud server" `pgrep -f ${RAMCLOUD_HOME}/obj.${RAMCLOUD_BRANCH}/server`
Naoki Shiota4e463182014-03-21 15:13:24 -0700895}
Naoki Shiota590c18d2014-03-31 17:52:59 -0700896############################################
Naoki Shiota4e463182014-03-21 15:13:24 -0700897
898
Naoki Shiota590c18d2014-03-31 17:52:59 -0700899## Functions related to ONOS core process ##
Naoki Shiota4e463182014-03-21 15:13:24 -0700900function onos {
Naoki Shiota590c18d2014-03-31 17:52:59 -0700901 CPFILE=${ONOS_HOME}/.javacp.${ONOS_HOST_NAME}
Naoki Shiota4e463182014-03-21 15:13:24 -0700902 if [ ! -f ${CPFILE} ]; then
Naoki Shiota9df15d32014-03-27 14:26:20 -0700903 echo "ONOS core needs to be built"
Naoki Shiota4e463182014-03-21 15:13:24 -0700904 ${MVN} -f ${ONOS_HOME}/pom.xml compile
905 fi
906 JAVA_CP=`cat ${CPFILE}`
907 JAVA_CP="${JAVA_CP}:${ONOS_HOME}/target/classes"
908
909 case "$1" in
910 start)
911 stop-onos
912 start-onos
913 ;;
914 startnokill)
915 start-onos
916 ;;
917 startifdown)
918 n=`jps -l | grep "${MAIN_CLASS}" | wc -l`
919 if [ $n == 0 ]; then
920 start-onos
921 else
922 echo "$n instance of onos running"
923 fi
924 ;;
925 stop)
926 stop-onos
927 ;;
928 stat*) # <- status
929 n=`jps -l | grep "${MAIN_CLASS}" | wc -l`
930 echo "$n instance of onos running"
931 ;;
932 *)
Naoki Shiota590c18d2014-03-31 17:52:59 -0700933 print_usage
Naoki Shiota4e463182014-03-21 15:13:24 -0700934 exit 1
935 esac
936}
937
938function start-onos {
939 if [ ! -d ${LOGDIR} ]; then
940 mkdir -p ${LOGDIR}
941 fi
Yuta HIGUCHI04713972014-05-30 11:01:17 -0700942 # Rotate log files
Naoki Shiota4e463182014-03-21 15:13:24 -0700943 for log in ${LOGS}; do
944 if [ -f ${log} ]; then
945 rotate-log ${log}
946 fi
947 done
Yuta HIGUCHI04713972014-05-30 11:01:17 -0700948
949 # Rotate logs rolled at runtime.
950 local rolled_log_shellpat=`echo ${ONOS_LOG_ROLLING_PATTERN} | sed -e "s/%i/\\*/"`
951 for rolled_log in ${rolled_log_shellpat}; do
952 if [ -f ${rolled_log} ]; then
953 rotate-log ${rolled_log}
Yuta HIGUCHI04713972014-05-30 11:01:17 -0700954 fi
955 done
956
Naoki Shiota4e463182014-03-21 15:13:24 -0700957 if [ ! -f ${ONOS_LOGBACK} ]; then
Naoki Shiota9df15d32014-03-27 14:26:20 -0700958 echo "[WARNING] ${ONOS_LOGBACK} not found."
959 echo " Run \"\$ $0 setup\" to create."
960 exit 1
Naoki Shiota4e463182014-03-21 15:13:24 -0700961 fi
Naoki Shiota9df15d32014-03-27 14:26:20 -0700962
Yuta HIGUCHI3ebc9482014-05-08 16:28:28 -0700963 if [ ! -f ${HC_CONF} ]; then
964 echo "[WARNING] ${HC_CONF} not found."
965 echo " Run \"\$ $0 setup\" to create."
966 exit 1
967 fi
968
Yuta HIGUCHI85de40d2014-06-12 14:06:41 -0700969 # specify ZooKeeper(curator) namespace
970 JVM_OPTS="${JVM_OPTS} -Dzookeeper.namespace=${ONOS_CLUSTER_NAME}"
971
Yuta HIGUCHI5f1ce1c2014-07-20 22:43:54 -0700972 # specify ZooKeeper connectionString
973 local zk_locator=`echo "${ZK_HOSTS}" | sed -e "s/,/:${ZK_CLIENTPORT},/g"`
974 zk_locator+=":${ZK_CLIENTPORT}"
975 zk_locator="localhost:${ZK_CLIENTPORT},${zk_locator}"
976
977 JVM_OPTS="${JVM_OPTS} -Dnet.onrc.onos.core.registry.ZookeeperRegistry.connectionString=${zk_locator}"
978
Yuta HIGUCHI3ebc9482014-05-08 16:28:28 -0700979 # specify hazelcast.xml to datagrid
980 JVM_OPTS="${JVM_OPTS} -Dnet.onrc.onos.core.datagrid.HazelcastDatagrid.datagridConfig=${HC_CONF}"
981
982 # specify backend config
Jonathan Hartef3dc1a2014-04-03 11:39:50 -0700983 JVM_OPTS="${JVM_OPTS} -Dnet.onrc.onos.core.datastore.backend=${ONOS_HOST_BACKEND}"
Yuta HIGUCHI13d1dbf2014-04-17 20:51:38 -0700984 if [ "${ONOS_HOST_BACKEND}" = "ramcloud" ]; then
985 JVM_OPTS="${JVM_OPTS} -Dramcloud.config.path=${RAMCLOUD_CONF}"
Yuta HIGUCHI3ebc9482014-05-08 16:28:28 -0700986 elif [ "${ONOS_HOST_BACKEND}" = "hazelcast" ]; then
987 JVM_OPTS="${JVM_OPTS} -Dnet.onrc.onos.core.datastore.hazelcast.baseConfig=${HC_CONF}"
Yuta HIGUCHI13d1dbf2014-04-17 20:51:38 -0700988 fi
989
Praseed Balakrishnan418c7b22014-06-16 13:33:53 -0700990 # check for jvm debug flag
991 if [ "${ONOS_DEBUG}" = "true" ]; then
992 JVM_OPTS="${JVM_OPTS} -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=${JVM_DEBUG_PORT}"
993 fi
994
Naoki Shiota9df15d32014-03-27 14:26:20 -0700995 # Run ONOS
Yuta HIGUCHIcce4f622014-04-18 16:48:53 -0700996
997 # Need to cd ONOS_HOME. onos.properties currently specify hazelcast config path relative to CWD
998 cd ${ONOS_HOME}
999
Yuta HIGUCHId150ece2014-04-29 16:25:36 -07001000 echo -n "Starting ONOS controller ... "
Naoki Shiota4e463182014-03-21 15:13:24 -07001001 java ${JVM_OPTS} -Dlogback.configurationFile=${ONOS_LOGBACK} -cp ${JAVA_CP} ${MAIN_CLASS} -cf ${ONOS_PROPS} > ${LOGDIR}/${LOGBASE}.stdout 2>${LOGDIR}/${LOGBASE}.stderr &
1002
1003 # We need to wait a bit to find out whether starting the ONOS process succeeded
1004 sleep 1
1005
1006 n=`jps -l |grep "${MAIN_CLASS}" | wc -l`
Naoki Shiota9df15d32014-03-27 14:26:20 -07001007 if [ $n -ge 1 ]; then
Naoki Shiota4e463182014-03-21 15:13:24 -07001008 echo " STARTED"
1009 else
1010 echo " FAILED"
1011 fi
1012
1013# echo "java ${JVM_OPTS} -Dlogback.configurationFile=${ONOS_LOGBACK} -jar ${ONOS_JAR} -cf ./onos.properties > /dev/null 2>&1 &"
1014# sudo -b /usr/sbin/tcpdump -n -i eth0 -s0 -w ${PCAP_LOG} 'tcp port 6633' > /dev/null 2>&1
1015}
1016
1017function stop-onos {
1018 kill-processes "ONOS controller" `jps -l | grep ${MAIN_CLASS} | awk '{print $1}'`
1019# kill-processes "tcpdump" `ps -edalf |grep tcpdump |grep ${PCAP_LOG} | awk '{print $4}'`
1020}
Naoki Shiota590c18d2014-03-31 17:52:59 -07001021############################################
Naoki Shiota4e463182014-03-21 15:13:24 -07001022
1023
Naoki Shiota590c18d2014-03-31 17:52:59 -07001024################## Main ####################
Naoki Shiota4e463182014-03-21 15:13:24 -07001025case "$1" in
Naoki Shiota9df15d32014-03-27 14:26:20 -07001026 setup)
Naoki Shiota4e928512014-04-03 15:49:35 -07001027 create-confs $2
Naoki Shiota9df15d32014-03-27 14:26:20 -07001028 ;;
Naoki Shiota4e463182014-03-21 15:13:24 -07001029 start)
Naoki Shiota9df15d32014-03-27 14:26:20 -07001030 mode_parameter=${ONOS_HOST_ROLE}
1031 if [ ! -z "$2" ]; then
1032 mode_parameter=$2
1033 fi
Praseed Balakrishnan418c7b22014-06-16 13:33:53 -07001034
Naoki Shiota9df15d32014-03-27 14:26:20 -07001035 case "${mode_parameter}" in
Naoki Shiota4e463182014-03-21 15:13:24 -07001036 single-node)
1037 zk start
Naoki Shiota590c18d2014-03-31 17:52:59 -07001038 start-backend coord
1039 start-backend server
Naoki Shiota4e463182014-03-21 15:13:24 -07001040 onos startifdown
1041 ;;
1042 coord-node)
1043 zk start
Naoki Shiota590c18d2014-03-31 17:52:59 -07001044 start-backend coord
Naoki Shiota4e463182014-03-21 15:13:24 -07001045 onos startifdown
1046 ;;
1047 server-node)
1048 zk start
Naoki Shiota590c18d2014-03-31 17:52:59 -07001049 start-backend server
1050 onos startifdown
1051 ;;
1052 coord-and-server-node)
1053 zk start
1054 start-backend coord
1055 start-backend server
Naoki Shiota4e463182014-03-21 15:13:24 -07001056 onos startifdown
1057 ;;
1058 *)
Naoki Shiota590c18d2014-03-31 17:52:59 -07001059 print_usage
Naoki Shiota4e463182014-03-21 15:13:24 -07001060 ;;
1061 esac
1062 echo
1063 ;;
1064 stop)
1065 on=`jps -l | grep "${MAIN_CLASS}" | wc -l`
1066 if [ $on != 0 ]; then
1067 onos stop
1068 fi
1069
Naoki Shiota9df15d32014-03-27 14:26:20 -07001070 stop-backend
Naoki Shiota4e463182014-03-21 15:13:24 -07001071
1072 zkn=`jps -l | grep org.apache.zookeeper.server | wc -l`
1073 if [ $zkn != 0 ]; then
1074 zk stop
1075 fi
1076 echo
1077 ;;
1078 restart)
1079 on=`jps -l | grep "${MAIN_CLASS}" | wc -l`
1080 if [ $on != 0 ]; then
1081 onos stop
1082 fi
Yuta HIGUCHI259b79a2014-06-04 12:21:22 -07001083
Naoki Shiota4e463182014-03-21 15:13:24 -07001084 rcsn=`pgrep -f obj.${RAMCLOUD_BRANCH}/server | wc -l`
1085 if [ $rcsn != 0 ]; then
1086 rc-server stop
1087 fi
Yuta HIGUCHI259b79a2014-06-04 12:21:22 -07001088
Naoki Shiota590c18d2014-03-31 17:52:59 -07001089 rccn=`pgrep -f obj.${RAMCLOUD_BRANCH}/coordinator | wc -l`
Naoki Shiota4e463182014-03-21 15:13:24 -07001090 if [ $rccn != 0 ]; then
1091 rc-coord stop
1092 fi
Yuta HIGUCHI259b79a2014-06-04 12:21:22 -07001093
Naoki Shiota4e463182014-03-21 15:13:24 -07001094 zkn=`jps -l | grep org.apache.zookeeper.server | wc -l`
1095 if [ $zkn != 0 ]; then
1096 zk restart
1097 fi
Yuta HIGUCHI259b79a2014-06-04 12:21:22 -07001098
Naoki Shiota4e463182014-03-21 15:13:24 -07001099 if [ $rccn != 0 ]; then
1100 rc-coord startifdown
1101 fi
Yuta HIGUCHI259b79a2014-06-04 12:21:22 -07001102
Naoki Shiota4e463182014-03-21 15:13:24 -07001103 if [ $rcsn != 0 ]; then
1104 rc-server startifdown
1105 fi
Yuta HIGUCHI259b79a2014-06-04 12:21:22 -07001106
Naoki Shiota4e463182014-03-21 15:13:24 -07001107 if [ $on != 0 ]; then
1108 onos startifdown
1109 fi
1110 echo
1111 ;;
1112 stat*) # <- status
1113 echo '[ZooKeeper]'
1114 zk status
1115 echo
1116 echo '[RAMCloud coordinator]'
1117 rc-coord status
1118 echo
1119 echo '[RAMCloud server]'
1120 rc-server status
1121 echo
1122 echo '[ONOS core]'
1123 onos status
1124 echo
1125 ;;
1126 zk)
1127 zk $2
1128 ;;
1129 rc-c*) # <- rc-coordinator
1130 rc-coord $2
1131 ;;
1132 rc-s*) # <- rc-server
1133 rc-server $2
1134 ;;
Yuta HIGUCHId150ece2014-04-29 16:25:36 -07001135 rc)
Yuta HIGUCHI259b79a2014-06-04 12:21:22 -07001136 # XXX rc command ignores if the host is not configured to have those roles,
1137 # while rc-s or rc-c executes the task regardless of role definition.
1138 # This is a workaround since TestON does not take role in account
1139 # and always issue rc deldb right now.
1140
Naoki Shiota9109a1e2014-05-13 11:11:01 -07001141 # TODO make deldb command more organized (clarify when it can work)
Yuta HIGUCHI259b79a2014-06-04 12:21:22 -07001142 if [ "`is-coord-role`" == "true" ]; then
1143 rc-coord $2
1144 fi
1145 if [ "`is-server-role`" == "true" ]; then
1146 rc-server $2
1147 fi
Yuta HIGUCHId150ece2014-04-29 16:25:36 -07001148 ;;
Naoki Shiota4e463182014-03-21 15:13:24 -07001149 core)
1150 onos $2
1151 ;;
1152 *)
Naoki Shiota590c18d2014-03-31 17:52:59 -07001153 print_usage
Naoki Shiota4e463182014-03-21 15:13:24 -07001154 exit 1
1155esac
Naoki Shiota590c18d2014-03-31 17:52:59 -07001156