You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by to...@apache.org on 2015/09/24 22:15:21 UTC
[3/6] usergrid git commit: Fixed bugs in migration of apps
Fixed bugs in migration of apps
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/521fc03e
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/521fc03e
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/521fc03e
Branch: refs/heads/two-dot-o-dev
Commit: 521fc03e556af47d110f0a7d98f2af215cb3fda1
Parents: 8281430
Author: Todd Nine <tn...@apigee.com>
Authored: Thu Sep 24 11:07:24 2015 -0600
Committer: Todd Nine <tn...@apigee.com>
Committed: Thu Sep 24 11:07:24 2015 -0600
----------------------------------------------------------------------
.../management/AppInfoMigrationPlugin.java | 47 +++++++++++---------
1 file changed, 25 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/usergrid/blob/521fc03e/stack/services/src/main/java/org/apache/usergrid/management/AppInfoMigrationPlugin.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/management/AppInfoMigrationPlugin.java b/stack/services/src/main/java/org/apache/usergrid/management/AppInfoMigrationPlugin.java
index 54779b9..d0f39e9 100644
--- a/stack/services/src/main/java/org/apache/usergrid/management/AppInfoMigrationPlugin.java
+++ b/stack/services/src/main/java/org/apache/usergrid/management/AppInfoMigrationPlugin.java
@@ -164,10 +164,18 @@ public class AppInfoMigrationPlugin implements MigrationPlugin {
throw new RuntimeException( e );
}
}
- } ).doOnCompleted( () -> {
- migrationInfoSerialization.setVersion( getName(), getMaxVersion() );
- observer.complete();
- } ).toBlocking().lastOrDefault( null );
+ } )
+ //we want a doOnError to catch something going wrong, otherwise we'll mark as complete
+ .doOnError( error -> {
+ logger.error( "Unable to migrate applications, an error occurred. Please try again", error );
+ observer.failed( getMaxVersion(), "Unable to migrate applications", error );
+ } )
+
+ //if we complete successfully, set the version and notify the observer
+ .doOnCompleted( () -> {
+ migrationInfoSerialization.setVersion( getName(), getMaxVersion() );
+ observer.complete();
+ } ).subscribe();
}
@@ -186,28 +194,23 @@ public class AppInfoMigrationPlugin implements MigrationPlugin {
UUID applicationId = getUuid( oldAppInfoMap, "applicationUuid" );
applicationId = applicationId == null ? getUuid( oldAppInfoMap, "appUuid" ) : applicationId;
//get app info from graph to see if it has been migrated already
- org.apache.usergrid.persistence.Entity appInfo = getApplicationInfo( applicationId );
- if ( appInfo == null ) {
- observer.update( getMaxVersion(), "Created application_info for " + appName );
- // create org->app connections, but not for apps in dummy "usergrid" internal organization
- if ( !orgName.equals( "usergrid" ) ) { //avoid management org
- EntityRef orgRef = managementEm.getAlias( Group.ENTITY_TYPE, orgName );
- // create and connect new APPLICATION_INFO oldAppInfo to Organization
- managementService.createApplication( orgRef.getUuid(), name, applicationId, null );
- }
- }
- else {
- //already migrated don't do anything
- observer.update( getMaxVersion(),
- "Received existing application_info for " + appName + " don't do anything" );
- }
+
+ // create org->app connections, but not for apps in dummy "usergrid" internal organization
+ //avoid management org
+
+ EntityRef orgRef = managementEm.getAlias( Group.ENTITY_TYPE, orgName );
+ // create and connect new APPLICATION_INFO oldAppInfo to Organization
+ managementService.createApplication( orgRef.getUuid(), name, applicationId, null );
+
+ observer.update( getMaxVersion(), "Created application_info for " + appName );
+ }
+ //swallow
+ catch ( ApplicationAlreadyExistsException appExists ) {
+ logger.info( "Application {} already migrated. Ignoring.", name );
}
catch ( Exception e ) {
- String msg = "Exception writing application_info for " + name;
- logger.error( msg, e );
- observer.failed( getMaxVersion(), msg );
throw new RuntimeException( e );
}
}