This is an automated email from the ASF dual-hosted git repository.
wangdan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-pegasus.git
The following commit(s) were added to refs/heads/master by this push:
new c27590bf3 chore(script): support specifying config file while
migrating node by shell (#1370)
c27590bf3 is described below
commit c27590bf3d3156db8e8c7b70396c16975d156c53
Author: WHBANG <[email protected]>
AuthorDate: Tue Mar 14 11:33:36 2023 +0800
chore(script): support specifying config file while migrating node by shell
(#1370)
https://github.com/apache/incubator-pegasus/issues/1368
While we've supported using default config file for the shell to migrate
node, sometimes
we have to specify another config file in different path for it.
---
run.sh | 20 +++++++++++++++++---
scripts/migrate_node.sh | 49 ++++++++++++++++++++++++++++++++++++++-----------
2 files changed, 55 insertions(+), 14 deletions(-)
diff --git a/run.sh b/run.sh
index 7bbe4b356..1db910e9c 100755
--- a/run.sh
+++ b/run.sh
@@ -1650,6 +1650,7 @@ function usage_migrate_node()
echo "Options for subcommand 'migrate_node':"
echo " -h|--help print the help info"
echo " -c|--cluster <str> cluster meta lists"
+ echo " -f|--config <str> shell config path"
echo " -n|--node <str> the node to migrate primary replicas out,
should be ip:port"
echo " -a|--app <str> the app to migrate primary replicas out, if
not set, means migrate all apps"
echo " -t|--type <str> type: test or run, default is test"
@@ -1658,6 +1659,7 @@ function usage_migrate_node()
function run_migrate_node()
{
CLUSTER=""
+ CONFIG=""
NODE=""
APP="*"
TYPE="test"
@@ -1672,6 +1674,10 @@ function run_migrate_node()
CLUSTER="$2"
shift
;;
+ -f|--config)
+ CONFIG="$2"
+ shift
+ ;;
-n|--node)
NODE="$2"
shift
@@ -1694,7 +1700,7 @@ function run_migrate_node()
shift
done
- if [ "$CLUSTER" == "" ]; then
+ if [ "$CLUSTER" == "" -a "$CONFIG" == "" ]; then
echo "ERROR: no cluster specified"
echo
usage_migrate_node
@@ -1715,14 +1721,22 @@ function run_migrate_node()
exit 1
fi
- echo "CLUSTER=$CLUSTER"
+ if [ "$CLUSTER" != "" ]; then
+ echo "CLUSTER=$CLUSTER"
+ else
+ echo "CONFIG=$CONFIG"
+ fi
echo "NODE=$NODE"
echo "APP=$APP"
echo "TYPE=$TYPE"
echo
cd ${ROOT}
echo "------------------------------"
- ./scripts/migrate_node.sh $CLUSTER $NODE "$APP" $TYPE
+ if [ "$CLUSTER" != "" ]; then
+ ./scripts/migrate_node.sh $CLUSTER $NODE "$APP" $TYPE
+ else
+ ./scripts/migrate_node.sh $CONFIG $NODE "$APP" $TYPE -f
+ fi
echo "------------------------------"
echo
if [ "$TYPE" == "test" ]; then
diff --git a/scripts/migrate_node.sh b/scripts/migrate_node.sh
index f19552a9a..4189ca9bd 100755
--- a/scripts/migrate_node.sh
+++ b/scripts/migrate_node.sh
@@ -20,11 +20,18 @@ set -e
PID=$$
-if [ $# -ne 4 ]
-then
+function usage()
+{
echo "This tool is for migrating primary replicas out of specified node."
- echo "USAGE: $0 <cluster-meta-list> <migrate-node> <app-name> <run|test>"
- echo " app-name = * means migrate all apps"
+ echo
+ echo "USAGE1: $0 <cluster-meta-list> <migrate-node> <app-name> <run|test>"
+ echo "USAGE2: $0 <shell-config-path> <migrate-node> <app-name> <run|test> -f"
+ echo "app-name = * means migrate all apps"
+}
+
+if [ $# -ne 4 -a $# -ne 5 ]
+then
+ usage
exit 1
fi
@@ -32,15 +39,23 @@ pwd="$( cd "$( dirname "$0" )" && pwd )"
shell_dir="$( cd $pwd/.. && pwd )"
cd $shell_dir
-cluster=$1
+if [ $# -eq 4 ]; then
+ cluster=$1
+elif [ "$5" == "-f" ]; then
+ config=$1
+else
+ usage
+ echo "ERROR: invalid option: $5"
+ exit 1
+fi
node=$2
app_name=$3
type=$4
if [ "$type" != "run" -a "$type" != "test" ]
then
+ usage
echo "ERROR: invalid type: $type"
- echo "USAGE: $0 <cluster-meta-list> <migrate-node> <app-name> <run|test>"
exit 1
fi
@@ -48,9 +63,13 @@ echo "UID=$UID"
echo "PID=$PID"
echo
-echo "set_meta_level steady" | ./run.sh shell --cluster $cluster
&>/tmp/$UID.$PID.pegasus.set_meta_level
-
-echo ls | ./run.sh shell --cluster $cluster &>/tmp/$UID.$PID.pegasus.ls
+if [ "$cluster" != "" ]; then
+ echo "set_meta_level steady" | ./run.sh shell --cluster $cluster
&>/tmp/$UID.$PID.pegasus.set_meta_level
+ echo ls | ./run.sh shell --cluster $cluster &>/tmp/$UID.$PID.pegasus.ls
+else
+ echo "set_meta_level steady" | ./run.sh shell --config $config
&>/tmp/$UID.$PID.pegasus.set_meta_level
+ echo ls | ./run.sh shell --config $config &>/tmp/$UID.$PID.pegasus.ls
+fi
while read app_line
do
@@ -64,7 +83,11 @@ do
continue
fi
- echo "app $app -d" | ./run.sh shell --cluster $cluster
&>/tmp/$UID.$PID.pegasus.app.$app
+ if [ "$cluster" != "" ]; then
+ echo "app $app -d" | ./run.sh shell --cluster $cluster
&>/tmp/$UID.$PID.pegasus.app.$app
+ else
+ echo "app $app -d" | ./run.sh shell --config $config
&>/tmp/$UID.$PID.pegasus.app.$app
+ fi
while read line
do
@@ -79,7 +102,11 @@ do
if [ "$type" = "run" ]
then
- cat /tmp/$UID.$PID.pegasus.cmd.$app | ./run.sh shell --cluster $cluster
2>/dev/null
+ if [ "$cluster" != "" ]; then
+ cat /tmp/$UID.$PID.pegasus.cmd.$app | ./run.sh shell --cluster
$cluster 2>/dev/null
+ else
+ cat /tmp/$UID.$PID.pegasus.cmd.$app | ./run.sh shell --config $config
2>/dev/null
+ fi
echo
echo
else
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]