Skip to content
This repository has been archived by the owner on Jun 7, 2021. It is now read-only.

[TRAFODION-2649] Fixed 'rmscheck' method for obtaining status #1138

Merged
merged 2 commits into from
Jun 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 0 additions & 28 deletions core/sqf/sql/scripts/gensq.pl
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,6 @@ sub printRMSStopScript{
}
}

sub printRMSCheckScript{
($dWhich, @rest) = @_;
if ($dWhich == 1) {
print RMSC @rest;
}
}

sub printTMScript {
($dWhich, @rest) = @_;
print TM @rest;
Expand Down Expand Up @@ -441,20 +434,6 @@ sub generateRMS {
printRMSStopScript(3, "sqshell -c persist kill SSCP\n");
printRMSStopScript(3, "exit \$?\n");


printRMSCheckScript(1, "-- Trafodion config/utility file generated @ ",getTime(),"\n");
printRMSCheckScript(1, "prepare rms_check from select current_timestamp, \n");
printRMSCheckScript(1, "cast('Node' as varchar(5)), \n");
printRMSCheckScript(1, "cast(tokenstr('nodeId:', variable_info) as varchar(3)) node, \n");
printRMSCheckScript(1, "cast(tokenstr('Status:', variable_info) as varchar(10)) status \n");
printRMSCheckScript(1, "from table(statistics(null, ?));\n");

for ($i=0; $i < $gdNumNodes; $i++) {

my $l_string = sprintf("execute rms_check using 'RMS_CHECK=%d' ;\n", $i);
printRMSCheckScript(1, $l_string);
}

printRMSScript(1, "\n");

printScript(1, "rmsstart\n");
Expand Down Expand Up @@ -704,9 +683,6 @@ sub openFiles {
open (RMSS,">$stopRMS")
or die("unable to open $stopRMS");

open (RMSC,">$checkRMS")
or die("unable to open $checkRMS");

open (SSMP,">$startSSMP")
or die("unable to open $startSSMP");

Expand Down Expand Up @@ -742,7 +718,6 @@ sub endGame {
print "Generated TM Startup file: $startTM\n";
print "Generated RMS Startup file: $startRMS\n";
print "Generated RMS Stop file: $stopRMS\n";
print "Generated RMS Check file: $checkRMS\n";
print "Generated SSMP Startup file: $startSSMP\n";
print "Generated SSMP Stop file: $stopSSMP\n";
print "Generated SSCP Startup file: $startSSCP\n";
Expand All @@ -755,7 +730,6 @@ sub endGame {

close(RMS);
close(RMSS);
close(RMSC);

close(SSMP);
close(SSMPS);
Expand All @@ -773,7 +747,6 @@ sub endGame {

chmod 0700, $startRMS;
chmod 0700, $stopRMS;
chmod 0700, $checkRMS;

chmod 0700, $startSSMP;
chmod 0700, $stopSSMP;
Expand All @@ -800,7 +773,6 @@ sub doInit {
$stopRMS="rmsstop";
$stopSSMP="ssmpstop";
$stopSSCP="sscpstop";
$checkRMS="rmscheck.sql";


$coldscriptFileName=sprintf("%s.cold", $scriptFileName);
Expand Down
19 changes: 17 additions & 2 deletions core/sqf/sql/scripts/rmscheck
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,22 @@
#
# @@@ END COPYRIGHT @@@
#
# Most of this was stolen from WMScheck... which may have started as NDCScheck

if [[ -z $TRAF_HOME ]]; then
echo
echo "The TRAF_HOME environment variable does not exist."
echo "Please ensure sqenv.sh has been sourced."
echo
exit 1;
fi

# Check whether the Trafodion environment up.
sqcheck -i 1 -d 1 > /dev/null 2>&1
sq_stat=$?
if [[ $sq_stat == 255 ]]; then
echo "The Trafodion environment is down. Exiting..."
exit 1
fi

echo "Timestamp Id Status "
sqlci -i $TRAF_HOME/sql/scripts/rmscheck.sql | grep 'Node\|ERROR' | grep -v varchar
sqgenrmscheck | sqlci | grep 'Node\|ERROR' | grep -v varchar
118 changes: 118 additions & 0 deletions core/sqf/sql/scripts/sqgenrmscheck
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
#!/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 @@@
#
# sqgen script - generates various files

function Usage {
script_name=`/bin/basename $0`
echo
echo $script_name displays generated the Trafodion rmscheck sqlci statements
echo
echo "Usage: $script_name [ -? | -h ]"
echo " -? Help"
echo " -h Help"
echo
exit 1;
}

function GenRmsCheckSqlQuery {

GENDATE=`date`

echo "-- 'rmscheck.sql' Generated on $GENDATE"
echo
echo "-- Prepare the 'rms_check' query"
echo "prepare rms_check from select current_timestamp,"
echo "cast('Node' as varchar(5)),"
echo "cast(tokenstr('nodeId:', variable_info) as varchar(3)) node,"
echo "cast(tokenstr('Status:', variable_info) as varchar(10)) status"
echo "from table(statistics(null, ?));"
echo
echo "-- Execute the 'rms_check' query for each node-id"

}

function GenRmsCheckSql {

# Get Trafodion node-id configuration
TempList=`trafconf -node | grep -o 'node-id=.[0-9]*' | cut -d "=" -f 2 | sort -u`

i=0
for NID in $TempList
do
TrNids[$i]=$NID
#echo "-- TrNids[${i}]=${TrNids[$i]}"
((i=i+1))
done

# Check that the <nid>s were correctly added
ExNidList=`echo ${TrNids[@]}`
if [[ ! -z ${ExNidList[@]} ]]; then
GenRmsCheckSqlQuery
j=0
for Nid in ${TrNids[@]}
do
Nid=$Nid
#echo "j=$j Nid=${Nid}"
echo "execute rms_check using 'RMS_CHECK=${Nid}';"
((j=j+1))
done
exit 0;
else
echo
echo "Could not obtain the Trafodion Configuration from the 'trafconf' utility!"
echo "Execute 'trafconf -node' to determine if Trafodion Configuration has been"
echo "initialized and can be accessed."
echo
exit 1;
fi
}

###########################################################
# MAIN portion of sqgen begins
###########################################################

if [[ -z $TRAF_HOME ]]; then
echo
echo "The TRAF_HOME environment variable does not exist."
echo "Please ensure sqenv.sh has been sourced."
echo
exit 1;
fi

cd $TRAF_HOME/sql/scripts

# Assume option is SQLCI_IN_FILE
while [ $# != 0 ]
do
flag="$1"
case "$flag" in
-h) Usage ;;
-?) Usage ;;
*) Usage ;;
esac
shift
done

GenRmsCheckSql