usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sfeld...@apache.org
Subject [33/50] [abbrv] incubator-usergrid git commit: Added REST tier invocation for migrations.
Date Thu, 19 Mar 2015 23:26:50 GMT
Added REST tier invocation for migrations.


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

Branch: refs/heads/USERGRID-480
Commit: 1eca2718df182dc93bbb269f20f3abfd467756a7
Parents: aa01d73
Author: Todd Nine <tnine@apigee.com>
Authored: Mon Mar 9 14:56:10 2015 -0600
Committer: Todd Nine <tnine@apigee.com>
Committed: Mon Mar 9 14:56:10 2015 -0600

----------------------------------------------------------------------
 .../corepersistence/CpEntityManagerFactory.java |  1 -
 .../apache/usergrid/rest/MigrateResource.java   | 52 +++++++++++++++-----
 2 files changed, 39 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1eca2718/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
index 45d94d4..c58cd5e 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
@@ -131,7 +131,6 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
         this.counterUtils = counterUtils;
         this.injector = injector;
         this.managerCache = injector.getInstance( ManagerCache.class );
-        this.dataMigrationManager = injector.getInstance( DataMigrationManager.class );
         this.metricsFactory = injector.getInstance( MetricsFactory.class );
 
         this.orgApplicationCache = new OrgApplicationCacheImpl( this );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1eca2718/stack/rest/src/main/java/org/apache/usergrid/rest/MigrateResource.java
----------------------------------------------------------------------
diff --git a/stack/rest/src/main/java/org/apache/usergrid/rest/MigrateResource.java b/stack/rest/src/main/java/org/apache/usergrid/rest/MigrateResource.java
index 702d134..a6d2daa 100644
--- a/stack/rest/src/main/java/org/apache/usergrid/rest/MigrateResource.java
+++ b/stack/rest/src/main/java/org/apache/usergrid/rest/MigrateResource.java
@@ -20,6 +20,7 @@ package org.apache.usergrid.rest;
 
 
 import java.util.Map;
+import java.util.Set;
 
 import javax.ws.rs.DefaultValue;
 import javax.ws.rs.GET;
@@ -37,6 +38,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Scope;
 import org.springframework.stereotype.Component;
 
+import org.apache.usergrid.persistence.core.migration.data.DataMigrationManager;
 import org.apache.usergrid.persistence.core.migration.schema.MigrationManager;
 import org.apache.usergrid.rest.security.annotations.RequireSystemAccess;
 
@@ -62,6 +64,7 @@ public class MigrateResource extends AbstractContextResource {
         logger.info( "SystemResource initialized" );
     }
 
+
     @Autowired
     private Injector guiceInjector;
 
@@ -78,8 +81,6 @@ public class MigrateResource extends AbstractContextResource {
         //TODO make this use the task scheduler
 
 
-
-
         final Thread migrate = new Thread() {
 
             @Override
@@ -106,7 +107,6 @@ public class MigrateResource extends AbstractContextResource {
     }
 
 
-
     @RequireSystemAccess
     @PUT
     @Path( "set" )
@@ -118,17 +118,23 @@ public class MigrateResource extends AbstractContextResource {
 
         Preconditions.checkNotNull( json, "You must provide a json body" );
 
-        Preconditions.checke
 
-        String version = ( String ) json.get( "version" );
+        Preconditions.checkArgument( json.keySet().size() > 0, "You must specify at least
one module and version" );
 
-        Preconditions
-            .checkArgument( version != null && version.length() > 0, "You must
specify a version field in your json" );
+        /**
+         *  Set the migration version for the plugins specified
+         */
+        for ( final String key : json.keySet() ) {
+            String version = ( String ) json.get( key );
 
+            Preconditions.checkArgument( version != null && version.length() >
0,
+                "You must specify a version field per module name" );
 
-        int intVersion = Integer.parseInt( version );
 
-        emf.setMigrationVersion( intVersion );
+            int intVersion = Integer.parseInt( version );
+
+            getDataMigrationManager().resetToVersion( key, intVersion );
+        }
 
 
         return migrateStatus( ui, callback );
@@ -146,9 +152,16 @@ public class MigrateResource extends AbstractContextResource {
         response.setAction( "Migrate Schema indexes" );
 
         ObjectNode node = JsonNodeFactory.instance.objectNode();
-        node.put( "currentVersion", emf.getMigrateDataVersion() );
-        node.put( "lastMessage", emf.getMigrateDataStatus() );
-        response.setProperty( "status", node );
+
+
+
+        final DataMigrationManager dataMigrationManager = getDataMigrationManager();
+
+        final Set<String> plugins = dataMigrationManager.getPluginNames();
+
+        for(final String pluginName: plugins){
+            node.put( pluginName, dataMigrationManager.getCurrentVersion( pluginName ) );
+        }
 
         response.setSuccess();
 
@@ -173,7 +186,20 @@ public class MigrateResource extends AbstractContextResource {
         return new JSONWithPadding( response, callback );
     }
 
-    private MigrationManager getMigrationManager(){
+
+    /**
+     * Get the Data migraiton manager
+     */
+    private DataMigrationManager getDataMigrationManager() {
+        return guiceInjector.getInstance( DataMigrationManager.class );
+    }
+
+
+    /**
+     * Get the Data migraiton manager
+     */
+    private MigrationManager getMigrationManager() {
         return guiceInjector.getInstance( MigrationManager.class );
     }
 }
+


Mime
View raw message