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/08/19 14:37:28 UTC

[ambari] branch branch-2.7 updated: AMBARI-24504. Solr API reports backup as complete while copy is still in progress. (#2115)

This is an automated email from the ASF dual-hosted git repository.

oleewere pushed a commit to branch branch-2.7
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/branch-2.7 by this push:
     new 0dd8b67  AMBARI-24504. Solr API reports backup as complete while copy is still in progress. (#2115)
0dd8b67 is described below

commit 0dd8b67ce2e82559e01e39a193726a988b521ce6
Author: Olivér Szabó <ol...@gmail.com>
AuthorDate: Sun Aug 19 16:37:25 2018 +0200

    AMBARI-24504. Solr API reports backup as complete while copy is still in progress. (#2115)
    
    * AMBARI-24504. Solr API reports backup as complete while copy is still in progress.
    
    * AMBARI-24504. Use continue instead of break
---
 .../AMBARI_INFRA_SOLR/0.1.0/metainfo.xml              |  3 ++-
 .../0.1.0/package/scripts/collection.py               |  3 +++
 .../0.1.0/package/scripts/command_commons.py          | 19 +++++++++++++++++++
 3 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/ambari-server/src/main/resources/common-services/AMBARI_INFRA_SOLR/0.1.0/metainfo.xml b/ambari-server/src/main/resources/common-services/AMBARI_INFRA_SOLR/0.1.0/metainfo.xml
index cd22ecc..d561f3e 100644
--- a/ambari-server/src/main/resources/common-services/AMBARI_INFRA_SOLR/0.1.0/metainfo.xml
+++ b/ambari-server/src/main/resources/common-services/AMBARI_INFRA_SOLR/0.1.0/metainfo.xml
@@ -49,7 +49,8 @@
               <commandScript>
                 <script>scripts/infra_solr.py</script>
                 <scriptType>PYTHON</scriptType>
-                <timeout>1200</timeout>
+                <timeout>36000</timeout>
+                <background>true</background>
               </commandScript>
             </customCommand>
             <customCommand>
diff --git a/ambari-server/src/main/resources/common-services/AMBARI_INFRA_SOLR/0.1.0/package/scripts/collection.py b/ambari-server/src/main/resources/common-services/AMBARI_INFRA_SOLR/0.1.0/package/scripts/collection.py
index e16a1bc..632874c 100644
--- a/ambari-server/src/main/resources/common-services/AMBARI_INFRA_SOLR/0.1.0/package/scripts/collection.py
+++ b/ambari-server/src/main/resources/common-services/AMBARI_INFRA_SOLR/0.1.0/package/scripts/collection.py
@@ -79,6 +79,9 @@ def backup_collection(env):
       command_commons.snapshot_status_check(status_check_cmd, status_check_json_output, core, True,
                                             log_output=command_commons.log_output, tries=command_commons.request_tries,
                                             time_interval=command_commons.request_time_interval)
+      snapshot_folder=format("{index_location}/snapshot.{core}")
+      if command_commons.check_folder_exists(snapshot_folder):
+        command_commons.check_folder_until_size_not_changes(snapshot_folder)
 
 
 def restore_collection(env):
diff --git a/ambari-server/src/main/resources/common-services/AMBARI_INFRA_SOLR/0.1.0/package/scripts/command_commons.py b/ambari-server/src/main/resources/common-services/AMBARI_INFRA_SOLR/0.1.0/package/scripts/command_commons.py
index 311fc0a..29f1857 100644
--- a/ambari-server/src/main/resources/common-services/AMBARI_INFRA_SOLR/0.1.0/package/scripts/command_commons.py
+++ b/ambari-server/src/main/resources/common-services/AMBARI_INFRA_SOLR/0.1.0/package/scripts/command_commons.py
@@ -352,3 +352,22 @@ def check_folder_exists(dir):
   if returncode:
     return False
   return True
+
+def check_folder_until_size_not_changes(dir):
+  """
+  Call du -d 0 <folder> | cut -f 1 on specific directory until the size not changes (so copy operation has finished)
+  """
+  cmd = format("du -d 0 {dir} | cut -f 1")
+  size_changed = True
+  size_str = "-1"
+  while size_changed:
+    returncode, stdout = call(cmd, user=params.infra_solr_user, timeout=300)
+    if stdout:
+      actual_size_str = stdout.strip()
+      if actual_size_str == size_str:
+        size_changed = False
+        continue
+      else:
+        Logger.info(format("Actual size of '{dir}' is {actual_size_str}, wait 5 sec and check again, to make sure no copy operation is in progress..."))
+        time.sleep(5)
+        size_str = actual_size_str
\ No newline at end of file