You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by gr...@apache.org on 2015/03/19 23:20:18 UTC
[28/50] [abbrv] incubator-usergrid git commit: Refactored packages
Refactored packages
Fixes system setup migration wiring
Added more tests
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/cf32557a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/cf32557a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/cf32557a
Branch: refs/heads/USERGRID-493
Commit: cf32557a101b7d654f2d2d2090b385cb74110220
Parents: 494f8ae
Author: Todd Nine <tn...@apigee.com>
Authored: Wed Mar 4 23:13:32 2015 -0700
Committer: Todd Nine <tn...@apigee.com>
Committed: Wed Mar 4 23:13:32 2015 -0700
----------------------------------------------------------------------
.../usergrid/corepersistence/CoreModule.java | 14 +-
.../corepersistence/CpEntityManagerFactory.java | 4 +-
.../migration/CoreMigration.java | 53 +++
.../migration/CoreMigrationPlugin.java | 8 +-
.../migration/EntityTypeMappingMigration.java | 8 +-
.../migration/MigrationModuleVersion.java | 8 +-
.../rx/impl/AbstractGraphVisitorImpl.java | 5 +-
.../MvccEntitySerializationStrategy.java | 2 +-
...vccEntitySerializationStrategyProxyImpl.java | 4 +-
.../serialization/impl/SerializationModule.java | 15 +-
.../impl/migration/CollectionMigration.java | 53 +++
.../migration/CollectionMigrationPlugin.java | 9 +-
.../migration/MvccEntityDataMigrationImpl.java | 13 +-
.../collection/guice/TestCollectionModule.java | 6 +-
...ntitySerializationStrategyProxyV1_3Test.java | 1 -
...ctMvccEntityDataMigrationV1ToV3ImplTest.java | 10 +-
.../MvccEntityDataMigrationV1ToV3ImplTest.java | 20 +-
.../MvccEntityDataMigrationV2ToV3ImplTest.java | 3 +-
.../persistence/core/guice/CommonModule.java | 2 +-
.../core/hystrix/HystrixCassandra.java | 30 +-
.../migration/data/AbstractMigrationPlugin.java | 128 +++++++
.../core/migration/data/DataMigration.java | 58 +++
.../data/DataMigrationManagerImpl.java | 21 +-
.../migration/data/MigrationDataProvider.java | 43 +++
.../core/migration/data/MigrationPlugin.java | 51 +++
.../migration/data/MigrationRelationship.java | 100 +++++
.../core/migration/data/ProgressObserver.java | 63 ++++
.../core/migration/data/VersionedData.java | 38 ++
.../migration/data/VersionedMigrationSet.java | 153 ++++++++
.../data/newimpls/AbstractMigrationPlugin.java | 126 -------
.../migration/data/newimpls/DataMigration2.java | 58 ---
.../data/newimpls/MigrationDataProvider.java | 43 ---
.../data/newimpls/MigrationPlugin.java | 51 ---
.../data/newimpls/MigrationRelationship.java | 100 -----
.../data/newimpls/ProgressObserver.java | 50 ---
.../migration/data/newimpls/VersionedData.java | 38 --
.../data/newimpls/VersionedMigrationSet.java | 153 --------
.../data/DataMigrationManagerImplTest.java | 366 +++++++------------
.../data/MigrationInfoSerializationTest.java | 112 +++---
.../data/TestMigrationDataProvider.java | 61 ++++
.../migration/data/TestProgressObserver.java | 24 +-
.../data/VersionedMigrationSetTest.java | 198 ++++++++++
.../newimpls/TestMigrationDataProvider.java | 61 ----
.../newimpls/VersionedMigrationSetTest.java | 194 ----------
.../persistence/graph/guice/GraphModule.java | 14 +-
.../EdgeMetadataSerialization.java | 2 +-
.../EdgeMetadataSerializationProxyImpl.java | 4 +-
.../impl/migration/EdgeDataMigrationImpl.java | 12 +-
.../impl/migration/GraphMigration.java | 53 +++
.../impl/migration/GraphMigrationPlugin.java | 9 +-
.../graph/guice/TestGraphModule.java | 5 +-
.../migration/EdgeDataMigrationImplTest.java | 4 +-
.../apache/usergrid/rest/MigrateResource.java | 4 +-
53 files changed, 1370 insertions(+), 1295 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cf32557a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
index 9f01feb..62be6cf 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CoreModule.java
@@ -21,8 +21,10 @@ import org.springframework.context.ApplicationContext;
import org.apache.usergrid.corepersistence.events.EntityDeletedHandler;
import org.apache.usergrid.corepersistence.events.EntityVersionCreatedHandler;
import org.apache.usergrid.corepersistence.events.EntityVersionDeletedHandler;
+import org.apache.usergrid.corepersistence.migration.CoreMigration;
import org.apache.usergrid.corepersistence.migration.CoreMigrationPlugin;
import org.apache.usergrid.corepersistence.migration.EntityTypeMappingMigration;
+import org.apache.usergrid.corepersistence.migration.MigrationModuleVersion;
import org.apache.usergrid.corepersistence.rx.impl.AllEntitiesInSystemImpl;
import org.apache.usergrid.corepersistence.rx.impl.AllNodesInGraphImpl;
import org.apache.usergrid.corepersistence.rx.impl.AllApplicationsObservableImpl;
@@ -34,9 +36,9 @@ import org.apache.usergrid.persistence.collection.guice.CollectionModule;
import org.apache.usergrid.persistence.collection.serialization.impl.migration.EntityIdScope;
import org.apache.usergrid.persistence.collection.serialization.impl.migration.MvccEntityDataMigrationImpl;
import org.apache.usergrid.persistence.core.guice.CommonModule;
-import org.apache.usergrid.persistence.core.migration.data.newimpls.DataMigration2;
-import org.apache.usergrid.persistence.core.migration.data.newimpls.MigrationDataProvider;
-import org.apache.usergrid.persistence.core.migration.data.newimpls.MigrationPlugin;
+import org.apache.usergrid.persistence.core.migration.data.DataMigration;
+import org.apache.usergrid.persistence.core.migration.data.MigrationDataProvider;
+import org.apache.usergrid.persistence.core.migration.data.MigrationPlugin;
import org.apache.usergrid.persistence.graph.guice.GraphModule;
import org.apache.usergrid.persistence.graph.serialization.impl.migration.GraphNode;
import org.apache.usergrid.persistence.index.guice.IndexModule;
@@ -121,12 +123,12 @@ public class CoreModule extends AbstractModule {
* Create our migrations for within our core plugin
*
*/
- Multibinder<DataMigration2<EntityIdScope>> dataMigrationMultibinder =
- Multibinder.newSetBinder( binder(), new TypeLiteral<DataMigration2<EntityIdScope>>() {} );
+ Multibinder<DataMigration<EntityIdScope>> dataMigrationMultibinder =
+ Multibinder.newSetBinder( binder(), new TypeLiteral<DataMigration<EntityIdScope>>() {}, CoreMigration.class );
- dataMigrationMultibinder.addBinding().to( MvccEntityDataMigrationImpl.class );
dataMigrationMultibinder.addBinding().to( EntityTypeMappingMigration.class );
+ dataMigrationMultibinder.addBinding().to( MigrationModuleVersion.class );
//wire up the collection migration plugin
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cf32557a/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 e0d7daa..3b39bc9 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
@@ -43,7 +43,7 @@ import org.apache.usergrid.persistence.collection.EntityCollectionManager;
import org.apache.usergrid.persistence.collection.impl.CollectionScopeImpl;
import org.apache.usergrid.persistence.collection.serialization.impl.migration.EntityIdScope;
import org.apache.usergrid.persistence.core.migration.data.DataMigrationManager;
-import org.apache.usergrid.persistence.core.migration.data.newimpls.MigrationDataProvider;
+import org.apache.usergrid.persistence.core.migration.data.MigrationDataProvider;
import org.apache.usergrid.persistence.core.scope.ApplicationScope;
import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl;
import org.apache.usergrid.persistence.core.util.Health;
@@ -367,7 +367,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
this.rebuildApplicationIndexes(applicationId, new ProgressObserver() {
@Override
public void onProgress(EntityRef entity) {
- logger.info("Restored entity {}:{}", entity.getType(), entity.getUuid());
+ logger.info( "Restored entity {}:{}", entity.getType(), entity.getUuid() );
}
});
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cf32557a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/CoreMigration.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/CoreMigration.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/CoreMigration.java
new file mode 100644
index 0000000..4df32da
--- /dev/null
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/CoreMigration.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.usergrid.corepersistence.migration;/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import com.google.inject.BindingAnnotation;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+
+@BindingAnnotation
+@Target({ FIELD, PARAMETER, METHOD }) @Retention(RUNTIME)
+public @interface CoreMigration {}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cf32557a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/CoreMigrationPlugin.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/CoreMigrationPlugin.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/CoreMigrationPlugin.java
index b95900f..91c1570 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/CoreMigrationPlugin.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/CoreMigrationPlugin.java
@@ -24,9 +24,9 @@ import java.util.Set;
import org.apache.usergrid.persistence.collection.serialization.impl.migration.EntityIdScope;
import org.apache.usergrid.persistence.core.migration.data.MigrationInfoSerialization;
-import org.apache.usergrid.persistence.core.migration.data.newimpls.AbstractMigrationPlugin;
-import org.apache.usergrid.persistence.core.migration.data.newimpls.DataMigration2;
-import org.apache.usergrid.persistence.core.migration.data.newimpls.MigrationDataProvider;
+import org.apache.usergrid.persistence.core.migration.data.AbstractMigrationPlugin;
+import org.apache.usergrid.persistence.core.migration.data.DataMigration;
+import org.apache.usergrid.persistence.core.migration.data.MigrationDataProvider;
import com.google.inject.Inject;
import com.google.inject.Singleton;
@@ -43,7 +43,7 @@ public class CoreMigrationPlugin extends AbstractMigrationPlugin<EntityIdScope>
@Inject
- public CoreMigrationPlugin( final Set<DataMigration2<EntityIdScope>> entityDataMigrations,
+ public CoreMigrationPlugin( @CoreMigration final Set<DataMigration<EntityIdScope>> entityDataMigrations,
final MigrationDataProvider<EntityIdScope> entityIdScopeDataMigrationProvider,
final MigrationInfoSerialization migrationInfoSerialization ) {
super( entityDataMigrations, entityIdScopeDataMigrationProvider, migrationInfoSerialization );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cf32557a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigration.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigration.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigration.java
index 80d7ebe..1a5ef13 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigration.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/EntityTypeMappingMigration.java
@@ -26,9 +26,9 @@ import java.util.concurrent.atomic.AtomicLong;
import org.apache.usergrid.corepersistence.ManagerCache;
import org.apache.usergrid.corepersistence.util.CpNamingUtils;
import org.apache.usergrid.persistence.collection.serialization.impl.migration.EntityIdScope;
-import org.apache.usergrid.persistence.core.migration.data.newimpls.DataMigration2;
-import org.apache.usergrid.persistence.core.migration.data.newimpls.MigrationDataProvider;
-import org.apache.usergrid.persistence.core.migration.data.newimpls.ProgressObserver;
+import org.apache.usergrid.persistence.core.migration.data.DataMigration;
+import org.apache.usergrid.persistence.core.migration.data.MigrationDataProvider;
+import org.apache.usergrid.persistence.core.migration.data.ProgressObserver;
import org.apache.usergrid.persistence.map.MapManager;
import org.apache.usergrid.persistence.map.MapScope;
@@ -42,7 +42,7 @@ import rx.functions.Func1;
/**
* Migration to ensure that our entity id is written into our map data
*/
-public class EntityTypeMappingMigration implements DataMigration2<EntityIdScope> {
+public class EntityTypeMappingMigration implements DataMigration<EntityIdScope> {
private final ManagerCache managerCache;
private final MigrationDataProvider<EntityIdScope> allEntitiesInSystemObservable;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cf32557a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/MigrationModuleVersion.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/MigrationModuleVersion.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/MigrationModuleVersion.java
index 1c124ac..9ddc219 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/MigrationModuleVersion.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/migration/MigrationModuleVersion.java
@@ -24,9 +24,9 @@ import org.apache.usergrid.persistence.collection.serialization.impl.MvccEntityS
import org.apache.usergrid.persistence.collection.serialization.impl.migration.CollectionMigrationPlugin;
import org.apache.usergrid.persistence.collection.serialization.impl.migration.EntityIdScope;
import org.apache.usergrid.persistence.core.migration.data.MigrationInfoSerialization;
-import org.apache.usergrid.persistence.core.migration.data.newimpls.DataMigration2;
-import org.apache.usergrid.persistence.core.migration.data.newimpls.MigrationDataProvider;
-import org.apache.usergrid.persistence.core.migration.data.newimpls.ProgressObserver;
+import org.apache.usergrid.persistence.core.migration.data.DataMigration;
+import org.apache.usergrid.persistence.core.migration.data.MigrationDataProvider;
+import org.apache.usergrid.persistence.core.migration.data.ProgressObserver;
import org.apache.usergrid.persistence.graph.serialization.impl.EdgeMetadataSerializationV2Impl;
import org.apache.usergrid.persistence.graph.serialization.impl.migration.GraphMigrationPlugin;
@@ -37,7 +37,7 @@ import com.google.inject.Inject;
* Migration to set our module versions now that we've refactor for sub modules Keeps the EntityIdScope because it won't
* subscribe to the data provider.
*/
-public class MigrationModuleVersion implements DataMigration2<EntityIdScope> {
+public class MigrationModuleVersion implements DataMigration<EntityIdScope> {
/**
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cf32557a/stack/core/src/main/java/org/apache/usergrid/corepersistence/rx/impl/AbstractGraphVisitorImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/rx/impl/AbstractGraphVisitorImpl.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/rx/impl/AbstractGraphVisitorImpl.java
index 07b7a3d..b8cb80b 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/rx/impl/AbstractGraphVisitorImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/rx/impl/AbstractGraphVisitorImpl.java
@@ -21,10 +21,7 @@ package org.apache.usergrid.corepersistence.rx.impl;
import org.apache.usergrid.corepersistence.AllApplicationsObservable;
-import org.apache.usergrid.corepersistence.util.CpNamingUtils;
-import org.apache.usergrid.persistence.collection.CollectionScope;
-import org.apache.usergrid.persistence.collection.serialization.impl.migration.EntityIdScope;
-import org.apache.usergrid.persistence.core.migration.data.newimpls.MigrationDataProvider;
+import org.apache.usergrid.persistence.core.migration.data.MigrationDataProvider;
import org.apache.usergrid.persistence.core.scope.ApplicationScope;
import org.apache.usergrid.persistence.graph.GraphManager;
import org.apache.usergrid.persistence.graph.GraphManagerFactory;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cf32557a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/MvccEntitySerializationStrategy.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/MvccEntitySerializationStrategy.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/MvccEntitySerializationStrategy.java
index de3cab3..7028620 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/MvccEntitySerializationStrategy.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/MvccEntitySerializationStrategy.java
@@ -26,7 +26,7 @@ import java.util.UUID;
import org.apache.usergrid.persistence.collection.CollectionScope;
import org.apache.usergrid.persistence.collection.EntitySet;
import org.apache.usergrid.persistence.collection.MvccEntity;
-import org.apache.usergrid.persistence.core.migration.data.newimpls.VersionedData;
+import org.apache.usergrid.persistence.core.migration.data.VersionedData;
import org.apache.usergrid.persistence.core.migration.schema.Migration;
import org.apache.usergrid.persistence.model.entity.Id;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cf32557a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyImpl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyImpl.java
index 19bfc9e..b815ef4 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyImpl.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyImpl.java
@@ -29,8 +29,8 @@ import org.apache.usergrid.persistence.collection.serialization.MvccEntitySerial
import org.apache.usergrid.persistence.collection.serialization.impl.migration.CollectionMigrationPlugin;
import org.apache.usergrid.persistence.core.astyanax.MultiTennantColumnFamilyDefinition;
import org.apache.usergrid.persistence.core.migration.data.MigrationInfoCache;
-import org.apache.usergrid.persistence.core.migration.data.newimpls.MigrationRelationship;
-import org.apache.usergrid.persistence.core.migration.data.newimpls.VersionedMigrationSet;
+import org.apache.usergrid.persistence.core.migration.data.MigrationRelationship;
+import org.apache.usergrid.persistence.core.migration.data.VersionedMigrationSet;
import org.apache.usergrid.persistence.model.entity.Id;
import com.google.common.base.Optional;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cf32557a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/SerializationModule.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/SerializationModule.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/SerializationModule.java
index 241a274..9d6d7fb 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/SerializationModule.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/SerializationModule.java
@@ -21,20 +21,20 @@ package org.apache.usergrid.persistence.collection.serialization.impl;
import org.apache.usergrid.persistence.collection.mvcc.MvccLogEntrySerializationStrategy;
import org.apache.usergrid.persistence.collection.serialization.MvccEntitySerializationStrategy;
import org.apache.usergrid.persistence.collection.serialization.UniqueValueSerializationStrategy;
+import org.apache.usergrid.persistence.collection.serialization.impl.migration.CollectionMigration;
import org.apache.usergrid.persistence.collection.serialization.impl.migration.CollectionMigrationPlugin;
import org.apache.usergrid.persistence.collection.serialization.impl.migration.EntityIdScope;
import org.apache.usergrid.persistence.collection.serialization.impl.migration.MvccEntityDataMigrationImpl;
import org.apache.usergrid.persistence.core.guice.ProxyImpl;
-import org.apache.usergrid.persistence.core.migration.data.newimpls.DataMigration2;
-import org.apache.usergrid.persistence.core.migration.data.newimpls.MigrationPlugin;
-import org.apache.usergrid.persistence.core.migration.data.newimpls.MigrationRelationship;
-import org.apache.usergrid.persistence.core.migration.data.newimpls.VersionedMigrationSet;
+import org.apache.usergrid.persistence.core.migration.data.DataMigration;
+import org.apache.usergrid.persistence.core.migration.data.MigrationPlugin;
+import org.apache.usergrid.persistence.core.migration.data.MigrationRelationship;
+import org.apache.usergrid.persistence.core.migration.data.VersionedMigrationSet;
import org.apache.usergrid.persistence.core.migration.schema.Migration;
import com.google.inject.AbstractModule;
import com.google.inject.Inject;
import com.google.inject.Key;
-import com.google.inject.Provider;
import com.google.inject.Provides;
import com.google.inject.Singleton;
import com.google.inject.TypeLiteral;
@@ -67,8 +67,9 @@ public class SerializationModule extends AbstractModule {
//migrations
//we want to make sure our generics are retained, so we use a typeliteral
- Multibinder<DataMigration2<EntityIdScope>> dataMigrationMultibinder =
- Multibinder.newSetBinder( binder(), new TypeLiteral<DataMigration2<EntityIdScope>>() {} );
+ Multibinder<DataMigration<EntityIdScope>> dataMigrationMultibinder =
+ Multibinder.newSetBinder( binder(), new TypeLiteral<DataMigration<EntityIdScope>>() {},
+ CollectionMigration.class );
dataMigrationMultibinder.addBinding().to( MvccEntityDataMigrationImpl.class );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cf32557a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/CollectionMigration.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/CollectionMigration.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/CollectionMigration.java
new file mode 100644
index 0000000..cec4d6f
--- /dev/null
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/CollectionMigration.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.usergrid.persistence.collection.serialization.impl.migration;/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import com.google.inject.BindingAnnotation;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+
+@BindingAnnotation
+@Target({ FIELD, PARAMETER, METHOD }) @Retention(RUNTIME)
+public @interface CollectionMigration {}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cf32557a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/CollectionMigrationPlugin.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/CollectionMigrationPlugin.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/CollectionMigrationPlugin.java
index 0cf25b2..55e42ff 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/CollectionMigrationPlugin.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/CollectionMigrationPlugin.java
@@ -27,9 +27,9 @@ package org.apache.usergrid.persistence.collection.serialization.impl.migration;
import java.util.Set;
import org.apache.usergrid.persistence.core.migration.data.MigrationInfoSerialization;
-import org.apache.usergrid.persistence.core.migration.data.newimpls.AbstractMigrationPlugin;
-import org.apache.usergrid.persistence.core.migration.data.newimpls.DataMigration2;
-import org.apache.usergrid.persistence.core.migration.data.newimpls.MigrationDataProvider;
+import org.apache.usergrid.persistence.core.migration.data.AbstractMigrationPlugin;
+import org.apache.usergrid.persistence.core.migration.data.DataMigration;
+import org.apache.usergrid.persistence.core.migration.data.MigrationDataProvider;
import com.google.inject.Inject;
import com.google.inject.Singleton;
@@ -46,7 +46,8 @@ public class CollectionMigrationPlugin extends AbstractMigrationPlugin<EntityIdS
@Inject
- public CollectionMigrationPlugin( final Set<DataMigration2<EntityIdScope>> entityDataMigrations,
+ public CollectionMigrationPlugin( @CollectionMigration
+ final Set<DataMigration<EntityIdScope>> entityDataMigrations,
final MigrationDataProvider<EntityIdScope> entityIdScopeDataMigrationProvider,
final MigrationInfoSerialization migrationInfoSerialization ) {
super( entityDataMigrations, entityIdScopeDataMigrationProvider, migrationInfoSerialization );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cf32557a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/MvccEntityDataMigrationImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/MvccEntityDataMigrationImpl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/MvccEntityDataMigrationImpl.java
index 05e5db5..beaaef9 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/MvccEntityDataMigrationImpl.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/MvccEntityDataMigrationImpl.java
@@ -32,7 +32,6 @@ import org.slf4j.LoggerFactory;
import org.apache.usergrid.persistence.collection.CollectionScope;
import org.apache.usergrid.persistence.collection.EntityVersionCleanupFactory;
import org.apache.usergrid.persistence.collection.MvccEntity;
-import org.apache.usergrid.persistence.collection.impl.EntityDeletedTask;
import org.apache.usergrid.persistence.collection.impl.EntityVersionCleanupTask;
import org.apache.usergrid.persistence.collection.serialization.MvccEntitySerializationStrategy;
import org.apache.usergrid.persistence.collection.serialization.UniqueValue;
@@ -41,11 +40,11 @@ import org.apache.usergrid.persistence.collection.serialization.impl.MvccEntityS
import org.apache.usergrid.persistence.collection.serialization.impl.UniqueValueImpl;
import org.apache.usergrid.persistence.collection.util.EntityUtils;
import org.apache.usergrid.persistence.core.migration.data.DataMigrationException;
-import org.apache.usergrid.persistence.core.migration.data.newimpls.DataMigration2;
-import org.apache.usergrid.persistence.core.migration.data.newimpls.MigrationDataProvider;
-import org.apache.usergrid.persistence.core.migration.data.newimpls.MigrationRelationship;
-import org.apache.usergrid.persistence.core.migration.data.newimpls.ProgressObserver;
-import org.apache.usergrid.persistence.core.migration.data.newimpls.VersionedMigrationSet;
+import org.apache.usergrid.persistence.core.migration.data.DataMigration;
+import org.apache.usergrid.persistence.core.migration.data.MigrationDataProvider;
+import org.apache.usergrid.persistence.core.migration.data.MigrationRelationship;
+import org.apache.usergrid.persistence.core.migration.data.ProgressObserver;
+import org.apache.usergrid.persistence.core.migration.data.VersionedMigrationSet;
import org.apache.usergrid.persistence.model.entity.Entity;
import org.apache.usergrid.persistence.model.entity.Id;
import org.apache.usergrid.persistence.model.field.Field;
@@ -68,7 +67,7 @@ import rx.schedulers.Schedulers;
* Data migration strategy for entities
*/
@Singleton
-public class MvccEntityDataMigrationImpl implements DataMigration2<EntityIdScope> {
+public class MvccEntityDataMigrationImpl implements DataMigration<EntityIdScope> {
private static final Logger LOGGER = LoggerFactory.getLogger( MvccEntityDataMigrationImpl.class );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cf32557a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/guice/TestCollectionModule.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/guice/TestCollectionModule.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/guice/TestCollectionModule.java
index b42ad94..5718e4f 100644
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/guice/TestCollectionModule.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/guice/TestCollectionModule.java
@@ -20,13 +20,11 @@
package org.apache.usergrid.persistence.collection.guice;
-import java.util.Collections;
-
import org.apache.usergrid.persistence.collection.serialization.impl.migration.EntityIdScope;
import org.apache.usergrid.persistence.core.guice.CommonModule;
import org.apache.usergrid.persistence.core.guice.TestModule;
-import org.apache.usergrid.persistence.core.migration.data.newimpls.MigrationDataProvider;
-import org.apache.usergrid.persistence.core.migration.data.newimpls.TestMigrationDataProvider;
+import org.apache.usergrid.persistence.core.migration.data.MigrationDataProvider;
+import org.apache.usergrid.persistence.core.migration.data.TestMigrationDataProvider;
import com.google.inject.TypeLiteral;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cf32557a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyV1_3Test.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyV1_3Test.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyV1_3Test.java
index 5c8a61f..42b10c4 100644
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyV1_3Test.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyV1_3Test.java
@@ -29,7 +29,6 @@ import org.apache.usergrid.persistence.collection.serialization.MvccEntitySerial
import org.apache.usergrid.persistence.collection.serialization.impl.migration.CollectionMigrationPlugin;
import org.apache.usergrid.persistence.core.guice.ProxyImpl;
import org.apache.usergrid.persistence.core.migration.data.MigrationInfoSerialization;
-import org.apache.usergrid.persistence.core.migration.data.newimpls.VersionedMigrationSet;
import org.apache.usergrid.persistence.core.test.ITRunner;
import org.apache.usergrid.persistence.core.test.UseModules;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cf32557a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/AbstractMvccEntityDataMigrationV1ToV3ImplTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/AbstractMvccEntityDataMigrationV1ToV3ImplTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/AbstractMvccEntityDataMigrationV1ToV3ImplTest.java
index 9894f07..747ea7b 100644
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/AbstractMvccEntityDataMigrationV1ToV3ImplTest.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/AbstractMvccEntityDataMigrationV1ToV3ImplTest.java
@@ -33,15 +33,13 @@ import org.apache.usergrid.persistence.collection.impl.CollectionScopeImpl;
import org.apache.usergrid.persistence.collection.mvcc.entity.impl.MvccEntityImpl;
import org.apache.usergrid.persistence.collection.serialization.MvccEntitySerializationStrategy;
import org.apache.usergrid.persistence.collection.serialization.impl.CollectionDataVersions;
-import org.apache.usergrid.persistence.collection.serialization.impl.MvccEntitySerializationStrategyV1Impl;
-import org.apache.usergrid.persistence.collection.serialization.impl.MvccEntitySerializationStrategyV3Impl;
import org.apache.usergrid.persistence.core.guice.DataMigrationResetRule;
import org.apache.usergrid.persistence.core.guice.MigrationManagerRule;
import org.apache.usergrid.persistence.core.migration.data.DataMigrationManager;
import org.apache.usergrid.persistence.core.migration.data.TestProgressObserver;
-import org.apache.usergrid.persistence.core.migration.data.newimpls.MigrationDataProvider;
-import org.apache.usergrid.persistence.core.migration.data.newimpls.MigrationRelationship;
-import org.apache.usergrid.persistence.core.migration.data.newimpls.VersionedMigrationSet;
+import org.apache.usergrid.persistence.core.migration.data.MigrationDataProvider;
+import org.apache.usergrid.persistence.core.migration.data.MigrationRelationship;
+import org.apache.usergrid.persistence.core.migration.data.VersionedMigrationSet;
import org.apache.usergrid.persistence.core.test.ITRunner;
import org.apache.usergrid.persistence.core.test.UseModules;
import org.apache.usergrid.persistence.model.entity.Entity;
@@ -150,7 +148,7 @@ public abstract class AbstractMvccEntityDataMigrationV1ToV3ImplTest implements D
final CollectionDataVersions expectedVersion = expectedTargetVersion();
assertEquals( "Correct version returned", newVersion, expectedVersion.getVersion() );
- assertFalse( "Progress observer should not have failed", progressObserver.getFailed() );
+ assertFalse( "Progress observer should not have failed", progressObserver.isFailed() );
assertTrue( "Progress observer should have update messages", progressObserver.getUpdates().size() > 0 );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cf32557a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/MvccEntityDataMigrationV1ToV3ImplTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/MvccEntityDataMigrationV1ToV3ImplTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/MvccEntityDataMigrationV1ToV3ImplTest.java
index f333fba..7d02b4b 100644
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/MvccEntityDataMigrationV1ToV3ImplTest.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/MvccEntityDataMigrationV1ToV3ImplTest.java
@@ -20,42 +20,24 @@
package org.apache.usergrid.persistence.collection.serialization.impl.migration;
-import java.util.UUID;
-
import org.junit.Rule;
-import org.junit.Test;
import org.junit.runner.RunWith;
-import org.apache.usergrid.persistence.collection.CollectionScope;
-import org.apache.usergrid.persistence.collection.MvccEntity;
import org.apache.usergrid.persistence.collection.guice.TestCollectionModule;
-import org.apache.usergrid.persistence.collection.impl.CollectionScopeImpl;
-import org.apache.usergrid.persistence.collection.mvcc.entity.impl.MvccEntityImpl;
import org.apache.usergrid.persistence.collection.serialization.MvccEntitySerializationStrategy;
import org.apache.usergrid.persistence.collection.serialization.impl.CollectionDataVersions;
import org.apache.usergrid.persistence.collection.serialization.impl.MvccEntitySerializationStrategyV1Impl;
import org.apache.usergrid.persistence.collection.serialization.impl.MvccEntitySerializationStrategyV3Impl;
-import org.apache.usergrid.persistence.core.guice.DataMigrationResetRule;
import org.apache.usergrid.persistence.core.guice.MigrationManagerRule;
import org.apache.usergrid.persistence.core.migration.data.DataMigrationManager;
-import org.apache.usergrid.persistence.core.migration.data.TestProgressObserver;
-import org.apache.usergrid.persistence.core.migration.data.newimpls.MigrationDataProvider;
-import org.apache.usergrid.persistence.core.migration.data.newimpls.MigrationRelationship;
-import org.apache.usergrid.persistence.core.migration.data.newimpls.VersionedMigrationSet;
+import org.apache.usergrid.persistence.core.migration.data.VersionedMigrationSet;
import org.apache.usergrid.persistence.core.test.ITRunner;
import org.apache.usergrid.persistence.core.test.UseModules;
-import org.apache.usergrid.persistence.model.entity.Entity;
-import org.apache.usergrid.persistence.model.entity.Id;
-import org.apache.usergrid.persistence.model.entity.SimpleId;
-import org.apache.usergrid.persistence.model.util.UUIDGenerator;
import com.google.inject.Inject;
-import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
import net.jcip.annotations.NotThreadSafe;
-import rx.Observable;
-
import static org.apache.usergrid.persistence.core.util.IdGenerator.createId;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cf32557a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/MvccEntityDataMigrationV2ToV3ImplTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/MvccEntityDataMigrationV2ToV3ImplTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/MvccEntityDataMigrationV2ToV3ImplTest.java
index 165105d..1d8c521 100644
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/MvccEntityDataMigrationV2ToV3ImplTest.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/migration/MvccEntityDataMigrationV2ToV3ImplTest.java
@@ -26,12 +26,11 @@ import org.junit.runner.RunWith;
import org.apache.usergrid.persistence.collection.guice.TestCollectionModule;
import org.apache.usergrid.persistence.collection.serialization.MvccEntitySerializationStrategy;
import org.apache.usergrid.persistence.collection.serialization.impl.CollectionDataVersions;
-import org.apache.usergrid.persistence.collection.serialization.impl.MvccEntitySerializationStrategyV1Impl;
import org.apache.usergrid.persistence.collection.serialization.impl.MvccEntitySerializationStrategyV2Impl;
import org.apache.usergrid.persistence.collection.serialization.impl.MvccEntitySerializationStrategyV3Impl;
import org.apache.usergrid.persistence.core.guice.MigrationManagerRule;
import org.apache.usergrid.persistence.core.migration.data.DataMigrationManager;
-import org.apache.usergrid.persistence.core.migration.data.newimpls.VersionedMigrationSet;
+import org.apache.usergrid.persistence.core.migration.data.VersionedMigrationSet;
import org.apache.usergrid.persistence.core.test.ITRunner;
import org.apache.usergrid.persistence.core.test.UseModules;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cf32557a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/guice/CommonModule.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/guice/CommonModule.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/guice/CommonModule.java
index 5e61753..bc84b6b 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/guice/CommonModule.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/guice/CommonModule.java
@@ -31,7 +31,7 @@ import org.apache.usergrid.persistence.core.astyanax.CassandraConfigImpl;
import org.apache.usergrid.persistence.core.astyanax.CassandraFig;
import org.apache.usergrid.persistence.core.consistency.TimeService;
import org.apache.usergrid.persistence.core.consistency.TimeServiceImpl;
-import org.apache.usergrid.persistence.core.migration.data.newimpls.MigrationPlugin;
+import org.apache.usergrid.persistence.core.migration.data.MigrationPlugin;
import org.apache.usergrid.persistence.core.migration.schema.Migration;
import org.apache.usergrid.persistence.core.migration.schema.MigrationManager;
import org.apache.usergrid.persistence.core.migration.schema.MigrationManagerFig;
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cf32557a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/hystrix/HystrixCassandra.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/hystrix/HystrixCassandra.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/hystrix/HystrixCassandra.java
index 76e0c2d..ab71782 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/hystrix/HystrixCassandra.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/hystrix/HystrixCassandra.java
@@ -30,8 +30,6 @@ import com.netflix.hystrix.HystrixThreadPoolProperties;
/**
* A utility class that creates graph observables wrapped in Hystrix for timeouts and circuit breakers.
- *
- * TODO USERGRId-405 restore this class before merge
*/
public class HystrixCassandra {
@@ -43,32 +41,32 @@ public class HystrixCassandra {
*/
public static final HystrixCommand.Setter
USER_GROUP = HystrixCommand.Setter.withGroupKey( HystrixCommandGroupKey.Factory.asKey( "user" ) ).andThreadPoolPropertiesDefaults(
- HystrixThreadPoolProperties.Setter().withCoreSize( 100 ) );
+ HystrixThreadPoolProperties.Setter().withCoreSize( 1000 ) );
/**
* Command group for asynchronous operations
*/
public static final HystrixCommand.Setter
ASYNC_GROUP = HystrixCommand.Setter.withGroupKey( HystrixCommandGroupKey.Factory.asKey( "async" ) ).andThreadPoolPropertiesDefaults(
- HystrixThreadPoolProperties.Setter().withCoreSize( 50 ) );
+ HystrixThreadPoolProperties.Setter().withCoreSize( 1000 ) );
/**
* Execute an user operation
*/
public static <R> OperationResult<R> user( final Execution<R> execution) {
-// return new HystrixCommand<OperationResult<R>>( USER_GROUP ) {
-//
-// @Override
-// protected OperationResult<R> run() {
+ return new HystrixCommand<OperationResult<R>>( USER_GROUP ) {
+
+ @Override
+ protected OperationResult<R> run() {
try {
return execution.execute();
}
catch ( ConnectionException e ) {
throw new RuntimeException( e );
}
-// }
-// }.execute();
+ }
+ }.execute();
}
@@ -78,18 +76,18 @@ public class HystrixCassandra {
public static <R> OperationResult<R> async( final Execution<R> execution) {
-// return new HystrixCommand<OperationResult<R>>( ASYNC_GROUP ) {
-//
-// @Override
-// protected OperationResult<R> run() {
+ return new HystrixCommand<OperationResult<R>>( ASYNC_GROUP ) {
+
+ @Override
+ protected OperationResult<R> run() {
try {
return execution.execute();
}
catch ( ConnectionException e ) {
throw new RuntimeException( e );
}
-// }
-// }.execute();
+ }
+ }.execute();
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cf32557a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/AbstractMigrationPlugin.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/AbstractMigrationPlugin.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/AbstractMigrationPlugin.java
new file mode 100644
index 0000000..1d351d1
--- /dev/null
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/AbstractMigrationPlugin.java
@@ -0,0 +1,128 @@
+/*
+ *
+ * *
+ * * Licensed to the Apache Software Foundation (ASF) under one
+ * * or more contributor license agreements. See the NOTICE file
+ * * distributed with this work for additional information
+ * * regarding copyright ownership. The ASF licenses this file
+ * * to you under the Apache License, Version 2.0 (the
+ * * "License"); you may not use this file except in compliance
+ * * with the License. You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing,
+ * * software distributed under the License is distributed on an
+ * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * * KIND, either express or implied. See the License for the
+ * * specific language governing permissions and limitations
+ * * under the License.
+ * *
+ *
+ */
+
+package org.apache.usergrid.persistence.core.migration.data;
+
+
+import java.util.Set;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * Standard implementation logic for plugins to extend
+ * @param <T>
+ */
+public abstract class AbstractMigrationPlugin<T> implements MigrationPlugin {
+
+
+
+ private static final Logger LOG = LoggerFactory.getLogger( AbstractMigrationPlugin.class );
+
+
+ private final Set<DataMigration<T>> entityDataMigrations;
+ private final MigrationDataProvider<T> entityIdScopeDataMigrationProvider;
+ private final MigrationInfoSerialization migrationInfoSerialization;
+
+
+ protected AbstractMigrationPlugin( final Set<DataMigration<T>> entityDataMigrations,
+ final MigrationDataProvider<T> entityIdScopeDataMigrationProvider,
+ final MigrationInfoSerialization migrationInfoSerialization ) {
+ this.entityDataMigrations = entityDataMigrations;
+ this.entityIdScopeDataMigrationProvider = entityIdScopeDataMigrationProvider;
+ this.migrationInfoSerialization = migrationInfoSerialization;
+ }
+
+
+ @Override
+ public void run( final ProgressObserver observer ) {
+
+ //run until complete
+ while(runMigration( observer )){
+ LOG.info( "Migration complete, checking for next run" );
+ }
+
+ }
+
+
+ @Override
+ public int getMaxVersion() {
+
+ int max = 0;
+
+ for(DataMigration<T> entityMigration: entityDataMigrations){
+ max = Math.max( max, entityMigration.getMaxVersion() );
+ }
+
+ return max;
+ }
+
+
+ /**
+ * Try to run the migration
+ *
+ * @return True if we ran a migration
+ */
+ private boolean runMigration( final ProgressObserver po ) {
+ DataMigration<T> migrationToExecute = null;
+
+
+ final int version = migrationInfoSerialization.getVersion( getName() );
+
+ for ( DataMigration<T> entityMigration : entityDataMigrations ) {
+ if ( entityMigration.supports( version ) ) {
+ if ( migrationToExecute != null ) {
+ throw new DataMigrationException(
+ "Two migrations attempted to migration the same version, this is not allowed. Class '"
+ + migrationToExecute.getClass().getName() + "' and class '" + entityMigration
+ .getClass().getName()
+ + "' both support this version. This means something is wired incorrectly" );
+ }
+
+ migrationToExecute = entityMigration;
+ }
+ }
+
+ if(migrationToExecute == null){
+ LOG.info( "No migrations found to execute" );
+ return false;
+ }
+
+ po.start();
+
+
+ //run the migration
+ final int newSystemVersion = migrationToExecute.migrate( version, entityIdScopeDataMigrationProvider, po );
+
+ //write the version
+ migrationInfoSerialization.setVersion( getName(), newSystemVersion );
+
+ po.stop();
+
+ //signal we've run a migration and return
+ return true;
+
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cf32557a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigration.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigration.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigration.java
new file mode 100644
index 0000000..ce250cc
--- /dev/null
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigration.java
@@ -0,0 +1,58 @@
+/*
+ *
+ * *
+ * * Licensed to the Apache Software Foundation (ASF) under one
+ * * or more contributor license agreements. See the NOTICE file
+ * * distributed with this work for additional information
+ * * regarding copyright ownership. The ASF licenses this file
+ * * to you under the Apache License, Version 2.0 (the
+ * * "License"); you may not use this file except in compliance
+ * * with the License. You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing,
+ * * software distributed under the License is distributed on an
+ * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * * KIND, either express or implied. See the License for the
+ * * specific language governing permissions and limitations
+ * * under the License.
+ * *
+ *
+ */
+
+package org.apache.usergrid.persistence.core.migration.data;
+
+
+/**
+ * Data migration. The internal version to migrate
+ *
+ * @param <T>
+ */
+public interface DataMigration<T> {
+
+ /**
+ * Perform the migration, returning an observable with a single emitted value
+ * @param currentVersion the current version of the system
+ * @param migrationDataProvider
+ * @param observer The observer to receive updates of the progress
+ *
+ * @return The version that the system is now running
+ */
+ public int migrate(final int currentVersion, MigrationDataProvider<T> migrationDataProvider, ProgressObserver observer);
+
+ /**
+ * Check if this version supports migration from the current system version. If this returns false,
+ * migrate will not be invoked
+ * @return
+ */
+ public boolean supports(final int currentVersion);
+
+ /**
+ * Get the max version this migration can migrate to
+ * @return
+ */
+ public int getMaxVersion();
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cf32557a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigrationManagerImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigrationManagerImpl.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigrationManagerImpl.java
index 41e76e8..7b97e8e 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigrationManagerImpl.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/DataMigrationManagerImpl.java
@@ -24,19 +24,13 @@ import java.io.StringWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
-import java.util.concurrent.TimeUnit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.apache.usergrid.persistence.core.migration.data.newimpls.MigrationPlugin;
-import org.apache.usergrid.persistence.core.migration.data.newimpls.ProgressObserver;
import org.apache.usergrid.persistence.core.migration.schema.MigrationException;
import com.google.common.base.Preconditions;
-import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.CacheLoader;
-import com.google.common.cache.LoadingCache;
import com.google.inject.Inject;
import com.google.inject.Singleton;
@@ -89,6 +83,8 @@ public class DataMigrationManagerImpl implements DataMigrationManager {
final ProgressObserver observer = new CassandraProgressObserver(plugin.getName());
plugin.run( observer );
+
+
}
@@ -98,6 +94,7 @@ public class DataMigrationManagerImpl implements DataMigrationManager {
@Override
public boolean isRunning() {
+ //we have to get our state from cassandra
for(final String pluginName :getPluginNames()){
if( migrationInfoSerialization.getStatusCode(pluginName) == StatusCode.RUNNING.status){
return true;
@@ -174,6 +171,18 @@ public class DataMigrationManagerImpl implements DataMigrationManager {
@Override
+ public void start() {
+ migrationInfoSerialization.setStatusCode( pluginName, StatusCode.RUNNING.status );
+ }
+
+
+ @Override
+ public void stop() {
+ migrationInfoSerialization.setStatusCode( pluginName, StatusCode.COMPLETE.status );
+ }
+
+
+ @Override
public void failed( final int migrationVersion, final String reason ) {
final String storedMessage = String.format( "Failed to migrate, reason is appended. Error '%s'", reason );
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cf32557a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationDataProvider.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationDataProvider.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationDataProvider.java
new file mode 100644
index 0000000..e232d7b
--- /dev/null
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationDataProvider.java
@@ -0,0 +1,43 @@
+/*
+ *
+ * *
+ * * Licensed to the Apache Software Foundation (ASF) under one
+ * * or more contributor license agreements. See the NOTICE file
+ * * distributed with this work for additional information
+ * * regarding copyright ownership. The ASF licenses this file
+ * * to you under the Apache License, Version 2.0 (the
+ * * "License"); you may not use this file except in compliance
+ * * with the License. You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing,
+ * * software distributed under the License is distributed on an
+ * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * * KIND, either express or implied. See the License for the
+ * * specific language governing permissions and limitations
+ * * under the License.
+ * *
+ *
+ */
+
+package org.apache.usergrid.persistence.core.migration.data;
+
+
+import rx.Observable;
+
+
+/**
+ * An interface for data providers to implement. The migration must take the migrationdata provider as an argument
+ * @param <T>
+ */
+public interface MigrationDataProvider<T> {
+
+
+ /**
+ * Get data that can be used in the migration
+ * @return
+ */
+ public Observable<T> getData();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cf32557a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationPlugin.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationPlugin.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationPlugin.java
new file mode 100644
index 0000000..897ce27
--- /dev/null
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationPlugin.java
@@ -0,0 +1,51 @@
+/*
+ *
+ * *
+ * * Licensed to the Apache Software Foundation (ASF) under one
+ * * or more contributor license agreements. See the NOTICE file
+ * * distributed with this work for additional information
+ * * regarding copyright ownership. The ASF licenses this file
+ * * to you under the Apache License, Version 2.0 (the
+ * * "License"); you may not use this file except in compliance
+ * * with the License. You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing,
+ * * software distributed under the License is distributed on an
+ * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * * KIND, either express or implied. See the License for the
+ * * specific language governing permissions and limitations
+ * * under the License.
+ * *
+ *
+ */
+
+package org.apache.usergrid.persistence.core.migration.data;
+
+
+
+/**
+ * A simple interface to return migration plugins. All versions within this migration plugin should have a name
+ */
+public interface MigrationPlugin {
+
+
+ /**
+ * Get the name of the plugin. Must be unique
+ * @return
+ */
+ public String getName();
+
+ /**
+ * Run any migrations that may need to be run in this plugin
+ */
+ public void run(ProgressObserver observer);
+
+
+ /**
+ * Get the max version this plugin supports
+ * @return
+ */
+ int getMaxVersion();
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cf32557a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationRelationship.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationRelationship.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationRelationship.java
new file mode 100644
index 0000000..806768e
--- /dev/null
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationRelationship.java
@@ -0,0 +1,100 @@
+/*
+ *
+ * *
+ * * Licensed to the Apache Software Foundation (ASF) under one
+ * * or more contributor license agreements. See the NOTICE file
+ * * distributed with this work for additional information
+ * * regarding copyright ownership. The ASF licenses this file
+ * * to you under the Apache License, Version 2.0 (the
+ * * "License"); you may not use this file except in compliance
+ * * with the License. You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing,
+ * * software distributed under the License is distributed on an
+ * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * * KIND, either express or implied. See the License for the
+ * * specific language governing permissions and limitations
+ * * under the License.
+ * *
+ *
+ */
+
+package org.apache.usergrid.persistence.core.migration.data;
+
+
+/**
+ * Simple relationship that defines the current state of the source and destination data versions. Note that
+ * ina current system, the from and then to will be the same instance
+ */
+public class MigrationRelationship<T extends VersionedData> {
+
+ //public so it's FAST. It's also immutable
+
+
+ public final T from;
+ public final T to;
+
+ private final int fromVersion;
+ private final int toVersion;
+
+
+ public MigrationRelationship( T from, T to ) {
+ this.from = from;
+ this.to = to;
+
+ fromVersion = from.getImplementationVersion();
+ toVersion = to.getImplementationVersion();
+ }
+
+
+ /**
+ * Returns true if we need to perform dual writes. IE. the from is not the same as the to
+ * @return
+ */
+ public boolean needsMigration(){
+ return fromVersion != toVersion;
+ }
+
+
+ /**
+ * Return true if this is the migration relationship we should use. The version matches the from
+ * and is <= the to
+ * @param currentVersion
+ * @return
+ */
+ public boolean correctRelationship(final int currentVersion){
+ return currentVersion == fromVersion && currentVersion <= toVersion;
+ }
+
+
+ @Override
+ public boolean equals( final Object o ) {
+ if ( this == o ) {
+ return true;
+ }
+ if ( !( o instanceof MigrationRelationship ) ) {
+ return false;
+ }
+
+ final MigrationRelationship that = ( MigrationRelationship ) o;
+
+ if ( !from.equals( that.from ) ) {
+ return false;
+ }
+ if ( !to.equals( that.to ) ) {
+ return false;
+ }
+
+ return true;
+ }
+
+
+ @Override
+ public int hashCode() {
+ int result = from.hashCode();
+ result = 31 * result + to.hashCode();
+ return result;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cf32557a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/ProgressObserver.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/ProgressObserver.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/ProgressObserver.java
new file mode 100644
index 0000000..50abc6f
--- /dev/null
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/ProgressObserver.java
@@ -0,0 +1,63 @@
+/*
+ *
+ * *
+ * * Licensed to the Apache Software Foundation (ASF) under one
+ * * or more contributor license agreements. See the NOTICE file
+ * * distributed with this work for additional information
+ * * regarding copyright ownership. The ASF licenses this file
+ * * to you under the Apache License, Version 2.0 (the
+ * * "License"); you may not use this file except in compliance
+ * * with the License. You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing,
+ * * software distributed under the License is distributed on an
+ * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * * KIND, either express or implied. See the License for the
+ * * specific language governing permissions and limitations
+ * * under the License.
+ * *
+ *
+ */
+
+package org.apache.usergrid.persistence.core.migration.data;
+
+
+public interface ProgressObserver {
+
+ /**
+ * Signal the process started
+ */
+ public void start();
+
+ /**
+ * Signal the process has stopped
+ */
+ public void stop();
+
+ /**
+ * Mark the migration as failed
+ *
+ * @param migrationVersion The migration version running during the failure
+ * @param reason The reason to save
+ */
+ public void failed( final int migrationVersion, final String reason );
+
+ /**
+ * Mark the migration as failed with a stack trace
+ *
+ * @param migrationVersion The migration version running during the failure
+ * @param reason The error description to save
+ * @param throwable The error that happened
+ */
+ public void failed( final int migrationVersion, final String reason, final Throwable throwable );
+
+
+ /**
+ * Update the status of the migration with the message
+ *
+ * @param message The message to save for the status
+ */
+ public void update( final int migrationVersion, final String message );
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cf32557a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/VersionedData.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/VersionedData.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/VersionedData.java
new file mode 100644
index 0000000..266697a
--- /dev/null
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/VersionedData.java
@@ -0,0 +1,38 @@
+/*
+ *
+ * *
+ * * Licensed to the Apache Software Foundation (ASF) under one
+ * * or more contributor license agreements. See the NOTICE file
+ * * distributed with this work for additional information
+ * * regarding copyright ownership. The ASF licenses this file
+ * * to you under the Apache License, Version 2.0 (the
+ * * "License"); you may not use this file except in compliance
+ * * with the License. You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing,
+ * * software distributed under the License is distributed on an
+ * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * * KIND, either express or implied. See the License for the
+ * * specific language governing permissions and limitations
+ * * under the License.
+ * *
+ *
+ */
+
+package org.apache.usergrid.persistence.core.migration.data;
+
+
+/**
+ * Marker interface for implementations that may migrate their internal format
+ */
+public interface VersionedData {
+
+ /**
+ * Get the version of the implementation
+ * @return
+ */
+ public int getImplementationVersion();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cf32557a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/VersionedMigrationSet.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/VersionedMigrationSet.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/VersionedMigrationSet.java
new file mode 100644
index 0000000..cadd919
--- /dev/null
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/VersionedMigrationSet.java
@@ -0,0 +1,153 @@
+/*
+ *
+ * *
+ * * Licensed to the Apache Software Foundation (ASF) under one
+ * * or more contributor license agreements. See the NOTICE file
+ * * distributed with this work for additional information
+ * * regarding copyright ownership. The ASF licenses this file
+ * * to you under the Apache License, Version 2.0 (the
+ * * "License"); you may not use this file except in compliance
+ * * with the License. You may obtain a copy of the License at
+ * *
+ * * http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ * * Unless required by applicable law or agreed to in writing,
+ * * software distributed under the License is distributed on an
+ * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * * KIND, either express or implied. See the License for the
+ * * specific language governing permissions and limitations
+ * * under the License.
+ * *
+ *
+ */
+
+package org.apache.usergrid.persistence.core.migration.data;
+
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.google.common.base.Preconditions;
+
+
+/**
+ * A set that represents a set of tuples that are used for
+ * @param <T>
+ */
+public class VersionedMigrationSet<T extends VersionedData> {
+
+
+ /**
+ * Cache so that after our initial lookup, it O(1) since this will be used heavily
+ *
+ */
+ private Map<Integer, MigrationRelationship<T>> cacheVersion = new HashMap<>();
+
+ private List<MigrationRelationship<T>> orderedVersions = new ArrayList<>();
+
+
+ /**
+ * Construct this set from a group of tuples. Imagine the following versions
+ *
+ * v1,
+ * v2,
+ * v3,
+ * v4
+ *
+ * Migrations can jump from v1->v3, but not directly to v4 without an extraneous migration. This would have 2 relationships
+ *
+ * v1, v3
+ * v2, v3
+ * and
+ * v3, v4
+ *
+ *
+ * @param migrations
+ */
+ public VersionedMigrationSet( final MigrationRelationship<T>... migrations ){
+ Preconditions.checkNotNull(migrations, "versions must not be null");
+ Preconditions.checkArgument( migrations.length > 0, "You must specify at least 1 migrationrelationship" );
+
+ orderedVersions.addAll( Arrays.asList(migrations ) );
+
+ Collections.sort( orderedVersions, new VersionedDataComparator() );
+
+ }
+
+
+ /**
+ * Get the migration relationship based on our current version. This will return a range that includes the current
+ * system version as the source, and the highest version we can roll to in the to field
+ * @param currentVersion
+ * @return The MigrationRelationship. Note the from and the to could be the same version in a current system.
+ */
+ public MigrationRelationship<T> getMigrationRelationship( final int currentVersion ){
+
+ final MigrationRelationship<T> relationship = cacheVersion.get( currentVersion );
+
+ if(relationship != null){
+ return relationship;
+ }
+
+ //not there, find it. Not the most efficient, but it happens once per version, which rarely changes, so not a big deal
+
+
+ for(MigrationRelationship<T> current: orderedVersions){
+
+ //not our instance, the from is too high
+ //our from is this instance, so we support this tuple. Our future is >= as well, so we can perform this I/O
+ if ( current.correctRelationship( currentVersion )) {
+ cacheVersion.put( currentVersion, current );
+ return current;
+ }
+
+ }
+
+ //if we get here, something is wrong
+ throw new IllegalArgumentException( "Could not find a migration version for version " + currentVersion + " min found was " + orderedVersions.get( orderedVersions.size()-1 ) );
+
+
+ }
+
+
+ /**
+ * Given the current system version, return the maximum migration version we can move to
+ * @param currentVersion
+ * @return
+ */
+ public int getMaxVersion(final int currentVersion){
+ return getMigrationRelationship( currentVersion ).to.getImplementationVersion();
+ }
+
+
+
+ /**
+ * Orders from high to low
+ */
+ private final class VersionedDataComparator implements Comparator<MigrationRelationship<T>>
+ {
+
+ @Override
+ public int compare( final MigrationRelationship<T> o1, final MigrationRelationship<T> o2 ) {
+ //Put higher target version first, since that's what we want to match based on current state and source
+
+ //order by the source. Put highest source first
+ int compare = Integer.compare( o1.to.getImplementationVersion(), o2.to.getImplementationVersion() ) *-1;
+
+
+ //put higher from first, if we fall within a range here we're good
+ if(compare == 0){
+ compare = Integer.compare( o1.from.getImplementationVersion(), o2.from.getImplementationVersion() ) *-1;
+ }
+
+ return compare;
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cf32557a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/newimpls/AbstractMigrationPlugin.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/newimpls/AbstractMigrationPlugin.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/newimpls/AbstractMigrationPlugin.java
deleted file mode 100644
index 17d88d0..0000000
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/newimpls/AbstractMigrationPlugin.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- *
- * *
- * * Licensed to the Apache Software Foundation (ASF) under one
- * * or more contributor license agreements. See the NOTICE file
- * * distributed with this work for additional information
- * * regarding copyright ownership. The ASF licenses this file
- * * to you under the Apache License, Version 2.0 (the
- * * "License"); you may not use this file except in compliance
- * * with the License. You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing,
- * * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * * KIND, either express or implied. See the License for the
- * * specific language governing permissions and limitations
- * * under the License.
- * *
- *
- */
-
-package org.apache.usergrid.persistence.core.migration.data.newimpls;
-
-
-import java.util.Set;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.usergrid.persistence.core.migration.data.DataMigrationException;
-import org.apache.usergrid.persistence.core.migration.data.MigrationInfoSerialization;
-
-
-/**
- * Standard implementation logic for plugins to extend
- * @param <T>
- */
-public abstract class AbstractMigrationPlugin<T> implements MigrationPlugin {
-
-
-
- private static final Logger LOG = LoggerFactory.getLogger( AbstractMigrationPlugin.class );
-
-
- private final Set<DataMigration2<T>> entityDataMigrations;
- private final MigrationDataProvider<T> entityIdScopeDataMigrationProvider;
- private final MigrationInfoSerialization migrationInfoSerialization;
-
-
- protected AbstractMigrationPlugin( final Set<DataMigration2<T>> entityDataMigrations,
- final MigrationDataProvider<T> entityIdScopeDataMigrationProvider,
- final MigrationInfoSerialization migrationInfoSerialization ) {
- this.entityDataMigrations = entityDataMigrations;
- this.entityIdScopeDataMigrationProvider = entityIdScopeDataMigrationProvider;
- this.migrationInfoSerialization = migrationInfoSerialization;
- }
-
-
- @Override
- public void run( final ProgressObserver observer ) {
-
- //run until complete
- while(runMigration( observer )){
- LOG.info( "Migration complete, checking for next run" );
- }
-
- }
-
-
- @Override
- public int getMaxVersion() {
-
- int max = 0;
-
- for(DataMigration2<T> entityMigration: entityDataMigrations){
- max = Math.max( max, entityMigration.getMaxVersion() );
- }
-
- return max;
- }
-
-
- /**
- * Try to run the migration
- *
- * @return True if we ran a migration
- */
- private boolean runMigration( final ProgressObserver po ) {
- DataMigration2<T> migrationToExecute = null;
-
-
- final int version = migrationInfoSerialization.getVersion( getName() );
-
- for ( DataMigration2<T> entityMigration : entityDataMigrations ) {
- if ( entityMigration.supports( version ) ) {
- if ( migrationToExecute != null ) {
- throw new DataMigrationException(
- "Two migrations attempted to migration the same version, this is not allowed. Class '"
- + migrationToExecute.getClass().getName() + "' and class '" + entityMigration
- .getClass().getName()
- + "' both support this version. This means something is wired incorrectly" );
- }
-
- migrationToExecute = entityMigration;
- }
- }
-
- if(migrationToExecute == null){
- LOG.info( "No migrations found to execute" );
- return false;
- }
-
- //run the migration
- final int newSystemVersion = migrationToExecute.migrate( version, entityIdScopeDataMigrationProvider, po );
-
- //write the version
- migrationInfoSerialization.setVersion( getName(), newSystemVersion );
-
- //signal we've run a migration and return
- return true;
-
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cf32557a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/newimpls/DataMigration2.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/newimpls/DataMigration2.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/newimpls/DataMigration2.java
deleted file mode 100644
index 303c11c..0000000
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/newimpls/DataMigration2.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- *
- * *
- * * Licensed to the Apache Software Foundation (ASF) under one
- * * or more contributor license agreements. See the NOTICE file
- * * distributed with this work for additional information
- * * regarding copyright ownership. The ASF licenses this file
- * * to you under the Apache License, Version 2.0 (the
- * * "License"); you may not use this file except in compliance
- * * with the License. You may obtain a copy of the License at
- * *
- * * http://www.apache.org/licenses/LICENSE-2.0
- * *
- * * Unless required by applicable law or agreed to in writing,
- * * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * * KIND, either express or implied. See the License for the
- * * specific language governing permissions and limitations
- * * under the License.
- * *
- *
- */
-
-package org.apache.usergrid.persistence.core.migration.data.newimpls;
-
-
-/**
- * Data migration. The internal version to migrate
- *
- * @param <T>
- */
-public interface DataMigration2<T> {
-
- /**
- * Perform the migration, returning an observable with a single emitted value
- * @param currentVersion the current version of the system
- * @param migrationDataProvider
- * @param observer The observer to receive updates of the progress
- *
- * @return The version that the system is now running
- */
- public int migrate(final int currentVersion, MigrationDataProvider<T> migrationDataProvider, ProgressObserver observer);
-
- /**
- * Check if this version supports migration from the current system version. If this returns false,
- * migrate will not be invoked
- * @return
- */
- public boolean supports(final int currentVersion);
-
- /**
- * Get the max version this migration can migrate to
- * @return
- */
- public int getMaxVersion();
-
-
-}