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/05/16 12:01:32 UTC

[ambari] branch trunk updated: AMBARI-23822. Put write.lock back if it was deleted during Solr index migration.

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 d66b2ee  AMBARI-23822. Put write.lock back if it was deleted during Solr index migration.
d66b2ee is described below

commit d66b2ee66ea9b7376f2e782564c643c0db28bf63
Author: Oliver Szabo <ol...@gmail.com>
AuthorDate: Wed May 16 13:59:17 2018 +0200

    AMBARI-23822. Put write.lock back if it was deleted during Solr index migration.
---
 .../src/main/resources/solrIndexHelper.sh                         | 8 +++++++-
 .../AMBARI_INFRA_SOLR/0.1.0/package/scripts/migrate.py            | 7 +++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/ambari-infra/ambari-infra-solr-client/src/main/resources/solrIndexHelper.sh b/ambari-infra/ambari-infra-solr-client/src/main/resources/solrIndexHelper.sh
index 64499e0..3ea2eab 100755
--- a/ambari-infra/ambari-infra-solr-client/src/main/resources/solrIndexHelper.sh
+++ b/ambari-infra/ambari-infra-solr-client/src/main/resources/solrIndexHelper.sh
@@ -57,7 +57,7 @@ function upgrade_core() {
   SOLR_CORE_FILTER_ARR=$(echo $SOLR_CORE_FILTERS | sed "s/,/ /g")
 
   local version_prefix="$(echo $LUCENE_VERSION | head -c 1)"
-
+  local write_lock_exists="false"
   local core_str="Core"
   if [[ "$BACKUP_MODE" == "true" ]]; then
     core_str="Snapshot"
@@ -70,6 +70,7 @@ function upgrade_core() {
 
   if [[ -f "$INDEX_DIR/write.lock" ]]; then
     echo "Deleting $INDEX_DIR/write.lock file..."
+    write_lock_exists="true"
     rm "$INDEX_DIR/write.lock"
   fi
 
@@ -92,6 +93,11 @@ function upgrade_core() {
       fi
     fi
   done
+
+  if [[ "$write_lock_exists" == "true" ]]; then
+    echo "Putting write.lock file back..."
+    touch "$INDEX_DIR/write.lock"
+  fi
 }
 
 function upgrade_index() {
diff --git a/ambari-server/src/main/resources/common-services/AMBARI_INFRA_SOLR/0.1.0/package/scripts/migrate.py b/ambari-server/src/main/resources/common-services/AMBARI_INFRA_SOLR/0.1.0/package/scripts/migrate.py
index 1ff7d95..3947ddc 100644
--- a/ambari-server/src/main/resources/common-services/AMBARI_INFRA_SOLR/0.1.0/package/scripts/migrate.py
+++ b/ambari-server/src/main/resources/common-services/AMBARI_INFRA_SOLR/0.1.0/package/scripts/migrate.py
@@ -42,10 +42,12 @@ def migrate_index(env):
   if command_commons.core_filter is not None:
     index_migrate_cmd+=format(" -c {core_filter}")
 
+  deleted_write_locks=[]
   if command_commons.delete_lock_on_start:
     Logger.info(format("Remove write.lock files from folder '{index_location}'"))
     for write_lock_file in command_commons.get_files_by_pattern(format("{index_location}"), 'write.lock'):
       File(write_lock_file, action="delete")
+      deleted_write_locks.append(write_lock_file)
   else:
     Logger.info("Skip removing write.lock files")
 
@@ -53,3 +55,8 @@ def migrate_index(env):
   # It can generate a write.lock file
   Execute(index_migrate_cmd, user=params.infra_solr_user, environment={'JAVA_HOME': params.java64_home}, logoutput=command_commons.log_output)
 
+  if command_commons.delete_lock_on_start:
+    for write_lock_file in deleted_write_locks:
+      Logger.info(format("Put '{write_lock_file}' file back"))
+      File(write_lock_file, action="create", mode = 0644, owner=params.infra_solr_user, group=params.user_group, not_if=format("test -f {write_lock_file}"))
+

-- 
To stop receiving notification emails like this one, please contact
oleewere@apache.org.