http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c39be5da/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/UniqueValueSerializationStrategy.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/UniqueValueSerializationStrategy.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/UniqueValueSerializationStrategy.java index d7a6407..8cee99d 100644 --- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/UniqueValueSerializationStrategy.java +++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/UniqueValueSerializationStrategy.java @@ -26,6 +26,7 @@ import com.netflix.astyanax.connectionpool.exceptions.ConnectionException; import com.netflix.astyanax.model.ConsistencyLevel; import org.apache.usergrid.persistence.collection.CollectionScope; 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; import org.apache.usergrid.persistence.model.field.Field; @@ -39,53 +40,59 @@ public interface UniqueValueSerializationStrategy extends Migration { /** * Write the specified UniqueValue to Cassandra with optional timeToLive in milliseconds. * + * @param applicationScope scope * @param uniqueValue Object to be written + * * @return MutatationBatch that encapsulates operation, caller may or may not execute. */ - public MutationBatch write( CollectionScope collectionScope, UniqueValue uniqueValue ); + MutationBatch write( ApplicationScope applicationScope, UniqueValue uniqueValue ); /** * Write the specified UniqueValue to Cassandra with optional timeToLive in milliseconds. * + * @param applicationScope scope * @param uniqueValue Object to be written * @param timeToLive How long object should live in seconds. -1 implies store forever * @return MutatationBatch that encapsulates operation, caller may or may not execute. */ - public MutationBatch write( CollectionScope collectionScope, UniqueValue uniqueValue, int timeToLive ); + MutationBatch write( ApplicationScope applicationScope, UniqueValue uniqueValue, int timeToLive ); /** * Load UniqueValue that matches field from collection or null if that value does not exist. * - * @param collectionScope scope in which to look for field name/value + * @param applicationScope scope in which to look for field name/value + * @param type The type the unique value exists within * @param fields Field name/value to search for * * @return UniqueValueSet containing fields from the collection that exist in cassandra * * @throws ConnectionException on error connecting to Cassandra */ - public UniqueValueSet load( CollectionScope collectionScope, Collection<Field> fields ) throws ConnectionException; + UniqueValueSet load( ApplicationScope applicationScope, String type, Collection<Field> fields ) throws ConnectionException; /** * Load UniqueValue that matches field from collection or null if that value does not exist. * * @param colScope Collection scope in which to look for field name/value * @param consistencyLevel Consistency level of query + * @param type The type the unique value exists within * @param fields Field name/value to search for * @return UniqueValueSet containing fields from the collection that exist in cassandra * @throws ConnectionException on error connecting to Cassandra */ - public UniqueValueSet load( CollectionScope colScope, ConsistencyLevel consistencyLevel, Collection<Field> fields ) throws ConnectionException; + UniqueValueSet load( ApplicationScope colScope, ConsistencyLevel consistencyLevel, String type, + Collection<Field> fields ) throws ConnectionException; /** * Loads the currently persisted history of every unique value the entity has held. This will * start from the max version and return values in descending version order. Note that for entities * with more than one unique field, sequential fields can be returned with the same version. - * @param collectionScope The scope the entity is stored in + * @param applicationScope The scope the entity is stored in * @param entityId * @return */ - public Iterator<UniqueValue> getAllUniqueFields(CollectionScope collectionScope, Id entityId); + Iterator<UniqueValue> getAllUniqueFields( ApplicationScope applicationScope, Id entityId ); /** @@ -94,7 +101,7 @@ public interface UniqueValueSerializationStrategy extends Migration { * @param uniqueValue Object to be deleted. * @return MutatationBatch that encapsulates operation, caller may or may not execute. */ - public MutationBatch delete( CollectionScope scope, UniqueValue uniqueValue ); + MutationBatch delete( ApplicationScope scope, UniqueValue uniqueValue ); }
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c39be5da/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/LogEntryIterator.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/LogEntryIterator.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/LogEntryIterator.java index 2b99033..3ecc61d 100644 --- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/LogEntryIterator.java +++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/LogEntryIterator.java @@ -7,7 +7,7 @@ import java.util.NoSuchElementException; import java.util.UUID; import org.apache.usergrid.persistence.collection.CollectionScope; -import org.apache.usergrid.persistence.collection.mvcc.MvccLogEntrySerializationStrategy; +import org.apache.usergrid.persistence.collection.serialization.MvccLogEntrySerializationStrategy; import org.apache.usergrid.persistence.collection.MvccLogEntry; import org.apache.usergrid.persistence.model.entity.Id; http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c39be5da/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImpl.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImpl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImpl.java index ad1d91a..5b324db 100644 --- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImpl.java +++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImpl.java @@ -33,13 +33,14 @@ import org.apache.cassandra.db.marshal.BytesType; import org.apache.cassandra.db.marshal.ReversedType; import org.apache.cassandra.db.marshal.UUIDType; -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.collection.exception.CollectionRuntimeException; import org.apache.usergrid.persistence.collection.exception.DataCorruptionException; import org.apache.usergrid.persistence.collection.mvcc.entity.impl.MvccEntityImpl; import org.apache.usergrid.persistence.collection.serialization.SerializationFig; +import org.apache.usergrid.persistence.collection.serialization.impl.util.LegacyScopeUtils; +import org.apache.usergrid.persistence.core.scope.ApplicationScope; import org.apache.usergrid.persistence.model.util.EntityUtils; import org.apache.usergrid.persistence.core.astyanax.CassandraFig; import org.apache.usergrid.persistence.core.astyanax.ColumnNameIterator; @@ -97,14 +98,14 @@ public abstract class MvccEntitySerializationStrategyImpl implements MvccEntityS @Override - public MutationBatch write( final CollectionScope collectionScope, final MvccEntity entity ) { - Preconditions.checkNotNull( collectionScope, "collectionScope is required" ); + public MutationBatch write( final ApplicationScope applicationScope, final MvccEntity entity ) { + Preconditions.checkNotNull( applicationScope, "applicationScope is required" ); Preconditions.checkNotNull( entity, "entity is required" ); final UUID colName = entity.getVersion(); final Id entityId = entity.getId(); - return doWrite( collectionScope, entityId, new RowOp() { + return doWrite( applicationScope, entityId, new RowOp() { @Override public void doOp( final ColumnListMutation<UUID> colMutation ) { colMutation.putColumn( colName, getEntitySerializer() @@ -115,11 +116,11 @@ public abstract class MvccEntitySerializationStrategyImpl implements MvccEntityS @Override - public EntitySet load( final CollectionScope collectionScope, final Collection<Id> entityIds, + public EntitySet load( final ApplicationScope applicationScope, final Collection<Id> entityIds, final UUID maxVersion ) { - Preconditions.checkNotNull( collectionScope, "collectionScope is required" ); + Preconditions.checkNotNull( applicationScope, "applicationScope is required" ); Preconditions.checkNotNull( entityIds, "entityIds is required" ); Preconditions.checkArgument( entityIds.size() > 0, "entityIds is required" ); Preconditions.checkNotNull( maxVersion, "version is required" ); @@ -130,15 +131,16 @@ public abstract class MvccEntitySerializationStrategyImpl implements MvccEntityS } - final Id applicationId = collectionScope.getApplication(); - final Id ownerId = collectionScope.getOwner(); - final String collectionName = collectionScope.getName(); - + final Id applicationId = applicationScope.getApplication(); + final Id ownerId = applicationId; final List<ScopedRowKey<CollectionPrefixedKey<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 ); @@ -190,7 +192,7 @@ public abstract class MvccEntitySerializationStrategyImpl implements MvccEntityS .withColumnRange( maxVersion, null, false, 1 ).execute().getResult(); } catch ( ConnectionException e ) { - throw new CollectionRuntimeException( null, collectionScope, + throw new CollectionRuntimeException( null, applicationScope, "An error occurred connecting to cassandra", e ); } } ).subscribeOn( scheduler ); @@ -230,18 +232,18 @@ public abstract class MvccEntitySerializationStrategyImpl implements MvccEntityS @Override - public Iterator<MvccEntity> loadDescendingHistory( final CollectionScope collectionScope, final Id entityId, + public Iterator<MvccEntity> loadDescendingHistory( final ApplicationScope applicationScope, final Id entityId, final UUID version, final int fetchSize ) { - Preconditions.checkNotNull( collectionScope, "collectionScope is required" ); + Preconditions.checkNotNull( applicationScope, "applicationScope is required" ); Preconditions.checkNotNull( entityId, "entity id is required" ); Preconditions.checkNotNull( version, "version is required" ); Preconditions.checkArgument( fetchSize > 0, "max Size must be greater than 0" ); - final Id applicationId = collectionScope.getApplication(); - final Id ownerId = collectionScope.getOwner(); - final String collectionName = collectionScope.getName(); + 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 ); @@ -260,18 +262,18 @@ public abstract class MvccEntitySerializationStrategyImpl implements MvccEntityS @Override - public Iterator<MvccEntity> loadAscendingHistory( final CollectionScope collectionScope, final Id entityId, + public Iterator<MvccEntity> loadAscendingHistory( final ApplicationScope applicationScope, final Id entityId, final UUID version, final int fetchSize ) { - Preconditions.checkNotNull( collectionScope, "collectionScope is required" ); + Preconditions.checkNotNull( applicationScope, "applicationScope is required" ); Preconditions.checkNotNull( entityId, "entity id is required" ); Preconditions.checkNotNull( version, "version is required" ); Preconditions.checkArgument( fetchSize > 0, "max Size must be greater than 0" ); - final Id applicationId = collectionScope.getApplication(); - final Id ownerId = collectionScope.getOwner(); - final String collectionName = collectionScope.getName(); + 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 ); @@ -290,7 +292,7 @@ public abstract class MvccEntitySerializationStrategyImpl implements MvccEntityS @Override - public Optional<MvccEntity> load( final CollectionScope scope, final Id entityId ) { + public Optional<MvccEntity> load( final ApplicationScope scope, final Id entityId ) { final EntitySet results = load( scope, Collections.singleton( entityId ), UUIDGenerator.newTimeUUID() ); return Optional.fromNullable( results.getEntity( entityId )); @@ -298,12 +300,12 @@ public abstract class MvccEntitySerializationStrategyImpl implements MvccEntityS @Override - public MutationBatch mark( final CollectionScope collectionScope, final Id entityId, final UUID version ) { - Preconditions.checkNotNull( collectionScope, "collectionScope is required" ); + public MutationBatch mark( final ApplicationScope applicationScope, final Id entityId, final UUID version ) { + Preconditions.checkNotNull( applicationScope, "applicationScope is required" ); Preconditions.checkNotNull( entityId, "entity id is required" ); Preconditions.checkNotNull( version, "version is required" ); - return doWrite( collectionScope, entityId, new RowOp() { + return doWrite( applicationScope, entityId, new RowOp() { @Override public void doOp( final ColumnListMutation<UUID> colMutation ) { colMutation.putColumn( version, getEntitySerializer() @@ -314,13 +316,13 @@ public abstract class MvccEntitySerializationStrategyImpl implements MvccEntityS @Override - public MutationBatch delete( final CollectionScope collectionScope, final Id entityId, final UUID version ) { - Preconditions.checkNotNull( collectionScope, "collectionScope is required" ); + public MutationBatch delete( final ApplicationScope applicationScope, final Id entityId, final UUID version ) { + Preconditions.checkNotNull( applicationScope, "applicationScope is required" ); Preconditions.checkNotNull( entityId, "entity id is required" ); Preconditions.checkNotNull( version, "version is required" ); - return doWrite( collectionScope, entityId, new RowOp() { + return doWrite( applicationScope, entityId, new RowOp() { @Override public void doOp( final ColumnListMutation<UUID> colMutation ) { colMutation.deleteColumn( version ); @@ -347,12 +349,12 @@ public abstract class MvccEntitySerializationStrategyImpl implements MvccEntityS /** * Do the write on the correct row for the entity id with the operation */ - private MutationBatch doWrite( final CollectionScope collectionScope, final Id entityId, final RowOp op ) { + private MutationBatch doWrite( final ApplicationScope applicationScope, final Id entityId, final RowOp op ) { final MutationBatch batch = keyspace.prepareMutationBatch(); - final Id applicationId = collectionScope.getApplication(); - final Id ownerId = collectionScope.getOwner(); - final String collectionName = collectionScope.getName(); + 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 ); http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c39be5da/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 b815ef4..bb143a4 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 @@ -22,7 +22,6 @@ import java.util.Collections; import java.util.Iterator; 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.collection.serialization.MvccEntitySerializationStrategy; @@ -31,6 +30,7 @@ import org.apache.usergrid.persistence.core.astyanax.MultiTennantColumnFamilyDef 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.common.base.Optional; @@ -64,7 +64,7 @@ public class MvccEntitySerializationStrategyProxyImpl implements MvccEntitySeria @Override - public MutationBatch write( final CollectionScope context, final MvccEntity entity ) { + public MutationBatch write( final ApplicationScope context, final MvccEntity entity ) { final MigrationRelationship<MvccEntitySerializationStrategy> migration = getMigrationRelationShip(); @@ -82,7 +82,7 @@ public class MvccEntitySerializationStrategyProxyImpl implements MvccEntitySeria @Override - public EntitySet load( final CollectionScope scope, final Collection<Id> entityIds, final UUID maxVersion ) { + public EntitySet load( final ApplicationScope scope, final Collection<Id> entityIds, final UUID maxVersion ) { final MigrationRelationship<MvccEntitySerializationStrategy> migration = getMigrationRelationShip(); @@ -96,7 +96,7 @@ public class MvccEntitySerializationStrategyProxyImpl implements MvccEntitySeria @Override - public Iterator<MvccEntity> loadDescendingHistory( final CollectionScope context, final Id entityId, + public Iterator<MvccEntity> loadDescendingHistory( final ApplicationScope context, final Id entityId, final UUID version, final int fetchSize ) { final MigrationRelationship<MvccEntitySerializationStrategy> migration = getMigrationRelationShip(); @@ -110,7 +110,7 @@ public class MvccEntitySerializationStrategyProxyImpl implements MvccEntitySeria @Override - public Iterator<MvccEntity> loadAscendingHistory( final CollectionScope context, final Id entityId, + public Iterator<MvccEntity> loadAscendingHistory( final ApplicationScope context, final Id entityId, final UUID version, final int fetchSize ) { final MigrationRelationship<MvccEntitySerializationStrategy> migration = getMigrationRelationShip(); @@ -123,7 +123,7 @@ public class MvccEntitySerializationStrategyProxyImpl implements MvccEntitySeria } @Override - public Optional<MvccEntity> load( final CollectionScope scope, final Id entityId ) { + public Optional<MvccEntity> load( final ApplicationScope scope, final Id entityId ) { final MigrationRelationship<MvccEntitySerializationStrategy> migration = getMigrationRelationShip(); @@ -136,7 +136,7 @@ public class MvccEntitySerializationStrategyProxyImpl implements MvccEntitySeria @Override - public MutationBatch mark( final CollectionScope context, final Id entityId, final UUID version ) { + public MutationBatch mark( final ApplicationScope context, final Id entityId, final UUID version ) { final MigrationRelationship<MvccEntitySerializationStrategy> migration = getMigrationRelationShip(); @@ -154,7 +154,7 @@ public class MvccEntitySerializationStrategyProxyImpl implements MvccEntitySeria @Override - public MutationBatch delete( final CollectionScope context, final Id entityId, final UUID version ) { + public MutationBatch delete( final ApplicationScope context, final Id entityId, final UUID version ) { final MigrationRelationship<MvccEntitySerializationStrategy> migration = getMigrationRelationShip(); http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c39be5da/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 de959b5..fe0d31d 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 @@ -24,6 +24,8 @@ import org.apache.usergrid.persistence.collection.exception.EntityTooLargeExcept 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.SerializationFig; +import org.apache.usergrid.persistence.collection.serialization.impl.util.LegacyScopeUtils; +import org.apache.usergrid.persistence.core.scope.ApplicationScope; import org.apache.usergrid.persistence.model.util.EntityUtils; import org.apache.usergrid.persistence.core.astyanax.CassandraFig; import org.apache.usergrid.persistence.core.astyanax.ColumnParser; @@ -103,14 +105,14 @@ public class MvccEntitySerializationStrategyV3Impl implements MvccEntitySerializ @Override - public MutationBatch write( final CollectionScope collectionScope, final MvccEntity entity ) { - Preconditions.checkNotNull( collectionScope, "collectionScope is required" ); + public MutationBatch write( final ApplicationScope applicationScope, final MvccEntity entity ) { + Preconditions.checkNotNull( applicationScope, "applicationScope is required" ); Preconditions.checkNotNull( entity, "entity is required" ); final Id entityId = entity.getId(); final UUID version = entity.getVersion(); - return doWrite( collectionScope, entityId, version, new RowOp() { + return doWrite( applicationScope, entityId, version, new RowOp() { @Override public void doOp( final ColumnListMutation<Boolean> colMutation ) { colMutation.putColumn( COL_VALUE, @@ -121,11 +123,11 @@ public class MvccEntitySerializationStrategyV3Impl implements MvccEntitySerializ @Override - public EntitySet load( final CollectionScope collectionScope, final Collection<Id> entityIds, + public EntitySet load( final ApplicationScope applicationScope, final Collection<Id> entityIds, final UUID maxVersion ) { - Preconditions.checkNotNull( collectionScope, "collectionScope is required" ); + Preconditions.checkNotNull( applicationScope, "applicationScope is required" ); Preconditions.checkNotNull( entityIds, "entityIds is required" ); Preconditions.checkArgument( entityIds.size() > 0, "entityIds is required" ); Preconditions.checkNotNull( maxVersion, "version is required" ); @@ -137,15 +139,17 @@ public class MvccEntitySerializationStrategyV3Impl implements MvccEntitySerializ } - final Id applicationId = collectionScope.getApplication(); - final Id ownerId = collectionScope.getOwner(); - final String collectionName = collectionScope.getName(); + final Id applicationId = applicationScope.getApplication(); + final Id ownerId = applicationId; final List<ScopedRowKey<CollectionPrefixedKey<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 ); @@ -199,7 +203,7 @@ public class MvccEntitySerializationStrategyV3Impl implements MvccEntitySerializ .withColumnSlice( COL_VALUE ).execute().getResult(); } catch ( ConnectionException e ) { - throw new CollectionRuntimeException( null, collectionScope, + throw new CollectionRuntimeException( null, applicationScope, "An error occurred connecting to cassandra", e ); } } ).subscribeOn( scheduler ); @@ -240,10 +244,10 @@ public class MvccEntitySerializationStrategyV3Impl implements MvccEntitySerializ @Override - public Iterator<MvccEntity> loadDescendingHistory( final CollectionScope collectionScope, final Id entityId, + public Iterator<MvccEntity> loadDescendingHistory( final ApplicationScope applicationScope, final Id entityId, final UUID version, final int fetchSize ) { - Preconditions.checkNotNull( collectionScope, "collectionScope is required" ); + Preconditions.checkNotNull( applicationScope, "applicationScope is required" ); Preconditions.checkNotNull( entityId, "entity id is required" ); Preconditions.checkNotNull( version, "version is required" ); Preconditions.checkArgument( fetchSize > 0, "max Size must be greater than 0" ); @@ -255,10 +259,10 @@ public class MvccEntitySerializationStrategyV3Impl implements MvccEntitySerializ @Override - public Iterator<MvccEntity> loadAscendingHistory( final CollectionScope collectionScope, final Id entityId, + public Iterator<MvccEntity> loadAscendingHistory( final ApplicationScope applicationScope, final Id entityId, final UUID version, final int fetchSize ) { - Preconditions.checkNotNull( collectionScope, "collectionScope is required" ); + Preconditions.checkNotNull( applicationScope, "applicationScope is required" ); Preconditions.checkNotNull( entityId, "entity id is required" ); Preconditions.checkNotNull( version, "version is required" ); Preconditions.checkArgument( fetchSize > 0, "max Size must be greater than 0" ); @@ -268,7 +272,7 @@ public class MvccEntitySerializationStrategyV3Impl implements MvccEntitySerializ @Override - public Optional<MvccEntity> load( final CollectionScope scope, final Id entityId ) { + public Optional<MvccEntity> load( final ApplicationScope scope, final Id entityId ) { final EntitySet results = load( scope, Collections.singleton( entityId ), UUIDGenerator.newTimeUUID() ); return Optional.fromNullable( results.getEntity( entityId )); @@ -276,13 +280,13 @@ public class MvccEntitySerializationStrategyV3Impl implements MvccEntitySerializ @Override - public MutationBatch mark( final CollectionScope collectionScope, final Id entityId, final UUID version ) { - Preconditions.checkNotNull( collectionScope, "collectionScope is required" ); + public MutationBatch mark( final ApplicationScope applicationScope, final Id entityId, final UUID version ) { + Preconditions.checkNotNull( applicationScope, "applicationScope is required" ); Preconditions.checkNotNull( entityId, "entity id is required" ); Preconditions.checkNotNull( version, "version is required" ); - return doWrite( collectionScope, entityId, version, new RowOp() { + return doWrite( applicationScope, entityId, version, new RowOp() { @Override public void doOp( final ColumnListMutation<Boolean> colMutation ) { colMutation.putColumn( COL_VALUE, entitySerializer.toByteBuffer( @@ -293,13 +297,13 @@ public class MvccEntitySerializationStrategyV3Impl implements MvccEntitySerializ @Override - public MutationBatch delete( final CollectionScope collectionScope, final Id entityId, final UUID version ) { - Preconditions.checkNotNull( collectionScope, "collectionScope is required" ); + public MutationBatch delete( final ApplicationScope applicationScope, final Id entityId, final UUID version ) { + Preconditions.checkNotNull( applicationScope, "applicationScope is required" ); Preconditions.checkNotNull( entityId, "entity id is required" ); Preconditions.checkNotNull( version, "version is required" ); - return doWrite( collectionScope, entityId, version, new RowOp() { + return doWrite( applicationScope, entityId, version, new RowOp() { @Override public void doOp( final ColumnListMutation<Boolean> colMutation ) { colMutation.deleteColumn( Boolean.TRUE ); @@ -326,12 +330,12 @@ public class MvccEntitySerializationStrategyV3Impl implements MvccEntitySerializ /** * Do the write on the correct row for the entity id with the operation */ - private MutationBatch doWrite( final CollectionScope collectionScope, final Id entityId, final UUID version, final RowOp op ) { + private MutationBatch doWrite( final ApplicationScope applicationScope, final Id entityId, final UUID version, final RowOp op ) { final MutationBatch batch = keyspace.prepareMutationBatch(); - final Id applicationId = collectionScope.getApplication(); - final Id ownerId = collectionScope.getOwner(); - final String collectionName = collectionScope.getName(); + 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 ); http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c39be5da/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 831091d..b915625 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 @@ -36,19 +36,19 @@ 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.CollectionScope; import org.apache.usergrid.persistence.collection.MvccLogEntry; import org.apache.usergrid.persistence.collection.VersionSet; import org.apache.usergrid.persistence.collection.exception.CollectionRuntimeException; -import org.apache.usergrid.persistence.collection.mvcc.MvccLogEntrySerializationStrategy; +import org.apache.usergrid.persistence.collection.serialization.MvccLogEntrySerializationStrategy; import org.apache.usergrid.persistence.collection.mvcc.entity.Stage; import org.apache.usergrid.persistence.collection.mvcc.entity.impl.MvccLogEntryImpl; 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.core.migration.schema.Migration; +import org.apache.usergrid.persistence.core.scope.ApplicationScope; import org.apache.usergrid.persistence.model.entity.Id; import com.google.common.base.Preconditions; @@ -98,7 +98,7 @@ public class MvccLogEntrySerializationStrategyImpl implements MvccLogEntrySerial @Override - public MutationBatch write( final CollectionScope collectionScope, final MvccLogEntry entry ) { + public MutationBatch write( final ApplicationScope collectionScope, final MvccLogEntry entry ) { Preconditions.checkNotNull( collectionScope, "collectionScope is required" ); Preconditions.checkNotNull( entry, "entry is required" ); @@ -126,7 +126,7 @@ public class MvccLogEntrySerializationStrategyImpl implements MvccLogEntrySerial @Override - public VersionSet load( final CollectionScope collectionScope, final Collection<Id> entityIds, + public VersionSet load( final ApplicationScope collectionScope, final Collection<Id> entityIds, final UUID maxVersion ) { Preconditions.checkNotNull( collectionScope, "collectionScope is required" ); Preconditions.checkNotNull( entityIds, "entityIds is required" ); @@ -140,14 +140,17 @@ public class MvccLogEntrySerializationStrategyImpl implements MvccLogEntrySerial final Id applicationId = collectionScope.getApplication(); - final Id ownerId = collectionScope.getOwner(); - final String collectionName = collectionScope.getName(); + final Id ownerId = applicationId; + final List<ScopedRowKey<CollectionPrefixedKey<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 ); @@ -207,7 +210,7 @@ public class MvccLogEntrySerializationStrategyImpl implements MvccLogEntrySerial @Override - public List<MvccLogEntry> load( final CollectionScope collectionScope, final Id entityId, final UUID version, + public List<MvccLogEntry> load( final ApplicationScope collectionScope, final Id entityId, final UUID version, final int maxSize ) { Preconditions.checkNotNull( collectionScope, "collectionScope is required" ); Preconditions.checkNotNull( entityId, "entity id is required" ); @@ -219,8 +222,8 @@ public class MvccLogEntrySerializationStrategyImpl implements MvccLogEntrySerial try { final Id applicationId = collectionScope.getApplication(); - final Id ownerId = collectionScope.getOwner(); - final String collectionName = collectionScope.getName(); + final Id ownerId = applicationId; + final String collectionName = LegacyScopeUtils.getCollectionScopeNameFromEntityType( entityId.getType() ); final CollectionPrefixedKey<Id> collectionPrefixedKey = @@ -253,7 +256,7 @@ public class MvccLogEntrySerializationStrategyImpl implements MvccLogEntrySerial @Override - public MutationBatch delete( final CollectionScope context, final Id entityId, final UUID version ) { + public MutationBatch delete( final ApplicationScope context, final Id entityId, final UUID version ) { Preconditions.checkNotNull( context, "context is required" ); Preconditions.checkNotNull( entityId, "entityId is required" ); @@ -299,7 +302,7 @@ public class MvccLogEntrySerializationStrategyImpl implements MvccLogEntrySerial * * @param collectionScope We need to use this when getting the keyspace */ - private MutationBatch doWrite( CollectionScope collectionScope, Id entityId, UUID version, RowOp op ) { + private MutationBatch doWrite( ApplicationScope collectionScope, Id entityId, UUID version, RowOp op ) { final MutationBatch batch = keyspace.prepareMutationBatch(); @@ -308,8 +311,8 @@ public class MvccLogEntrySerializationStrategyImpl implements MvccLogEntrySerial LOG.debug( "Writing version with timestamp '{}'", timestamp ); final Id applicationId = collectionScope.getApplication(); - final Id ownerId = collectionScope.getOwner(); - final String collectionName = collectionScope.getName(); + final Id ownerId = applicationId; + final String collectionName = LegacyScopeUtils.getCollectionScopeNameFromEntityType( entityId.getType() ); final CollectionPrefixedKey<Id> collectionPrefixedKey = http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c39be5da/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 9d6d7fb..1ebc0ca 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 @@ -18,7 +18,7 @@ package org.apache.usergrid.persistence.collection.serialization.impl; -import org.apache.usergrid.persistence.collection.mvcc.MvccLogEntrySerializationStrategy; +import org.apache.usergrid.persistence.collection.serialization.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; http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c39be5da/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueValueSerializationStrategyImpl.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueValueSerializationStrategyImpl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueValueSerializationStrategyImpl.java index c95650c..86ad706 100644 --- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueValueSerializationStrategyImpl.java +++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueValueSerializationStrategyImpl.java @@ -26,13 +26,14 @@ import java.util.List; import java.util.UUID; import com.netflix.astyanax.model.ConsistencyLevel; + +import org.apache.usergrid.persistence.collection.serialization.impl.util.LegacyScopeUtils; import org.apache.usergrid.persistence.core.astyanax.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.apache.cassandra.db.marshal.BytesType; -import org.apache.usergrid.persistence.collection.CollectionScope; import org.apache.usergrid.persistence.collection.serialization.SerializationFig; import org.apache.usergrid.persistence.collection.serialization.UniqueValue; import org.apache.usergrid.persistence.collection.serialization.UniqueValueSerializationStrategy; @@ -44,6 +45,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.scope.ApplicationScope; import org.apache.usergrid.persistence.core.util.ValidationUtils; import org.apache.usergrid.persistence.model.entity.Id; import org.apache.usergrid.persistence.model.field.Field; @@ -113,7 +115,7 @@ public class UniqueValueSerializationStrategyImpl implements UniqueValueSerializ } - public MutationBatch write( final CollectionScope collectionScope, UniqueValue value ) { + public MutationBatch write( final ApplicationScope collectionScope, UniqueValue value ) { Preconditions.checkNotNull( value, "value is required" ); @@ -126,9 +128,6 @@ public class UniqueValueSerializationStrategyImpl implements UniqueValueSerializ ValidationUtils.verifyIdentity( entityId ); ValidationUtils.verifyVersion( entityVersion ); - log.debug( "Writing unique value collectionScope={} id={} version={} name={} value={} ttl={} ", new Object[] { - collectionScope.getName(), entityId, entityVersion, value.getField().getName(), value.getField().getValue() - } ); final EntityVersion ev = new EntityVersion( entityId, entityVersion ); final UniqueFieldEntry uniqueFieldEntry = new UniqueFieldEntry( entityVersion, field ); @@ -150,7 +149,7 @@ public class UniqueValueSerializationStrategyImpl implements UniqueValueSerializ @Override - public MutationBatch write( final CollectionScope collectionScope, final UniqueValue value, final int timeToLive ) { + public MutationBatch write( final ApplicationScope collectionScope, final UniqueValue value, final int timeToLive ) { Preconditions.checkNotNull( value, "value is required" ); Preconditions.checkArgument( timeToLive > 0, "timeToLive must be greater than 0 is required" ); @@ -184,7 +183,7 @@ public class UniqueValueSerializationStrategyImpl implements UniqueValueSerializ @Override - public MutationBatch delete( final CollectionScope scope, UniqueValue value ) { + public MutationBatch delete( final ApplicationScope scope, UniqueValue value ) { Preconditions.checkNotNull( value, "value is required" ); @@ -219,27 +218,42 @@ public class UniqueValueSerializationStrategyImpl implements UniqueValueSerializ /** * Do the column update or delete for the given column and row key * - * @param collectionScope We need to use this when getting the keyspace + * @param applicationScope We need to use this when getting the keyspace + * @param uniqueValue The unique value to write + * @param op The operation to write */ - private MutationBatch doWrite( CollectionScope collectionScope, UniqueValue uniqueValue, RowOp op ) { + private MutationBatch doWrite( ApplicationScope applicationScope, UniqueValue uniqueValue, RowOp op ) { final MutationBatch batch = keyspace.prepareMutationBatch(); + + final Id applicationId = applicationScope.getApplication(); + final Id uniqueValueId = uniqueValue.getEntityId(); + + final String collectionName = LegacyScopeUtils.getCollectionScopeNameFromEntityType( uniqueValueId.getType() ); + final CollectionPrefixedKey<Field> uniquePrefixedKey = - new CollectionPrefixedKey<>( collectionScope.getName(), collectionScope.getOwner(), uniqueValue.getField() ); + new CollectionPrefixedKey<>( collectionName, applicationId, uniqueValue.getField() ); op.doLookup( batch - .withRow( CF_UNIQUE_VALUES, ScopedRowKey.fromKey( collectionScope.getApplication(), uniquePrefixedKey ) ) ); + .withRow( CF_UNIQUE_VALUES, ScopedRowKey.fromKey( applicationId, uniquePrefixedKey ) ) ); - final Id ownerId = collectionScope.getOwner(); - final String collectionName = collectionScope.getName(); + final Id ownerId = applicationId; final CollectionPrefixedKey<Id> collectionPrefixedEntityKey = new CollectionPrefixedKey<>( collectionName, ownerId, uniqueValue.getEntityId() ); op.doLog( batch.withRow( CF_ENTITY_UNIQUE_VALUES, - ScopedRowKey.fromKey( collectionScope.getApplication(), collectionPrefixedEntityKey ) ) ); + ScopedRowKey.fromKey( applicationId, collectionPrefixedEntityKey ) ) ); + + + if(log.isDebugEnabled()) { + log.debug( "Writing unique value collectionScope={} id={} version={} name={} value={} ttl={} ", new + Object[] { + collectionName, uniqueValueId, uniqueValue.getEntityVersion(), uniqueValue.getField().getName(), uniqueValue.getField().getValue() + } ); + } return batch; @@ -248,11 +262,12 @@ public class UniqueValueSerializationStrategyImpl implements UniqueValueSerializ @Override - public UniqueValueSet load(final CollectionScope colScope, final Collection<Field> fields ) throws ConnectionException{ - return load(colScope,ConsistencyLevel.valueOf(cassandraFig.getReadCL()), fields); + public UniqueValueSet load(final ApplicationScope colScope, final String type, final Collection<Field> fields ) throws ConnectionException{ + return load(colScope,ConsistencyLevel.valueOf(cassandraFig.getReadCL()), type, fields); } + @Override - public UniqueValueSet load(final CollectionScope colScope, final ConsistencyLevel consistencyLevel, final Collection<Field> fields ) + public UniqueValueSet load(final ApplicationScope appScope, final ConsistencyLevel consistencyLevel, final String type, final Collection<Field> fields ) throws ConnectionException { Preconditions.checkNotNull( fields, "fields are required" ); @@ -261,9 +276,9 @@ public class UniqueValueSerializationStrategyImpl implements UniqueValueSerializ final List<ScopedRowKey<CollectionPrefixedKey<Field>>> keys = new ArrayList<>( fields.size() ); - final Id applicationId = colScope.getApplication(); - final Id ownerId = colScope.getOwner(); - final String collectionName = colScope.getName(); + final Id applicationId = appScope.getApplication(); + final Id ownerId = appScope.getApplication(); + final String collectionName = LegacyScopeUtils.getCollectionScopeNameFromEntityType( type ); for ( Field field : fields ) { @@ -312,7 +327,7 @@ public class UniqueValueSerializationStrategyImpl implements UniqueValueSerializ @Override - public Iterator<UniqueValue> getAllUniqueFields( final CollectionScope collectionScope, final Id entityId ) { + public Iterator<UniqueValue> getAllUniqueFields( final ApplicationScope collectionScope, final Id entityId ) { Preconditions.checkNotNull( collectionScope, "collectionScope is required" ); @@ -320,8 +335,8 @@ public class UniqueValueSerializationStrategyImpl implements UniqueValueSerializ final Id applicationId = collectionScope.getApplication(); - final Id ownerId = collectionScope.getOwner(); - final String collectionName = collectionScope.getName(); + final Id ownerId = applicationId; + final String collectionName = LegacyScopeUtils.getCollectionScopeNameFromEntityType( entityId.getType() ); final CollectionPrefixedKey<Id> collectionPrefixedKey = new CollectionPrefixedKey<>( collectionName, ownerId, entityId ); http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c39be5da/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/util/Inflector.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/util/Inflector.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/util/Inflector.java new file mode 100644 index 0000000..eab69fa --- /dev/null +++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/util/Inflector.java @@ -0,0 +1,370 @@ +/* + * 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.util; + + +import java.util.HashSet; +import java.util.LinkedList; +import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + + +/** + * Transforms words to singular, plural, humanized (human readable), underscore, camel case, or ordinal form. This is + * inspired by the <a href="http://api.rubyonrails.org/classes/Inflector.html">Inflector</a> class in <a + * href="http://www.rubyonrails.org">Ruby on Rails</a>, which is distributed under the <a + * href="http://wiki.rubyonrails.org/rails/pages/License">Rails license</a>. + */ +public class Inflector { + + protected static final Inflector INSTANCE = new Inflector(); + + + public static Inflector getInstance() { + return INSTANCE; + } + + + protected class Rule { + + protected final String expression; + protected final Pattern expressionPattern; + protected final String replacement; + + + protected Rule( String expression, String replacement ) { + this.expression = expression; + this.replacement = replacement != null ? replacement : ""; + expressionPattern = Pattern.compile( this.expression, Pattern.CASE_INSENSITIVE ); + } + + + /** + * Apply the rule against the input string, returning the modified string or null if the rule didn't apply (and + * no modifications were made) + * + * @param input the input string + * + * @return the modified string if this rule applied, or null if the input was not modified by this rule + */ + protected String apply( String input ) { + Matcher matcher = expressionPattern.matcher( input ); + if ( !matcher.find() ) { + return null; + } + return matcher.replaceAll( replacement ); + } + + + @Override + public int hashCode() { + return expression.hashCode(); + } + + + @Override + public boolean equals( Object obj ) { + if ( obj == this ) { + return true; + } + if ( ( obj != null ) && ( obj.getClass() == this.getClass() ) ) { + final Rule that = ( Rule ) obj; + if ( expression.equalsIgnoreCase( that.expression ) ) { + return true; + } + } + return false; + } + + + @Override + public String toString() { + return expression + ", " + replacement; + } + } + + + private final LinkedList<Rule> plurals = new LinkedList<Rule>(); + private final LinkedList<Rule> singulars = new LinkedList<Rule>(); + /** + * The lowercase words that are to be excluded and not processed. This map can be modified by the users via {@link + * #getUncountables()}. + */ + private final Set<String> uncountables = new HashSet<String>(); + + + public Inflector() { + initialize(); + } + + + protected Inflector( Inflector original ) { + plurals.addAll( original.plurals ); + singulars.addAll( original.singulars ); + uncountables.addAll( original.uncountables ); + } + + + @Override + @SuppressWarnings("all") + public Inflector clone() { + return new Inflector( this ); + } + + // ------------------------------------------------------------------------------------------------ + // Usage functions + // ------------------------------------------------------------------------------------------------ + + + /** + * Returns the plural form of the word in the string. <p> Examples: <p/> + * <pre> + * inflector.pluralize("post") #=> "posts" + * inflector.pluralize("octopus") #=> "octopi" + * inflector.pluralize("sheep") #=> "sheep" + * inflector.pluralize("words") #=> "words" + * inflector.pluralize("the blue mailman") #=> "the blue mailmen" + * inflector.pluralize("CamelOctopus") #=> "CamelOctopi" + * </pre> + * <p/> </p> <p> Note that if the {@link Object#toString()} is called on the supplied object, so this method works + * for non-strings, too. </p> + * + * @param word the word that is to be pluralized. + * + * @return the pluralized form of the word, or the word itself if it could not be pluralized + * + * @see #singularize(Object) + */ + public String pluralize( Object word ) { + if ( word == null ) { + return null; + } + String wordStr = word.toString().trim(); + if ( wordStr.length() == 0 ) { + return wordStr; + } + if ( isUncountable( wordStr ) ) { + return wordStr; + } + for ( Rule rule : plurals ) { + String result = rule.apply( wordStr ); + if ( result != null ) { + return result; + } + } + return wordStr; + } + + + public String pluralize( Object word, int count ) { + if ( word == null ) { + return null; + } + if ( ( count == 1 ) || ( count == -1 ) ) { + return word.toString(); + } + return pluralize( word ); + } + + + + /** + * Returns the singular form of the word in the string. <p> Examples: <p/> + * <pre> + * inflector.singularize("posts") #=> "post" + * inflector.singularize("octopi") #=> "octopus" + * inflector.singularize("sheep") #=> "sheep" + * inflector.singularize("words") #=> "word" + * inflector.singularize("the blue mailmen") #=> "the blue mailman" + * inflector.singularize("CamelOctopi") #=> "CamelOctopus" + * </pre> + * <p/> </p> <p> Note that if the {@link Object#toString()} is called on the supplied object, so this method works + * for non-strings, too. </p> + * + * @param word the word that is to be pluralized. + * + * @return the pluralized form of the word, or the word itself if it could not be pluralized + * + * @see #pluralize(Object) + */ + public String singularize( Object word ) { + if ( word == null ) { + return null; + } + String wordStr = word.toString().trim(); + if ( wordStr.length() == 0 ) { + return wordStr; + } + if ( isUncountable( wordStr ) ) { + return wordStr; + } + for ( Rule rule : singulars ) { + String result = rule.apply( wordStr ); + if ( result != null ) { + return result; + } + } + return wordStr; + } + + + + // ------------------------------------------------------------------------------------------------ + // Management methods + // ------------------------------------------------------------------------------------------------ + + + /** + * Determine whether the supplied word is considered uncountable by the {@link #pluralize(Object) pluralize} and + * {@link #singularize(Object) singularize} methods. + * + * @param word the word + * + * @return true if the plural and singular forms of the word are the same + */ + public boolean isUncountable( String word ) { + if ( word == null ) { + return false; + } + String trimmedLower = word.trim().toLowerCase(); + return uncountables.contains( trimmedLower ); + } + + + public void addPluralize( String rule, String replacement ) { + final Rule pluralizeRule = new Rule( rule, replacement ); + plurals.addFirst( pluralizeRule ); + } + + + public void addSingularize( String rule, String replacement ) { + final Rule singularizeRule = new Rule( rule, replacement ); + singulars.addFirst( singularizeRule ); + } + + + public void addIrregular( String singular, String plural ) { + if ( org.apache.commons.lang.StringUtils.isEmpty( singular ) ) { + throw new IllegalArgumentException( "singular rule may not be empty" ); + } + if ( org.apache.commons.lang.StringUtils.isEmpty( plural ) ) { + throw new IllegalArgumentException( "plural rule may not be empty" ); + } + String singularRemainder = singular.length() > 1 ? singular.substring( 1 ) : ""; + String pluralRemainder = plural.length() > 1 ? plural.substring( 1 ) : ""; + addPluralize( "(" + singular.charAt( 0 ) + ")" + singularRemainder + "$", "$1" + pluralRemainder ); + addSingularize( "(" + plural.charAt( 0 ) + ")" + pluralRemainder + "$", "$1" + singularRemainder ); + } + + + public void addUncountable( String... words ) { + if ( ( words == null ) || ( words.length == 0 ) ) { + return; + } + for ( String word : words ) { + if ( word != null ) { + uncountables.add( word.trim().toLowerCase() ); + } + } + } + + + /** Completely remove all rules within this inflector. */ + public void clear() { + uncountables.clear(); + plurals.clear(); + singulars.clear(); + } + + + protected void initialize() { + Inflector inflect = this; + inflect.addPluralize( "$", "s" ); + inflect.addPluralize( "s$", "s" ); + inflect.addPluralize( "(ax|test)is$", "$1es" ); + inflect.addPluralize( "(octop|vir)us$", "$1i" ); + inflect.addPluralize( "(octop|vir)i$", "$1i" ); // already plural + inflect.addPluralize( "(alias|status)$", "$1es" ); + inflect.addPluralize( "(bu)s$", "$1ses" ); + inflect.addPluralize( "(buffal|tomat)o$", "$1oes" ); + inflect.addPluralize( "([ti])um$", "$1a" ); + inflect.addPluralize( "([ti])a$", "$1a" ); // already plural + inflect.addPluralize( "sis$", "ses" ); + inflect.addPluralize( "(?:([^f])fe|([lr])f)$", "$1$2ves" ); + inflect.addPluralize( "(hive)$", "$1s" ); + inflect.addPluralize( "([^aeiouy]|qu)y$", "$1ies" ); + inflect.addPluralize( "(x|ch|ss|sh)$", "$1es" ); + inflect.addPluralize( "(matr|vert|ind)ix|ex$", "$1ices" ); + inflect.addPluralize( "([m|l])ouse$", "$1ice" ); + inflect.addPluralize( "([m|l])ice$", "$1ice" ); + inflect.addPluralize( "^(ox)$", "$1en" ); + inflect.addPluralize( "(quiz)$", "$1zes" ); + // Need to check for the following words that are already pluralized: + inflect.addPluralize( "(people|men|children|sexes|moves|stadiums)$", "$1" ); // irregulars + inflect.addPluralize( "(oxen|octopi|viri|aliases|quizzes)$", "$1" ); // special + // rules + + inflect.addSingularize( "s$", "" ); + inflect.addSingularize( "(s|si|u)s$", "$1s" ); // '-us' and '-ss' are + // already singular + inflect.addSingularize( "(n)ews$", "$1ews" ); + inflect.addSingularize( "([ti])a$", "$1um" ); + inflect.addSingularize( "((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$", "$1$2sis" ); + inflect.addSingularize( "(^analy)ses$", "$1sis" ); + inflect.addSingularize( "(^analy)sis$", "$1sis" ); // already singular, + // but ends in 's' + inflect.addSingularize( "([^f])ves$", "$1fe" ); + inflect.addSingularize( "(hive)s$", "$1" ); + inflect.addSingularize( "(tive)s$", "$1" ); + inflect.addSingularize( "([lr])ves$", "$1f" ); + inflect.addSingularize( "([^aeiouy]|qu)ies$", "$1y" ); + inflect.addSingularize( "(s)eries$", "$1eries" ); + inflect.addSingularize( "(m)ovies$", "$1ovie" ); + inflect.addSingularize( "(x|ch|ss|sh)es$", "$1" ); + inflect.addSingularize( "([m|l])ice$", "$1ouse" ); + inflect.addSingularize( "(bus)es$", "$1" ); + inflect.addSingularize( "(o)es$", "$1" ); + inflect.addSingularize( "(shoe)s$", "$1" ); + inflect.addSingularize( "(cris|ax|test)is$", "$1is" ); // already + // singular, but + // ends in 's' + inflect.addSingularize( "(cris|ax|test)es$", "$1is" ); + inflect.addSingularize( "(octop|vir)i$", "$1us" ); + inflect.addSingularize( "(octop|vir)us$", "$1us" ); // already singular, + // but ends in 's' + inflect.addSingularize( "(alias|status)es$", "$1" ); + inflect.addSingularize( "(alias|status)$", "$1" ); // already singular, + // but ends in 's' + inflect.addSingularize( "^(ox)en", "$1" ); + inflect.addSingularize( "(vert|ind)ices$", "$1ex" ); + inflect.addSingularize( "(matr)ices$", "$1ix" ); + inflect.addSingularize( "(quiz)zes$", "$1" ); + + inflect.addIrregular( "person", "people" ); + inflect.addIrregular( "man", "men" ); + inflect.addIrregular( "child", "children" ); + inflect.addIrregular( "sex", "sexes" ); + inflect.addIrregular( "move", "moves" ); + inflect.addIrregular( "stadium", "stadiums" ); + + inflect.addUncountable( "equipment", "information", "rice", "money", "species", "series", "fish", "sheep", + "data", "analytics" ); + } +} http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c39be5da/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/util/LegacyScopeUtils.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/util/LegacyScopeUtils.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/util/LegacyScopeUtils.java new file mode 100644 index 0000000..d538685 --- /dev/null +++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/util/LegacyScopeUtils.java @@ -0,0 +1,57 @@ +/* + * 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.util; + + +import org.apache.usergrid.persistence.collection.CollectionScope; +import org.apache.usergrid.persistence.collection.impl.CollectionScopeImpl; +import org.apache.usergrid.persistence.core.scope.ApplicationScope; +import org.apache.usergrid.persistence.model.entity.Id; + + +/** + * This class is a helper to keep our legacy CollectionScope for older serialization apis. This will generate + * the scope in the same way previous scopes were generated in the core module. This only exists to migrate + * perviously collection scoped Api's to versions without them. + * This can be removed once we do an official release and prune our impls. + */ +public class LegacyScopeUtils { + + /** + * Edge types for collection suffix + */ + public static final String EDGE_COLL_SUFFIX = "zzzcollzzz"; + + + + /** + * Get the collection name from the entity/id type + * @param type + * @return + */ + public static String getCollectionScopeNameFromEntityType( String type ) { + String csn = EDGE_COLL_SUFFIX + Inflector.INSTANCE.pluralize( type ); + return csn.toLowerCase(); + } + + + + +} http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c39be5da/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/impl/EntityVersionCleanupTaskTest.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/impl/EntityVersionCleanupTaskTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/impl/EntityVersionCleanupTaskTest.java index 787ab30..1e9dae7 100644 --- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/impl/EntityVersionCleanupTaskTest.java +++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/impl/EntityVersionCleanupTaskTest.java @@ -19,7 +19,6 @@ package org.apache.usergrid.persistence.collection.impl; -import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -29,16 +28,12 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.Semaphore; import org.junit.AfterClass; -import org.junit.Ignore; import org.junit.Test; import org.apache.usergrid.persistence.collection.CollectionScope; -import org.apache.usergrid.persistence.collection.MvccEntity; import org.apache.usergrid.persistence.collection.MvccLogEntry; import org.apache.usergrid.persistence.collection.event.EntityVersionDeleted; -import org.apache.usergrid.persistence.collection.mvcc.MvccLogEntrySerializationStrategy; -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.MvccLogEntrySerializationStrategy; import org.apache.usergrid.persistence.collection.serialization.SerializationFig; import org.apache.usergrid.persistence.collection.serialization.UniqueValue; import org.apache.usergrid.persistence.collection.serialization.UniqueValueSerializationStrategy; @@ -47,12 +42,9 @@ import org.apache.usergrid.persistence.collection.util.UniqueValueEntryMock; import org.apache.usergrid.persistence.collection.util.VersionGenerator; import org.apache.usergrid.persistence.core.task.NamedTaskExecutorImpl; import org.apache.usergrid.persistence.core.task.TaskExecutor; -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.common.base.Optional; import com.google.common.util.concurrent.ListenableFuture; import com.netflix.astyanax.Keyspace; import com.netflix.astyanax.MutationBatch; @@ -63,7 +55,6 @@ import static org.mockito.Matchers.any; import static org.mockito.Matchers.same; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; -import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c39be5da/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/MarkCommitTest.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/MarkCommitTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/MarkCommitTest.java index bbc791d..9a806d0 100644 --- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/MarkCommitTest.java +++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/MarkCommitTest.java @@ -6,7 +6,7 @@ import org.mockito.ArgumentCaptor; import org.apache.usergrid.persistence.collection.CollectionScope; import org.apache.usergrid.persistence.collection.serialization.MvccEntitySerializationStrategy; -import org.apache.usergrid.persistence.collection.mvcc.MvccLogEntrySerializationStrategy; +import org.apache.usergrid.persistence.collection.serialization.MvccLogEntrySerializationStrategy; import org.apache.usergrid.persistence.collection.MvccEntity; import org.apache.usergrid.persistence.collection.MvccLogEntry; import org.apache.usergrid.persistence.collection.mvcc.entity.Stage; http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c39be5da/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/MarkStartTest.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/MarkStartTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/MarkStartTest.java index 6c13dd5..d308fec 100644 --- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/MarkStartTest.java +++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/MarkStartTest.java @@ -7,7 +7,7 @@ import org.junit.Test; import org.mockito.ArgumentCaptor; import org.apache.usergrid.persistence.collection.CollectionScope; -import org.apache.usergrid.persistence.collection.mvcc.MvccLogEntrySerializationStrategy; +import org.apache.usergrid.persistence.collection.serialization.MvccLogEntrySerializationStrategy; import org.apache.usergrid.persistence.collection.MvccEntity; import org.apache.usergrid.persistence.collection.MvccLogEntry; import org.apache.usergrid.persistence.collection.mvcc.entity.Stage; http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c39be5da/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteCommitTest.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteCommitTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteCommitTest.java index 2b49478..c21a403 100644 --- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteCommitTest.java +++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteCommitTest.java @@ -23,7 +23,7 @@ import org.mockito.ArgumentCaptor; import org.apache.usergrid.persistence.collection.CollectionScope; import org.apache.usergrid.persistence.collection.serialization.MvccEntitySerializationStrategy; -import org.apache.usergrid.persistence.collection.mvcc.MvccLogEntrySerializationStrategy; +import org.apache.usergrid.persistence.collection.serialization.MvccLogEntrySerializationStrategy; import org.apache.usergrid.persistence.collection.MvccEntity; import org.apache.usergrid.persistence.collection.MvccLogEntry; import org.apache.usergrid.persistence.collection.mvcc.entity.Stage; http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c39be5da/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteOptimisticVerifyTest.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteOptimisticVerifyTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteOptimisticVerifyTest.java index 8f64b38..06640f0 100644 --- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteOptimisticVerifyTest.java +++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteOptimisticVerifyTest.java @@ -29,7 +29,7 @@ import org.slf4j.LoggerFactory; import org.apache.usergrid.persistence.collection.CollectionScope; import org.apache.usergrid.persistence.collection.exception.WriteOptimisticVerifyException; import org.apache.usergrid.persistence.collection.guice.TestCollectionModule; -import org.apache.usergrid.persistence.collection.mvcc.MvccLogEntrySerializationStrategy; +import org.apache.usergrid.persistence.collection.serialization.MvccLogEntrySerializationStrategy; import org.apache.usergrid.persistence.collection.MvccEntity; import org.apache.usergrid.persistence.collection.MvccLogEntry; import org.apache.usergrid.persistence.collection.mvcc.entity.Stage; @@ -83,12 +83,12 @@ public class WriteOptimisticVerifyTest extends AbstractMvccEntityStageTest { final MvccEntity mvccEntity = fromEntity( entity ); List<MvccLogEntry> logEntries = new ArrayList<MvccLogEntry>(); - logEntries.add( new MvccLogEntryImpl( + logEntries.add( new MvccLogEntryImpl( entity.getId(), UUIDGenerator.newTimeUUID(), Stage.ACTIVE, MvccLogEntry.State.COMPLETE )); - logEntries.add( new MvccLogEntryImpl( + logEntries.add( new MvccLogEntryImpl( entity.getId(), UUIDGenerator.newTimeUUID(), Stage.COMMITTED, MvccLogEntry.State.COMPLETE )); - MvccLogEntrySerializationStrategy noConflictLog = + MvccLogEntrySerializationStrategy noConflictLog = mock( MvccLogEntrySerializationStrategy.class ); when( noConflictLog.load( collectionScope, entity.getId(), entity.getVersion(), 2) ) @@ -121,15 +121,15 @@ public class WriteOptimisticVerifyTest extends AbstractMvccEntityStageTest { // log that one operation is active on entity List<MvccLogEntry> logEntries = new ArrayList<MvccLogEntry>(); - logEntries.add( new MvccLogEntryImpl( + logEntries.add( new MvccLogEntryImpl( entity.getId(), UUIDGenerator.newTimeUUID(), Stage.ACTIVE, MvccLogEntry.State.COMPLETE )); // log another operation as active on entity - logEntries.add( new MvccLogEntryImpl( + logEntries.add( new MvccLogEntryImpl( entity.getId(), UUIDGenerator.newTimeUUID(), Stage.ACTIVE, MvccLogEntry.State.COMPLETE )); // mock up the log - MvccLogEntrySerializationStrategy mvccLog = + MvccLogEntrySerializationStrategy mvccLog = mock( MvccLogEntrySerializationStrategy.class ); when( mvccLog.load( scope, entity.getId(), entity.getVersion(), 2) ) .thenReturn( logEntries ); http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c39be5da/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteStartTest.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteStartTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteStartTest.java index c00c82a..6171f79 100644 --- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteStartTest.java +++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteStartTest.java @@ -23,7 +23,7 @@ import org.junit.Test; import org.mockito.ArgumentCaptor; import org.apache.usergrid.persistence.collection.CollectionScope; -import org.apache.usergrid.persistence.collection.mvcc.MvccLogEntrySerializationStrategy; +import org.apache.usergrid.persistence.collection.serialization.MvccLogEntrySerializationStrategy; import org.apache.usergrid.persistence.collection.MvccEntity; import org.apache.usergrid.persistence.collection.MvccLogEntry; import org.apache.usergrid.persistence.collection.mvcc.entity.Stage; http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c39be5da/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/LogEntryIteratorTest.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/LogEntryIteratorTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/LogEntryIteratorTest.java index 6081b48..8a62505 100644 --- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/LogEntryIteratorTest.java +++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/LogEntryIteratorTest.java @@ -9,7 +9,7 @@ import org.junit.Test; import org.apache.usergrid.persistence.collection.CollectionScope; import org.apache.usergrid.persistence.collection.impl.CollectionScopeImpl; -import org.apache.usergrid.persistence.collection.mvcc.MvccLogEntrySerializationStrategy; +import org.apache.usergrid.persistence.collection.serialization.MvccLogEntrySerializationStrategy; import org.apache.usergrid.persistence.collection.MvccLogEntry; import org.apache.usergrid.persistence.collection.util.LogEntryMock; import org.apache.usergrid.persistence.collection.util.VersionGenerator; http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c39be5da/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLESSTransientTest.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLESSTransientTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLESSTransientTest.java index 09b350c..5336b05 100644 --- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLESSTransientTest.java +++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLESSTransientTest.java @@ -20,7 +20,6 @@ package org.apache.usergrid.persistence.collection.serialization.impl; -import java.lang.annotation.Annotation; import java.util.Collections; import java.util.UUID; @@ -29,16 +28,13 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; -import org.safehaus.guicyfig.Bypass; -import org.safehaus.guicyfig.Env; -import org.safehaus.guicyfig.Option; import org.apache.usergrid.persistence.collection.CollectionScope; import org.apache.usergrid.persistence.collection.MvccLogEntry; import org.apache.usergrid.persistence.core.guice.MigrationManagerRule; import org.apache.usergrid.persistence.collection.guice.TestCollectionModule; import org.apache.usergrid.persistence.collection.impl.CollectionScopeImpl; -import org.apache.usergrid.persistence.collection.mvcc.MvccLogEntrySerializationStrategy; +import org.apache.usergrid.persistence.collection.serialization.MvccLogEntrySerializationStrategy; import org.apache.usergrid.persistence.collection.mvcc.entity.Stage; import org.apache.usergrid.persistence.collection.mvcc.entity.impl.MvccLogEntryImpl; import org.apache.usergrid.persistence.collection.serialization.SerializationFig; http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c39be5da/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 f7cc615..148fcf8 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 @@ -33,7 +33,7 @@ import org.apache.usergrid.persistence.collection.CollectionScope; import org.apache.usergrid.persistence.core.guice.MigrationManagerRule; import org.apache.usergrid.persistence.collection.guice.TestCollectionModule; import org.apache.usergrid.persistence.collection.impl.CollectionScopeImpl; -import org.apache.usergrid.persistence.collection.mvcc.MvccLogEntrySerializationStrategy; +import org.apache.usergrid.persistence.collection.serialization.MvccLogEntrySerializationStrategy; import org.apache.usergrid.persistence.collection.MvccLogEntry; import org.apache.usergrid.persistence.collection.mvcc.entity.Stage; import org.apache.usergrid.persistence.collection.mvcc.entity.impl.MvccLogEntryImpl; http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c39be5da/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/util/LogEntryMock.java ---------------------------------------------------------------------- diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/util/LogEntryMock.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/util/LogEntryMock.java index c25d1bc..ec27e8a 100644 --- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/util/LogEntryMock.java +++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/util/LogEntryMock.java @@ -30,12 +30,11 @@ import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; import org.apache.usergrid.persistence.collection.CollectionScope; -import org.apache.usergrid.persistence.collection.mvcc.MvccLogEntrySerializationStrategy; +import org.apache.usergrid.persistence.collection.serialization.MvccLogEntrySerializationStrategy; import org.apache.usergrid.persistence.collection.MvccLogEntry; import org.apache.usergrid.persistence.collection.mvcc.entity.Stage; import org.apache.usergrid.persistence.collection.mvcc.entity.impl.MvccLogEntryImpl; import org.apache.usergrid.persistence.model.entity.Id; -import org.apache.usergrid.persistence.model.util.UUIDGenerator; import com.fasterxml.uuid.UUIDComparator; import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
