usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mru...@apache.org
Subject usergrid git commit: Add index mapping migration to the migration script.
Date Tue, 01 Sep 2015 20:58:30 GMT
Repository: usergrid
Updated Branches:
  refs/heads/two-dot-o-dev c24b06ceb -> a4a8b1e6d (forced update)


Add index mapping migration to the migration script.


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/a4a8b1e6
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/a4a8b1e6
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/a4a8b1e6

Branch: refs/heads/two-dot-o-dev
Commit: a4a8b1e6d56cc9ea90aa70d774fcc0e703f0d5e7
Parents: c4b5071
Author: Michael Russo <michaelarusso@gmail.com>
Authored: Tue Sep 1 13:49:20 2015 -0700
Committer: Michael Russo <michaelarusso@gmail.com>
Committed: Tue Sep 1 13:58:08 2015 -0700

----------------------------------------------------------------------
 stack/scripts/migrate_entity_data.py | 42 ++++++++++++++++++++++++++++++-
 1 file changed, 41 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/a4a8b1e6/stack/scripts/migrate_entity_data.py
----------------------------------------------------------------------
diff --git a/stack/scripts/migrate_entity_data.py b/stack/scripts/migrate_entity_data.py
index 13c1b41..233e693 100644
--- a/stack/scripts/migrate_entity_data.py
+++ b/stack/scripts/migrate_entity_data.py
@@ -53,6 +53,7 @@ import json
 # Version expected in status response post-migration for entity and app-info data
 TARGET_VERSION = 2
 TARGET_MIGRATION_SYSTEM_VERSION = 1
+TARGET_INDEX_MAPPING_VERSION = 1
 
 # Set an interval (in seconds) for checking if re-index and/or migration has finished
 STATUS_INTERVAL_SECONDS = 2
@@ -61,6 +62,7 @@ STATUS_INTERVAL_SECONDS = 2
 PLUGIN_MIGRATION_SYSTEM = 'migration-system'
 PLUGIN_APPINFO = 'appinfo-migration'
 PLUGIN_ENTITYDATA = 'collections-entity-data'
+PLUGIN_INDEX_MAPPING = 'index_mapping_migration'
 
 
 
@@ -132,7 +134,7 @@ class Migrate:
             migration_system_updated = self.is_migration_system_updated()
 
             if not migration_system_updated:
-                self.logger.info('Migration system needs to updated.  Updating migration
system..')
+                self.logger.info('Migration system needs to be updated.  Updating migration
system..')
                 self.start_migration_system_update()
                 while not migration_system_updated:
                     time.sleep(STATUS_INTERVAL_SECONDS)
@@ -163,6 +165,18 @@ class Migrate:
             else:
                 self.logger.info('Full Data Migration previously ran... skipping AppInfo
migration.')
 
+            # We need to check and roll index mapping version to 1 if not already there
+            index_mapping_updated = self.is_index_mapping_updated()
+
+            if not index_mapping_updated:
+                self.logger.info('Index Mapping needs to be updated.  Updating index mapping..')
+                self.start_index_mapping_migration()
+                while not index_mapping_updated:
+                    time.sleep(STATUS_INTERVAL_SECONDS)
+                    index_mapping_updated = self.is_index_mapping_updated()
+                    if index_mapping_updated:
+                        break
+            
             # Perform system re-index (it will grab date from input if provided)
             job = self.start_reindex()
             self.metrics['reindex_start'] = get_current_time()
@@ -241,6 +255,16 @@ class Migrate:
             self.logger.error('Failed to start migration, %s', e)
             exit_on_error(str(e))
 
+    def start_index_mapping_migration(self):
+        try:
+            migrateUrl = self.get_migration_url() + '/' + PLUGIN_INDEX_MAPPING
+            r = requests.put(url=migrateUrl, auth=(self.admin_user, self.admin_pass))
+            response = r.json()
+            return response
+        except requests.exceptions.RequestException as e:
+            self.logger.error('Failed to start migration, %s', e)
+            exit_on_error(str(e))
+
     def start_appinfo_migration(self):
         try:
             migrateUrl = self.get_migration_url() + '/' + PLUGIN_APPINFO
@@ -325,6 +349,22 @@ class Migrate:
                                  migration_system_version)
         return False
 
+    def is_index_mapping_updated(self):
+        status = self.check_data_migration_status()
+        if status is not None:
+            migration_system_version = status['data'][PLUGIN_INDEX_MAPPING]
+
+            if migration_system_version == TARGET_INDEX_MAPPING_VERSION:
+                self.logger.info('Index Mapping CURRENT, %s=[%s]',
+                                 PLUGIN_MIGRATION_SYSTEM,
+                                 migration_system_version)
+                return True
+            else:
+                self.logger.info('Index Mapping OLD, %s=[%s]',
+                                 PLUGIN_MIGRATION_SYSTEM,
+                                 migration_system_version)
+        return False
+
     def check_data_migration_status(self):
 
         try:


Mime
View raw message