Implemented the new row key without collection scope for the log entries Implemented the proxy for log entries
Remove redundant proxy annotation Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/6e3fab6e Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/6e3fab6e Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/6e3fab6e Branch: refs/heads/two-dot-o-dev Commit: 6e3fab6e475862798174a86eb244ab987ddb215f Parents: 5eb4d0b Author: Todd Nine <[email protected]> Authored: Mon Mar 30 17:57:14 2015 -0600 Committer: Todd Nine <[email protected]> Committed: Mon Mar 30 17:57:14 2015 -0600 ---------------------------------------------------------------------- .../EntityCollectionManagerFactoryImpl.java | 3 +- .../impl/EntityCollectionManagerImpl.java | 3 +- .../collection/impl/EntityDeletedTask.java | 3 +- .../mvcc/stage/delete/MarkCommit.java | 3 +- .../collection/mvcc/stage/delete/MarkStart.java | 2 +- .../mvcc/stage/write/RollbackAction.java | 2 +- .../mvcc/stage/write/WriteCommit.java | 3 +- .../MvccEntitySerializationStrategy.java | 16 +- .../MvccLogEntrySerializationStrategy.java | 3 +- .../impl/CollectionDataVersions.java | 2 +- .../MvccEntitySerializationStrategyV3Impl.java | 35 ++--- .../MvccLogEntrySerializationProxyImpl.java | 147 +++++++++++++++++++ .../MvccLogEntrySerializationStrategyImpl.java | 79 +++------- ...MvccLogEntrySerializationStrategyV1Impl.java | 118 +++++++++++++++ ...MvccLogEntrySerializationStrategyV2Impl.java | 106 +++++++++++++ .../serialization/impl/SerializationModule.java | 117 +++++++++------ .../collection/EntityCollectionManagerIT.java | 2 - ...ntitySerializationStrategyProxyV1_3Test.java | 2 - ...ntitySerializationStrategyProxyV2_3Test.java | 2 - ...ccLogEntrySerializationStrategyImplTest.java | 20 ++- ...EntrySerializationStrategyProxyImplTest.java | 90 ++++++++++++ ...LogEntrySerializationStrategyV1ImplTest.java | 55 +++++++ ...LogEntrySerializationStrategyV2ImplTest.java | 53 +++++++ .../persistence/core/guice/ProxyImpl.java | 42 ------ .../core/migration/data/VersionedData.java | 2 +- .../core/migration/schema/Migration.java | 2 +- .../persistence/graph/guice/GraphModule.java | 5 +- .../graph/impl/GraphManagerImpl.java | 3 +- .../graph/impl/stage/EdgeMetaRepairImpl.java | 3 +- .../impl/stage/NodeDeleteListenerImpl.java | 3 +- .../graph/impl/EdgeDeleteListenerTest.java | 3 - .../graph/impl/NodeDeleteListenerTest.java | 3 - .../graph/impl/stage/EdgeMetaRepairTest.java | 3 - .../EdgeMetaDataSerializationProxyV1Test.java | 3 - .../EdgeMetaDataSerializationProxyV2Test.java | 2 - .../apache/usergrid/rest/MigrateResource.java | 2 + 36 files changed, 721 insertions(+), 221 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6e3fab6e/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerFactoryImpl.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerFactoryImpl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerFactoryImpl.java index 8574324..9191c06 100644 --- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerFactoryImpl.java +++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerFactoryImpl.java @@ -38,7 +38,6 @@ import org.apache.usergrid.persistence.collection.mvcc.stage.write.WriteUniqueVe import org.apache.usergrid.persistence.collection.serialization.MvccEntitySerializationStrategy; import org.apache.usergrid.persistence.collection.serialization.MvccLogEntrySerializationStrategy; import org.apache.usergrid.persistence.collection.serialization.UniqueValueSerializationStrategy; -import org.apache.usergrid.persistence.core.guice.ProxyImpl; import org.apache.usergrid.persistence.core.metrics.MetricsFactory; import org.apache.usergrid.persistence.core.scope.ApplicationScope; import org.apache.usergrid.persistence.core.task.TaskExecutor; @@ -100,7 +99,7 @@ public class EntityCollectionManagerFactoryImpl implements EntityCollectionManag final WriteUniqueVerify writeVerifyUnique, final WriteOptimisticVerify writeOptimisticVerify, final WriteCommit writeCommit, final RollbackAction rollback, - final MarkStart markStart, final MarkCommit markCommit, @ProxyImpl + final MarkStart markStart, final MarkCommit markCommit, final MvccEntitySerializationStrategy entitySerializationStrategy, final UniqueValueSerializationStrategy uniqueValueSerializationStrategy, final MvccLogEntrySerializationStrategy mvccLogEntrySerializationStrategy, http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6e3fab6e/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerImpl.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerImpl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerImpl.java index 8e29f4a..f0b070c 100644 --- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerImpl.java +++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityCollectionManagerImpl.java @@ -48,7 +48,6 @@ import org.apache.usergrid.persistence.collection.serialization.UniqueValue; import org.apache.usergrid.persistence.collection.serialization.UniqueValueSerializationStrategy; import org.apache.usergrid.persistence.collection.serialization.UniqueValueSet; import org.apache.usergrid.persistence.collection.serialization.impl.MutableFieldSet; -import org.apache.usergrid.persistence.core.guice.ProxyImpl; import org.apache.usergrid.persistence.core.metrics.MetricsFactory; import org.apache.usergrid.persistence.core.scope.ApplicationScope; import org.apache.usergrid.persistence.core.task.Task; @@ -134,7 +133,7 @@ public class EntityCollectionManagerImpl implements EntityCollectionManager { final RollbackAction rollback, final MarkStart markStart, final MarkCommit markCommit, - @ProxyImpl final MvccEntitySerializationStrategy entitySerializationStrategy, + final MvccEntitySerializationStrategy entitySerializationStrategy, final UniqueValueSerializationStrategy uniqueValueSerializationStrategy, final MvccLogEntrySerializationStrategy mvccLogEntrySerializationStrategy, final Keyspace keyspace, http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6e3fab6e/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityDeletedTask.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityDeletedTask.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityDeletedTask.java index d858930..1753d26 100644 --- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityDeletedTask.java +++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/impl/EntityDeletedTask.java @@ -28,7 +28,6 @@ import org.slf4j.LoggerFactory; import org.apache.usergrid.persistence.collection.event.EntityDeleted; import org.apache.usergrid.persistence.collection.serialization.MvccEntitySerializationStrategy; import org.apache.usergrid.persistence.collection.serialization.MvccLogEntrySerializationStrategy; -import org.apache.usergrid.persistence.core.guice.ProxyImpl; import org.apache.usergrid.persistence.core.scope.ApplicationScope; import org.apache.usergrid.persistence.core.task.Task; import org.apache.usergrid.persistence.model.entity.Id; @@ -60,7 +59,7 @@ public class EntityDeletedTask implements Task<Void> { public EntityDeletedTask( EntityVersionTaskFactory entityVersionTaskFactory, final MvccLogEntrySerializationStrategy logEntrySerializationStrategy, - @ProxyImpl final MvccEntitySerializationStrategy entitySerializationStrategy, + final MvccEntitySerializationStrategy entitySerializationStrategy, final Set<EntityDeleted> listeners, // MUST be a set or Guice will not inject @Assisted final ApplicationScope collectionScope, @Assisted final Id entityId, http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6e3fab6e/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/MarkCommit.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/MarkCommit.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/MarkCommit.java index 14977eb..a0d0c1a 100644 --- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/MarkCommit.java +++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/MarkCommit.java @@ -34,7 +34,6 @@ import org.apache.usergrid.persistence.collection.serialization.MvccEntitySerial import org.apache.usergrid.persistence.collection.serialization.MvccLogEntrySerializationStrategy; import org.apache.usergrid.persistence.collection.serialization.SerializationFig; import org.apache.usergrid.persistence.collection.serialization.UniqueValueSerializationStrategy; -import org.apache.usergrid.persistence.core.guice.ProxyImpl; import org.apache.usergrid.persistence.core.scope.ApplicationScope; import org.apache.usergrid.persistence.model.entity.Id; @@ -65,7 +64,7 @@ public class MarkCommit implements Action1<CollectionIoEvent<MvccEntity>> { @Inject public MarkCommit( final MvccLogEntrySerializationStrategy logStrat, - @ProxyImpl final MvccEntitySerializationStrategy entityStrat, + final MvccEntitySerializationStrategy entityStrat, final UniqueValueSerializationStrategy uniqueValueStrat, final SerializationFig serializationFig, final Keyspace keyspace ) { http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6e3fab6e/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/MarkStart.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/MarkStart.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/MarkStart.java index 4ab1b09..040e893 100644 --- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/MarkStart.java +++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/MarkStart.java @@ -67,7 +67,7 @@ public class MarkStart implements Func1<CollectionIoEvent<Id>, CollectionIoEvent * Create a new stage with the current context */ @Inject - public MarkStart( final MvccLogEntrySerializationStrategy logStrategy, final UUIDService uuidService ) { + public MarkStart(final MvccLogEntrySerializationStrategy logStrategy, final UUIDService uuidService ) { Preconditions.checkNotNull( logStrategy, "logStrategy is required" ); Preconditions.checkNotNull( uuidService, "uuidService is required" ); http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6e3fab6e/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/RollbackAction.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/RollbackAction.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/RollbackAction.java index a54bf77..cd15c26 100644 --- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/RollbackAction.java +++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/RollbackAction.java @@ -55,7 +55,7 @@ public class RollbackAction implements Action1<Throwable> { @Inject - public RollbackAction( MvccLogEntrySerializationStrategy logEntryStrat, + public RollbackAction(MvccLogEntrySerializationStrategy logEntryStrat, UniqueValueSerializationStrategy uniqueValueStrat ) { scheduler = Schedulers.io(); http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6e3fab6e/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteCommit.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteCommit.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteCommit.java index 647f29e..2afb144 100644 --- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteCommit.java +++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteCommit.java @@ -35,7 +35,6 @@ import org.apache.usergrid.persistence.collection.serialization.MvccLogEntrySeri import org.apache.usergrid.persistence.collection.serialization.UniqueValue; import org.apache.usergrid.persistence.collection.serialization.UniqueValueSerializationStrategy; import org.apache.usergrid.persistence.collection.serialization.impl.UniqueValueImpl; -import org.apache.usergrid.persistence.core.guice.ProxyImpl; import org.apache.usergrid.persistence.core.scope.ApplicationScope; import org.apache.usergrid.persistence.core.util.ValidationUtils; import org.apache.usergrid.persistence.model.entity.Entity; @@ -71,7 +70,7 @@ public class WriteCommit implements Func1<CollectionIoEvent<MvccEntity>, Entity> @Inject public WriteCommit( final MvccLogEntrySerializationStrategy logStrat, - @ProxyImpl final MvccEntitySerializationStrategy entryStrat, + final MvccEntitySerializationStrategy entryStrat, final UniqueValueSerializationStrategy uniqueValueStrat) { Preconditions.checkNotNull( logStrat, "MvccLogEntrySerializationStrategy is required" ); http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6e3fab6e/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 fab0db6..3e57447 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 @@ -45,7 +45,7 @@ public interface MvccEntitySerializationStrategy extends Migration, VersionedDat * @param entity The entity to persist * @return The MutationBatch operations for this update */ - public MutationBatch write(ApplicationScope context, MvccEntity entity); + MutationBatch write( ApplicationScope context, MvccEntity entity ); /** @@ -55,7 +55,7 @@ public interface MvccEntitySerializationStrategy extends Migration, VersionedDat * @param entityIds * @return */ - public EntitySet load(ApplicationScope scope, Collection<Id> entityIds, UUID maxVersion); + EntitySet load( ApplicationScope scope, Collection<Id> entityIds, UUID maxVersion ); /** * Load a list, from highest to lowest of the entity with versions <= version up to maxSize elements @@ -69,8 +69,7 @@ public interface MvccEntitySerializationStrategy extends Migration, VersionedDat */ @Deprecated //this has been made obsolete in the latest version, only use the load methods - public Iterator<MvccEntity> loadDescendingHistory( ApplicationScope context, Id entityId, UUID version, - int fetchSize ); + Iterator<MvccEntity> loadDescendingHistory( ApplicationScope context, Id entityId, UUID version, int fetchSize ); /** * Load a historical list of entities, from lowest to highest entity with versions < version up to maxSize elements @@ -85,8 +84,7 @@ public interface MvccEntitySerializationStrategy extends Migration, VersionedDat */ @Deprecated //this has been made obsolete in the latest version, only use the load methods - public Iterator<MvccEntity> loadAscendingHistory( ApplicationScope context, Id entityId, UUID version, - int fetchSize ); + Iterator<MvccEntity> loadAscendingHistory( ApplicationScope context, Id entityId, UUID version, int fetchSize ); /** @@ -96,7 +94,7 @@ public interface MvccEntitySerializationStrategy extends Migration, VersionedDat * @param entityId * @return The MvccEntity if it exists. Null otherwise */ - public Optional<MvccEntity> load(ApplicationScope scope, Id entityId); + Optional<MvccEntity> load( ApplicationScope scope, Id entityId ); /** @@ -104,7 +102,7 @@ public interface MvccEntitySerializationStrategy extends Migration, VersionedDat * can be used in a mark+sweep system. The entity with the given version will exist in the context, but no data * will be stored */ - public MutationBatch mark(ApplicationScope context, Id entityId, UUID version); + MutationBatch mark( ApplicationScope context, Id entityId, UUID version ); /** @@ -114,6 +112,6 @@ public interface MvccEntitySerializationStrategy extends Migration, VersionedDat * @param entityId The entity id to delete * @param version The version to delete */ - public MutationBatch delete(ApplicationScope context, Id entityId, UUID version); + MutationBatch delete( ApplicationScope context, Id entityId, UUID version ); } http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6e3fab6e/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/MvccLogEntrySerializationStrategy.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/MvccLogEntrySerializationStrategy.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/MvccLogEntrySerializationStrategy.java index d029249..92669a7 100644 --- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/MvccLogEntrySerializationStrategy.java +++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/MvccLogEntrySerializationStrategy.java @@ -25,6 +25,7 @@ import java.util.UUID; import org.apache.usergrid.persistence.collection.MvccLogEntry; import org.apache.usergrid.persistence.collection.VersionSet; +import org.apache.usergrid.persistence.core.migration.data.VersionedData; import org.apache.usergrid.persistence.core.migration.schema.Migration; import org.apache.usergrid.persistence.core.scope.ApplicationScope; import org.apache.usergrid.persistence.model.entity.Id; @@ -35,7 +36,7 @@ import com.netflix.astyanax.MutationBatch; /** * The interface that allows us to serialize a log entry to disk */ -public interface MvccLogEntrySerializationStrategy extends Migration { +public interface MvccLogEntrySerializationStrategy extends Migration, VersionedData { /** * Serialize the entity to the data store with the given collection context http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6e3fab6e/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/CollectionDataVersions.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/CollectionDataVersions.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/CollectionDataVersions.java index 76d35d7..84028d6 100644 --- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/CollectionDataVersions.java +++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/CollectionDataVersions.java @@ -35,7 +35,7 @@ public enum CollectionDataVersions{ private final int version; - private CollectionDataVersions( final int version ) {this.version = version;} + CollectionDataVersions( final int version ) {this.version = version;} public int getVersion() { http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6e3fab6e/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV3Impl.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV3Impl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV3Impl.java index 9867621..be08da8 100644 --- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV3Impl.java +++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV3Impl.java @@ -34,6 +34,7 @@ import org.apache.usergrid.persistence.core.astyanax.IdRowCompositeSerializer; import org.apache.usergrid.persistence.core.astyanax.MultiTennantColumnFamily; import org.apache.usergrid.persistence.core.astyanax.MultiTennantColumnFamilyDefinition; import org.apache.usergrid.persistence.core.astyanax.ScopedRowKey; +import org.apache.usergrid.persistence.core.astyanax.ScopedRowKeySerializer; import org.apache.usergrid.persistence.core.scope.ApplicationScope; import org.apache.usergrid.persistence.model.entity.Entity; import org.apache.usergrid.persistence.model.entity.EntityMap; @@ -67,12 +68,10 @@ import rx.schedulers.Schedulers; public class MvccEntitySerializationStrategyV3Impl implements MvccEntitySerializationStrategy { private static final IdRowCompositeSerializer ID_SER = IdRowCompositeSerializer.get(); + private static final ScopedRowKeySerializer<Id> ROW_KEY_SER = new ScopedRowKeySerializer<>( ID_SER ); - private static final CollectionScopedRowKeySerializer<Id> ROW_KEY_SER = - new CollectionScopedRowKeySerializer<>( ID_SER ); - - private static final MultiTennantColumnFamily<ScopedRowKey<CollectionPrefixedKey<Id>>, Boolean> CF_ENTITY_DATA = + private static final MultiTennantColumnFamily<ScopedRowKey<Id>, Boolean> CF_ENTITY_DATA = new MultiTennantColumnFamily<>( "Entity_Version_Data_V3", ROW_KEY_SER, BooleanSerializer.get() ); private static final FieldBufferSerializer FIELD_BUFFER_SERIALIZER = FieldBufferSerializer.get(); @@ -139,19 +138,13 @@ public class MvccEntitySerializationStrategyV3Impl implements MvccEntitySerializ final Id ownerId = applicationId; - final List<ScopedRowKey<CollectionPrefixedKey<Id>>> rowKeys = new ArrayList<>( entityIds.size() ); + final List<ScopedRowKey<Id>> rowKeys = new ArrayList<>( entityIds.size() ); for ( final Id entityId : entityIds ) { - final String collectionName = LegacyScopeUtils.getCollectionScopeNameFromEntityType( entityId.getType() ); - - final CollectionPrefixedKey<Id> collectionPrefixedKey = - new CollectionPrefixedKey<>( collectionName, ownerId, entityId ); - - - final ScopedRowKey<CollectionPrefixedKey<Id>> rowKey = - ScopedRowKey.fromKey( applicationId, collectionPrefixedKey ); + final ScopedRowKey<Id> rowKey = + ScopedRowKey.fromKey( applicationId, entityId ); rowKeys.add( rowKey ); @@ -206,11 +199,11 @@ public class MvccEntitySerializationStrategyV3Impl implements MvccEntitySerializ }, 10 ) .reduce( new EntitySetImpl( entityIds.size() ), ( entitySet, rows ) -> { - final Iterator<Row<ScopedRowKey<CollectionPrefixedKey<Id>>, Boolean>> latestEntityColumns = + final Iterator<Row<ScopedRowKey<Id>, Boolean>> latestEntityColumns = rows.iterator(); while ( latestEntityColumns.hasNext() ) { - final Row<ScopedRowKey<CollectionPrefixedKey<Id>>, Boolean> row = latestEntityColumns.next(); + final Row<ScopedRowKey<Id>, Boolean> row = latestEntityColumns.next(); final ColumnList<Boolean> columns = row.getColumns(); @@ -218,7 +211,7 @@ public class MvccEntitySerializationStrategyV3Impl implements MvccEntitySerializ continue; } - final Id entityId = row.getKey().getKey().getSubKey(); + final Id entityId = row.getKey().getKey(); final Column<Boolean> column = columns.getColumnByIndex( 0 ); @@ -330,15 +323,9 @@ public class MvccEntitySerializationStrategyV3Impl implements MvccEntitySerializ final MutationBatch batch = keyspace.prepareMutationBatch(); final Id applicationId = applicationScope.getApplication(); - final Id ownerId = applicationId; - final String collectionName = LegacyScopeUtils.getCollectionScopeNameFromEntityType( entityId.getType() ); - - final CollectionPrefixedKey<Id> collectionPrefixedKey = - new CollectionPrefixedKey<>( collectionName, ownerId, entityId ); - - final ScopedRowKey<CollectionPrefixedKey<Id>> rowKey = - ScopedRowKey.fromKey( applicationId, collectionPrefixedKey ); + final ScopedRowKey<Id> rowKey = + ScopedRowKey.fromKey( applicationId, entityId ); final long timestamp = version.timestamp(); http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6e3fab6e/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationProxyImpl.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationProxyImpl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationProxyImpl.java new file mode 100644 index 0000000..e0f6f03 --- /dev/null +++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationProxyImpl.java @@ -0,0 +1,147 @@ +/* + * 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; + + +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.UUID; + +import org.apache.usergrid.persistence.collection.MvccLogEntry; +import org.apache.usergrid.persistence.collection.VersionSet; +import org.apache.usergrid.persistence.collection.serialization.MvccLogEntrySerializationStrategy; +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.MigrationRelationship; +import org.apache.usergrid.persistence.core.migration.data.VersionedMigrationSet; +import org.apache.usergrid.persistence.core.scope.ApplicationScope; +import org.apache.usergrid.persistence.model.entity.Id; + +import com.google.inject.Inject; +import com.netflix.astyanax.Keyspace; +import com.netflix.astyanax.MutationBatch; + + +/** + * The proxy for performing log entry serialization + */ +public class MvccLogEntrySerializationProxyImpl implements MvccLogEntrySerializationStrategy { + + protected final Keyspace keyspace; + private final VersionedMigrationSet<MvccLogEntrySerializationStrategy> versions; + private final MigrationInfoCache migrationInfoCache; + + + @Inject + public MvccLogEntrySerializationProxyImpl( final Keyspace keyspace, + final VersionedMigrationSet<MvccLogEntrySerializationStrategy> + allVersions, + final MigrationInfoCache migrationInfoCache ) { + + this.keyspace = keyspace; + this.migrationInfoCache = migrationInfoCache; + this.versions = allVersions; + } + + + @Override + public MutationBatch write( final ApplicationScope applicationScope, final MvccLogEntry entry ) { + final MigrationRelationship<MvccLogEntrySerializationStrategy> migration = getMigrationRelationShip(); + + if ( migration.needsMigration() ) { + final MutationBatch aggregateBatch = keyspace.prepareMutationBatch(); + + aggregateBatch.mergeShallow( migration.from.write( applicationScope, entry ) ); + aggregateBatch.mergeShallow( migration.to.write( applicationScope, entry ) ); + + return aggregateBatch; + } + + return migration.to.write( applicationScope, entry ); + } + + + @Override + public VersionSet load( final ApplicationScope applicationScope, final Collection<Id> entityIds, + final UUID version ) { + + + final MigrationRelationship<MvccLogEntrySerializationStrategy> migration = getMigrationRelationShip(); + + if ( migration.needsMigration() ) { + return migration.from.load( applicationScope, entityIds, version ); + } + + return migration.to.load( applicationScope, entityIds, version ); + } + + + @Override + public List<MvccLogEntry> load( final ApplicationScope applicationScope, final Id entityId, final UUID version, + final int maxSize ) { + final MigrationRelationship<MvccLogEntrySerializationStrategy> migration = getMigrationRelationShip(); + + if ( migration.needsMigration() ) { + return migration.from.load( applicationScope, entityId, version, maxSize ); + } + + return migration.to.load( applicationScope, entityId, version, maxSize ); + } + + + @Override + public MutationBatch delete( final ApplicationScope applicationScope, final Id entityId, final UUID version ) { + final MigrationRelationship<MvccLogEntrySerializationStrategy> migration = getMigrationRelationShip(); + + if ( migration.needsMigration() ) { + final MutationBatch aggregateBatch = keyspace.prepareMutationBatch(); + + aggregateBatch.mergeShallow( migration.from.delete( applicationScope, entityId, version ) ); + aggregateBatch.mergeShallow( migration.to.delete( applicationScope, entityId, version ) ); + + return aggregateBatch; + } + + return migration.to.delete( applicationScope, entityId, version ); + } + + + @Override + public Collection<MultiTennantColumnFamilyDefinition> getColumnFamilies() { + return Collections.emptyList(); + } + + + @Override + public int getImplementationVersion() { + throw new UnsupportedOperationException( "Not supported in the proxy" ); + } + + + /** + * Return true if we're on an old version + */ + private MigrationRelationship<MvccLogEntrySerializationStrategy> getMigrationRelationShip() { + return this.versions + .getMigrationRelationship( migrationInfoCache.getVersion( CollectionMigrationPlugin.PLUGIN_NAME ) ); + } +} http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6e3fab6e/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyImpl.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyImpl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyImpl.java index 866b87c..d6baa3c 100644 --- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyImpl.java +++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyImpl.java @@ -52,8 +52,6 @@ import org.apache.usergrid.persistence.core.scope.ApplicationScope; import org.apache.usergrid.persistence.model.entity.Id; import com.google.common.base.Preconditions; -import com.google.inject.Inject; -import com.google.inject.Singleton; import com.netflix.astyanax.ColumnListMutation; import com.netflix.astyanax.Keyspace; import com.netflix.astyanax.MutationBatch; @@ -62,7 +60,6 @@ import com.netflix.astyanax.model.Column; import com.netflix.astyanax.model.ColumnList; import com.netflix.astyanax.model.Row; import com.netflix.astyanax.serializers.AbstractSerializer; -import com.netflix.astyanax.serializers.UUIDSerializer; /** @@ -70,30 +67,23 @@ import com.netflix.astyanax.serializers.UUIDSerializer; * * @author tnine */ -@Singleton -public class MvccLogEntrySerializationStrategyImpl implements MvccLogEntrySerializationStrategy { +public abstract class MvccLogEntrySerializationStrategyImpl<K> implements MvccLogEntrySerializationStrategy { private static final Logger LOG = LoggerFactory.getLogger( MvccLogEntrySerializationStrategyImpl.class ); private static final StageSerializer SER = new StageSerializer(); - private static final IdRowCompositeSerializer ID_SER = IdRowCompositeSerializer.get(); - - private static final CollectionScopedRowKeySerializer<Id> ROW_KEY_SER = - new CollectionScopedRowKeySerializer<Id>( ID_SER ); - - private static final MultiTennantColumnFamily<ScopedRowKey<CollectionPrefixedKey<Id>>, UUID> CF_ENTITY_LOG = - new MultiTennantColumnFamily<>( "Entity_Log", ROW_KEY_SER, UUIDSerializer.get() ); + private final MultiTennantColumnFamily<ScopedRowKey<K>, UUID> CF_ENTITY_LOG; protected final Keyspace keyspace; protected final SerializationFig fig; - @Inject public MvccLogEntrySerializationStrategyImpl( final Keyspace keyspace, final SerializationFig fig ) { this.keyspace = keyspace; this.fig = fig; + CF_ENTITY_LOG = getColumnFamily(); } @@ -144,26 +134,18 @@ public class MvccLogEntrySerializationStrategyImpl implements MvccLogEntrySerial - final List<ScopedRowKey<CollectionPrefixedKey<Id>>> rowKeys = new ArrayList<>( entityIds.size() ); + final List<ScopedRowKey<K>> rowKeys = new ArrayList<>( entityIds.size() ); for ( final Id entityId : entityIds ) { - - final String collectionName = LegacyScopeUtils.getCollectionScopeNameFromEntityType( entityId.getType() ); - - final CollectionPrefixedKey<Id> collectionPrefixedKey = - new CollectionPrefixedKey<>( collectionName, ownerId, entityId ); - - - final ScopedRowKey<CollectionPrefixedKey<Id>> rowKey = - ScopedRowKey.fromKey( applicationId, collectionPrefixedKey ); + final ScopedRowKey<K> rowKey = createKey( applicationId, entityId ); rowKeys.add( rowKey ); } - final Iterator<Row<ScopedRowKey<CollectionPrefixedKey<Id>>, UUID>> latestEntityColumns; + final Iterator<Row<ScopedRowKey<K>, UUID>> latestEntityColumns; try { @@ -180,7 +162,7 @@ public class MvccLogEntrySerializationStrategyImpl implements MvccLogEntrySerial final VersionSetImpl versionResults = new VersionSetImpl( entityIds.size() ); while ( latestEntityColumns.hasNext() ) { - final Row<ScopedRowKey<CollectionPrefixedKey<Id>>, UUID> row = latestEntityColumns.next(); + final Row<ScopedRowKey<K>, UUID> row = latestEntityColumns.next(); final ColumnList<UUID> columns = row.getColumns(); @@ -189,7 +171,7 @@ public class MvccLogEntrySerializationStrategyImpl implements MvccLogEntrySerial } - final Id entityId = row.getKey().getKey().getSubKey(); + final Id entityId = getEntityIdFromKey( row.getKey() ); final Column<UUID> column = columns.getColumnByIndex( 0 ); @@ -222,16 +204,8 @@ public class MvccLogEntrySerializationStrategyImpl implements MvccLogEntrySerial try { final Id applicationId = collectionScope.getApplication(); - final Id ownerId = applicationId; - final String collectionName = LegacyScopeUtils.getCollectionScopeNameFromEntityType( entityId.getType() ); - - - final CollectionPrefixedKey<Id> collectionPrefixedKey = - new CollectionPrefixedKey<>( collectionName, ownerId, entityId ); - - final ScopedRowKey<CollectionPrefixedKey<Id>> rowKey = - ScopedRowKey.fromKey( applicationId, collectionPrefixedKey ); + final ScopedRowKey<K> rowKey = createKey( applicationId, entityId ); columns = keyspace.prepareQuery( CF_ENTITY_LOG ).getKey( rowKey ) @@ -271,24 +245,12 @@ public class MvccLogEntrySerializationStrategyImpl implements MvccLogEntrySerial } - @Override - public Collection<MultiTennantColumnFamilyDefinition> getColumnFamilies() { - //create the CF entity data. We want it reversed b/c we want the most recent version at the top of the - //row for fast seeks - MultiTennantColumnFamilyDefinition cf = - new MultiTennantColumnFamilyDefinition( CF_ENTITY_LOG, BytesType.class.getSimpleName(), - ReversedType.class.getSimpleName() + "(" + UUIDType.class.getSimpleName() + ")", - IntegerType.class.getSimpleName(), MultiTennantColumnFamilyDefinition.CacheOption.KEYS ); - - - return Collections.singleton( cf ); - } /** * Simple callback to perform puts and deletes with a common row setup code */ - private static interface RowOp { + private interface RowOp { /** * The operation to perform on the row @@ -314,20 +276,27 @@ public class MvccLogEntrySerializationStrategyImpl implements MvccLogEntrySerial final Id ownerId = applicationId; final String collectionName = LegacyScopeUtils.getCollectionScopeNameFromEntityType( entityId.getType() ); + final ScopedRowKey<K> key = createKey( applicationId, entityId ); +// +// final CollectionPrefixedKey<Id> collectionPrefixedKey = +// new CollectionPrefixedKey<>( collectionName, ownerId, entityId ); +// +// +// final ScopedRowKey<CollectionPrefixedKey<Id>> rowKey = +// ScopedRowKey.fromKey( applicationId, collectionPrefixedKey ); - final CollectionPrefixedKey<Id> collectionPrefixedKey = - new CollectionPrefixedKey<>( collectionName, ownerId, entityId ); + op.doOp( batch.withRow( CF_ENTITY_LOG, key ) ); - final ScopedRowKey<CollectionPrefixedKey<Id>> rowKey = - ScopedRowKey.fromKey( applicationId, collectionPrefixedKey ); + return batch; + } + protected abstract MultiTennantColumnFamily<ScopedRowKey<K>, UUID> getColumnFamily(); - op.doOp( batch.withRow( CF_ENTITY_LOG, rowKey ) ); - return batch; - } + protected abstract ScopedRowKey<K> createKey(final Id applicationId, final Id entityId); + protected abstract Id getEntityIdFromKey(final ScopedRowKey<K> key); /** * Internal stage shard http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6e3fab6e/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyV1Impl.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyV1Impl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyV1Impl.java new file mode 100644 index 0000000..57e7421 --- /dev/null +++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyV1Impl.java @@ -0,0 +1,118 @@ +/* + * 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; + + +import java.util.Collection; +import java.util.Collections; +import java.util.UUID; + +import org.apache.cassandra.db.marshal.BytesType; +import org.apache.cassandra.db.marshal.IntegerType; +import org.apache.cassandra.db.marshal.ReversedType; +import org.apache.cassandra.db.marshal.UUIDType; + +import org.apache.usergrid.persistence.collection.serialization.SerializationFig; +import org.apache.usergrid.persistence.collection.serialization.impl.util.LegacyScopeUtils; +import org.apache.usergrid.persistence.core.astyanax.IdRowCompositeSerializer; +import org.apache.usergrid.persistence.core.astyanax.MultiTennantColumnFamily; +import org.apache.usergrid.persistence.core.astyanax.MultiTennantColumnFamilyDefinition; +import org.apache.usergrid.persistence.core.astyanax.ScopedRowKey; +import org.apache.usergrid.persistence.model.entity.Id; + +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.netflix.astyanax.Keyspace; +import com.netflix.astyanax.serializers.UUIDSerializer; + + +/** + * Our v1 row key implementation + */ +@Singleton +public class MvccLogEntrySerializationStrategyV1Impl + extends MvccLogEntrySerializationStrategyImpl<CollectionPrefixedKey<Id>> { + + + private static final IdRowCompositeSerializer ID_SER = IdRowCompositeSerializer.get(); + + private static final CollectionScopedRowKeySerializer<Id> ROW_KEY_SER = + new CollectionScopedRowKeySerializer<Id>( ID_SER ); + + private static final MultiTennantColumnFamily<ScopedRowKey<CollectionPrefixedKey<Id>>, UUID> CF_ENTITY_LOG = + new MultiTennantColumnFamily<>( "Entity_Log", ROW_KEY_SER, UUIDSerializer.get() ); + + + @Inject + public MvccLogEntrySerializationStrategyV1Impl( final Keyspace keyspace, final SerializationFig fig ) { + super( keyspace, fig ); + } + + + @Override + public int getImplementationVersion() { + return CollectionDataVersions.INITIAL.getVersion(); + } + + + @Override + protected MultiTennantColumnFamily<ScopedRowKey<CollectionPrefixedKey<Id>>, UUID> getColumnFamily() { + return CF_ENTITY_LOG; + } + + + @Override + protected ScopedRowKey<CollectionPrefixedKey<Id>> createKey( final Id applicationId, final Id entityId ) { + final Id ownerId = applicationId; + + + final String collectionName = LegacyScopeUtils.getCollectionScopeNameFromEntityType( entityId.getType() ); + + final CollectionPrefixedKey<Id> collectionPrefixedKey = + new CollectionPrefixedKey<>( collectionName, ownerId, entityId ); + + + final ScopedRowKey<CollectionPrefixedKey<Id>> rowKey = + ScopedRowKey.fromKey( applicationId, collectionPrefixedKey ); + + return rowKey; + + } + + + @Override + protected Id getEntityIdFromKey( final ScopedRowKey<CollectionPrefixedKey<Id>> key ) { + return key.getKey().getSubKey(); + } + + + @Override + public Collection<MultiTennantColumnFamilyDefinition> getColumnFamilies() { + //create the CF entity data. We want it reversed b/c we want the most recent version at the top of the + //row for fast seeks + MultiTennantColumnFamilyDefinition cf = + new MultiTennantColumnFamilyDefinition( CF_ENTITY_LOG, BytesType.class.getSimpleName(), + ReversedType.class.getSimpleName() + "(" + UUIDType.class.getSimpleName() + ")", + IntegerType.class.getSimpleName(), MultiTennantColumnFamilyDefinition.CacheOption.KEYS ); + + + return Collections.singleton( cf ); + } +} http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6e3fab6e/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyV2Impl.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyV2Impl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyV2Impl.java new file mode 100644 index 0000000..99cc97f --- /dev/null +++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyV2Impl.java @@ -0,0 +1,106 @@ +/* + * 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; + + +import java.util.Collection; +import java.util.Collections; +import java.util.UUID; + +import org.apache.cassandra.db.marshal.BytesType; +import org.apache.cassandra.db.marshal.IntegerType; +import org.apache.cassandra.db.marshal.ReversedType; +import org.apache.cassandra.db.marshal.UUIDType; + +import org.apache.usergrid.persistence.collection.serialization.SerializationFig; +import org.apache.usergrid.persistence.core.astyanax.IdRowCompositeSerializer; +import org.apache.usergrid.persistence.core.astyanax.MultiTennantColumnFamily; +import org.apache.usergrid.persistence.core.astyanax.MultiTennantColumnFamilyDefinition; +import org.apache.usergrid.persistence.core.astyanax.ScopedRowKey; +import org.apache.usergrid.persistence.core.astyanax.ScopedRowKeySerializer; +import org.apache.usergrid.persistence.model.entity.Id; + +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.netflix.astyanax.Keyspace; +import com.netflix.astyanax.serializers.UUIDSerializer; + + +/** + * Serialization strategy V2 that doesn't contain collection scope + */ +@Singleton +public class MvccLogEntrySerializationStrategyV2Impl extends MvccLogEntrySerializationStrategyImpl<Id> { + + + private static final IdRowCompositeSerializer ID_SER = IdRowCompositeSerializer.get(); + + private static final ScopedRowKeySerializer<Id> ROW_KEY_SER = new ScopedRowKeySerializer<>( ID_SER ); + + + private static final MultiTennantColumnFamily<ScopedRowKey<Id>, UUID> CF_ENTITY_LOG_V2 = + new MultiTennantColumnFamily<>( "Entity_Log_V2", ROW_KEY_SER, UUIDSerializer.get() ); + + + @Inject + public MvccLogEntrySerializationStrategyV2Impl( final Keyspace keyspace, final SerializationFig fig ) { + super( keyspace, fig ); + } + + + @Override + public int getImplementationVersion() { + return CollectionDataVersions.LOG_REMOVAL.getVersion(); + } + + + @Override + protected MultiTennantColumnFamily<ScopedRowKey<Id>, UUID> getColumnFamily() { + return CF_ENTITY_LOG_V2; + } + + + @Override + protected ScopedRowKey<Id> createKey( final Id applicationId, final Id entityId ) { + final ScopedRowKey<Id> rowKey = ScopedRowKey.fromKey( applicationId, entityId ); + + return rowKey; + } + + + @Override + protected Id getEntityIdFromKey( final ScopedRowKey<Id> key ) { + return key.getKey(); + } + + + @Override + public Collection<MultiTennantColumnFamilyDefinition> getColumnFamilies() { + //create the CF entity data. We want it reversed b/c we want the most recent version at the top of the + //row for fast seeks + MultiTennantColumnFamilyDefinition cf = + new MultiTennantColumnFamilyDefinition( CF_ENTITY_LOG_V2, BytesType.class.getSimpleName(), + ReversedType.class.getSimpleName() + "(" + UUIDType.class.getSimpleName() + ")", + IntegerType.class.getSimpleName(), MultiTennantColumnFamilyDefinition.CacheOption.KEYS ); + + + return Collections.singleton( cf ); + } +} http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6e3fab6e/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 f248af6..fa1991a 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 @@ -25,7 +25,6 @@ import org.apache.usergrid.persistence.collection.serialization.impl.migration.C 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.DataMigration; import org.apache.usergrid.persistence.core.migration.data.MigrationPlugin; import org.apache.usergrid.persistence.core.migration.data.MigrationRelationship; @@ -52,24 +51,46 @@ public class SerializationModule extends AbstractModule { // bind the serialization strategies - //We've migrated this one, so we need to set up the previous, current, and proxy - - - bind( MvccEntitySerializationStrategy.class ).annotatedWith( ProxyImpl.class ) - .to( MvccEntitySerializationStrategyProxyImpl.class ); - //bind all 3 implementations bind( MvccEntitySerializationStrategyV1Impl.class ); bind( MvccEntitySerializationStrategyV2Impl.class ); bind( MvccEntitySerializationStrategyV3Impl.class ); + //We've migrated this one, so we need to set up the previous, current, and proxy + + + bind( MvccEntitySerializationStrategy.class ).to( MvccEntitySerializationStrategyProxyImpl.class ); + + + //bind 2 implementations + bind( MvccLogEntrySerializationStrategyV1Impl.class ); + bind( MvccLogEntrySerializationStrategyV2Impl.class ); + + + bind( MvccLogEntrySerializationStrategy.class ) + .to( MvccLogEntrySerializationProxyImpl.class ); + + + bind( UniqueValueSerializationStrategy.class ).to( UniqueValueSerializationStrategyImpl.class ); + + //do multibindings for migrations + Multibinder<Migration> migrationBinder = Multibinder.newSetBinder( binder(), Migration.class ); + migrationBinder.addBinding().to( Key.get( MvccEntitySerializationStrategyV1Impl.class ) ); + migrationBinder.addBinding().to( Key.get( MvccEntitySerializationStrategyV2Impl.class ) ); + migrationBinder.addBinding().to( Key.get( MvccEntitySerializationStrategyV3Impl.class ) ); + migrationBinder.addBinding().to( Key.get( MvccLogEntrySerializationStrategyV1Impl.class ) ); + migrationBinder.addBinding().to( Key.get( MvccLogEntrySerializationStrategyV2Impl.class ) ); + migrationBinder.addBinding().to( Key.get( UniqueValueSerializationStrategy.class ) ); + + + //bind our settings as an eager singleton so it's checked on startup + bind( SettingsValidation.class ).asEagerSingleton(); //migrations //we want to make sure our generics are retained, so we use a typeliteral - Multibinder<DataMigration<EntityIdScope>> dataMigrationMultibinder = - Multibinder.newSetBinder( binder(), new TypeLiteral<DataMigration<EntityIdScope>>() {}, - CollectionMigration.class ); + Multibinder<DataMigration<EntityIdScope>> dataMigrationMultibinder = Multibinder + .newSetBinder( binder(), new TypeLiteral<DataMigration<EntityIdScope>>() {}, CollectionMigration.class ); dataMigrationMultibinder.addBinding().to( MvccEntityDataMigrationImpl.class ); @@ -77,56 +98,66 @@ public class SerializationModule extends AbstractModule { //wire up the collection migration plugin Multibinder.newSetBinder( binder(), MigrationPlugin.class ).addBinding().to( CollectionMigrationPlugin.class ); + } + /** + * Configure via explicit declaration the migration path we can follow + */ + @Singleton + @Inject + @Provides + public VersionedMigrationSet<MvccEntitySerializationStrategy> getVersions( + final MvccEntitySerializationStrategyV1Impl v1, final MvccEntitySerializationStrategyV2Impl v2, + final MvccEntitySerializationStrategyV3Impl v3 ) { - bind( MvccLogEntrySerializationStrategy.class ).to( MvccLogEntrySerializationStrategyImpl.class ); - bind( UniqueValueSerializationStrategy.class ).to( UniqueValueSerializationStrategyImpl.class ); + //we must perform a migration from v1 to v3 in order to maintain consistency + MigrationRelationship<MvccEntitySerializationStrategy> v1Tov3 = new MigrationRelationship<>( v1, v3 ); - //do multibindings for migrations - Multibinder<Migration> uriBinder = Multibinder.newSetBinder( binder(), Migration.class ); - uriBinder.addBinding().to( Key.get( MvccEntitySerializationStrategyV1Impl.class ) ); - uriBinder.addBinding().to( Key.get( MvccEntitySerializationStrategyV2Impl.class ) ); - uriBinder.addBinding().to( Key.get( MvccEntitySerializationStrategyV3Impl.class ) ); - uriBinder.addBinding().to( Key.get( MvccLogEntrySerializationStrategy.class ) ); - uriBinder.addBinding().to( Key.get( UniqueValueSerializationStrategy.class ) ); + //we must migrate from 2 to 3, this is a bridge that must happen to maintain data consistency + MigrationRelationship<MvccEntitySerializationStrategy> v2Tov3 = new MigrationRelationship<>( v2, v3 ); - //bind our settings as an eager singleton so it's checked on startup - bind( SettingsValidation.class ).asEagerSingleton(); - } - /** - * Configure via explicit declaration the migration path we can follow - * @param v1 - * @param v2 - * @param v3 - * @return - */ - @Singleton - @Inject - @Provides - public VersionedMigrationSet<MvccEntitySerializationStrategy> getVersions(final MvccEntitySerializationStrategyV1Impl v1, final MvccEntitySerializationStrategyV2Impl v2, final MvccEntitySerializationStrategyV3Impl v3){ + //note that we MUST migrate to v3 before our next migration, if v4 and v5 is implemented we will need a + // v3->v5 and a v4->v5 set + MigrationRelationship<MvccEntitySerializationStrategy> current = + new MigrationRelationship<MvccEntitySerializationStrategy>( v3, v3 ); - //we must perform a migration from v1 to v3 in order to maintain consistency - MigrationRelationship<MvccEntitySerializationStrategy> v1Tov3 = new MigrationRelationship<>( v1, v3 ); + //now create our set of versions + VersionedMigrationSet<MvccEntitySerializationStrategy> set = + new VersionedMigrationSet<>( v1Tov3, v2Tov3, current ); + + return set; + } - //we must migrate from 2 to 3, this is a bridge that must happen to maintain data consistency - MigrationRelationship<MvccEntitySerializationStrategy> v2Tov3 = new MigrationRelationship<>( v2, v3 ); + /** + * Configure via explicit declaration the migration path we can follow + */ + @Singleton + @Inject + @Provides + public VersionedMigrationSet<MvccLogEntrySerializationStrategy> getVersions( + final MvccLogEntrySerializationStrategyV1Impl v1, final MvccLogEntrySerializationStrategyV2Impl v2) { - //note that we MUST migrate to v3 before our next migration, if v4 and v5 is implemented we will need a v3->v5 and a v4->v5 set - MigrationRelationship<MvccEntitySerializationStrategy> current = new MigrationRelationship<MvccEntitySerializationStrategy>( v3, v3 ); + //we must perform a migration from v1 to v3 in order to maintain consistency + MigrationRelationship<MvccLogEntrySerializationStrategy> v1Tov2 = new MigrationRelationship<>( v1, v2 ); - //now create our set of versions - VersionedMigrationSet<MvccEntitySerializationStrategy> set = new VersionedMigrationSet<>( v1Tov3, v2Tov3, current ); + //note that we MUST migrate to v3 before our next migration, if v4 and v5 is implemented we will need a + // v3->v5 and a v4->v5 set + MigrationRelationship<MvccLogEntrySerializationStrategy> current = + new MigrationRelationship<MvccLogEntrySerializationStrategy>( v2, v2 ); - return set; - } + //now create our set of versions + VersionedMigrationSet<MvccLogEntrySerializationStrategy> set = + new VersionedMigrationSet<>( v1Tov2, current ); + return set; + } } http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6e3fab6e/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerIT.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerIT.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerIT.java index 945cebd..252ce1f 100644 --- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerIT.java +++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/EntityCollectionManagerIT.java @@ -36,7 +36,6 @@ import org.apache.usergrid.persistence.collection.serialization.UniqueValueSeria import org.apache.usergrid.persistence.collection.serialization.UniqueValueSet; import org.apache.usergrid.persistence.collection.util.EntityHelper; import org.apache.usergrid.persistence.core.guice.MigrationManagerRule; -import org.apache.usergrid.persistence.core.guice.ProxyImpl; import org.apache.usergrid.persistence.core.guicyfig.SetConfigTestBypass; import org.apache.usergrid.persistence.core.scope.ApplicationScope; import org.apache.usergrid.persistence.core.scope.ApplicationScopeImpl; @@ -85,7 +84,6 @@ public class EntityCollectionManagerIT { private UniqueValueSerializationStrategy uniqueValueSerializationStrategy; @Inject - @ProxyImpl private MvccEntitySerializationStrategy entitySerializationStrategy; http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6e3fab6e/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 56abfd8..452086a 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 @@ -27,7 +27,6 @@ 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.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.test.ITRunner; import org.apache.usergrid.persistence.core.test.UseModules; @@ -43,7 +42,6 @@ import net.jcip.annotations.NotThreadSafe; public class MvccEntitySerializationStrategyProxyV1_3Test extends MvccEntitySerializationStrategyImplTest { @Inject - @ProxyImpl private MvccEntitySerializationStrategy serializationStrategy; @Inject http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6e3fab6e/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyV2_3Test.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyV2_3Test.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyV2_3Test.java index b372fbf..221b1d3 100644 --- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyV2_3Test.java +++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyProxyV2_3Test.java @@ -27,7 +27,6 @@ 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.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.test.ITRunner; import org.apache.usergrid.persistence.core.test.UseModules; @@ -43,7 +42,6 @@ import net.jcip.annotations.NotThreadSafe; public class MvccEntitySerializationStrategyProxyV2_3Test extends MvccEntitySerializationStrategyV2Test { @Inject - @ProxyImpl private MvccEntitySerializationStrategy serializationStrategy; @Inject http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6e3fab6e/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyImplTest.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyImplTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyImplTest.java index 19a75fa..107b2a0 100644 --- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyImplTest.java +++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyImplTest.java @@ -24,6 +24,7 @@ import java.util.Collections; import java.util.List; import java.util.UUID; +import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -54,16 +55,29 @@ import static org.mockito.Mockito.mock; /** @author tnine */ @RunWith( ITRunner.class ) @UseModules( TestCollectionModule.class ) -public class MvccLogEntrySerializationStrategyImplTest { +public abstract class MvccLogEntrySerializationStrategyImplTest { - @Inject - private MvccLogEntrySerializationStrategy logEntryStrategy; @Inject @Rule public MigrationManagerRule migrationManagerRule; + private MvccLogEntrySerializationStrategy logEntryStrategy; + + @Before + public void wireLogEntryStrategy(){ + logEntryStrategy = getLogEntryStrategy(); + } + + + /** + * Get the log entry strategy from + * @return + */ + protected abstract MvccLogEntrySerializationStrategy getLogEntryStrategy(); + + @Test public void createAndDelete() throws ConnectionException { http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6e3fab6e/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyProxyImplTest.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyProxyImplTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyProxyImplTest.java new file mode 100644 index 0000000..a5efce3 --- /dev/null +++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyProxyImplTest.java @@ -0,0 +1,90 @@ +/* + * 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; + + +import org.junit.After; +import org.junit.Before; +import org.junit.runner.RunWith; + +import org.apache.usergrid.persistence.collection.guice.TestCollectionModule; +import org.apache.usergrid.persistence.collection.serialization.MvccLogEntrySerializationStrategy; +import org.apache.usergrid.persistence.collection.serialization.impl.migration.CollectionMigrationPlugin; +import org.apache.usergrid.persistence.core.migration.data.MigrationInfoSerialization; +import org.apache.usergrid.persistence.core.test.ITRunner; +import org.apache.usergrid.persistence.core.test.UseModules; + +import com.google.inject.Inject; + +import net.jcip.annotations.NotThreadSafe; + + +@RunWith( ITRunner.class ) +@UseModules( TestCollectionModule.class ) +@NotThreadSafe//anything that changes the system version state is not safe to be run concurrently +public class MvccLogEntrySerializationStrategyProxyImplTest extends MvccLogEntrySerializationStrategyImplTest { + + + @Inject + private MvccLogEntrySerializationStrategy logEntryStrategy; + + + + @Inject + private MvccLogEntrySerializationStrategyV1Impl v1Impl; + + + @Inject + protected MigrationInfoSerialization migrationInfoSerialization; + + private int existingVersion; + + + + @Override + protected MvccLogEntrySerializationStrategy getLogEntryStrategy() { + return logEntryStrategy; + } + + + + + + /** + * We need to run our migration to ensure that we are on the current version, and everything still functions + * correctly + */ + @Before + public void setMigrationVersion() { + existingVersion = migrationInfoSerialization.getVersion( CollectionMigrationPlugin.PLUGIN_NAME); + + //set our migration version to be v1 + migrationInfoSerialization.setVersion( CollectionMigrationPlugin.PLUGIN_NAME, v1Impl.getImplementationVersion() ); + } + + + + + @After + public void reSetMigrationVersion() { + migrationInfoSerialization.setVersion(CollectionMigrationPlugin.PLUGIN_NAME, existingVersion ); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6e3fab6e/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyV1ImplTest.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyV1ImplTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyV1ImplTest.java new file mode 100644 index 0000000..d87e216 --- /dev/null +++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyV1ImplTest.java @@ -0,0 +1,55 @@ +/* + * 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; + + +import org.junit.Test; +import org.junit.runner.RunWith; + +import org.apache.usergrid.persistence.collection.guice.TestCollectionModule; +import org.apache.usergrid.persistence.collection.serialization.MvccLogEntrySerializationStrategy; +import org.apache.usergrid.persistence.core.test.ITRunner; +import org.apache.usergrid.persistence.core.test.UseModules; + +import com.google.inject.Inject; + +import static org.junit.Assert.assertEquals; + + +@RunWith( ITRunner.class ) +@UseModules( TestCollectionModule.class ) +public class MvccLogEntrySerializationStrategyV1ImplTest extends MvccLogEntrySerializationStrategyImplTest { + + + @Inject + private MvccLogEntrySerializationStrategyV1Impl logEntryStrategy; + + + @Override + protected MvccLogEntrySerializationStrategy getLogEntryStrategy() { + return logEntryStrategy; + } + + + @Test + public void checkVersion() { + assertEquals( CollectionDataVersions.INITIAL.getVersion(), logEntryStrategy.getImplementationVersion() ); + } +} http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6e3fab6e/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyV2ImplTest.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyV2ImplTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyV2ImplTest.java new file mode 100644 index 0000000..5e906e0 --- /dev/null +++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyV2ImplTest.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; + + +import org.junit.Test; +import org.junit.runner.RunWith; + +import org.apache.usergrid.persistence.collection.guice.TestCollectionModule; +import org.apache.usergrid.persistence.collection.serialization.MvccLogEntrySerializationStrategy; +import org.apache.usergrid.persistence.core.test.ITRunner; +import org.apache.usergrid.persistence.core.test.UseModules; + +import com.google.inject.Inject; + +import static org.junit.Assert.assertEquals; + + +@RunWith( ITRunner.class ) +@UseModules( TestCollectionModule.class ) +public class MvccLogEntrySerializationStrategyV2ImplTest extends MvccLogEntrySerializationStrategyImplTest { + + + @Inject + private MvccLogEntrySerializationStrategyV2Impl logEntryStrategy; + + @Override + protected MvccLogEntrySerializationStrategy getLogEntryStrategy() { + return logEntryStrategy; + } + + @Test + public void checkVersion(){ + assertEquals(CollectionDataVersions.LOG_REMOVAL.getVersion(), logEntryStrategy.getImplementationVersion()); + } +} http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6e3fab6e/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/guice/ProxyImpl.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/guice/ProxyImpl.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/guice/ProxyImpl.java deleted file mode 100644 index 0bebd6c..0000000 --- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/guice/ProxyImpl.java +++ /dev/null @@ -1,42 +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.guice; - -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; - - - -/** - * Represents 2 versions of an impl. Generally used for online migration. This represents the version of the impl - * that is responsible for bridging the versions from previous to current during the migration. - */ -@BindingAnnotation -@Target({ FIELD, PARAMETER, METHOD }) @Retention(RUNTIME) -public @interface ProxyImpl {} http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6e3fab6e/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 index 266697a..16fd17f 100644 --- 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 @@ -33,6 +33,6 @@ public interface VersionedData { * Get the version of the implementation * @return */ - public int getImplementationVersion(); + int getImplementationVersion(); } http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6e3fab6e/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/schema/Migration.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/schema/Migration.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/schema/Migration.java index fdf483a..7343f07 100644 --- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/schema/Migration.java +++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/schema/Migration.java @@ -32,5 +32,5 @@ public interface Migration { /** * Get the column families required for this implementation. If one does not exist it will be created. */ - public Collection<MultiTennantColumnFamilyDefinition> getColumnFamilies(); + Collection<MultiTennantColumnFamilyDefinition> getColumnFamilies(); } http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6e3fab6e/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/guice/GraphModule.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/guice/GraphModule.java b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/guice/GraphModule.java index 91a0b88..6cdaef0 100644 --- a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/guice/GraphModule.java +++ b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/guice/GraphModule.java @@ -23,7 +23,6 @@ import org.safehaus.guicyfig.GuicyFigModule; import org.apache.usergrid.persistence.core.consistency.TimeService; import org.apache.usergrid.persistence.core.consistency.TimeServiceImpl; -import org.apache.usergrid.persistence.core.guice.ProxyImpl; 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; @@ -46,7 +45,6 @@ import org.apache.usergrid.persistence.graph.serialization.EdgeSerialization; import org.apache.usergrid.persistence.graph.serialization.EdgesObservable; import org.apache.usergrid.persistence.graph.serialization.NodeSerialization; import org.apache.usergrid.persistence.graph.serialization.TargetIdObservable; -import org.apache.usergrid.persistence.graph.serialization.impl.migration.EdgeDataMigrationImpl; import org.apache.usergrid.persistence.graph.serialization.impl.EdgeMetadataSerializationProxyImpl; import org.apache.usergrid.persistence.graph.serialization.impl.EdgeMetadataSerializationV1Impl; import org.apache.usergrid.persistence.graph.serialization.impl.EdgeMetadataSerializationV2Impl; @@ -55,6 +53,7 @@ import org.apache.usergrid.persistence.graph.serialization.impl.EdgesObservableI import org.apache.usergrid.persistence.graph.serialization.impl.GraphManagerFactoryImpl; import org.apache.usergrid.persistence.graph.serialization.impl.NodeSerializationImpl; import org.apache.usergrid.persistence.graph.serialization.impl.TargetIdObservableImpl; +import org.apache.usergrid.persistence.graph.serialization.impl.migration.EdgeDataMigrationImpl; import org.apache.usergrid.persistence.graph.serialization.impl.migration.GraphMigration; import org.apache.usergrid.persistence.graph.serialization.impl.migration.GraphMigrationPlugin; import org.apache.usergrid.persistence.graph.serialization.impl.migration.GraphNode; @@ -189,7 +188,7 @@ public abstract class GraphModule extends AbstractModule { bind( EdgeMetadataSerializationV1Impl.class ); bind( EdgeMetadataSerializationV2Impl.class ); - bind(EdgeMetadataSerialization.class).annotatedWith( ProxyImpl.class ).to( EdgeMetadataSerializationProxyImpl.class ); + bind( EdgeMetadataSerialization.class ).to( EdgeMetadataSerializationProxyImpl.class ); //invoke the migration plugin config configureMigrationProvider(); http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/6e3fab6e/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/GraphManagerImpl.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/GraphManagerImpl.java b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/GraphManagerImpl.java index ef258f4..9c0c62d 100644 --- a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/GraphManagerImpl.java +++ b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/GraphManagerImpl.java @@ -28,7 +28,6 @@ import java.util.UUID; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.apache.usergrid.persistence.core.guice.ProxyImpl; import org.apache.usergrid.persistence.core.metrics.MetricsFactory; import org.apache.usergrid.persistence.core.rx.ObservableIterator; import org.apache.usergrid.persistence.core.scope.ApplicationScope; @@ -119,7 +118,7 @@ public class GraphManagerImpl implements GraphManager { @Inject - public GraphManagerImpl( @ProxyImpl final EdgeMetadataSerialization edgeMetadataSerialization, + public GraphManagerImpl( final EdgeMetadataSerialization edgeMetadataSerialization, final EdgeSerialization storageEdgeSerialization, final NodeSerialization nodeSerialization, final GraphFig graphFig,
