Repository: incubator-usergrid Updated Branches: refs/heads/two-dot-o-dev 0794d9416 -> e3a4a9571
Ensure we migrate app infos before re-index when using the force (delta) option. Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/7476ea1b Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/7476ea1b Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/7476ea1b Branch: refs/heads/two-dot-o-dev Commit: 7476ea1b3c24033b733d556b94e3bd23d5d5a533 Parents: 9f81d7b Author: Michael Russo <michaelaru...@gmail.com> Authored: Tue Aug 11 16:44:08 2015 -0700 Committer: Michael Russo <michaelaru...@gmail.com> Committed: Tue Aug 11 16:44:08 2015 -0700 ---------------------------------------------------------------------- stack/scripts/migrate_entity_data.py | 42 +++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/7476ea1b/stack/scripts/migrate_entity_data.py ---------------------------------------------------------------------- diff --git a/stack/scripts/migrate_entity_data.py b/stack/scripts/migrate_entity_data.py index 40013ad..58b2b82 100644 --- a/stack/scripts/migrate_entity_data.py +++ b/stack/scripts/migrate_entity_data.py @@ -108,6 +108,14 @@ class Migrate: self.reset_data_migration() time.sleep(STATUS_INTERVAL_SECONDS) self.is_data_migrated() + self.start_appinfo_migration() + self.logger.info('AppInfo Migration Started.') + is_appinfo_migrated = False + while not is_appinfo_migrated: + time.sleep(STATUS_INTERVAL_SECONDS) + is_appinfo_migrated = self.is_appinfo_migrated() + if is_appinfo_migrated: + break else: self.logger.error('Entity Data has already been migrated. To re-run data migration provide the' ' force parameter: python migrate.py -u <user:pass> -f') @@ -128,9 +136,9 @@ class Migrate: self.metrics['reindex_end'] = get_current_time() if not reindex_only: - self.start_data_migration() + self.start_fulldata_migration() self.metrics['data_migration_start'] = get_current_time() - self.logger.info("Entity Data Migration Started") + self.logger.info("Full Data Migration Started") is_migrated = False while not is_migrated: time.sleep(STATUS_INTERVAL_SECONDS) @@ -164,7 +172,7 @@ class Migrate: url = self.endpoint + '/system/index/rebuild' return url - def start_data_migration(self): + def start_fulldata_migration(self): try: r = requests.put(url=self.get_migration_url(), auth=(self.admin_user, self.admin_pass)) response = r.json() @@ -173,6 +181,16 @@ class Migrate: 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() + '/' + 'appinfo-migration' + 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 reset_data_migration(self): version = TARGET_VERSION - 1 body = json.dumps({'collections-entity-data': version, 'appinfo-migration': version}) @@ -193,13 +211,27 @@ class Migrate: appinfo_version = status['data']['appinfo-migration'] if entity_version == TARGET_VERSION and appinfo_version == TARGET_VERSION: - self.logger.info('Data Migration status=[COMPLETE], collections-entity-data=[v%s], ' + self.logger.info('Full Data Migration status=[COMPLETE], collections-entity-data=[v%s], ' 'appinfo-migration=[v%s]', entity_version, appinfo_version) return True else: - self.logger.info('Data Migration status=[NOTSTARTED/INPROGRESS]') + self.logger.info('Full Data Migration status=[NOTSTARTED/INPROGRESS]') + return False + + def is_appinfo_migrated(self): + status = self.check_data_migration_status() + if status is not None: + appinfo_version = status['data']['appinfo-migration'] + + if appinfo_version == TARGET_VERSION: + self.logger.info('AppInfo Migration status=[COMPLETE],' + 'appinfo-migration=[v%s]', + appinfo_version) + return True + else: + self.logger.info('AppInfo Migration status=[NOTSTARTED/INPROGRESS]') return False def check_data_migration_status(self):