Repository: incubator-trafodion
Updated Branches:
refs/heads/master c422ae9a5 -> ebeecd7b2
[TRAFODION-1617]
Add a few convenience scripts (and associated helper scripts)
Note: All the scripts with an "ilh_" prefix work if one has used
install_local_hadoop
ilh_trafinit: ckillall, restarts HBase(clobbers HBase data), sqstart and
initializes trafodion
ilh_traf_restart: ckillall, restarts HBase, sqstart
trafnodestatus: Prints the trafodion-status (whether Trafodion is UP or DOWN on
a node)
of the nodes in the Trafodion cluster. Has a '-j' switch to
print the
output in JSON format.
Note: There is another script 'sqnodestatus' with a similar
output but that
prints the status of the nodes from a Linux perspective.
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit:
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/79670d0b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/79670d0b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/79670d0b
Branch: refs/heads/master
Commit: 79670d0b2784618e38fdc750a4aec47fdf5a7047
Parents: c422ae9
Author: Narendra Goyal <[email protected]>
Authored: Fri Mar 25 01:39:46 2016 +0000
Committer: Narendra Goyal <[email protected]>
Committed: Fri Mar 25 01:39:46 2016 +0000
----------------------------------------------------------------------
core/sqf/sql/scripts/ilh_cleanhb | 106 +++++++++++++++++
core/sqf/sql/scripts/ilh_hbase_repair | 65 +++++++++++
core/sqf/sql/scripts/ilh_hbcheck | 72 ++++++++++++
core/sqf/sql/scripts/ilh_traf_restart | 117 +++++++++++++++++++
core/sqf/sql/scripts/ilh_trafinit | 108 +++++++++++++++++
.../sql/scripts/install_hadoop_regr_test_env | 4 +-
core/sqf/sql/scripts/install_local_hadoop | 5 +
core/sqf/sql/scripts/trafnodestatus | 100 ++++++++++++++++
core/sqf/sql/scripts/trafnodestatus.awk | 50 ++++++++
core/sqf/tools/sqtools.sh | 56 +++++++++
10 files changed, 681 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/79670d0b/core/sqf/sql/scripts/ilh_cleanhb
----------------------------------------------------------------------
diff --git a/core/sqf/sql/scripts/ilh_cleanhb b/core/sqf/sql/scripts/ilh_cleanhb
new file mode 100755
index 0000000..0b1076b
--- /dev/null
+++ b/core/sqf/sql/scripts/ilh_cleanhb
@@ -0,0 +1,106 @@
+#!/bin/bash
+#
+# @@@ START COPYRIGHT @@@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# @@@ END COPYRIGHT @@@
+#
+
+#
+# This script cleans up the HBase env
+# that was setup by install_local_hadoop.
+# It requires Hadoop to be up.
+#
+# - kills the HBase Master process (if it exists)
+# - deletes the HBase log files
+# - deletes the HDFS directory /hbase
+#
+# After running this script:
+# - swstarthbase
+# - sqstart
+# - initialize trafodion
+#
+
+function getMyNameNode {
+ jps | grep -w NameNode | cut -d' ' -f1
+}
+
+function getMyDataNode {
+ jps | grep -w DataNode | cut -d' ' -f1
+}
+
+function getMyHMaster {
+ jps | grep HMaster | cut -d' ' -f1
+}
+
+function killMyHMaster {
+
+ lv_hbpid=`getMyHMaster`
+ if [ ! -z ${lv_hbpid} ]; then
+ echo "Killing HMaster pid: ${lv_hbpid}"
+ kill -9 ${lv_hbpid}
+ else
+ echo "There's no HMaster process to kill"
+ fi
+
+}
+
+lv_clean_hb_data=0
+if [[ ! -z "$1" ]]; then
+ lv_clean_hb_data=$1
+fi
+
+lv_nnpid=`getMyNameNode`
+if [[ -z ${lv_nnpid} ]]; then
+ echo "NameNode is not up - please run swstarthadoop to start it or check
the Hadoop logs - exitting..."
+ exit 1
+fi
+echo "NameNode pid: ${lv_nnpid}"
+
+lv_dnpid=`getMyDataNode`
+if [[ -z ${lv_dnpid} ]]; then
+ echo "DataNode is not up - please run swstarthadoop to start it or check
the Hadoop logs - exitting..."
+ exit 1
+fi
+echo "DataNode pid: ${lv_dnpid}"
+
+# stop / kill the HMaster process
+killMyHMaster
+
+# delete the zookeeper info
+if [[ ${lv_clean_hb_data} -gt 0 ]]; then
+ lv_zk_dir="${MY_SW_ROOT}/hdfs:"
+ echo "Deleting the zookeeper directory: ${lv_zk_dir}"
+ rm -rf ${lv_zk_dir}
+fi
+
+#delete the logs
+echo "Deleting HBase logs in: ${MY_SQROOT}/sql/local_hadoop/hbase/logs"
+if [ ! -z ${MY_SQROOT} ]; then
+ rm -rf ${MY_SQROOT}/sql/local_hadoop/hbase/logs/*.log
+ rm -rf ${MY_SQROOT}/sql/local_hadoop/hbase/logs/*log.[0-9]*
+ rm -rf ${MY_SQROOT}/sql/local_hadoop/hbase/logs/*.out
+ rm -rf ${MY_SQROOT}/sql/local_hadoop/hbase/logs/*.out.[0-9]*
+fi
+
+if [[ ${lv_clean_hb_data} -gt 1 ]]; then
+# delete the HBase table data from HDFS
+ echo "Deleting the HBase data directory (hdfs) /hbase"
+ swhdfs dfs -rm -f -r -skipTrash /hbase
+fi
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/79670d0b/core/sqf/sql/scripts/ilh_hbase_repair
----------------------------------------------------------------------
diff --git a/core/sqf/sql/scripts/ilh_hbase_repair
b/core/sqf/sql/scripts/ilh_hbase_repair
new file mode 100755
index 0000000..547a539
--- /dev/null
+++ b/core/sqf/sql/scripts/ilh_hbase_repair
@@ -0,0 +1,65 @@
+#!/bin/bash
+# @@@ START COPYRIGHT @@@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# @@@ END COPYRIGHT @@@
+
+####################################################
+#
+# Executes the following:
+#
+# - Executes: hbase hbck -repair
+#
+####################################################
+
+if [ ! -z $MY_SQROOT ]; then
+ cd $MY_SQROOT/sql/scripts
+else
+ echo "The environment variable MY_SQROOT does not exist."
+ echo "Please ensure sqenv.sh has been sourced."
+ echo
+ exit 1;
+fi
+
+echo 'This script will execute: hbase hbck -repair'
+
+if [[ -z $1 ]]; then
+ read -p 'Do you want to proceed? y/n : ' lv_ans
+else
+ lv_ans=$1
+fi
+
+if [ "$lv_ans" != "y" ]; then
+ echo "Not proceeding. Exitting..."
+ exit 0
+else
+ echo "Ok...going ahead..."
+fi
+
+lv_starttime=`date`
+
+lv_stderr_file="$MY_SQROOT/logs/hbase_hbck_repair.log"
+echo "Stderr being written to the file: ${lv_stderr_file}"
+${HBASE_HOME}/bin/hbase hbck -repair > ${lv_stderr_file} 2>${lv_stderr_file}
+
+echo "done with hbase hbck. return code: $?"
+lv_endtime=`date`
+echo "Start time: ${lv_starttime}"
+echo "End time: ${lv_endtime}"
+exit 0
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/79670d0b/core/sqf/sql/scripts/ilh_hbcheck
----------------------------------------------------------------------
diff --git a/core/sqf/sql/scripts/ilh_hbcheck b/core/sqf/sql/scripts/ilh_hbcheck
new file mode 100755
index 0000000..2c6149c
--- /dev/null
+++ b/core/sqf/sql/scripts/ilh_hbcheck
@@ -0,0 +1,72 @@
+#!/bin/bash
+#
+# @@@ START COPYRIGHT @@@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# @@@ END COPYRIGHT @@@
+#
+
+if [ -z $JAVA_HOME ]; then
+ echo "The environment variable \$JAVA_HOME has not been set"
+ echo "Please ensure \$MY_SQROOT/sqenv.sh has been sourced."
+ echo
+ exit 1;
+fi
+
+cd $MY_SQROOT/tools/check_hbase_available
+echo "Building some utility Java programs."
+. ./build 2>/dev/null
+$JAVA_HOME/bin/java CheckHBase | grep -v "Checking" | grep "HBase is available"
+lv_status=$?
+if [[ $lv_status == 0 ]]; then
+ echo "HBase Master is available."
+else
+ echo "HBase Master is not accessible. Please check the HBase logs"
+ exit 1
+fi
+
+echo
+echo "Checking if HBase is functional..."
+echo
+
+swhbase <<EOF > hbase_status_detailed.out
+status 'detailed'
+EOF
+
+declare -i lv_num_live_rs
+lv_num_live_rs=`cat hbase_status_detailed.out | grep live | cut -d' ' -f1`
+echo "Number of live region servers: ${lv_num_live_rs}"
+if [ ${lv_num_live_rs} '>' '0' ] ; then
+ echo
+ echo "Checking if regions are online"
+else
+ echo "There does not seem to be any live region server available"
+ echo "Please check the HBase logs or the management interfaces"
+ exit 1
+fi
+
+declare -i lv_num_online_regions
+lv_num_online_regions=`cat hbase_status_detailed.out | grep -o
"numberOfOnlineRegions=[0-9]*" | cut -d= -f2`
+echo "The number of online regions: ${lv_num_online_regions}"
+if [ ${lv_num_online_regions} -lt 2 ]; then
+ echo "Error: There does not seem to be enough online region. Exitting..."
+ exit 1
+fi
+
+exit 0
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/79670d0b/core/sqf/sql/scripts/ilh_traf_restart
----------------------------------------------------------------------
diff --git a/core/sqf/sql/scripts/ilh_traf_restart
b/core/sqf/sql/scripts/ilh_traf_restart
new file mode 100755
index 0000000..ed5141c
--- /dev/null
+++ b/core/sqf/sql/scripts/ilh_traf_restart
@@ -0,0 +1,117 @@
+#!/bin/bash
+# @@@ START COPYRIGHT @@@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# @@@ END COPYRIGHT @@@
+
+####################################################
+#
+# Executes the following:
+#
+# - Kills the Trafodion Env
+# - Kills the HBase Master process and the zookeeper data
+# (uses ilh_cleanhb 1)
+# - Restarts HBase
+# - Repairs HBase (ilh_hbase_repair)
+# - Checks whether HBase is ready (uses ilh_hbcheck)
+# - Deletes the Trafodion env file: $MY_SQROOT/etc/ms.env
+# - Regenerates Config (sqgen)
+# - Starts up Trafodion (sqstart)
+#
+####################################################
+
+if [ ! -z $MY_SQROOT ]; then
+ cd $MY_SQROOT/sql/scripts
+else
+ echo "The environment variable MY_SQROOT does not exist."
+ echo "Please ensure sqenv.sh has been sourced."
+ echo
+ exit 1;
+fi
+
+lv_ilh_cleanhb_mode=1
+
+echo 'This script will do the following:'
+echo ' - Kill the Trafodion env (pkillall)'
+echo " - Kill the HBase env and delete the zookeeper data directory
(ilh_cleanhb ${lv_ilh_cleanhb_mode})"
+echo ' - Restart HBase (swstarthbase)'
+echo ' - Delete the env file: $MY_SQROOT/etc/ms.env'
+echo ' - sqgen'
+echo ' - sqstart'
+
+if [[ -z $1 ]]; then
+ read -p 'Do you want to proceed? y/n : ' lv_ans
+else
+ lv_ans=$1
+fi
+
+if [ "$lv_ans" != "y" ]; then
+ echo "Not proceeding. Exitting..."
+ exit 0
+else
+ echo "Ok...going ahead..."
+fi
+
+lv_starttime=`date`
+
+run_util pkillall
+sleep 5
+run_util pkillall
+
+echo "Stopping HBase"
+swstophbase &
+sleep 45
+kill %1
+
+run_util 'ilh_cleanhb 1'
+
+run_util swstarthbase
+
+echo "Sleeping for 15 seconds before checking the status of HBase"
+sleep 15
+
+echo "--------------------------------------"
+if [ -e $MY_SQROOT/sql/scripts/hbcheck ]; then
+ run_util hbcheck 4 10
+else
+ run_util ilh_hbcheck
+fi
+echo "--------------------------------------"
+
+echo "Repairing HBase (hbase hbck -repair)"
+ilh_hbase_repair y
+
+echo "--------------------------------------"
+echo "deleting $MY_SQROOT/etc/ms.env"
+rm $MY_SQROOT/etc/ms.env
+
+run_util sqgen
+
+run_util sqstart
+
+echo "executing: sqlci -> get schemas"
+sqlci <<EOF
+get schemas;
+EOF
+
+echo "done"
+lv_endtime=`date`
+echo "Start time: ${lv_starttime}"
+echo "End time: ${lv_endtime}"
+exit 0
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/79670d0b/core/sqf/sql/scripts/ilh_trafinit
----------------------------------------------------------------------
diff --git a/core/sqf/sql/scripts/ilh_trafinit
b/core/sqf/sql/scripts/ilh_trafinit
new file mode 100755
index 0000000..77669c1
--- /dev/null
+++ b/core/sqf/sql/scripts/ilh_trafinit
@@ -0,0 +1,108 @@
+#!/bin/bash
+# @@@ START COPYRIGHT @@@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# @@@ END COPYRIGHT @@@
+
+####################################################
+#
+# Executes the following:
+#
+# - Kills the Trafodion Env
+# - Kills the HBase env and the HDFS data directory associated with HBase
+# (uses ilh_cleanhb)
+# - Restarts HBase
+# - Checks whether HBase is ready (uses ilh_hbcheck)
+# - Deletes the Trafodion env file: $MY_SQROOT/etc/ms.env
+# - Regenerates Config (sqgen)
+# - Starts up Trafodion (sqstart)
+# - Initializes Trafodion (sqlci -> initialize trafodion)
+#
+####################################################
+
+if [ ! -z $MY_SQROOT ]; then
+ cd $MY_SQROOT/sql/scripts
+else
+ echo "The environment variable MY_SQROOT does not exist."
+ echo "Please ensure sqenv.sh has been sourced."
+ echo
+ exit 1;
+fi
+
+echo 'This script will do the following:'
+echo ' - Kill the Trafodion env (pkillall)'
+echo ' - Kill the HBase env and Delete the HDFS data directory associated with
HBase (ilh_cleanhb 2)'
+echo ' - Restart HBase (swstarthbase)'
+echo ' - Delete the env file: $MY_SQROOT/etc/ms.env'
+echo ' - sqgen'
+echo ' - sqstart'
+echo ' - sqlci -> initialize trafodion'
+
+if [[ -z $1 ]]; then
+ read -p 'Do you want to proceed? y/n : ' lv_ans
+else
+ lv_ans=$1
+fi
+
+if [ "$lv_ans" != "y" ]; then
+ echo "Not proceeding. Exitting..."
+ exit 0
+else
+ echo "Ok...going ahead..."
+fi
+
+lv_starttime=`date`
+run_util pkillall
+sleep 5
+run_util pkillall
+
+run_util 'ilh_cleanhb 2'
+
+run_util swstarthbase
+
+echo "Sleeping for 10 seconds before checking the status of HBase"
+sleep 10
+if [ -e $MY_SQROOT/sql/scripts/hbcheck ]; then
+ run_util hbcheck 4 10
+else
+ run_util ilh_hbcheck
+fi
+
+echo "deleting $MY_SQROOT/etc/ms.env"
+rm $MY_SQROOT/etc/ms.env
+
+run_util sqgen
+
+run_util sqstart
+
+echo "executing: sqlci -> initialize trafodion"
+sqlci <<EOF
+initialize trafodion;
+EOF
+
+echo "executing: sqlci -> get schemas"
+sqlci <<EOF
+get schemas;
+EOF
+
+echo "done"
+lv_endtime=`date`
+echo "Start time: ${lv_starttime}"
+echo "End time: ${lv_endtime}"
+exit 0
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/79670d0b/core/sqf/sql/scripts/install_hadoop_regr_test_env
----------------------------------------------------------------------
diff --git a/core/sqf/sql/scripts/install_hadoop_regr_test_env
b/core/sqf/sql/scripts/install_hadoop_regr_test_env
index 17da726..5fea8be 100755
--- a/core/sqf/sql/scripts/install_hadoop_regr_test_env
+++ b/core/sqf/sql/scripts/install_hadoop_regr_test_env
@@ -155,7 +155,7 @@ if [ -z "$MY_TPCDS_UNPACK_DIR" ]; then
MY_TPCDS_UNPACK_DIR=.
cd -P .
else
- mkdir $MY_TPCDS_UNPACK_DIR
+ mkdir -p $MY_TPCDS_UNPACK_DIR
cd $MY_TPCDS_UNPACK_DIR
fi
@@ -183,7 +183,7 @@ fi
make >>${MY_LOG_FILE} 2>&1
echo "Generating the data..." | tee -a ${MY_LOG_FILE}
- mkdir $MY_TPCDS_DATA_DIR
+ mkdir -p $MY_TPCDS_DATA_DIR
SCALE=1
FORCE=Y
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/79670d0b/core/sqf/sql/scripts/install_local_hadoop
----------------------------------------------------------------------
diff --git a/core/sqf/sql/scripts/install_local_hadoop
b/core/sqf/sql/scripts/install_local_hadoop
index ba928dd..b929799 100755
--- a/core/sqf/sql/scripts/install_local_hadoop
+++ b/core/sqf/sql/scripts/install_local_hadoop
@@ -737,10 +737,15 @@ EOF
cat <<EOF >$MY_SW_SCRIPTS_DIR/sw_env.sh
# Basic environment variables for Trafodion/Hadoop/Hive/HBase/MySQL setup
export JAVA_HOME=${JAVA_HOME}
+export JAVA_LIBRARY_PATH=${LD_LIBRARY_PATH}
+export MY_SW_SCRIPTS_DIR=${MY_SW_SCRIPTS_DIR}
+export MY_SW_ROOT=${MY_SW_ROOT}
export MYSQL_HOME=${MYSQL_HOME}
export YARN_HOME=${YARN_HOME}
export HIVE_HOME=${HIVE_HOME}
export HBASE_HOME=${HBASE_HOME}
+export HADOOP_PID_DIR=${MY_SW_ROOT}/tmp
+export HBASE_PID_DIR=${MY_SW_ROOT}/tmp
export MY_HADOOP_HDFS_PORT_NUM=${MY_HADOOP_HDFS_PORT_NUM}
export MY_HBASE_ZOOKEEPER_PEERPORT_NUM=${MY_HBASE_ZOOKEEPER_PEERPORT_NUM}
export MY_HBASE_ZOOKEEPER_LEADERPORT_NUM=${MY_HBASE_ZOOKEEPER_LEADERPORT_NUM}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/79670d0b/core/sqf/sql/scripts/trafnodestatus
----------------------------------------------------------------------
diff --git a/core/sqf/sql/scripts/trafnodestatus
b/core/sqf/sql/scripts/trafnodestatus
new file mode 100755
index 0000000..0c9aacd
--- /dev/null
+++ b/core/sqf/sql/scripts/trafnodestatus
@@ -0,0 +1,100 @@
+ #!/bin/bash
+#
+# @@@ START COPYRIGHT @@@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# @@@ END COPYRIGHT @@@
+#
+
+function traf_echo {
+ if [[ ${lv_jason_output} == "1" ]]; then
+ if [[ ${lv_first} == "1" ]]; then
+ lv_first=0
+ echo -n "["
+ else
+ echo -n ","
+ fi
+ echo -n "{\"ERROR\":\"$*\"}"
+ else
+ echo $*
+ fi
+
+}
+
+function traf_exit {
+ if [[ ${lv_jason_output} == "1" ]]; then
+ if [[ ${lv_first} == "0" ]]; then
+ echo "]"
+ fi
+ fi
+ exit $1
+}
+
+lv_first=1
+lv_jason_output=0
+if [[ ! -z $1 ]]; then
+ if [[ $1 == "-j" ]]; then
+ lv_jason_output=1
+ fi
+fi
+
+if [[ -z $MY_SQROOT ]]; then
+ traf_echo "Looks like the Trafodion environment has not been configured.
Exitting..."
+ traf_exit 5;
+fi
+
+if [[ -z $SQSCRIPTS_DIR ]]; then
+ SQSCRIPTS_DIR=$MY_SQROOT/sql/scripts
+fi
+SQCONFIGDB_FILE="$SQSCRIPTS_DIR/sqconfig.db"
+if [[ ! -e ${SQCONFIGDB_FILE} ]]; then
+ traf_echo "Cannot find the Trafodion configuration DB file
${SQCONFIGDB_FILE}"
+ traf_echo "Please execute sqgen to generate this file."
+ traf_exit 5;
+fi
+
+grep_out=`pstat | grep "monitor COLD" | grep -v mpirun`
+if [[ $? == '0' ]]; then
+ sqshell -c node info | awk -v jason_output=${lv_jason_output} -f
$MY_SQROOT/sql/scripts/trafnodestatus.awk
+ traf_exit $?
+else
+ traf_echo "Trafodion is not running on the current node: `hostname`"
+ lv_monitor_not_running_on_curr_node=1
+fi
+
+if [[ ! -z ${SQ_VIRTUAL_NODES} ]]; then
+ # Running in a single node environment
+ traf_echo "Trafodion has been configured to run on a single virtual node
environment."
+ traf_exit 1
+fi
+
+grep_out_mon=`$SQ_ROOT/sql/scripts/cstat | grep "monitor COLD" `
+lv_ret=$?
+if [[ $lv_ret == 0 ]]; then
+ grep_out=`cstat | grep "monitor COLD" | grep -v mpirun | sort | cut -d:
-f1`
+ for lv_node in $grep_out; do
+ ssh $lv_node sqshell -c node info | awk -v
jason_output=${lv_jason_output} -f $MY_SQROOT/sql/scripts/trafnodestatus.awk
+ lv_sqcheck_retcode=$?
+ traf_exit ${lv_exit_code}
+ done
+else
+ traf_echo "None of the Trafodion nodes have a Trafodion monitor running on
them."
+ traf_echo "Trafodion is currently down."
+ traf_exit 255;
+fi
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/79670d0b/core/sqf/sql/scripts/trafnodestatus.awk
----------------------------------------------------------------------
diff --git a/core/sqf/sql/scripts/trafnodestatus.awk
b/core/sqf/sql/scripts/trafnodestatus.awk
new file mode 100644
index 0000000..4c758a7
--- /dev/null
+++ b/core/sqf/sql/scripts/trafnodestatus.awk
@@ -0,0 +1,50 @@
+BEGIN {
+ lv_header_line_number = 0;
+ lv_lines_since_header = 0;
+ lv_first = 1;
+ lv_got_data = 0;
+}
+
+{
+ if (lv_header_line_number > 0) {
+ lv_lines_since_header = FNR - lv_header_line_number;
+ if (lv_lines_since_header >= 3) {
+ if ( ((lv_lines_since_header - 1) % 2) == 0) {
+ lv_node_status = toupper($3);
+ if (lv_node_status ~ "UP") {
+ lv_node_name = $8;
+ }
+ else {
+ lv_node_name = $4;
+ }
+ if (jason_output == 1) {
+ if (lv_first == 1) {
+ lv_first = 0;
+ printf("[");
+ lv_got_data = 1;
+ }
+ else {
+ printf(",");
+ }
+ printf("{\"NODE\":\"%s\",\"STATUS\":\"%s\"}",
+ lv_node_name,
+ lv_node_status);
+ }
+ else {
+ printf ("%s [ %s ]\n",
+ lv_node_name,
+ lv_node_status);
+ }
+ }
+ }
+ }
+}
+
+/MemFree SwapFree/ {lv_header_line_number = FNR;}
+
+END {
+ if ((jason_output == 1) &&
+ (lv_got_data == 1)) {
+ printf("]\n");
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/79670d0b/core/sqf/tools/sqtools.sh
----------------------------------------------------------------------
diff --git a/core/sqf/tools/sqtools.sh b/core/sqf/tools/sqtools.sh
index 0c7767c..d369959 100644
--- a/core/sqf/tools/sqtools.sh
+++ b/core/sqf/tools/sqtools.sh
@@ -266,6 +266,58 @@ function ndbm {
eval '$SQPDSHA "df -h | grep database" 2>/dev/null | wc -l'
}
+function chkReturnCodeExit {
+ if [[ $1 != 0 ]]; then
+ echo "$2 returned error $1, exitting..."
+ exit $1;
+ else
+ echo "$2 executed successfully."
+ fi
+}
+
+function chkReturnCode {
+ if [[ $1 != 0 ]]; then
+ echo "$2 returned error $1..."
+ return $1;
+ else
+ echo "$2 executed successfully."
+ return 0
+ fi
+}
+
+# $1: program/utility/script to run
+# $2: (optional): retry count (default 0)
+# $3: (optional): sleep for this many seconds
+#
+function run_util {
+ echo "--------------------------------------"
+ lv_cmd=$*
+ echo "executing: $1"
+ $1
+ lv_stat=$?
+ if [ ! -z $3 ]; then
+ declare -i lv_retries=0
+ while [ $lv_retries -lt $2 ]; do
+ let lv_retries=($lv_retries+1)
+ chkReturnCode ${lv_stat} $1
+ if [ $? != 0 ]; then
+ if [ $lv_retries -lt $2 ]; then
+ echo "retrying in $3 seconds"
+ sleep $3
+ $1
+ lv_stat=$?
+ else
+ exit ${lv_stat}
+ fi
+ else
+ return 0
+ fi
+ done
+ else
+ chkReturnCodeExit ${lv_stat} $1
+ fi
+ echo "--------------------------------------"
+}
# check the startup log and sort the interesting even chronologically
function sqchksl {
setup_sqpdsh
@@ -906,6 +958,10 @@ export -f sqpostsem
export -f sqgdb_doit
export -f sq_gdb_main
+export -f chkReturnCodeExit
+export -f chkReturnCode
+export -f run_util
+
# A front end to sq_gdb_main (as sq_gdb_main is a function, this function
executes sq_gdb_main in a fresh
# bash context and that allows background tasks spawned by sq_gdb_main to be
managed).
function sq_gdb {