You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ol...@apache.org on 2018/06/23 14:10:22 UTC
[ambari] branch trunk updated: AMBARI-23945. Add script for
migration happy path.
This is an automated email from the ASF dual-hosted git repository.
oleewere pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git
The following commit(s) were added to refs/heads/trunk by this push:
new a45643d AMBARI-23945. Add script for migration happy path.
a45643d is described below
commit a45643d03bdbc1a88cbe871d74cc9eb6e8c97222
Author: Oliver Szabo <ol...@gmail.com>
AuthorDate: Sat Jun 23 15:36:16 2018 +0200
AMBARI-23945. Add script for migration happy path.
---
ambari-infra/ambari-infra-solr-client/README.md | 51 +++--
ambari-infra/ambari-infra-solr-client/build.xml | 1 +
.../src/main/python/migrationHelper.py | 80 +++++---
.../src/main/resources/ambariSolrMigration.sh | 217 +++++++++++++++++++++
4 files changed, 314 insertions(+), 35 deletions(-)
diff --git a/ambari-infra/ambari-infra-solr-client/README.md b/ambari-infra/ambari-infra-solr-client/README.md
index 92e6b85..4ff38e1 100644
--- a/ambari-infra/ambari-infra-solr-client/README.md
+++ b/ambari-infra/ambari-infra-solr-client/README.md
@@ -685,39 +685,68 @@ nohup infra-solr-data-manager -m archive -v -c $OLD_COLLECTION -s $SOLR_URL -z n
### <a id="happy-path">Happy path</a>
+Happy path steps are mainly for automation.
+
+##### 1. Generate migration config
+
+Generate ini config first for the migration, after running the following script, review the ini file content.
+
```bash
CONFIG_INI_LOCATION=ambari_migration.ini
BACKUP_BASE_PATH=/tmp
+/usr/bin/python /usr/lib/ambari-infra-solr-client/migrationConfigGenerator.py --ini-file $CONFIG_INI_LOCATION --host c7401.ambari.apache.org -port 8080 --cluster cl1 --username admin --password admin --backup-base-path=$BACKUP_BASE_PATH --java-home /usr/jdk64/jdk1.8.0_112
+```
+##### 2.a) Do backup-migrate-restore
+
+For doing a backup + cleanup, then later migrate + restore, use the following commands:
-# if backup is required:
+```bash
+/usr/lib/ambari-infra-solr-client/ambariSolrMigration.sh --ini-file $CONFIG_INI_LOCATION --mode backup
+/usr/lib/ambari-infra-solr-client/ambariSolrMigration.sh --ini-file $CONFIG_INI_LOCATION --mode delete --skip-solr-client-upgrade
+# go ahead with HDP upgrade or anything else, then if you have resource / time:
+/usr/lib/ambari-infra-solr-client/ambariSolrMigration.sh --ini-file $CONFIG_INI_LOCATION --mode migrate-restore
+```
+
+Or you can execute these commands togather (if you won't go with HDP upgrade after backup):
+```bash
+/usr/lib/ambari-infra-solr-client/ambariSolrMigration.sh --ini-file $CONFIG_INI_LOCATION --mode all
+```
+
+Which is equivalent will execute the following migrationHelper.py commands:
+
+```bash
/usr/bin/python /usr/lib/ambari-infra-solr-client/migrationConfigGenerator.py --ini-file $CONFIG_INI_LOCATION --host c7401.ambari.apache.org -port 8080 --cluster cl1 --username admin --password admin --backup-base-path=$BACKUP_BASE_PATH --java-home /usr/jdk64/jdk1.8.0_112
-# use action upgrade-logfeeders and upgrade-logsearch-portal as well if LOGSEARCH installed
/usr/bin/python /usr/lib/ambari-infra-solr-client/migrationHelper.py --ini-file $CONFIG_INI_LOCATION --action upgrade-solr-clients
/usr/bin/python /usr/lib/ambari-infra-solr-client/migrationHelper.py --ini-file $CONFIG_INI_LOCATION --action backup-and-cleanup
/usr/bin/python /usr/lib/ambari-infra-solr-client/migrationHelper.py --ini-file $CONFIG_INI_LOCATION --action upgrade-solr-instances
+/usr/bin/python /usr/lib/ambari-infra-solr-client/migrationHelper.py --ini-file $CONFIG_INI_LOCATION --action upgrade-logsearch-portal
+/usr/bin/python /usr/lib/ambari-infra-solr-client/migrationHelper.py --ini-file $CONFIG_INI_LOCATION --action upgrade-logfeeders
/usr/bin/python /usr/lib/ambari-infra-solr-client/migrationHelper.py --ini-file $CONFIG_INI_LOCATION --action restart-solr
-# if logsearch installed
/usr/bin/python /usr/lib/ambari-infra-solr-client/migrationHelper.py --ini-file $CONFIG_INI_LOCATION --action restart-logsearch
-# if ranger installed
/usr/bin/python /usr/lib/ambari-infra-solr-client/migrationHelper.py --ini-file $CONFIG_INI_LOCATION --action restart-ranger
-# if atlas installed
/usr/bin/python /usr/lib/ambari-infra-solr-client/migrationHelper.py --ini-file $CONFIG_INI_LOCATION --action restart-atlas
/usr/bin/python /usr/lib/ambari-infra-solr-client/migrationHelper.py --ini-file $CONFIG_INI_LOCATION --action migrate
/usr/bin/python /usr/lib/ambari-infra-solr-client/migrationHelper.py --ini-file $CONFIG_INI_LOCATION --action restore
/usr/bin/python /usr/lib/ambari-infra-solr-client/migrationHelper.py --ini-file $CONFIG_INI_LOCATION --action rolling-restart-solr
+```
-# or if backup is not required:
-/usr/bin/python /usr/lib/ambari-infra-solr-client/migrationConfigGenerator.py --ini-file $CONFIG_INI_LOCATION --host c7401.ambari.apache.org -port 8080 --cluster cl1 --username admin --password admin --backup-base-path=$BACKUP_BASE_PATH --java-home /usr/jdk64/jdk1.8.0_112
-# use action upgrade-logfeeders and upgrade-logsearch-portal as well if LOGSEARCH installed
+##### 2.a) Do delete only if backup is not required
+
+For only cleanup collections, execute this script:
+```bash
+/usr/lib/ambari-infra-solr-client/ambariSolrMigration.sh --ini-file $CONFIG_INI_LOCATION --mode delete
+```
+
+Which is equivalent will execute the following migrationHelper.py commands:
+```bash
/usr/bin/python /usr/lib/ambari-infra-solr-client/migrationHelper.py --ini-file $CONFIG_INI_LOCATION --action upgrade-solr-clients
/usr/bin/python /usr/lib/ambari-infra-solr-client/migrationHelper.py --ini-file $CONFIG_INI_LOCATION --action delete-collections
/usr/bin/python /usr/lib/ambari-infra-solr-client/migrationHelper.py --ini-file $CONFIG_INI_LOCATION --action upgrade-solr-instances
+/usr/bin/python /usr/lib/ambari-infra-solr-client/migrationHelper.py --ini-file $CONFIG_INI_LOCATION --action upgrade-logsearch-portal
+/usr/bin/python /usr/lib/ambari-infra-solr-client/migrationHelper.py --ini-file $CONFIG_INI_LOCATION --action upgrade-logfeeders
/usr/bin/python /usr/lib/ambari-infra-solr-client/migrationHelper.py --ini-file $CONFIG_INI_LOCATION --action restart-solr
-# if logsearch installed
/usr/bin/python /usr/lib/ambari-infra-solr-client/migrationHelper.py --ini-file $CONFIG_INI_LOCATION --action restart-logsearch
-# if ranger installed
/usr/bin/python /usr/lib/ambari-infra-solr-client/migrationHelper.py --ini-file $CONFIG_INI_LOCATION --action restart-ranger
-# if atlas installed
/usr/bin/python /usr/lib/ambari-infra-solr-client/migrationHelper.py --ini-file $CONFIG_INI_LOCATION --action restart-atlas
```
diff --git a/ambari-infra/ambari-infra-solr-client/build.xml b/ambari-infra/ambari-infra-solr-client/build.xml
index 822eadc..f7b2633 100644
--- a/ambari-infra/ambari-infra-solr-client/build.xml
+++ b/ambari-infra/ambari-infra-solr-client/build.xml
@@ -51,6 +51,7 @@
<copy todir="target/package" includeEmptyDirs="no">
<fileset file="src/main/resources/solrCloudCli.sh"/>
<fileset file="src/main/resources/solrIndexHelper.sh"/>
+ <fileset file="src/main/resources/ambariSolrMigration.sh"/>
<fileset file="src/main/python/solrDataManager.py"/>
<fileset file="src/main/python/migrationHelper.py"/>
<fileset file="src/main/python/migrationConfigGenerator.py"/>
diff --git a/ambari-infra/ambari-infra-solr-client/src/main/python/migrationHelper.py b/ambari-infra/ambari-infra-solr-client/src/main/python/migrationHelper.py
index 14d6cfd..859afda 100755
--- a/ambari-infra/ambari-infra-solr-client/src/main/python/migrationHelper.py
+++ b/ambari-infra/ambari-infra-solr-client/src/main/python/migrationHelper.py
@@ -50,7 +50,7 @@ LOGSEARCH_SERVER_COMPONENT_NAME ='LOGSEARCH_SERVER'
LOGSEARCH_LOGFEEDER_COMPONENT_NAME ='LOGSEARCH_LOGFEEDER'
RANGER_SERVICE_NAME = "RANGER"
-RANGER_ADMIN_COMPONENT_NAME = "RANDER_ADMIN"
+RANGER_ADMIN_COMPONENT_NAME = "RANGER_ADMIN"
ATLAS_SERVICE_NAME = "ATLAS"
ATLAS_SERVER_COMPONENT_NAME = "ATLAS_SERVER"
@@ -1448,31 +1448,35 @@ def disable_solr_authorization(options, accessor, parser, config):
else:
print "Security is not enabled. Skipping disable Solr authorization operation."
-def check_shards(options, accessor, parser, config):
+def check_shards(options, accessor, parser, config, backup_shards = False):
collections=list_collections(options, config, COLLECTIONS_DATA_JSON_LOCATION.format("check_collections.json"))
collections=filter_collections(options, collections)
if is_ranger_available(config, service_filter):
- ranger_collection = config.get('ranger_collection', 'ranger_collection_name')
+ ranger_collection = config.get('ranger_collection', 'backup_ranger_collection_name') if backup_shards \
+ else config.get('ranger_collection', 'ranger_collection_name')
if ranger_collection in collections:
check_shard_for_collection(ranger_collection)
else:
- print "Collection '{0}' does not exist or filtered out. Skipping update collection state operation.".format(ranger_collection)
+ print "Collection '{0}' does not exist or filtered out. Skipping check collection operation.".format(ranger_collection)
if is_atlas_available(config, service_filter):
- fulltext_index_name = config.get('atlas_collections', 'fulltext_index_name')
+ fulltext_index_name = config.get('atlas_collections', 'backup_fulltext_index_name') if backup_shards \
+ else config.get('atlas_collections', 'fulltext_index_name')
if fulltext_index_name in collections:
check_shard_for_collection(fulltext_index_name)
else:
- print "Collection '{0}' does not exist or filtered out. Skipping update collection state operation.".format(fulltext_index_name)
- edge_index_name = config.get('atlas_collections', 'edge_index_name')
+ print "Collection '{0}' does not exist or filtered out. Skipping check collection operation.".format(fulltext_index_name)
+ edge_index_name = config.get('atlas_collections', 'backup_edge_index_name') if backup_shards \
+ else config.get('atlas_collections', 'edge_index_name')
if edge_index_name in collections:
check_shard_for_collection(edge_index_name)
else:
- print "Collection '{0}' does not exist or filtered out. Skipping update collection state operation.".format(edge_index_name)
- vertex_index_name = config.get('atlas_collections', 'vertex_index_name')
+ print "Collection '{0}' does not exist or filtered out. Skipping check collection operation.".format(edge_index_name)
+ vertex_index_name = config.get('atlas_collections', 'backup_vertex_index_name') if backup_shards \
+ else config.get('atlas_collections', 'vertex_index_name')
if vertex_index_name in collections:
check_shard_for_collection(vertex_index_name)
else:
- print "Collection '{0}' does not exist or filtered out. Skipping update collection state operation.".format(fulltext_index_name)
+ print "Collection '{0}' does not exist or filtered out. Skipping check collection operation.".format(fulltext_index_name)
def check_docs(options, accessor, parser, config):
collections=list_collections(options, config, COLLECTIONS_DATA_JSON_LOCATION.format("check_docs_collections.json"), include_number_of_docs=True)
@@ -1482,7 +1486,7 @@ def check_docs(options, accessor, parser, config):
for collection_docs_data in docs_map:
print "Collection: '{0}' - Number of docs: {1}".format(collection_docs_data, docs_map[collection_docs_data])
else:
- print "Not found any collections."
+ print "Check number of documents - Not found any collections."
if __name__=="__main__":
parser = optparse.OptionParser("usage: %prog [options]")
@@ -1571,39 +1575,67 @@ if __name__=="__main__":
elif options.action.lower() == 'upgrade-solr-instances':
upgrade_solr_instances(options, accessor, parser, config)
elif options.action.lower() == 'upgrade-logsearch-portal':
- upgrade_logsearch_portal(options, accessor, parser, config)
+ if is_logsearch_available(config, service_filter):
+ upgrade_logsearch_portal(options, accessor, parser, config)
+ else:
+ print "LOGSEARCH service has not found in the config or filtered out."
elif options.action.lower() == 'upgrade-logfeeders':
- upgrade_logfeeders(options, accessor, parser, config)
+ if is_logsearch_available(config, service_filter):
+ upgrade_logfeeders(options, accessor, parser, config)
+ else:
+ print "LOGSEARCH service has not found in the config or filtered out."
elif options.action.lower() == 'stop-logsearch':
- service_components_command(options, accessor, parser, config, LOGSEARCH_SERVICE_NAME, LOGSEARCH_SERVER_COMPONENT_NAME, "STOP", "Stop")
- service_components_command(options, accessor, parser, config, LOGSEARCH_SERVICE_NAME, LOGSEARCH_LOGFEEDER_COMPONENT_NAME, "STOP", "Stop")
+ if is_logsearch_available(config, service_filter):
+ service_components_command(options, accessor, parser, config, LOGSEARCH_SERVICE_NAME, LOGSEARCH_SERVER_COMPONENT_NAME, "STOP", "Stop")
+ service_components_command(options, accessor, parser, config, LOGSEARCH_SERVICE_NAME, LOGSEARCH_LOGFEEDER_COMPONENT_NAME, "STOP", "Stop")
+ else:
+ print "LOGSEARCH service has not found in the config or filtered out."
elif options.action.lower() == 'restart-solr':
service_components_command(options, accessor, parser, config, SOLR_SERVICE_NAME, SOLR_COMPONENT_NAME, "RESTART", "Restart")
elif options.action.lower() == 'restart-logsearch':
- service_components_command(options, accessor, parser, config, LOGSEARCH_SERVICE_NAME, LOGSEARCH_SERVER_COMPONENT_NAME, "RESTART", "Restart")
- service_components_command(options, accessor, parser, config, LOGSEARCH_SERVICE_NAME, LOGSEARCH_LOGFEEDER_COMPONENT_NAME, "RESTART", "Restart")
+ if is_logsearch_available(config, service_filter):
+ service_components_command(options, accessor, parser, config, LOGSEARCH_SERVICE_NAME, LOGSEARCH_SERVER_COMPONENT_NAME, "RESTART", "Restart")
+ service_components_command(options, accessor, parser, config, LOGSEARCH_SERVICE_NAME, LOGSEARCH_LOGFEEDER_COMPONENT_NAME, "RESTART", "Restart")
+ else:
+ print "LOGSEARCH service has not found in the config or filtered out."
elif options.action.lower() == 'restart-atlas':
- service_components_command(options, accessor, parser, config, ATLAS_SERVICE_NAME, ATLAS_SERVER_COMPONENT_NAME, "RESTART", "Restart")
+ if is_atlas_available(config, service_filter):
+ service_components_command(options, accessor, parser, config, ATLAS_SERVICE_NAME, ATLAS_SERVER_COMPONENT_NAME, "RESTART", "Restart")
+ else:
+ print "ATLAS service has not found in the config or filtered out."
elif options.action.lower() == 'restart-ranger':
- service_components_command(options, accessor, parser, config, RANGER_SERVICE_NAME, RANGER_ADMIN_COMPONENT_NAME, "RESTART", "Restart")
+ if is_ranger_available(config, service_filter):
+ service_components_command(options, accessor, parser, config, RANGER_SERVICE_NAME, RANGER_ADMIN_COMPONENT_NAME, "RESTART", "Restart")
+ else:
+ print "RANGER service has not found in the config or filtered out."
elif options.action.lower() == 'rolling-restart-ranger':
- rolling_restart(options, accessor, parser, config, RANGER_SERVICE_NAME, RANGER_ADMIN_COMPONENT_NAME, "Rolling Restart Ranger Admin Instances")
+ if is_ranger_available(config, service_filter):
+ rolling_restart(options, accessor, parser, config, RANGER_SERVICE_NAME, RANGER_ADMIN_COMPONENT_NAME, "Rolling Restart Ranger Admin Instances")
+ else:
+ print "RANGER service has not found in the config or filtered out."
elif options.action.lower() == 'rolling-restart-atlas':
- rolling_restart(options, accessor, parser, config, ATLAS_SERVICE_NAME, ATLAS_SERVER_COMPONENT_NAME, "Rolling Restart Atlas Server Instances")
+ if is_atlas_available(config, service_filter):
+ rolling_restart(options, accessor, parser, config, ATLAS_SERVICE_NAME, ATLAS_SERVER_COMPONENT_NAME, "Rolling Restart Atlas Server Instances")
+ else:
+ print "ATLAS service has not found in the config or filtered out."
elif options.action.lower() == 'rolling-restart-solr':
rolling_restart(options, accessor, parser, config, SOLR_SERVICE_NAME, SOLR_COMPONENT_NAME, "Rolling Restart Infra Solr Instances")
elif options.action.lower() == 'disable-solr-authorization':
disable_solr_authorization(options, accessor, parser, config)
elif options.action.lower() == 'check-shards':
check_shards(options, accessor, parser, config)
+ elif options.action.lower() == 'check-backup-shards':
+ check_shards(options, accessor, parser, config, backup_shards=True)
elif options.action.lower() == 'check-docs':
check_docs(options, accessor, parser, config)
else:
parser.print_help()
print 'action option is invalid (available actions: delete-collections | backup | cleanup-znodes | backup-and-cleanup | migrate | restore |' \
- ' rolling-restart-solr | rolling-restart-ranger | rolling-restart-atlas | check-shards | check-docs | disable-solr-authorization |' \
+ ' rolling-restart-solr | rolling-restart-ranger | rolling-restart-atlas | check-shards | check-backup-shards | check-docs | disable-solr-authorization |' \
' upgrade-solr-clients | upgrade-solr-instances | upgrade-logsearch-portal | upgrade-logfeeders | stop-logsearch | restart-solr |' \
' restart-logsearch | restart-ranger | restart-atlas)'
sys.exit(1)
-
- print "Migration helper command {0}FINISHED{1}".format(colors.OKGREEN, colors.ENDC)
\ No newline at end of file
+ if options.verbose:
+ print "Migration helper command ({0}) {1}FINISHED{2}".format(str(args), colors.OKGREEN, colors.ENDC)
+ else:
+ print "Migration helper command {0}FINISHED{1}".format(colors.OKGREEN, colors.ENDC)
\ No newline at end of file
diff --git a/ambari-infra/ambari-infra-solr-client/src/main/resources/ambariSolrMigration.sh b/ambari-infra/ambari-infra-solr-client/src/main/resources/ambariSolrMigration.sh
new file mode 100755
index 0000000..f3271ca
--- /dev/null
+++ b/ambari-infra/ambari-infra-solr-client/src/main/resources/ambariSolrMigration.sh
@@ -0,0 +1,217 @@
+#!/bin/bash
+# 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.
+
+function print_help() {
+ cat << EOF
+ Usage: --mode <MODE> --ini-file <ini_file>
+
+ -m, --mode <MODE> available migration modes: delete-only | backup-only | migrate-restore | all
+ -i, --ini-file <INI_FILE> ini-file location (used by migrationHelper.py)
+ -s, --migration-script-location <file> migrateHelper.py location (default: /usr/lib/ambari-infra-solr-client/migrationHelper.py)
+ -w, --wait-between-steps <seconds> wait between different migration steps in seconds (default: 30)
+ --skip-solr-client-upgrade skip ambari-infra-solr-client package upgrades
+ --skip-solr-server-upgrade skip ambari-infra-solr package upgrades
+ --skip-logsearch-upgrade skip ambari-logsearch-portal and ambari-logsearch-logfeeder package upgrades
+ -h, --help print help
+EOF
+}
+
+function handle_result() {
+ local result_code=${1:?"usage: <last_command_result>"}
+ local step=${2:?"usage: <step_context"}
+ if [[ "$result_code" != "0" ]] ; then
+ echo "$step command failed. Stop migration commands ..."
+ exit 1
+ fi
+}
+
+function run_migrate_commands() {
+ local mode=${1:?"usage: <mode>"}
+ local script_location=${2:?"usage: <script_location>"}
+ local ini_file=${3:?"usage <ini_file>"}
+ local time_sleep=${4:?"usage <time_sleep_seconds>"}
+ local skip_solr_client_upgrade=${5:?"usage <true|false>"}
+ local skip_solr_server_upgrade=${6:?"usage <true|false>"}
+ local skip_logsearch_upgrade=${7:?"usage <true|false>"}
+ local verbose=${8:?"usage <true|false>"}
+
+ local verbose_val=""
+ if [[ "$verbose" == "true" ]]; then
+ verbose_val="--verbose"
+ fi
+
+ # execute on: backup - all
+ if [[ "$mode" == "backup" || "$mode" == "all" ]] ; then
+ $script_location --ini-file $ini_file --action check-shards $verbose_val
+ handle_result "$?" "Check Shards"
+ fi
+
+ # execute on: backup - delete - all
+ if [[ "$mode" != "migrate-restore" ]] ; then
+ if [[ "$skip_solr_client_upgrade" != "true" ]]; then
+ $script_location --ini-file $ini_file --action upgrade-solr-clients $verbose_val
+ handle_result "$?" "Upgrade Solr Clients"
+ fi
+ $script_location --ini-file $ini_file --action check-docs $verbose_val
+ handle_result "$?" "Check Documents"
+ fi
+
+ # ececute on: backup - all
+ if [[ "$mode" == "backup" || "$mode" == "all" ]] ; then
+ $script_location --ini-file $ini_file --action backup $verbose_val
+ handle_result "$?" "Backup"
+ fi
+
+ # execute on: delete - all
+ if [[ "$mode" == "delete" || "$mode" == "all" ]] ; then
+ $script_location --ini-file $ini_file --action delete-collections $verbose_val
+ handle_result "$?" "Delete collections"
+ fi
+
+ # execute on: delete - all
+ if [[ "$mode" == "delete" || "$mode" == "all" ]] ; then
+ if [[ "$skip_solr_server_upgrade" != "true" ]]; then
+ $script_location --ini-file $ini_file --action upgrade-solr-instances $verbose_val
+ handle_result "$?" "Upgrade Solr Instances"
+ fi
+ fi
+
+ # execute on: delete - all
+ if [[ "$mode" == "delete" || "$mode" == "all" ]] ; then
+ $script_location --ini-file $ini_file --action restart-solr $verbose_val
+ handle_result "$?" "Restart Solr Instances"
+ $script_location --ini-file $ini_file --action restart-ranger $verbose_val
+ handle_result "$?" "Restart Ranger Admins"
+ $script_location --ini-file $ini_file --action restart-atlas $verbose_val
+ handle_result "$?" "Restart Atlas Servers"
+ if [[ "$skip_logsearch_upgrade" != "true" ]]; then
+ $script_location --ini-file $ini_file --action upgrade-logsearch-portal $verbose_val
+ handle_result "$?" "Upgrade Log Search Portal"
+ $script_location --ini-file $ini_file --action upgrade-logfeeders $verbose_val
+ handle_result "$?" "Upgrade Log Feeders"
+ fi
+ $script_location --ini-file $ini_file --action restart-logsearch $verbose_val
+ handle_result "$?" "Restart Log Search"
+ fi
+
+ # execute on migrate-restore - all
+ if [[ "$mode" == "migrate-restore" || "$mode" == "all" ]] ; then
+ $script_location --ini-file $ini_file --action check-docs $verbose_val
+ handle_result "$?" "Check Documents"
+ $script_location --ini-file $ini_file --action migrate $verbose_val
+ handle_result "$?" "Migrate Index"
+ $script_location --ini-file $ini_file --action restore $verbose_val
+ handle_result "$?" "Restore"
+ $script_location --ini-file $ini_file --action rolling-restart-solr $verbose_val
+ handle_result "$?" "Rolling Restart Solr"
+ fi
+}
+
+function main() {
+ while [[ $# -gt 0 ]]
+ do
+ key="$1"
+ case $key in
+ -m|--mode)
+ local MODE="$2"
+ shift 2
+ ;;
+ -i|--ini-file)
+ local INI_FILE="$2"
+ shift 2
+ ;;
+ -w|--wait-between-steps)
+ local WAIT="$2"
+ shift 2
+ ;;
+ -s|--migration-script-location)
+ local SCRIPT_LOCATION="$2"
+ shift 2
+ ;;
+ --skip-solr-client-upgrade)
+ local SKIP_SOLR_CLIENT_UPGRADE="true"
+ shift 1
+ ;;
+ --skip-solr-server-upgrade)
+ local SKIP_SOLR_SERVER_UPGRADE="true"
+ shift 1
+ ;;
+ --skip-logsearch-upgrade)
+ local SKIP_LOGSEARCH_UPGRADE="true"
+ shift 1
+ ;;
+ -v|--verbose)
+ local VERBOSE="true"
+ shift 1
+ ;;
+ -h|--help)
+ shift 1
+ print_help
+ exit 0
+ ;;
+ *)
+ echo "Unknown option: $1"
+ exit 1
+ ;;
+ esac
+ done
+
+ if [[ -z "$SCRIPT_LOCATION" ]] ; then
+ SCRIPT_LOCATION="/usr/lib/ambari-infra-solr-client/migrationHelper.py"
+ fi
+
+ if [[ -z "$WAIT" ]] ; then
+ WAIT="30"
+ fi
+
+ if [[ -z "$VERBOSE" ]] ; then
+ VERBOSE="false"
+ fi
+
+ if [[ -z "$SKIP_SOLR_CLIENT_UPGRADE" ]] ; then
+ SKIP_SOLR_CLIENT_UPGRADE="false"
+ fi
+
+ if [[ -z "$SKIP_SOLR_SERVER_UPGRADE" ]] ; then
+ SKIP_SOLR_SERVER_UPGRADE="false"
+ fi
+
+ if [[ -z "$SKIP_LOGSEARCH_UPGRADE" ]] ; then
+ SKIP_LOGSEARCH_UPGRADE="false"
+ fi
+
+ if [[ -z "$INI_FILE" ]] ; then
+ echo "ini-file argument is required (-i or --ini-file)."
+ print_help
+ exit 1
+ fi
+
+ if [[ -z "$MODE" ]] ; then
+ echo "mode argument is required (-m or --mode)."
+ print_help
+ exit 1
+ else
+ if [[ "$MODE" == "delete" || "$MODE" == "backup" || "$MODE" == "migrate-restore" || "$MODE" == "all" ]]; then
+ run_migrate_commands "$MODE" "$SCRIPT_LOCATION" "$INI_FILE" "$WAIT" "$SKIP_SOLR_CLIENT_UPGRADE" "$SKIP_SOLR_SERVER_UPGRADE" "$SKIP_LOGSEARCH_UPGRADE" "$VERBOSE"
+ else
+ echo "mode '$MODE' is not supported"
+ print_help
+ exit 1
+ fi
+ fi
+}
+
+main ${1+"$@"}
\ No newline at end of file