usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject [02/51] [abbrv] git commit: Minor re-organization of new classes and interfaces.
Date Mon, 20 Jan 2014 05:21:33 GMT
Minor re-organization of new classes and interfaces.


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

Branch: refs/pull/18/merge
Commit: 3fff2966cae516755942c875b183155131863eec
Parents: 2fdeca3
Author: Dave Johnson <snoopdave@gmail.com>
Authored: Thu Jan 9 16:24:37 2014 -0500
Committer: Dave Johnson <snoopdave@gmail.com>
Committed: Thu Jan 9 16:24:37 2014 -0500

----------------------------------------------------------------------
 .../collection/guice/CollectionModule.java      |   4 +-
 .../mvcc/stage/write/EntityVersion.java         |  62 ++++++++
 .../stage/write/EntityVersionSerializer.java    |  67 ++++++++
 .../mvcc/stage/write/FieldSerializer.java       | 102 ++++++++++++
 .../mvcc/stage/write/UniqueValue.java           |  37 +++++
 .../mvcc/stage/write/UniqueValueImpl.java       | 121 ++++++++++++++
 .../write/UniqueValueSerializationStrategy.java |  56 +++++++
 .../UniqueValueSerializationStrategyImpl.java   | 158 +++++++++++++++++++
 .../mvcc/stage/write/WriteCommit.java           |   3 -
 .../mvcc/stage/write/WriteUniqueVerify.java     |   3 -
 .../stage/write/uniquevalues/EntityVersion.java |  62 --------
 .../uniquevalues/EntityVersionSerializer.java   |  67 --------
 .../write/uniquevalues/FieldSerializer.java     | 102 ------------
 .../stage/write/uniquevalues/UniqueValue.java   |  37 -----
 .../write/uniquevalues/UniqueValueImpl.java     | 121 --------------
 .../UniqueValueSerializationStrategy.java       |  56 -------
 .../UniqueValueSerializationStrategyImpl.java   | 158 -------------------
 .../serialization/impl/SerializationModule.java |   2 +-
 .../mvcc/stage/delete/DeleteCommitTest.java     |   2 +-
 .../write/EntityVersionSerializerTest.java      |  42 +++++
 .../mvcc/stage/write/FieldSerializerTest.java   |  48 ++++++
 ...niqueValueSerializationStrategyImplTest.java | 124 +++++++++++++++
 .../mvcc/stage/write/WriteCommitTest.java       |   1 -
 .../mvcc/stage/write/WriteUniqueVerifyTest.java |   1 -
 .../EntityVersionSerializerTest.java            |  40 -----
 .../write/uniquevalues/FieldSerializerTest.java |  47 ------
 ...niqueValueSerializationStrategyImplTest.java | 121 --------------
 27 files changed, 821 insertions(+), 823 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3fff2966/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/guice/CollectionModule.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/guice/CollectionModule.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/guice/CollectionModule.java
index 90ab393..e05084b 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/guice/CollectionModule.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/guice/CollectionModule.java
@@ -18,8 +18,8 @@ import org.apache.usergrid.persistence.collection.service.impl.ServiceModule;
 
 import com.google.inject.AbstractModule;
 import com.google.inject.assistedinject.FactoryModuleBuilder;
-import org.apache.usergrid.persistence.collection.mvcc.stage.write.uniquevalues.UniqueValueSerializationStrategy;
-import org.apache.usergrid.persistence.collection.mvcc.stage.write.uniquevalues.UniqueValueSerializationStrategyImpl;
+import org.apache.usergrid.persistence.collection.mvcc.stage.write.UniqueValueSerializationStrategy;
+import org.apache.usergrid.persistence.collection.mvcc.stage.write.UniqueValueSerializationStrategyImpl;
 
 import rx.Scheduler;
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3fff2966/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/EntityVersion.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/EntityVersion.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/EntityVersion.java
new file mode 100644
index 0000000..8f2e239
--- /dev/null
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/EntityVersion.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.usergrid.persistence.collection.mvcc.stage.write;
+
+import java.util.UUID;
+import org.apache.usergrid.persistence.model.entity.Id;
+
+/**
+ * Combine entity ID and entity version for use as column name for UniqueValues Column Family.
+ */
+class EntityVersion {
+    private final Id entityId;
+    private final UUID entityVersion;
+
+    public EntityVersion(Id id, UUID uuid) {
+        this.entityId = id;
+        this.entityVersion = uuid;
+    }
+
+    public Id getEntityId() {
+        return entityId;
+    }
+
+    public UUID getEntityVersion() {
+        return entityVersion;
+    }
+
+    public boolean equals( Object o ) {
+
+        if ( o == null || !(o instanceof EntityVersion) ) {
+            return false;
+        }
+
+        EntityVersion other = (EntityVersion)o;
+
+        if ( !other.getEntityId().equals( getEntityId() )) {
+            return false;
+        }
+
+        if ( !other.getEntityVersion().equals( getEntityVersion() )) {
+            return false;
+        }
+
+        return true;
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3fff2966/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/EntityVersionSerializer.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/EntityVersionSerializer.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/EntityVersionSerializer.java
new file mode 100644
index 0000000..ae075f3
--- /dev/null
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/EntityVersionSerializer.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.usergrid.persistence.collection.mvcc.stage.write;
+
+import com.google.common.base.Preconditions;
+import com.netflix.astyanax.model.CompositeBuilder;
+import com.netflix.astyanax.model.Composites;
+import com.netflix.astyanax.model.DynamicComposite;
+import com.netflix.astyanax.serializers.AbstractSerializer;
+import com.netflix.astyanax.serializers.StringSerializer;
+import com.netflix.astyanax.serializers.UUIDSerializer;
+import java.nio.ByteBuffer;
+import java.util.UUID;
+import org.apache.usergrid.persistence.model.entity.SimpleId;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Serialize EntityVersion, entity ID and version, for use a column name in Unique Values Column Family. 
+ */
+class EntityVersionSerializer extends AbstractSerializer<EntityVersion> {
+
+    private static final Logger LOG = LoggerFactory.getLogger( EntityVersionSerializer.class );
+
+    @Override
+    public ByteBuffer toByteBuffer(final EntityVersion ev) {
+
+        CompositeBuilder builder = Composites.newDynamicCompositeBuilder();
+
+        builder.add( ev.getEntityId().getUuid(), UUIDSerializer.get() );
+        builder.add( ev.getEntityId().getType(), StringSerializer.get() );
+        builder.add( ev.getEntityVersion(),      UUIDSerializer.get() );
+
+        return builder.build();
+    }
+
+    @Override
+    public EntityVersion fromByteBuffer(final ByteBuffer byteBuffer) {
+
+        // would use Composites.newDynamicCompositeParser(byteBuffer) but it is not implemented
+
+        DynamicComposite composite = DynamicComposite.fromByteBuffer(byteBuffer);
+        Preconditions.checkArgument(composite.size() == 3, "Composite should have 3 elements");
+
+        final UUID entityId     = composite.get( 0, UUIDSerializer.get() );
+        final String entityType = composite.get( 1, StringSerializer.get() );
+        final UUID version      = composite.get( 2, UUIDSerializer.get() );
+        
+        return new EntityVersion( new SimpleId( entityId, entityType ), version);
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3fff2966/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/FieldSerializer.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/FieldSerializer.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/FieldSerializer.java
new file mode 100644
index 0000000..ce67763
--- /dev/null
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/FieldSerializer.java
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.usergrid.persistence.collection.mvcc.stage.write;
+
+import com.netflix.astyanax.model.CompositeBuilder;
+import com.netflix.astyanax.model.CompositeParser;
+import java.util.UUID;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.usergrid.persistence.collection.astyanax.CompositeFieldSerializer;
+import org.apache.usergrid.persistence.model.field.DoubleField;
+import org.apache.usergrid.persistence.model.field.Field;
+import org.apache.usergrid.persistence.model.field.IntegerField;
+import org.apache.usergrid.persistence.model.field.LongField;
+import org.apache.usergrid.persistence.model.field.StringField;
+import org.apache.usergrid.persistence.model.field.UUIDField;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+// TODO: replace with "real" serializer
+
+/**
+ * Serialize Field for use as part of row-key in Unique Values Column Family.
+ */
+public class FieldSerializer implements CompositeFieldSerializer<Field> {
+
+    private static final Logger LOG = LoggerFactory.getLogger( FieldSerializer.class );
+
+    public enum FieldType {
+        BOOLEAN_FIELD,
+        DOUBLE_FIELD,
+        INTEGER_FIELD,
+        LONG_FIELD,
+        STRING_FIELD,
+        UUID_FIELD
+    };
+
+    private static final FieldSerializer INSTANCE = new FieldSerializer();
+
+    @Override
+    public void toComposite( final CompositeBuilder builder, final Field field ) {
+
+        builder.addString( field.getName() );
+
+        // TODO: use the real field value serializer(s) here? Store hash instead?
+        builder.addString( field.getValue().toString() );
+         
+        String simpleName = field.getClass().getSimpleName();
+        int nameIndex = simpleName.lastIndexOf(".");
+        String fieldType = simpleName.substring(nameIndex + 1, simpleName.length() - "Field".length());
+        fieldType = StringUtils.upperCase( fieldType + "_FIELD" );
+
+        builder.addString( fieldType );
+    }
+
+    @Override
+    public Field fromComposite( final CompositeParser composite ) {
+
+        final String name = composite.readString();
+        final String value = composite.readString();
+        final String typeString = composite.readString();
+
+        final FieldType fieldType = FieldType.valueOf( typeString );
+
+        switch (fieldType) {
+            case DOUBLE_FIELD: 
+                return new DoubleField(name, Double.parseDouble(value));
+            case INTEGER_FIELD: 
+                return new IntegerField(name, Integer.parseInt(value));
+            case LONG_FIELD: 
+                return new LongField(name, Long.parseLong(value));
+            case STRING_FIELD: 
+                return new StringField(name, value);
+            case UUID_FIELD: 
+                return new UUIDField(name, UUID.fromString(value));
+            default:
+                throw new RuntimeException("Unknown unique field type");
+        }
+    }
+
+
+    /**
+     * Get the singleton serializer
+     */
+    public static FieldSerializer get() {
+        return INSTANCE;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3fff2966/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/UniqueValue.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/UniqueValue.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/UniqueValue.java
new file mode 100644
index 0000000..9726059
--- /dev/null
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/UniqueValue.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.usergrid.persistence.collection.mvcc.stage.write;
+
+import java.util.UUID;
+import org.apache.usergrid.persistence.collection.CollectionScope;
+import org.apache.usergrid.persistence.model.entity.Id;
+import org.apache.usergrid.persistence.model.field.Field;
+
+/**
+ * Represents a Unique Value of a field within a collection.
+ */
+public interface UniqueValue {
+
+    public CollectionScope getCollectionScope();
+
+    public Id getEntityId();
+
+    public Field getField();
+
+    public UUID getEntityVersion();
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3fff2966/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/UniqueValueImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/UniqueValueImpl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/UniqueValueImpl.java
new file mode 100644
index 0000000..686eb1f
--- /dev/null
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/UniqueValueImpl.java
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.usergrid.persistence.collection.mvcc.stage.write;
+
+import com.google.common.base.Preconditions;
+import java.util.UUID;
+import org.apache.usergrid.persistence.collection.CollectionScope;
+import org.apache.usergrid.persistence.model.entity.Id;
+import org.apache.usergrid.persistence.model.field.Field;
+
+/**
+ * Represents a Unique Value of a field within a collection.
+ */
+public class UniqueValueImpl implements UniqueValue {
+    private final CollectionScope collectionScope;
+    private final Field field;
+    private final Id entityId;
+    private UUID entityVersion;
+
+    public UniqueValueImpl(
+            final CollectionScope scope, final Field field, Id entityId, final UUID version ) {
+
+        Preconditions.checkNotNull( scope, "scope is required" );
+        Preconditions.checkNotNull( field, "field is required" );
+        Preconditions.checkNotNull( version, "version is required" );
+        Preconditions.checkNotNull( entityId, "entityId is required" );
+
+        this.collectionScope = scope;
+        this.field = field;
+        this.entityVersion = version;
+        this.entityId = entityId;
+    }
+
+    @Override
+    public CollectionScope getCollectionScope() {
+        return collectionScope;
+    }
+
+    @Override
+    public Field getField() {
+        return field;
+    }
+
+    @Override
+    public UUID getEntityVersion() {
+        return entityVersion;
+    }
+
+    @Override
+    public Id getEntityId() {
+        return entityId;
+    }
+
+    
+    @Override
+    public boolean equals( final Object o ) {
+        if ( this == o ) {
+            return true;
+        }
+        if ( o == null || getClass() != o.getClass() ) {
+            return false;
+        }
+
+        final UniqueValueImpl that = ( UniqueValueImpl ) o;
+
+        if ( !getCollectionScope().equals( that.getCollectionScope() ) ) {
+            return false;
+        }
+
+        if ( !getField().equals( that.getField()) ) {
+            return false;
+        }
+
+        if ( !getEntityVersion().equals( that.getEntityVersion() ) ) {
+            return false;
+        }
+
+        if ( !getEntityId().equals( that.getEntityId() ) ) {
+            return false;
+        }
+
+        return true;
+    }
+
+
+    @Override
+    public int hashCode() {
+        int result = 31 * getCollectionScope().hashCode();
+        result = 31 * result + getField().hashCode();
+        result = 31 * result + getEntityVersion().hashCode();
+        result = 31 * result + getEntityId().hashCode();
+        return result;
+    }
+
+
+    @Override
+    public String toString() {
+        return "UniqueValueImpl{" +
+                ", collectionScope =" + collectionScope.getName() +
+                ", field =" + field +
+                ", entityVersion=" + entityVersion +
+                ", entityId =" + entityId +
+                '}';
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3fff2966/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/UniqueValueSerializationStrategy.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/UniqueValueSerializationStrategy.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/UniqueValueSerializationStrategy.java
new file mode 100644
index 0000000..0169361
--- /dev/null
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/UniqueValueSerializationStrategy.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.usergrid.persistence.collection.mvcc.stage.write;
+
+import com.netflix.astyanax.MutationBatch;
+import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
+import org.apache.usergrid.persistence.collection.CollectionScope;
+import org.apache.usergrid.persistence.model.field.Field;
+
+/**
+ * Reads and writes to UniqueValues column family.
+ */
+public interface UniqueValueSerializationStrategy {
+
+    /**
+     * Write the specified UniqueValue to Cassandra with optional timeToLive in milliseconds.
+     * 
+     * @param uniqueValue Object to be written
+     * @param timeToLive How long object should live in seconds (or null to live forever)
+     * @return MutatationBatch that encapsulates operation, caller may or may not execute.
+     */
+    public MutationBatch write( UniqueValue uniqueValue, Integer timeToLive );
+
+    /**
+     * 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 field Field name/value to search for
+     * @return UniqueValue or null if not found
+     * @throws ConnectionException on error connecting to Cassandra
+     */
+    public UniqueValue load( CollectionScope colScope, Field field ) throws ConnectionException;
+
+    /**
+     * Delete the specified Unique Value from Cassandra.
+     * 
+     * @param uniqueValue Object to be deleted.
+     * @return MutatationBatch that encapsulates operation, caller may or may not execute.
+     */
+    public MutationBatch delete( UniqueValue uniqueValue );
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3fff2966/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/UniqueValueSerializationStrategyImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/UniqueValueSerializationStrategyImpl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/UniqueValueSerializationStrategyImpl.java
new file mode 100644
index 0000000..35c924f
--- /dev/null
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/UniqueValueSerializationStrategyImpl.java
@@ -0,0 +1,158 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.usergrid.persistence.collection.mvcc.stage.write;
+
+import com.google.common.base.Preconditions;
+import com.google.inject.Inject;
+import com.netflix.astyanax.ColumnListMutation;
+import com.netflix.astyanax.Keyspace;
+import com.netflix.astyanax.MutationBatch;
+import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
+import com.netflix.astyanax.connectionpool.exceptions.NotFoundException;
+import com.netflix.astyanax.model.ColumnList;
+import java.util.Collections;
+import org.apache.cassandra.db.marshal.BytesType;
+import org.apache.usergrid.persistence.collection.CollectionScope;
+import org.apache.usergrid.persistence.collection.astyanax.MultiTennantColumnFamily;
+import org.apache.usergrid.persistence.collection.astyanax.MultiTennantColumnFamilyDefinition;
+import org.apache.usergrid.persistence.collection.astyanax.ScopedRowKey;
+import org.apache.usergrid.persistence.collection.migration.Migration;
+import org.apache.usergrid.persistence.collection.serialization.impl.CollectionScopedRowKeySerializer;
+import org.apache.usergrid.persistence.model.field.Field;
+
+
+/**
+ * Reads and writes to UniqueValues column family.
+ */
+public class UniqueValueSerializationStrategyImpl implements UniqueValueSerializationStrategy, Migration {
+
+    // TODO: use "real" field serializer here instead once it is ready
+    private static final CollectionScopedRowKeySerializer<Field> ROW_KEY_SER = 
+            new CollectionScopedRowKeySerializer<Field>( FieldSerializer.get() );
+
+    private static final EntityVersionSerializer ENTITY_VERSION_SER = new EntityVersionSerializer();
+
+    private static final MultiTennantColumnFamily<CollectionScope, Field, EntityVersion> CF_UNIQUE_VALUES =
+        new MultiTennantColumnFamily<CollectionScope, Field, EntityVersion>( "Unique_Values", 
+                ROW_KEY_SER, 
+                ENTITY_VERSION_SER );
+
+    protected final Keyspace keyspace;
+
+
+    /**
+     * Construct serialization strategy for keyspace.
+     * @param keyspace Keyspace in which to store Unique Values.
+     */
+    @Inject
+    public UniqueValueSerializationStrategyImpl( final Keyspace keyspace ) {
+        this.keyspace = keyspace;
+    }
+
+
+    @Override
+    public java.util.Collection getColumnFamilies() {
+
+        MultiTennantColumnFamilyDefinition cf = new MultiTennantColumnFamilyDefinition( 
+                CF_UNIQUE_VALUES,
+                BytesType.class.getSimpleName(), 
+                BytesType.class.getSimpleName(),
+                BytesType.class.getSimpleName() );
+
+        return Collections.singleton( cf );
+    } 
+
+
+    @Override
+    public MutationBatch write( UniqueValue value, final Integer timeToLive ) {
+
+        Preconditions.checkNotNull( value, "value is required" );
+
+        final EntityVersion ev = new EntityVersion( value.getEntityId(), value.getEntityVersion() );
+
+        return doWrite( value.getCollectionScope(), value.getField(), 
+            new UniqueValueSerializationStrategyImpl.RowOp() {
+
+            @Override
+            public void doOp( final ColumnListMutation<EntityVersion> colMutation ) {
+                colMutation.putColumn( ev, 0x0, timeToLive );
+            }
+        } );
+    }
+
+
+    @Override
+    public MutationBatch delete(UniqueValue value) {
+
+        Preconditions.checkNotNull( value, "value is required" );
+
+        final EntityVersion ev = new EntityVersion( value.getEntityId(), value.getEntityVersion() );
+
+        return doWrite( value.getCollectionScope(), value.getField(), 
+            new UniqueValueSerializationStrategyImpl.RowOp() {
+
+            @Override
+            public void doOp( final ColumnListMutation<EntityVersion> colMutation ) {
+                colMutation.deleteColumn(ev);
+            }
+        } );
+    } 
+
+    
+    /**
+     * Do the column update or delete for the given column and row key
+     * @param context We need to use this when getting the keyspace
+     */
+    private MutationBatch doWrite( CollectionScope context, Field field, RowOp op ) {
+        final MutationBatch batch = keyspace.prepareMutationBatch();
+        op.doOp( batch.withRow( CF_UNIQUE_VALUES, ScopedRowKey.fromKey( context, field ) ) );
+        return batch;
+    }
+
+
+    @Override
+    public UniqueValue load( CollectionScope colScope, Field field ) throws ConnectionException {
+
+        Preconditions.checkNotNull( field, "field is required" );
+
+        ColumnList<EntityVersion> result;
+        try {
+            result = keyspace.prepareQuery( CF_UNIQUE_VALUES )
+                .getKey( ScopedRowKey.fromKey( colScope, field ) )
+                .execute().getResult();
+        }
+        catch ( NotFoundException nfe ) {
+            return null;
+        }
+
+        if ( result.isEmpty() ) {
+            return null;
+        }
+
+        EntityVersion ev = result.getColumnByIndex(0).getName();
+        return new UniqueValueImpl( colScope, field, ev.getEntityId(), ev.getEntityVersion() );
+    }
+
+
+    /**
+     * Simple callback to perform puts and deletes with a common row setup code
+     */
+    private static interface RowOp {
+        void doOp( ColumnListMutation<EntityVersion> colMutation );
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3fff2966/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 8848296..acc4cf9 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
@@ -39,9 +39,6 @@ import com.google.inject.Inject;
 import com.google.inject.Singleton;
 import com.netflix.astyanax.MutationBatch;
 import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
-import org.apache.usergrid.persistence.collection.mvcc.stage.write.uniquevalues.UniqueValue;
-import org.apache.usergrid.persistence.collection.mvcc.stage.write.uniquevalues.UniqueValueImpl;
-import org.apache.usergrid.persistence.collection.mvcc.stage.write.uniquevalues.UniqueValueSerializationStrategy;
 import org.apache.usergrid.persistence.model.field.Field;
 
 import rx.util.functions.Func1;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3fff2966/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerify.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerify.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerify.java
index a5fb545..a147469 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerify.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerify.java
@@ -18,9 +18,6 @@
 package org.apache.usergrid.persistence.collection.mvcc.stage.write;
 
 
-import org.apache.usergrid.persistence.collection.mvcc.stage.write.uniquevalues.UniqueValueImpl;
-import org.apache.usergrid.persistence.collection.mvcc.stage.write.uniquevalues.UniqueValue;
-import org.apache.usergrid.persistence.collection.mvcc.stage.write.uniquevalues.UniqueValueSerializationStrategy;
 import org.apache.usergrid.persistence.collection.mvcc.entity.MvccEntity;
 import org.apache.usergrid.persistence.collection.mvcc.entity.ValidationUtils;
 import org.apache.usergrid.persistence.collection.mvcc.stage.CollectionIoEvent;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3fff2966/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/uniquevalues/EntityVersion.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/uniquevalues/EntityVersion.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/uniquevalues/EntityVersion.java
deleted file mode 100644
index aed77a1..0000000
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/uniquevalues/EntityVersion.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  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.  For additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-package org.apache.usergrid.persistence.collection.mvcc.stage.write.uniquevalues;
-
-import java.util.UUID;
-import org.apache.usergrid.persistence.model.entity.Id;
-
-/**
- * Combine entity ID and entity version for use as column name for UniqueValues Column Family.
- */
-class EntityVersion {
-    private final Id entityId;
-    private final UUID entityVersion;
-
-    public EntityVersion(Id id, UUID uuid) {
-        this.entityId = id;
-        this.entityVersion = uuid;
-    }
-
-    public Id getEntityId() {
-        return entityId;
-    }
-
-    public UUID getEntityVersion() {
-        return entityVersion;
-    }
-
-    public boolean equals( Object o ) {
-
-        if ( o == null || !(o instanceof EntityVersion) ) {
-            return false;
-        }
-
-        EntityVersion other = (EntityVersion)o;
-
-        if ( !other.getEntityId().equals( getEntityId() )) {
-            return false;
-        }
-
-        if ( !other.getEntityVersion().equals( getEntityVersion() )) {
-            return false;
-        }
-
-        return true;
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3fff2966/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/uniquevalues/EntityVersionSerializer.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/uniquevalues/EntityVersionSerializer.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/uniquevalues/EntityVersionSerializer.java
deleted file mode 100644
index 0293ff7..0000000
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/uniquevalues/EntityVersionSerializer.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  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.  For additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-package org.apache.usergrid.persistence.collection.mvcc.stage.write.uniquevalues;
-
-import com.google.common.base.Preconditions;
-import com.netflix.astyanax.model.CompositeBuilder;
-import com.netflix.astyanax.model.Composites;
-import com.netflix.astyanax.model.DynamicComposite;
-import com.netflix.astyanax.serializers.AbstractSerializer;
-import com.netflix.astyanax.serializers.StringSerializer;
-import com.netflix.astyanax.serializers.UUIDSerializer;
-import java.nio.ByteBuffer;
-import java.util.UUID;
-import org.apache.usergrid.persistence.model.entity.SimpleId;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Serialize EntityVersion, entity ID and version, for use a column name in Unique Values Column Family. 
- */
-class EntityVersionSerializer extends AbstractSerializer<EntityVersion> {
-
-    private static final Logger LOG = LoggerFactory.getLogger( EntityVersionSerializer.class );
-
-    @Override
-    public ByteBuffer toByteBuffer(final EntityVersion ev) {
-
-        CompositeBuilder builder = Composites.newDynamicCompositeBuilder();
-
-        builder.add( ev.getEntityId().getUuid(), UUIDSerializer.get() );
-        builder.add( ev.getEntityId().getType(), StringSerializer.get() );
-        builder.add( ev.getEntityVersion(),      UUIDSerializer.get() );
-
-        return builder.build();
-    }
-
-    @Override
-    public EntityVersion fromByteBuffer(final ByteBuffer byteBuffer) {
-
-        // would use Composites.newDynamicCompositeParser(byteBuffer) but it is not implemented
-
-        DynamicComposite composite = DynamicComposite.fromByteBuffer(byteBuffer);
-        Preconditions.checkArgument(composite.size() == 3, "Composite should have 3 elements");
-
-        final UUID entityId     = composite.get( 0, UUIDSerializer.get() );
-        final String entityType = composite.get( 1, StringSerializer.get() );
-        final UUID version      = composite.get( 2, UUIDSerializer.get() );
-        
-        return new EntityVersion( new SimpleId( entityId, entityType ), version);
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3fff2966/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/uniquevalues/FieldSerializer.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/uniquevalues/FieldSerializer.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/uniquevalues/FieldSerializer.java
deleted file mode 100644
index 485c459..0000000
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/uniquevalues/FieldSerializer.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  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.  For additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-package org.apache.usergrid.persistence.collection.mvcc.stage.write.uniquevalues;
-
-import com.netflix.astyanax.model.CompositeBuilder;
-import com.netflix.astyanax.model.CompositeParser;
-import java.util.UUID;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.usergrid.persistence.collection.astyanax.CompositeFieldSerializer;
-import org.apache.usergrid.persistence.model.field.DoubleField;
-import org.apache.usergrid.persistence.model.field.Field;
-import org.apache.usergrid.persistence.model.field.IntegerField;
-import org.apache.usergrid.persistence.model.field.LongField;
-import org.apache.usergrid.persistence.model.field.StringField;
-import org.apache.usergrid.persistence.model.field.UUIDField;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-// TODO: replace with "real" serializer
-
-/**
- * Serialize Field for use as part of row-key in Unique Values Column Family.
- */
-public class FieldSerializer implements CompositeFieldSerializer<Field> {
-
-    private static final Logger LOG = LoggerFactory.getLogger( FieldSerializer.class );
-
-    public enum FieldType {
-        BOOLEAN_FIELD,
-        DOUBLE_FIELD,
-        INTEGER_FIELD,
-        LONG_FIELD,
-        STRING_FIELD,
-        UUID_FIELD
-    };
-
-    private static final FieldSerializer INSTANCE = new FieldSerializer();
-
-    @Override
-    public void toComposite( final CompositeBuilder builder, final Field field ) {
-
-        builder.addString( field.getName() );
-
-        // TODO: use the real field value serializer(s) here? Store hash instead?
-        builder.addString( field.getValue().toString() );
-         
-        String simpleName = field.getClass().getSimpleName();
-        int nameIndex = simpleName.lastIndexOf(".");
-        String fieldType = simpleName.substring(nameIndex + 1, simpleName.length() - "Field".length());
-        fieldType = StringUtils.upperCase( fieldType + "_FIELD" );
-
-        builder.addString( fieldType );
-    }
-
-    @Override
-    public Field fromComposite( final CompositeParser composite ) {
-
-        final String name = composite.readString();
-        final String value = composite.readString();
-        final String typeString = composite.readString();
-
-        final FieldType fieldType = FieldType.valueOf( typeString );
-
-        switch (fieldType) {
-            case DOUBLE_FIELD: 
-                return new DoubleField(name, Double.parseDouble(value));
-            case INTEGER_FIELD: 
-                return new IntegerField(name, Integer.parseInt(value));
-            case LONG_FIELD: 
-                return new LongField(name, Long.parseLong(value));
-            case STRING_FIELD: 
-                return new StringField(name, value);
-            case UUID_FIELD: 
-                return new UUIDField(name, UUID.fromString(value));
-            default:
-                throw new RuntimeException("Unknown unique field type");
-        }
-    }
-
-
-    /**
-     * Get the singleton serializer
-     */
-    public static FieldSerializer get() {
-        return INSTANCE;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3fff2966/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/uniquevalues/UniqueValue.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/uniquevalues/UniqueValue.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/uniquevalues/UniqueValue.java
deleted file mode 100644
index 733e740..0000000
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/uniquevalues/UniqueValue.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  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.  For additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-package org.apache.usergrid.persistence.collection.mvcc.stage.write.uniquevalues;
-
-import java.util.UUID;
-import org.apache.usergrid.persistence.collection.CollectionScope;
-import org.apache.usergrid.persistence.model.entity.Id;
-import org.apache.usergrid.persistence.model.field.Field;
-
-/**
- * Represents a Unique Value of a field within a collection.
- */
-public interface UniqueValue {
-
-    public CollectionScope getCollectionScope();
-
-    public Id getEntityId();
-
-    public Field getField();
-
-    public UUID getEntityVersion();
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3fff2966/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/uniquevalues/UniqueValueImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/uniquevalues/UniqueValueImpl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/uniquevalues/UniqueValueImpl.java
deleted file mode 100644
index 3be0f93..0000000
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/uniquevalues/UniqueValueImpl.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  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.  For additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-package org.apache.usergrid.persistence.collection.mvcc.stage.write.uniquevalues;
-
-import com.google.common.base.Preconditions;
-import java.util.UUID;
-import org.apache.usergrid.persistence.collection.CollectionScope;
-import org.apache.usergrid.persistence.model.entity.Id;
-import org.apache.usergrid.persistence.model.field.Field;
-
-/**
- * Represents a Unique Value of a field within a collection.
- */
-public class UniqueValueImpl implements UniqueValue {
-    private final CollectionScope collectionScope;
-    private final Field field;
-    private final Id entityId;
-    private UUID entityVersion;
-
-    public UniqueValueImpl(
-            final CollectionScope scope, final Field field, Id entityId, final UUID version ) {
-
-        Preconditions.checkNotNull( scope, "scope is required" );
-        Preconditions.checkNotNull( field, "field is required" );
-        Preconditions.checkNotNull( version, "version is required" );
-        Preconditions.checkNotNull( entityId, "entityId is required" );
-
-        this.collectionScope = scope;
-        this.field = field;
-        this.entityVersion = version;
-        this.entityId = entityId;
-    }
-
-    @Override
-    public CollectionScope getCollectionScope() {
-        return collectionScope;
-    }
-
-    @Override
-    public Field getField() {
-        return field;
-    }
-
-    @Override
-    public UUID getEntityVersion() {
-        return entityVersion;
-    }
-
-    @Override
-    public Id getEntityId() {
-        return entityId;
-    }
-
-    
-    @Override
-    public boolean equals( final Object o ) {
-        if ( this == o ) {
-            return true;
-        }
-        if ( o == null || getClass() != o.getClass() ) {
-            return false;
-        }
-
-        final UniqueValueImpl that = ( UniqueValueImpl ) o;
-
-        if ( !getCollectionScope().equals( that.getCollectionScope() ) ) {
-            return false;
-        }
-
-        if ( !getField().equals( that.getField()) ) {
-            return false;
-        }
-
-        if ( !getEntityVersion().equals( that.getEntityVersion() ) ) {
-            return false;
-        }
-
-        if ( !getEntityId().equals( that.getEntityId() ) ) {
-            return false;
-        }
-
-        return true;
-    }
-
-
-    @Override
-    public int hashCode() {
-        int result = 31 * getCollectionScope().hashCode();
-        result = 31 * result + getField().hashCode();
-        result = 31 * result + getEntityVersion().hashCode();
-        result = 31 * result + getEntityId().hashCode();
-        return result;
-    }
-
-
-    @Override
-    public String toString() {
-        return "UniqueValueImpl{" +
-                ", collectionScope =" + collectionScope.getName() +
-                ", field =" + field +
-                ", entityVersion=" + entityVersion +
-                ", entityId =" + entityId +
-                '}';
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3fff2966/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/uniquevalues/UniqueValueSerializationStrategy.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/uniquevalues/UniqueValueSerializationStrategy.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/uniquevalues/UniqueValueSerializationStrategy.java
deleted file mode 100644
index 5bfd834..0000000
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/uniquevalues/UniqueValueSerializationStrategy.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  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.  For additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-package org.apache.usergrid.persistence.collection.mvcc.stage.write.uniquevalues;
-
-import com.netflix.astyanax.MutationBatch;
-import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
-import org.apache.usergrid.persistence.collection.CollectionScope;
-import org.apache.usergrid.persistence.model.field.Field;
-
-/**
- * Reads and writes to UniqueValues column family.
- */
-public interface UniqueValueSerializationStrategy {
-
-    /**
-     * Write the specified UniqueValue to Cassandra with optional timeToLive in milliseconds.
-     * 
-     * @param uniqueValue Object to be written
-     * @param timeToLive How long object should live in seconds (or null to live forever)
-     * @return MutatationBatch that encapsulates operation, caller may or may not execute.
-     */
-    public MutationBatch write( UniqueValue uniqueValue, Integer timeToLive );
-
-    /**
-     * 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 field Field name/value to search for
-     * @return UniqueValue or null if not found
-     * @throws ConnectionException on error connecting to Cassandra
-     */
-    public UniqueValue load( CollectionScope colScope, Field field ) throws ConnectionException;
-
-    /**
-     * Delete the specified Unique Value from Cassandra.
-     * 
-     * @param uniqueValue Object to be deleted.
-     * @return MutatationBatch that encapsulates operation, caller may or may not execute.
-     */
-    public MutationBatch delete( UniqueValue uniqueValue );
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3fff2966/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/uniquevalues/UniqueValueSerializationStrategyImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/uniquevalues/UniqueValueSerializationStrategyImpl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/uniquevalues/UniqueValueSerializationStrategyImpl.java
deleted file mode 100644
index fde4269..0000000
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/uniquevalues/UniqueValueSerializationStrategyImpl.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  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.  For additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-package org.apache.usergrid.persistence.collection.mvcc.stage.write.uniquevalues;
-
-import com.google.common.base.Preconditions;
-import com.google.inject.Inject;
-import com.netflix.astyanax.ColumnListMutation;
-import com.netflix.astyanax.Keyspace;
-import com.netflix.astyanax.MutationBatch;
-import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
-import com.netflix.astyanax.connectionpool.exceptions.NotFoundException;
-import com.netflix.astyanax.model.ColumnList;
-import java.util.Collections;
-import org.apache.cassandra.db.marshal.BytesType;
-import org.apache.usergrid.persistence.collection.CollectionScope;
-import org.apache.usergrid.persistence.collection.astyanax.MultiTennantColumnFamily;
-import org.apache.usergrid.persistence.collection.astyanax.MultiTennantColumnFamilyDefinition;
-import org.apache.usergrid.persistence.collection.astyanax.ScopedRowKey;
-import org.apache.usergrid.persistence.collection.migration.Migration;
-import org.apache.usergrid.persistence.collection.serialization.impl.CollectionScopedRowKeySerializer;
-import org.apache.usergrid.persistence.model.field.Field;
-
-
-/**
- * Reads and writes to UniqueValues column family.
- */
-public class UniqueValueSerializationStrategyImpl implements UniqueValueSerializationStrategy, Migration {
-
-    // TODO: use "real" field serializer here instead once it is ready
-    private static final CollectionScopedRowKeySerializer<Field> ROW_KEY_SER = 
-            new CollectionScopedRowKeySerializer<Field>( FieldSerializer.get() );
-
-    private static final EntityVersionSerializer ENTITY_VERSION_SER = new EntityVersionSerializer();
-
-    private static final MultiTennantColumnFamily<CollectionScope, Field, EntityVersion> CF_UNIQUE_VALUES =
-        new MultiTennantColumnFamily<CollectionScope, Field, EntityVersion>( "Unique_Values", 
-                ROW_KEY_SER, 
-                ENTITY_VERSION_SER );
-
-    protected final Keyspace keyspace;
-
-
-    /**
-     * Construct serialization strategy for keyspace.
-     * @param keyspace Keyspace in which to store Unique Values.
-     */
-    @Inject
-    public UniqueValueSerializationStrategyImpl( final Keyspace keyspace ) {
-        this.keyspace = keyspace;
-    }
-
-
-    @Override
-    public java.util.Collection getColumnFamilies() {
-
-        MultiTennantColumnFamilyDefinition cf = new MultiTennantColumnFamilyDefinition( 
-                CF_UNIQUE_VALUES,
-                BytesType.class.getSimpleName(), 
-                BytesType.class.getSimpleName(),
-                BytesType.class.getSimpleName() );
-
-        return Collections.singleton( cf );
-    } 
-
-
-    @Override
-    public MutationBatch write( UniqueValue value, final Integer timeToLive ) {
-
-        Preconditions.checkNotNull( value, "value is required" );
-
-        final EntityVersion ev = new EntityVersion( value.getEntityId(), value.getEntityVersion() );
-
-        return doWrite( value.getCollectionScope(), value.getField(), 
-            new UniqueValueSerializationStrategyImpl.RowOp() {
-
-            @Override
-            public void doOp( final ColumnListMutation<EntityVersion> colMutation ) {
-                colMutation.putColumn( ev, 0x0, timeToLive );
-            }
-        } );
-    }
-
-
-    @Override
-    public MutationBatch delete(UniqueValue value) {
-
-        Preconditions.checkNotNull( value, "value is required" );
-
-        final EntityVersion ev = new EntityVersion( value.getEntityId(), value.getEntityVersion() );
-
-        return doWrite( value.getCollectionScope(), value.getField(), 
-            new UniqueValueSerializationStrategyImpl.RowOp() {
-
-            @Override
-            public void doOp( final ColumnListMutation<EntityVersion> colMutation ) {
-                colMutation.deleteColumn(ev);
-            }
-        } );
-    } 
-
-    
-    /**
-     * Do the column update or delete for the given column and row key
-     * @param context We need to use this when getting the keyspace
-     */
-    private MutationBatch doWrite( CollectionScope context, Field field, RowOp op ) {
-        final MutationBatch batch = keyspace.prepareMutationBatch();
-        op.doOp( batch.withRow( CF_UNIQUE_VALUES, ScopedRowKey.fromKey( context, field ) ) );
-        return batch;
-    }
-
-
-    @Override
-    public UniqueValue load( CollectionScope colScope, Field field ) throws ConnectionException {
-
-        Preconditions.checkNotNull( field, "field is required" );
-
-        ColumnList<EntityVersion> result;
-        try {
-            result = keyspace.prepareQuery( CF_UNIQUE_VALUES )
-                .getKey( ScopedRowKey.fromKey( colScope, field ) )
-                .execute().getResult();
-        }
-        catch ( NotFoundException nfe ) {
-            return null;
-        }
-
-        if ( result.isEmpty() ) {
-            return null;
-        }
-
-        EntityVersion ev = result.getColumnByIndex(0).getName();
-        return new UniqueValueImpl( colScope, field, ev.getEntityId(), ev.getEntityVersion() );
-    }
-
-
-    /**
-     * Simple callback to perform puts and deletes with a common row setup code
-     */
-    private static interface RowOp {
-        void doOp( ColumnListMutation<EntityVersion> colMutation );
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3fff2966/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 ffa4195..2c58e88 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
@@ -11,7 +11,7 @@ import org.apache.usergrid.persistence.collection.mvcc.MvccLogEntrySerialization
 import com.google.inject.AbstractModule;
 import com.google.inject.multibindings.Multibinder;
 import com.netflix.astyanax.Keyspace;
-import org.apache.usergrid.persistence.collection.mvcc.stage.write.uniquevalues.UniqueValueSerializationStrategyImpl;
+import org.apache.usergrid.persistence.collection.mvcc.stage.write.UniqueValueSerializationStrategyImpl;
 
 
 /**

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3fff2966/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/DeleteCommitTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/DeleteCommitTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/DeleteCommitTest.java
index 2c19a06..2fdab50 100644
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/DeleteCommitTest.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/delete/DeleteCommitTest.java
@@ -17,7 +17,7 @@ import org.apache.usergrid.persistence.collection.mvcc.stage.write.WriteCommit;
 import org.apache.usergrid.persistence.model.entity.Entity;
 
 import com.netflix.astyanax.MutationBatch;
-import org.apache.usergrid.persistence.collection.mvcc.stage.write.uniquevalues.UniqueValueSerializationStrategy;
+import org.apache.usergrid.persistence.collection.mvcc.stage.write.UniqueValueSerializationStrategy;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertSame;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3fff2966/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/EntityVersionSerializerTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/EntityVersionSerializerTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/EntityVersionSerializerTest.java
new file mode 100644
index 0000000..b11cdcf
--- /dev/null
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/EntityVersionSerializerTest.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.usergrid.persistence.collection.mvcc.stage.write;
+
+import org.apache.usergrid.persistence.collection.mvcc.stage.write.EntityVersion;
+import org.apache.usergrid.persistence.collection.mvcc.stage.write.EntityVersionSerializer;
+import java.nio.ByteBuffer;
+import org.apache.usergrid.persistence.model.entity.SimpleId;
+import org.apache.usergrid.persistence.model.util.UUIDGenerator;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class EntityVersionSerializerTest {
+    
+    @Test
+    public void testBasicOperation() {
+
+        EntityVersion original = new EntityVersion( new SimpleId("test"), UUIDGenerator.newTimeUUID() );
+
+        EntityVersionSerializer evs = new EntityVersionSerializer();
+        ByteBuffer serialized = evs.toByteBuffer(original);
+
+        EntityVersion deserialized = evs.fromBytes( serialized.array() );
+
+        Assert.assertEquals( original, deserialized );
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3fff2966/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/FieldSerializerTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/FieldSerializerTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/FieldSerializerTest.java
new file mode 100644
index 0000000..de683af
--- /dev/null
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/FieldSerializerTest.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.usergrid.persistence.collection.mvcc.stage.write;
+
+import org.apache.usergrid.persistence.collection.mvcc.stage.write.FieldSerializer;
+import com.netflix.astyanax.model.CompositeBuilder;
+import com.netflix.astyanax.model.CompositeParser;
+import com.netflix.astyanax.model.Composites;
+import java.nio.ByteBuffer;
+import org.apache.usergrid.persistence.model.field.Field;
+import org.apache.usergrid.persistence.model.field.IntegerField;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class FieldSerializerTest {
+
+    @Test
+    public void testBasicOperation() {
+
+        Field original = new IntegerField( "count", 5 );
+
+        CompositeBuilder builder = Composites.newCompositeBuilder();
+        FieldSerializer fs = new FieldSerializer();
+        fs.toComposite( builder, original );
+        ByteBuffer serializer = builder.build();
+
+        CompositeParser parser = Composites.newCompositeParser( serializer );
+        
+        Field deserialized = fs.fromComposite( parser );
+
+        Assert.assertEquals( original, deserialized );
+    } 
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3fff2966/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/UniqueValueSerializationStrategyImplTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/UniqueValueSerializationStrategyImplTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/UniqueValueSerializationStrategyImplTest.java
new file mode 100644
index 0000000..075e4bb
--- /dev/null
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/UniqueValueSerializationStrategyImplTest.java
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.usergrid.persistence.collection.mvcc.stage.write;
+
+import org.apache.usergrid.persistence.collection.mvcc.stage.write.UniqueValue;
+import org.apache.usergrid.persistence.collection.mvcc.stage.write.UniqueValueSerializationStrategy;
+import org.apache.usergrid.persistence.collection.mvcc.stage.write.UniqueValueImpl;
+import com.google.inject.Inject;
+import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
+import java.util.UUID;
+import org.apache.usergrid.persistence.collection.CollectionScope;
+import org.apache.usergrid.persistence.collection.cassandra.CassandraRule;
+import org.apache.usergrid.persistence.collection.guice.CollectionModule;
+import org.apache.usergrid.persistence.collection.guice.MigrationManagerRule;
+import org.apache.usergrid.persistence.collection.impl.CollectionScopeImpl;
+import org.apache.usergrid.persistence.model.entity.Id;
+import org.apache.usergrid.persistence.model.entity.SimpleId;
+import org.apache.usergrid.persistence.model.field.IntegerField;
+import org.apache.usergrid.persistence.model.util.UUIDGenerator;
+import org.jukito.JukitoRunner;
+import org.jukito.UseModules;
+import org.junit.Assert;
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@RunWith( JukitoRunner.class )
+@UseModules( CollectionModule.class )
+public class UniqueValueSerializationStrategyImplTest {
+    private static final Logger LOG = LoggerFactory.getLogger( UniqueValueSerializationStrategyImplTest.class );
+
+    @ClassRule
+    public static CassandraRule rule = new CassandraRule();
+
+    @Inject
+    @Rule
+    public MigrationManagerRule migrationManagerRule;
+    
+    @Inject
+    UniqueValueSerializationStrategy strategy;
+
+
+    @Test
+    public void testBasicOperation() throws ConnectionException, InterruptedException {
+
+        CollectionScope scope = new CollectionScopeImpl(
+                new SimpleId( "organization" ), new SimpleId( "test" ), "test" );
+
+        IntegerField field = new IntegerField( "count", 5 );
+        Id entityId = new SimpleId( UUIDGenerator.newTimeUUID(), "entity");
+        UUID version = UUIDGenerator.newTimeUUID();
+        UniqueValue stored = new UniqueValueImpl( scope, field, entityId, version );
+        strategy.write( stored, null ).execute();
+
+        UniqueValue retrieved = strategy.load( scope, field );
+        Assert.assertNotNull( retrieved );
+        Assert.assertEquals( stored, retrieved );
+    }
+
+
+    @Test
+    public void testWriteWithTTL() throws InterruptedException, ConnectionException {
+        
+        CollectionScope scope = new CollectionScopeImpl(
+                new SimpleId( "organization" ), new SimpleId( "test" ), "test" );
+
+        // write object that lives 2 seconds
+        IntegerField field = new IntegerField( "count", 5 );
+        Id entityId = new SimpleId( UUIDGenerator.newTimeUUID(), "entity");
+        UUID version = UUIDGenerator.newTimeUUID();
+        UniqueValue stored = new UniqueValueImpl( scope, field, entityId, version );
+        strategy.write( stored, 2 ).execute();
+
+        Thread.sleep( 1000 );
+
+        // waited one sec, should be still here
+        UniqueValue retrieved = strategy.load( scope, field );
+        Assert.assertNotNull( retrieved );
+        Assert.assertEquals( stored, retrieved );
+
+        Thread.sleep( 1500 );
+
+        // wait another second, should be gone now
+        UniqueValue nullExpected = strategy.load( scope, field );
+        Assert.assertNull( nullExpected );
+    }
+
+
+    @Test
+    public void testDelete() throws ConnectionException {
+
+        CollectionScope scope = new CollectionScopeImpl(
+                new SimpleId( "organization" ), new SimpleId( "test" ), "test" );
+
+        IntegerField field = new IntegerField( "count", 5 );
+        Id entityId = new SimpleId( UUIDGenerator.newTimeUUID(), "entity");
+        UUID version = UUIDGenerator.newTimeUUID();
+        UniqueValue stored = new UniqueValueImpl( scope, field, entityId, version );
+        strategy.write( stored, null ).execute();
+
+        strategy.delete( stored ).execute();
+
+        UniqueValue nullExpected = strategy.load( scope, field );
+        Assert.assertNull( nullExpected );
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3fff2966/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 ab4699e..ca1a057 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
@@ -16,7 +16,6 @@ import org.apache.usergrid.persistence.collection.mvcc.stage.TestEntityGenerator
 import org.apache.usergrid.persistence.model.entity.Entity;
 
 import com.netflix.astyanax.MutationBatch;
-import org.apache.usergrid.persistence.collection.mvcc.stage.write.uniquevalues.UniqueValueSerializationStrategy;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertSame;

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3fff2966/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerifyTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerifyTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerifyTest.java
index fc372b4..ec095bf 100644
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerifyTest.java
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/WriteUniqueVerifyTest.java
@@ -17,7 +17,6 @@
  */
 package org.apache.usergrid.persistence.collection.mvcc.stage.write;
 
-import org.apache.usergrid.persistence.collection.mvcc.stage.write.uniquevalues.UniqueValueSerializationStrategy;
 import com.google.inject.Inject;
 import org.junit.Test;
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3fff2966/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/uniquevalues/EntityVersionSerializerTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/uniquevalues/EntityVersionSerializerTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/uniquevalues/EntityVersionSerializerTest.java
deleted file mode 100644
index b4547b4..0000000
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/uniquevalues/EntityVersionSerializerTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  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.  For additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-package org.apache.usergrid.persistence.collection.mvcc.stage.write.uniquevalues;
-
-import java.nio.ByteBuffer;
-import org.apache.usergrid.persistence.model.entity.SimpleId;
-import org.apache.usergrid.persistence.model.util.UUIDGenerator;
-import org.junit.Assert;
-import org.junit.Test;
-
-public class EntityVersionSerializerTest {
-    
-    @Test
-    public void testBasicOperation() {
-
-        EntityVersion original = new EntityVersion( new SimpleId("test"), UUIDGenerator.newTimeUUID() );
-
-        EntityVersionSerializer evs = new EntityVersionSerializer();
-        ByteBuffer serialized = evs.toByteBuffer(original);
-
-        EntityVersion deserialized = evs.fromBytes( serialized.array() );
-
-        Assert.assertEquals( original, deserialized );
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/3fff2966/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/uniquevalues/FieldSerializerTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/uniquevalues/FieldSerializerTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/uniquevalues/FieldSerializerTest.java
deleted file mode 100644
index 32a254d..0000000
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/mvcc/stage/write/uniquevalues/FieldSerializerTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- *  contributor license agreements.  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.  For additional information regarding
- * copyright in this work, please see the NOTICE file in the top level
- * directory of this distribution.
- */
-package org.apache.usergrid.persistence.collection.mvcc.stage.write.uniquevalues;
-
-import com.netflix.astyanax.model.CompositeBuilder;
-import com.netflix.astyanax.model.CompositeParser;
-import com.netflix.astyanax.model.Composites;
-import java.nio.ByteBuffer;
-import org.apache.usergrid.persistence.model.field.Field;
-import org.apache.usergrid.persistence.model.field.IntegerField;
-import org.junit.Assert;
-import org.junit.Test;
-
-public class FieldSerializerTest {
-
-    @Test
-    public void testBasicOperation() {
-
-        Field original = new IntegerField( "count", 5 );
-
-        CompositeBuilder builder = Composites.newCompositeBuilder();
-        FieldSerializer fs = new FieldSerializer();
-        fs.toComposite( builder, original );
-        ByteBuffer serializer = builder.build();
-
-        CompositeParser parser = Composites.newCompositeParser( serializer );
-        
-        Field deserialized = fs.fromComposite( parser );
-
-        Assert.assertEquals( original, deserialized );
-    } 
-}


Mime
View raw message