You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by mr...@apache.org on 2015/09/01 22:51:32 UTC
usergrid git commit: Add index mapping migration to the migration
script.
Repository: usergrid
Updated Branches:
refs/heads/two-dot-o-dev c4b507154 -> c24b06ceb
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/c24b06ce
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/c24b06ce
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/c24b06ce
Branch: refs/heads/two-dot-o-dev
Commit: c24b06ceb0f5928f45f1aecc38fab382ada11442
Parents: c4b5071
Author: Michael Russo <mi...@gmail.com>
Authored: Tue Sep 1 13:49:20 2015 -0700
Committer: Michael Russo <mi...@gmail.com>
Committed: Tue Sep 1 13:49:20 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/c24b06ce/stack/scripts/migrate_entity_data.py
----------------------------------------------------------------------
diff --git a/stack/scripts/migrate_entity_data.py b/stack/scripts/migrate_entity_data.py
index 13c1b41..d9bfb08 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)
@@ -140,6 +142,18 @@ class Migrate:
if migration_system_updated:
break
+ # 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
+
# Run AppInfo migration only when both appinfos and collection entity data have not been migrated
if not self.is_data_migrated():
@@ -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: