usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From toddn...@apache.org
Subject [1/2] usergrid git commit: WIP overwrite
Date Wed, 02 Sep 2015 20:58:59 GMT
Repository: usergrid
Updated Branches:
  refs/heads/USERGRID-909 46033cdea -> d75b91d2e


WIP overwrite


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

Branch: refs/heads/USERGRID-909
Commit: aff393561adeaac8c96d9276c4687477519c3b9b
Parents: 46033cd
Author: Todd Nine <tnine@apigee.com>
Authored: Wed Sep 2 09:54:32 2015 -0600
Committer: Todd Nine <tnine@apigee.com>
Committed: Wed Sep 2 09:54:32 2015 -0600

----------------------------------------------------------------------
 .../MvccEntitySerializationStrategyImpl.java    |   2 +-
 .../MvccEntitySerializationStrategyV3Impl.java  |   2 +-
 ...MvccLogEntrySerializationStrategyV1Impl.java |   4 +-
 ...MvccLogEntrySerializationStrategyV2Impl.java |   4 +-
 .../UniqueValueSerializationStrategyImpl.java   |   7 +-
 .../UniqueValueSerializationStrategyV1Impl.java |   7 +-
 .../UniqueValueSerializationStrategyV2Impl.java |   7 +-
 .../persistence/core/astyanax/CassandraFig.java |  10 +-
 .../core/astyanax/CompositeFieldSerializer.java |   4 +-
 .../MultiTennantColumnFamilyDefinition.java     |  12 +-
 .../data/MigrationInfoSerializationImpl.java    |   4 +-
 .../impl/EdgeMetadataSerializationV1Impl.java   |   4 +-
 .../impl/EdgeMetadataSerializationV2Impl.java   |   3 +-
 .../impl/NodeSerializationImpl.java             |   3 +-
 .../impl/shard/ShardConsistency.java            |  41 -----
 .../NodeShardCounterSerializationImpl.java      |   4 +-
 .../shard/impl/EdgeShardSerializationImpl.java  |   4 +-
 .../impl/shard/impl/ShardConsistencyImpl.java   |  54 ------
 .../shard/impl/SizebasedEdgeColumnFamilies.java |   7 +-
 .../graph/src/test/resources/log4j.properties   |   1 +
 .../usergrid/persistence/locks/LockId.java      |   9 +
 .../persistence/locks/guice/LockModule.java     |   6 +
 .../locks/impl/CassandraLockFig.java            |  49 ++++++
 .../locks/impl/CassandraMultiRegionLock.java    |   5 +
 .../persistence/locks/impl/LockCandidate.java   | 100 +++++++++++
 .../persistence/locks/impl/LockConsistency.java |  41 +++++
 .../locks/impl/LockConsistencyImpl.java         |  51 ++++++
 .../impl/NodeShardProposalSerialization.java    |  19 ++-
 .../NodeShardProposalSerializationImpl.java     | 167 ++++++++++++++++++-
 .../persistence/locks/impl/Proposal.java        |  95 -----------
 .../map/impl/MapSerializationImpl.java          |   5 +-
 31 files changed, 503 insertions(+), 228 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/aff39356/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 6fa539a..c77b2d4 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
@@ -336,7 +336,7 @@ public abstract class MvccEntitySerializationStrategyImpl implements MvccEntityS
         MultiTennantColumnFamilyDefinition cf =
                 new MultiTennantColumnFamilyDefinition( columnFamily, BytesType.class.getSimpleName(),
                         ReversedType.class.getSimpleName() + "(" + UUIDType.class.getSimpleName() + ")",
-                        BytesType.class.getSimpleName(), MultiTennantColumnFamilyDefinition.CacheOption.KEYS );
+                        BytesType.class.getSimpleName(), MultiTennantColumnFamilyDefinition.CacheOption.KEYS, Optional.absent() );
 
 
         return Collections.singleton( cf );

http://git-wip-us.apache.org/repos/asf/usergrid/blob/aff39356/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 81a0e6d..23bf7b6 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
@@ -293,7 +293,7 @@ public class MvccEntitySerializationStrategyV3Impl implements MvccEntitySerializ
         MultiTennantColumnFamilyDefinition cf =
                 new MultiTennantColumnFamilyDefinition( CF_ENTITY_DATA, BytesType.class.getSimpleName(),
                         BooleanType.class.getSimpleName() ,
-                        BytesType.class.getSimpleName(), MultiTennantColumnFamilyDefinition.CacheOption.KEYS );
+                        BytesType.class.getSimpleName(), MultiTennantColumnFamilyDefinition.CacheOption.KEYS,Optional.absent() );
 
 
         return Collections.singleton( cf );

http://git-wip-us.apache.org/repos/asf/usergrid/blob/aff39356/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyV1Impl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyV1Impl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyV1Impl.java
index 57e7421..d91cd2f 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyV1Impl.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyV1Impl.java
@@ -37,6 +37,7 @@ import org.apache.usergrid.persistence.core.astyanax.MultiTennantColumnFamilyDef
 import org.apache.usergrid.persistence.core.astyanax.ScopedRowKey;
 import org.apache.usergrid.persistence.model.entity.Id;
 
+import com.google.common.base.Optional;
 import com.google.inject.Inject;
 import com.google.inject.Singleton;
 import com.netflix.astyanax.Keyspace;
@@ -110,7 +111,8 @@ public class MvccLogEntrySerializationStrategyV1Impl
         MultiTennantColumnFamilyDefinition cf =
                 new MultiTennantColumnFamilyDefinition( CF_ENTITY_LOG, BytesType.class.getSimpleName(),
                         ReversedType.class.getSimpleName() + "(" + UUIDType.class.getSimpleName() + ")",
-                        IntegerType.class.getSimpleName(), MultiTennantColumnFamilyDefinition.CacheOption.KEYS );
+                        IntegerType.class.getSimpleName(), MultiTennantColumnFamilyDefinition.CacheOption.KEYS, Optional
+                                            .absent() );
 
 
         return Collections.singleton( cf );

http://git-wip-us.apache.org/repos/asf/usergrid/blob/aff39356/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyV2Impl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyV2Impl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyV2Impl.java
index 99cc97f..7885200 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyV2Impl.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyV2Impl.java
@@ -37,6 +37,7 @@ import org.apache.usergrid.persistence.core.astyanax.ScopedRowKey;
 import org.apache.usergrid.persistence.core.astyanax.ScopedRowKeySerializer;
 import org.apache.usergrid.persistence.model.entity.Id;
 
+import com.google.common.base.Optional;
 import com.google.inject.Inject;
 import com.google.inject.Singleton;
 import com.netflix.astyanax.Keyspace;
@@ -98,7 +99,8 @@ public class MvccLogEntrySerializationStrategyV2Impl extends MvccLogEntrySeriali
         MultiTennantColumnFamilyDefinition cf =
             new MultiTennantColumnFamilyDefinition( CF_ENTITY_LOG_V2, BytesType.class.getSimpleName(),
                 ReversedType.class.getSimpleName() + "(" + UUIDType.class.getSimpleName() + ")",
-                IntegerType.class.getSimpleName(), MultiTennantColumnFamilyDefinition.CacheOption.KEYS );
+                IntegerType.class.getSimpleName(), MultiTennantColumnFamilyDefinition.CacheOption.KEYS, Optional
+                                .absent() );
 
 
         return Collections.singleton( cf );

http://git-wip-us.apache.org/repos/asf/usergrid/blob/aff39356/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 a1fb4cc..2e0b472 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
@@ -47,6 +47,7 @@ import org.apache.usergrid.persistence.core.util.ValidationUtils;
 import org.apache.usergrid.persistence.model.entity.Id;
 import org.apache.usergrid.persistence.model.field.Field;
 
+import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.inject.Inject;
 import com.netflix.astyanax.ColumnListMutation;
@@ -372,12 +373,14 @@ public abstract class UniqueValueSerializationStrategyImpl<FieldKey, EntityKey>
         final MultiTennantColumnFamilyDefinition uniqueLookupCF =
             new MultiTennantColumnFamilyDefinition( CF_UNIQUE_VALUES, BytesType.class.getSimpleName(),
                 ColumnTypes.DYNAMIC_COMPOSITE_TYPE, BytesType.class.getSimpleName(),
-                MultiTennantColumnFamilyDefinition.CacheOption.KEYS );
+                MultiTennantColumnFamilyDefinition.CacheOption.KEYS, Optional
+                                                .absent() );
 
         final MultiTennantColumnFamilyDefinition uniqueLogCF =
             new MultiTennantColumnFamilyDefinition( CF_ENTITY_UNIQUE_VALUE_LOG, BytesType.class.getSimpleName(),
                 ColumnTypes.DYNAMIC_COMPOSITE_TYPE, BytesType.class.getSimpleName(),
-                MultiTennantColumnFamilyDefinition.CacheOption.KEYS );
+                MultiTennantColumnFamilyDefinition.CacheOption.KEYS, Optional
+                                                .absent());
 
         return Arrays.asList( uniqueLookupCF, uniqueLogCF );
     }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/aff39356/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueValueSerializationStrategyV1Impl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueValueSerializationStrategyV1Impl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueValueSerializationStrategyV1Impl.java
index 6551f5d..da76ca0 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueValueSerializationStrategyV1Impl.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueValueSerializationStrategyV1Impl.java
@@ -37,6 +37,7 @@ import org.apache.usergrid.persistence.core.astyanax.ScopedRowKey;
 import org.apache.usergrid.persistence.model.entity.Id;
 import org.apache.usergrid.persistence.model.field.Field;
 
+import com.google.common.base.Optional;
 import com.google.inject.Inject;
 import com.google.inject.Singleton;
 import com.netflix.astyanax.Keyspace;
@@ -90,12 +91,14 @@ public class UniqueValueSerializationStrategyV1Impl  extends UniqueValueSerializ
         final MultiTennantColumnFamilyDefinition uniqueLookupCF =
             new MultiTennantColumnFamilyDefinition( CF_UNIQUE_VALUES, BytesType.class.getSimpleName(),
                 ColumnTypes.DYNAMIC_COMPOSITE_TYPE, BytesType.class.getSimpleName(),
-                MultiTennantColumnFamilyDefinition.CacheOption.KEYS );
+                MultiTennantColumnFamilyDefinition.CacheOption.KEYS, Optional
+                                                .absent() );
 
         final MultiTennantColumnFamilyDefinition uniqueLogCF =
             new MultiTennantColumnFamilyDefinition( CF_ENTITY_UNIQUE_VALUE_LOG, BytesType.class.getSimpleName(),
                 ColumnTypes.DYNAMIC_COMPOSITE_TYPE, BytesType.class.getSimpleName(),
-                MultiTennantColumnFamilyDefinition.CacheOption.KEYS );
+                MultiTennantColumnFamilyDefinition.CacheOption.KEYS, Optional
+                                                .absent() );
 
         return Arrays.asList( uniqueLookupCF, uniqueLogCF );
     }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/aff39356/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueValueSerializationStrategyV2Impl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueValueSerializationStrategyV2Impl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueValueSerializationStrategyV2Impl.java
index 1e8b389..3d89b74 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueValueSerializationStrategyV2Impl.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/UniqueValueSerializationStrategyV2Impl.java
@@ -37,6 +37,7 @@ import org.apache.usergrid.persistence.core.astyanax.ScopedRowKeySerializer;
 import org.apache.usergrid.persistence.model.entity.Id;
 import org.apache.usergrid.persistence.model.field.Field;
 
+import com.google.common.base.Optional;
 import com.google.inject.Inject;
 import com.google.inject.Singleton;
 import com.netflix.astyanax.Keyspace;
@@ -90,12 +91,14 @@ public class UniqueValueSerializationStrategyV2Impl  extends UniqueValueSerializ
         final MultiTennantColumnFamilyDefinition uniqueLookupCF =
             new MultiTennantColumnFamilyDefinition( CF_UNIQUE_VALUES, BytesType.class.getSimpleName(),
                 ColumnTypes.DYNAMIC_COMPOSITE_TYPE, BytesType.class.getSimpleName(),
-                MultiTennantColumnFamilyDefinition.CacheOption.KEYS );
+                MultiTennantColumnFamilyDefinition.CacheOption.KEYS, Optional
+                                                .absent() );
 
         final MultiTennantColumnFamilyDefinition uniqueLogCF =
             new MultiTennantColumnFamilyDefinition( CF_ENTITY_UNIQUE_VALUE_LOG, BytesType.class.getSimpleName(),
                 ColumnTypes.DYNAMIC_COMPOSITE_TYPE, BytesType.class.getSimpleName(),
-                MultiTennantColumnFamilyDefinition.CacheOption.KEYS );
+                MultiTennantColumnFamilyDefinition.CacheOption.KEYS, Optional
+                                                .absent() );
 
         return Arrays.asList( uniqueLookupCF, uniqueLogCF );
     }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/aff39356/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/CassandraFig.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/CassandraFig.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/CassandraFig.java
index 0702185..f3654a2 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/CassandraFig.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/CassandraFig.java
@@ -33,15 +33,15 @@ import org.safehaus.guicyfig.Key;
 public interface CassandraFig extends GuicyFig {
 
 
-    public static final String READ_CONSISTENT_CL = "usergrid.consistent.read.cl";
+    String READ_CONSISTENT_CL = "usergrid.consistent.read.cl";
 
-    public static final String READ_CL = "usergrid.read.cl";
+    String READ_CL = "usergrid.read.cl";
 
-    public static final String WRITE_CL = "usergrid.write.cl";
+    String WRITE_CL = "usergrid.write.cl";
 
-    public static final String SHARD_VALUES = "cassandra.shardvalues";
+    String SHARD_VALUES = "cassandra.shardvalues";
 
-    public static final String THRIFT_TRANSPORT_SIZE = "cassandra.thrift.transport.frame";
+    String THRIFT_TRANSPORT_SIZE = "cassandra.thrift.transport.frame";
 
 
     @Key( "cassandra.hosts" )

http://git-wip-us.apache.org/repos/asf/usergrid/blob/aff39356/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/CompositeFieldSerializer.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/CompositeFieldSerializer.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/CompositeFieldSerializer.java
index e241859..ad9d96f 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/CompositeFieldSerializer.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/CompositeFieldSerializer.java
@@ -34,12 +34,12 @@ public interface CompositeFieldSerializer<K> {
     /**
      * Add this to the composite
      */
-    public void toComposite( CompositeBuilder builder, K value );
+    void toComposite( CompositeBuilder builder, K value );
 
 
     /**
      * Create an instance from the composite
      */
-    public K fromComposite( CompositeParser composite );
+    K fromComposite( CompositeParser composite );
 
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/aff39356/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiTennantColumnFamilyDefinition.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiTennantColumnFamilyDefinition.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiTennantColumnFamilyDefinition.java
index 9ee886e..ad5ad39 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiTennantColumnFamilyDefinition.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/MultiTennantColumnFamilyDefinition.java
@@ -22,6 +22,7 @@ package org.apache.usergrid.persistence.core.astyanax;
 import java.util.HashMap;
 import java.util.Map;
 
+import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.netflix.astyanax.model.ColumnFamily;
 
@@ -81,6 +82,7 @@ public class MultiTennantColumnFamilyDefinition {
     public static final String COMPACTION_STRATEGY_OPTIONS = "compaction_strategy_options";
     public static final String COMPACTION_SSTABLE_SIZE = "sstable_size_in_mb";
     public static final String BLOOM_FILTER_FP = "sstable_size_in_mb";
+    public static final String GC_GRACE = "gc_grace";
 
 
 
@@ -89,22 +91,25 @@ public class MultiTennantColumnFamilyDefinition {
     private final String keyValidationType;
     private final String columnValidationType;
     private final CacheOption cacheOption;
+    private final Optional<Integer> gcGrace;
 
 
     public MultiTennantColumnFamilyDefinition( final ColumnFamily columnFamily, final String keyValidationType,
-                                               final String columnComparatorType, final String columnValidationType, final CacheOption cacheOption ) {
+                                               final String columnComparatorType, final String columnValidationType, final CacheOption cacheOption, final Optional<Integer> gcGrace ) {
 
         Preconditions.checkNotNull( columnFamily, "columnFamily is required" );
         Preconditions.checkNotNull( columnComparatorType, "columnComparatorType is required" );
         Preconditions.checkNotNull( keyValidationType, "keyValidationType is required" );
         Preconditions.checkNotNull( columnValidationType, "columnValueValidationType is required" );
         Preconditions.checkNotNull( cacheOption, "cacheOption is required" );
+        Preconditions.checkNotNull( gcGrace , "gcGrace is required" );
 
         this.columnFamily = columnFamily;
         this.columnComparatorType = columnComparatorType;
         this.keyValidationType = keyValidationType;
         this.columnValidationType = columnValidationType;
         this.cacheOption = cacheOption;
+        this.gcGrace = gcGrace;
     }
 
 
@@ -128,6 +133,11 @@ public class MultiTennantColumnFamilyDefinition {
 
         options.put( COMPACTION_STRATEGY_OPTIONS, compactionOptions  );
 
+        //set our GC grace if supplied
+        if(gcGrace.isPresent()){
+            options.put( GC_GRACE, gcGrace.get() );
+        }
+
         return options;
     }
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/aff39356/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationInfoSerializationImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationInfoSerializationImpl.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationInfoSerializationImpl.java
index 3def798..43aa675 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationInfoSerializationImpl.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/data/MigrationInfoSerializationImpl.java
@@ -24,6 +24,7 @@ import java.util.Collections;
 import java.util.UUID;
 import java.util.concurrent.TimeUnit;
 
+import com.google.common.base.Optional;
 import com.google.common.cache.CacheBuilder;
 import com.google.common.cache.CacheLoader;
 import com.google.common.cache.LoadingCache;
@@ -211,6 +212,7 @@ public class MigrationInfoSerializationImpl implements MigrationInfoSerializatio
         return Collections.singletonList(
                 new MultiTennantColumnFamilyDefinition( CF_MIGRATION_INFO, BytesType.class.getSimpleName(),
                         UTF8Type.class.getSimpleName(), BytesType.class.getSimpleName(),
-                        MultiTennantColumnFamilyDefinition.CacheOption.KEYS ) );
+                        MultiTennantColumnFamilyDefinition.CacheOption.KEYS, Optional
+                                                        .absent() ) );
     }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/aff39356/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/EdgeMetadataSerializationV1Impl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/EdgeMetadataSerializationV1Impl.java b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/EdgeMetadataSerializationV1Impl.java
index 5fd270f..65c4913 100644
--- a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/EdgeMetadataSerializationV1Impl.java
+++ b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/EdgeMetadataSerializationV1Impl.java
@@ -47,6 +47,7 @@ import org.apache.usergrid.persistence.graph.serialization.EdgeMetadataSerializa
 import org.apache.usergrid.persistence.graph.serialization.util.GraphValidation;
 import org.apache.usergrid.persistence.model.entity.Id;
 
+import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.inject.Inject;
 import com.google.inject.Singleton;
@@ -383,7 +384,8 @@ public class EdgeMetadataSerializationV1Impl implements EdgeMetadataSerializatio
     private MultiTennantColumnFamilyDefinition graphCf( MultiTennantColumnFamily cf ) {
         return new MultiTennantColumnFamilyDefinition( cf, BytesType.class.getSimpleName(),
                 UTF8Type.class.getSimpleName(), BytesType.class.getSimpleName(),
-                MultiTennantColumnFamilyDefinition.CacheOption.KEYS );
+                MultiTennantColumnFamilyDefinition.CacheOption.KEYS, Optional
+                                                .absent() );
     }
 
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/aff39356/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/EdgeMetadataSerializationV2Impl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/EdgeMetadataSerializationV2Impl.java b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/EdgeMetadataSerializationV2Impl.java
index 9e59dbf..b03a302 100644
--- a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/EdgeMetadataSerializationV2Impl.java
+++ b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/EdgeMetadataSerializationV2Impl.java
@@ -477,7 +477,8 @@ public class EdgeMetadataSerializationV2Impl implements EdgeMetadataSerializatio
     private MultiTennantColumnFamilyDefinition graphCf( MultiTennantColumnFamily cf ) {
         return new MultiTennantColumnFamilyDefinition( cf, BytesType.class.getSimpleName(),
                 UTF8Type.class.getSimpleName(), BytesType.class.getSimpleName(),
-                MultiTennantColumnFamilyDefinition.CacheOption.KEYS );
+                MultiTennantColumnFamilyDefinition.CacheOption.KEYS, Optional
+                                                .absent() );
     }
 
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/aff39356/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/NodeSerializationImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/NodeSerializationImpl.java b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/NodeSerializationImpl.java
index 18062c4..e63884f 100644
--- a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/NodeSerializationImpl.java
+++ b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/NodeSerializationImpl.java
@@ -107,7 +107,8 @@ public class NodeSerializationImpl implements NodeSerialization, Migration {
         return Collections.singleton(
                 new MultiTennantColumnFamilyDefinition( GRAPH_DELETE, BytesType.class.getSimpleName(),
                         BooleanType.class.getSimpleName(), BytesType.class.getSimpleName(),
-                        MultiTennantColumnFamilyDefinition.CacheOption.ALL ) );
+                        MultiTennantColumnFamilyDefinition.CacheOption.ALL, Optional
+                                                        .absent() ) );
     }
 
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/aff39356/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/ShardConsistency.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/ShardConsistency.java b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/ShardConsistency.java
deleted file mode 100644
index 6f992eb..0000000
--- a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/ShardConsistency.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.usergrid.persistence.graph.serialization.impl.shard;
-
-
-import com.netflix.astyanax.model.ConsistencyLevel;
-
-
-/**
- * Interface for shard consistency levels
- */
-public interface ShardConsistency {
-
-    /**
-     * Get the consistency level for wiring new shards
-     * @return
-     */
-    ConsistencyLevel getShardWriteConsistency();
-
-    /**
-     * Get the consistency level for doing reads
-     * @return
-     */
-    ConsistencyLevel getShardReadConsistency();
-
-}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/aff39356/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/count/NodeShardCounterSerializationImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/count/NodeShardCounterSerializationImpl.java b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/count/NodeShardCounterSerializationImpl.java
index 6934275..fca1949 100644
--- a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/count/NodeShardCounterSerializationImpl.java
+++ b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/count/NodeShardCounterSerializationImpl.java
@@ -43,6 +43,7 @@ import org.apache.usergrid.persistence.graph.serialization.impl.shard.Shard;
 import org.apache.usergrid.persistence.graph.serialization.impl.shard.impl.serialize.EdgeShardRowKeySerializer;
 import org.apache.usergrid.persistence.model.entity.Id;
 
+import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.inject.Inject;
 import com.google.inject.Singleton;
@@ -138,7 +139,8 @@ public class NodeShardCounterSerializationImpl implements NodeShardCounterSerial
         return Collections.singleton(
                 new MultiTennantColumnFamilyDefinition( EDGE_SHARD_COUNTS, BytesType.class.getSimpleName(),
                         ColumnTypes.BOOLEAN, CounterColumnType.class.getSimpleName(),
-                        MultiTennantColumnFamilyDefinition.CacheOption.ALL ) );
+                        MultiTennantColumnFamilyDefinition.CacheOption.ALL, Optional
+                                                        .absent() ) );
     }
 
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/aff39356/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/EdgeShardSerializationImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/EdgeShardSerializationImpl.java b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/EdgeShardSerializationImpl.java
index d6cd998..81068c5 100644
--- a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/EdgeShardSerializationImpl.java
+++ b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/EdgeShardSerializationImpl.java
@@ -51,7 +51,6 @@ import com.google.inject.Singleton;
 import com.netflix.astyanax.Keyspace;
 import com.netflix.astyanax.MutationBatch;
 import com.netflix.astyanax.model.Column;
-import com.netflix.astyanax.model.ConsistencyLevel;
 import com.netflix.astyanax.query.RowQuery;
 import com.netflix.astyanax.serializers.LongSerializer;
 import com.netflix.astyanax.util.RangeBuilder;
@@ -174,7 +173,8 @@ public class EdgeShardSerializationImpl implements EdgeShardSerialization {
         return Collections.singleton(
             new MultiTennantColumnFamilyDefinition( EDGE_SHARDS, BytesType.class.getSimpleName(),
                 ColumnTypes.LONG_TYPE_REVERSED, BytesType.class.getSimpleName(),
-                MultiTennantColumnFamilyDefinition.CacheOption.KEYS ) );
+                MultiTennantColumnFamilyDefinition.CacheOption.KEYS, Optional
+                                                .absent() ) );
     }
 
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/aff39356/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/ShardConsistencyImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/ShardConsistencyImpl.java b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/ShardConsistencyImpl.java
deleted file mode 100644
index a52ec0c..0000000
--- a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/ShardConsistencyImpl.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.usergrid.persistence.graph.serialization.impl.shard.impl;
-
-
-import org.apache.usergrid.persistence.graph.GraphFig;
-import org.apache.usergrid.persistence.graph.serialization.impl.shard.ShardConsistency;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-import com.netflix.astyanax.model.ConsistencyLevel;
-
-
-/**
- * Implementation wrapper for enums
- */
-@Singleton
-public class ShardConsistencyImpl implements ShardConsistency{
-
-    private final GraphFig graphFig;
-
-
-    @Inject
-    public ShardConsistencyImpl( final GraphFig graphFig ) {this.graphFig = graphFig;}
-
-
-    @Override
-    public ConsistencyLevel getShardWriteConsistency() {
-        return ConsistencyLevel.valueOf( graphFig.getShardWriteConsistency() );
-    }
-
-
-    @Override
-    public ConsistencyLevel getShardReadConsistency() {
-        return ConsistencyLevel.valueOf( graphFig.getShardReadConsistency() );
-    }
-
-
-}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/aff39356/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/SizebasedEdgeColumnFamilies.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/SizebasedEdgeColumnFamilies.java b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/SizebasedEdgeColumnFamilies.java
index 8f16448..4ba7cb9 100644
--- a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/SizebasedEdgeColumnFamilies.java
+++ b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/SizebasedEdgeColumnFamilies.java
@@ -42,6 +42,7 @@ import org.apache.usergrid.persistence.graph.serialization.impl.shard.impl.seria
 import org.apache.usergrid.persistence.graph.serialization.impl.shard.impl.serialize.RowSerializer;
 import org.apache.usergrid.persistence.graph.serialization.impl.shard.impl.serialize.RowTypeSerializer;
 
+import com.google.common.base.Optional;
 import com.netflix.astyanax.serializers.LongSerializer;
 
 import static org.apache.usergrid.persistence.core.astyanax.ColumnTypes.LONG_TYPE_REVERSED;
@@ -140,7 +141,8 @@ public class SizebasedEdgeColumnFamilies implements EdgeColumnFamilies {
                         graphCf( TARGET_NODE_SOURCE_TYPE ),
                         new MultiTennantColumnFamilyDefinition( EDGE_VERSIONS, BytesType.class.getSimpleName(),
                                 ColumnTypes.LONG_TYPE_REVERSED, BytesType.class.getSimpleName(),
-                                MultiTennantColumnFamilyDefinition.CacheOption.KEYS ) );
+                                MultiTennantColumnFamilyDefinition.CacheOption.KEYS, Optional
+                                                                .absent() ) );
     }
 
 
@@ -149,6 +151,7 @@ public class SizebasedEdgeColumnFamilies implements EdgeColumnFamilies {
      */
     private MultiTennantColumnFamilyDefinition graphCf( MultiTennantColumnFamily cf ) {
         return new MultiTennantColumnFamilyDefinition( cf, BytesType.class.getSimpleName(), EDGE_DYNAMIC_COMPOSITE_TYPE,
-                BytesType.class.getSimpleName(), MultiTennantColumnFamilyDefinition.CacheOption.KEYS );
+                BytesType.class.getSimpleName(), MultiTennantColumnFamilyDefinition.CacheOption.KEYS, Optional
+                                                .absent() );
     }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/aff39356/stack/corepersistence/graph/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/test/resources/log4j.properties b/stack/corepersistence/graph/src/test/resources/log4j.properties
index d0dede1..deaa813 100644
--- a/stack/corepersistence/graph/src/test/resources/log4j.properties
+++ b/stack/corepersistence/graph/src/test/resources/log4j.properties
@@ -39,4 +39,5 @@ log4j.logger.cassandra.db=ERROR
 #log4j.logger.org.apache.usergrid.persistence.graph.serialization.impl.parse=TRACE
 
 log4j.logger.org.apache.usergrid.persistence.graph.serialization.impl.shard.impl.NodeShardAllocationImpl=TRACE
+log4j.logger.org.apache.usergrid.persistence.graph.serialization.impl.shard.impl.ShardGroupCompactionImpl=TRACE
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/aff39356/stack/corepersistence/locks/src/main/java/org/apache/usergrid/persistence/locks/LockId.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/locks/src/main/java/org/apache/usergrid/persistence/locks/LockId.java b/stack/corepersistence/locks/src/main/java/org/apache/usergrid/persistence/locks/LockId.java
index ca7001e..c298162 100644
--- a/stack/corepersistence/locks/src/main/java/org/apache/usergrid/persistence/locks/LockId.java
+++ b/stack/corepersistence/locks/src/main/java/org/apache/usergrid/persistence/locks/LockId.java
@@ -18,6 +18,9 @@
 package org.apache.usergrid.persistence.locks;
 
 
+import org.apache.usergrid.persistence.core.scope.ApplicationScope;
+
+
 /**
  * Key that uniquely represents a lock
  */
@@ -28,4 +31,10 @@ public interface LockId {
      * @return
      */
     String generateKey();
+
+    /**
+     * Get the application scope for the lockId
+     * @return
+     */
+    ApplicationScope getApplicationScope();
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/aff39356/stack/corepersistence/locks/src/main/java/org/apache/usergrid/persistence/locks/guice/LockModule.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/locks/src/main/java/org/apache/usergrid/persistence/locks/guice/LockModule.java b/stack/corepersistence/locks/src/main/java/org/apache/usergrid/persistence/locks/guice/LockModule.java
index 3bd0e0a..4b0d433 100644
--- a/stack/corepersistence/locks/src/main/java/org/apache/usergrid/persistence/locks/guice/LockModule.java
+++ b/stack/corepersistence/locks/src/main/java/org/apache/usergrid/persistence/locks/guice/LockModule.java
@@ -18,7 +18,10 @@
 package org.apache.usergrid.persistence.locks.guice;
 
 
+import org.safehaus.guicyfig.GuicyFigModule;
+
 import org.apache.usergrid.persistence.locks.LockManager;
+import org.apache.usergrid.persistence.locks.impl.CassandraLockFig;
 import org.apache.usergrid.persistence.locks.impl.CassandraLockManager;
 import org.apache.usergrid.persistence.locks.impl.NodeShardProposalSerialization;
 import org.apache.usergrid.persistence.locks.impl.NodeShardProposalSerializationImpl;
@@ -34,6 +37,9 @@ public abstract class LockModule extends AbstractModule {
     @Override
     protected void configure() {
 
+        //install the lock config
+        install(new GuicyFigModule( CassandraLockFig.class ));
+
         //bind our lockManager
         bind( LockManager.class).to( CassandraLockManager.class );
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/aff39356/stack/corepersistence/locks/src/main/java/org/apache/usergrid/persistence/locks/impl/CassandraLockFig.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/locks/src/main/java/org/apache/usergrid/persistence/locks/impl/CassandraLockFig.java b/stack/corepersistence/locks/src/main/java/org/apache/usergrid/persistence/locks/impl/CassandraLockFig.java
new file mode 100644
index 0000000..4583dad
--- /dev/null
+++ b/stack/corepersistence/locks/src/main/java/org/apache/usergrid/persistence/locks/impl/CassandraLockFig.java
@@ -0,0 +1,49 @@
+/*
+ * 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.locks.impl;
+
+
+import org.safehaus.guicyfig.Default;
+import org.safehaus.guicyfig.FigSingleton;
+import org.safehaus.guicyfig.GuicyFig;
+import org.safehaus.guicyfig.Key;
+
+
+@FigSingleton
+public interface CassandraLockFig extends GuicyFig {
+
+    String READ_CONSISTENT_CL = "usergrid.lock.multiregion.read.cl";
+
+    String WRITE_CONSISTENT_CL = "usergrid.lock.multiregion.write.cl";
+
+
+    /**
+     * Get multi region write consistency level
+     * @return
+     */
+    @Default( "CL_EACH_QUORUM" )
+    @Key( WRITE_CONSISTENT_CL )
+    String getMultiRegionLockWriteConsistency();
+
+    /**
+     * Get the consistency level for doing reads
+     */
+    @Default( "CL_LOCAL_QUORUM" )
+    @Key( READ_CONSISTENT_CL )
+    String getMultiRegionLockReadConsistency();
+}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/aff39356/stack/corepersistence/locks/src/main/java/org/apache/usergrid/persistence/locks/impl/CassandraMultiRegionLock.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/locks/src/main/java/org/apache/usergrid/persistence/locks/impl/CassandraMultiRegionLock.java b/stack/corepersistence/locks/src/main/java/org/apache/usergrid/persistence/locks/impl/CassandraMultiRegionLock.java
index decacc2..e3d6362 100644
--- a/stack/corepersistence/locks/src/main/java/org/apache/usergrid/persistence/locks/impl/CassandraMultiRegionLock.java
+++ b/stack/corepersistence/locks/src/main/java/org/apache/usergrid/persistence/locks/impl/CassandraMultiRegionLock.java
@@ -57,6 +57,11 @@ public class CassandraMultiRegionLock implements Lock {
 
         //now read back our proposal
 
+        final LockCandidate lockCandidate = nodeShardProposalSerialization.getProposedLock( lockId );
+
+
+
+
 
 
         return false;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/aff39356/stack/corepersistence/locks/src/main/java/org/apache/usergrid/persistence/locks/impl/LockCandidate.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/locks/src/main/java/org/apache/usergrid/persistence/locks/impl/LockCandidate.java b/stack/corepersistence/locks/src/main/java/org/apache/usergrid/persistence/locks/impl/LockCandidate.java
new file mode 100644
index 0000000..ed25b38
--- /dev/null
+++ b/stack/corepersistence/locks/src/main/java/org/apache/usergrid/persistence/locks/impl/LockCandidate.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.usergrid.persistence.locks.impl;
+
+
+import java.util.UUID;
+
+import com.fasterxml.uuid.UUIDComparator;
+import com.google.common.base.Optional;
+
+
+/**
+ * Represents a proposed value
+ */
+public class LockCandidate {
+
+
+    private final UUID first;
+    private final Optional<UUID> second;
+    private final Optional<UUID> secondAcked;
+
+
+    public LockCandidate( final UUID first, final Optional<UUID> second, final Optional<UUID> secondAcked ) {
+        this.first = first;
+        this.second = second;
+        this.secondAcked = secondAcked;
+    }
+
+
+    /**
+     * Return true if the proposedUuid is the first UUID
+     * @param proposedUuid
+     * @return
+     */
+    public boolean isFirst(final UUID proposedUuid){
+        return UUIDComparator.staticCompare( first, proposedUuid ) ==0 ;
+    }
+
+
+    /**
+     * Return trus if the proposedUuid is the
+     * @param proposedUuid
+     * @return
+     */
+    public boolean isLocked(final UUID proposedUuid){
+        if(!isFirst( proposedUuid )) {
+            return false;
+        }
+
+
+        //we have an "acked" value from a previous time uuid.  Compare them and be sure the
+        //second has recognized the first as the being first, otherwise we can't proceed.
+        if(secondAcked.isPresent()) {
+            return UUIDComparator.staticCompare( first, secondAcked.get() ) == 0;
+        }
+
+        //there is no second we have the lock
+        return true;
+    }
+
+
+    /**
+     * True if the proposed UUID is the second Id, and we haven't acked the first
+     *
+     * @param proposedUuid
+     * @return
+     */
+    public boolean shouldAck(final UUID proposedUuid){
+        //no second, or the second isn't equal to our proposed
+        if(!second.isPresent() || UUIDComparator.staticCompare( proposedUuid, second.get()) != 0){
+            return false;
+        }
+
+        /**
+         * If our second hasn't acked the first, ack it
+         */
+        return !secondAcked.isPresent();
+
+    }
+
+
+    public UUID getFirst() {
+        return first;
+    }
+}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/aff39356/stack/corepersistence/locks/src/main/java/org/apache/usergrid/persistence/locks/impl/LockConsistency.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/locks/src/main/java/org/apache/usergrid/persistence/locks/impl/LockConsistency.java b/stack/corepersistence/locks/src/main/java/org/apache/usergrid/persistence/locks/impl/LockConsistency.java
new file mode 100644
index 0000000..40ddaa1
--- /dev/null
+++ b/stack/corepersistence/locks/src/main/java/org/apache/usergrid/persistence/locks/impl/LockConsistency.java
@@ -0,0 +1,41 @@
+/*
+ * 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.locks.impl;
+
+
+import com.netflix.astyanax.model.ConsistencyLevel;
+
+
+/**
+ * Interface for shard consistency levels
+ */
+public interface LockConsistency {
+
+    /**
+     * Get the consistency level for wiring new shards
+     * @return
+     */
+    ConsistencyLevel getShardWriteConsistency();
+
+    /**
+     * Get the consistency level for doing reads
+     * @return
+     */
+    ConsistencyLevel getShardReadConsistency();
+
+}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/aff39356/stack/corepersistence/locks/src/main/java/org/apache/usergrid/persistence/locks/impl/LockConsistencyImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/locks/src/main/java/org/apache/usergrid/persistence/locks/impl/LockConsistencyImpl.java b/stack/corepersistence/locks/src/main/java/org/apache/usergrid/persistence/locks/impl/LockConsistencyImpl.java
new file mode 100644
index 0000000..c8ff217
--- /dev/null
+++ b/stack/corepersistence/locks/src/main/java/org/apache/usergrid/persistence/locks/impl/LockConsistencyImpl.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.usergrid.persistence.locks.impl;
+
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import com.netflix.astyanax.model.ConsistencyLevel;
+
+
+/**
+ * Implementation wrapper for enums
+ */
+@Singleton
+public class LockConsistencyImpl implements LockConsistency {
+
+    private final CassandraLockFig cassandraLockFig;
+
+
+    @Inject
+    public LockConsistencyImpl( final CassandraLockFig cassandraLockFig ) {this.cassandraLockFig = cassandraLockFig;}
+
+
+    @Override
+    public ConsistencyLevel getShardWriteConsistency() {
+        return ConsistencyLevel.valueOf( cassandraLockFig.getMultiRegionLockWriteConsistency() );
+    }
+
+
+    @Override
+    public ConsistencyLevel getShardReadConsistency() {
+        return ConsistencyLevel.valueOf( cassandraLockFig.getMultiRegionLockReadConsistency() );
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/aff39356/stack/corepersistence/locks/src/main/java/org/apache/usergrid/persistence/locks/impl/NodeShardProposalSerialization.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/locks/src/main/java/org/apache/usergrid/persistence/locks/impl/NodeShardProposalSerialization.java b/stack/corepersistence/locks/src/main/java/org/apache/usergrid/persistence/locks/impl/NodeShardProposalSerialization.java
index 6bf294e..11314b2 100644
--- a/stack/corepersistence/locks/src/main/java/org/apache/usergrid/persistence/locks/impl/NodeShardProposalSerialization.java
+++ b/stack/corepersistence/locks/src/main/java/org/apache/usergrid/persistence/locks/impl/NodeShardProposalSerialization.java
@@ -20,29 +20,36 @@ package org.apache.usergrid.persistence.locks.impl;
 
 import java.util.UUID;
 
+import org.apache.usergrid.persistence.core.migration.schema.Migration;
 import org.apache.usergrid.persistence.locks.LockId;
 
 
 /**
  * Interface for serializing node shard proposals
  */
-public interface NodeShardProposalSerialization {
+public interface NodeShardProposalSerialization extends Migration {
 
 
     /**
-     * Propose a new shard and return the UUID of the proposal
+     * Propose a new shard and ack shards that are before us
      * @param lockId The key for the locks
      * @param proposed The proposed time uuid key
      * @param expirationInSeconds The time to allow the proposal to live.
+     *
+     * @return The Proposal of the 2 items in the proposal queue
      */
-    void writeNewValue( final LockId lockId, final UUID proposed, final int expirationInSeconds );
+    LockCandidate writeNewValue( final LockId lockId, final UUID proposed, final int expirationInSeconds );
+
 
     /**
-     * Get the proposed locks from the proposed value
-     * @param lockId The key for the locks
+     * Ack the proposal and re-read
+     * @param lockId
+     * @param proposed The proposed uuid we set
+     * @param seen The uuid to set into the seen value
+     * @param expirationInSeconds The time to allow the proposal to live.
      * @return
      */
-    Proposal getProposal(  final LockId lockId);
+    LockCandidate ackProposed(final LockId lockId, final UUID proposed, final UUID seen, final int expirationInSeconds);
 
     /**
      * Remove all the proposals

http://git-wip-us.apache.org/repos/asf/usergrid/blob/aff39356/stack/corepersistence/locks/src/main/java/org/apache/usergrid/persistence/locks/impl/NodeShardProposalSerializationImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/locks/src/main/java/org/apache/usergrid/persistence/locks/impl/NodeShardProposalSerializationImpl.java b/stack/corepersistence/locks/src/main/java/org/apache/usergrid/persistence/locks/impl/NodeShardProposalSerializationImpl.java
index 9fb35d5..a28e8e6 100644
--- a/stack/corepersistence/locks/src/main/java/org/apache/usergrid/persistence/locks/impl/NodeShardProposalSerializationImpl.java
+++ b/stack/corepersistence/locks/src/main/java/org/apache/usergrid/persistence/locks/impl/NodeShardProposalSerializationImpl.java
@@ -18,9 +18,28 @@
 package org.apache.usergrid.persistence.locks.impl;
 
 
+import java.util.Collection;
+import java.util.Collections;
 import java.util.UUID;
 
+import org.apache.cassandra.db.marshal.BytesType;
+import org.apache.cassandra.db.marshal.UUIDType;
+
+import org.apache.usergrid.persistence.core.astyanax.MultiTennantColumnFamily;
+import org.apache.usergrid.persistence.core.astyanax.MultiTennantColumnFamilyDefinition;
+import org.apache.usergrid.persistence.core.astyanax.ScopedRowKey;
+import org.apache.usergrid.persistence.core.astyanax.ScopedRowKeySerializer;
+import org.apache.usergrid.persistence.core.astyanax.StringRowCompositeSerializer;
 import org.apache.usergrid.persistence.locks.LockId;
+import org.apache.usergrid.persistence.model.entity.Id;
+
+import com.google.common.base.Optional;
+import com.netflix.astyanax.Keyspace;
+import com.netflix.astyanax.MutationBatch;
+import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
+import com.netflix.astyanax.model.Column;
+import com.netflix.astyanax.model.ColumnList;
+import com.netflix.astyanax.serializers.UUIDSerializer;
 
 
 /**
@@ -28,21 +47,163 @@ import org.apache.usergrid.persistence.locks.LockId;
  */
 public class NodeShardProposalSerializationImpl implements NodeShardProposalSerialization {
 
+    private static final StringRowCompositeSerializer STRING_SER = StringRowCompositeSerializer.get();
+
+    private static final ScopedRowKeySerializer<String> ROW_KEY_SER = new ScopedRowKeySerializer<>( STRING_SER );
+
+
+    private static final MultiTennantColumnFamily<ScopedRowKey<String>, UUID> CF_MULTI_REGION_LOCKS =
+        new MultiTennantColumnFamily<>( "Multi_Region_Locks", ROW_KEY_SER, UUIDSerializer.get() );
+
+
+    private static final byte[] EMPTY = new byte[0];
+
+
+    protected final Keyspace keyspace;
+    protected final LockConsistency lockConsistency;
+
+
+    public NodeShardProposalSerializationImpl( final Keyspace keyspace, final LockConsistency lockConsistency ) {
+        this.keyspace = keyspace;
+        this.lockConsistency = lockConsistency;
+    }
+
 
     @Override
-    public void writeNewValue( final LockId lockId, final UUID proposed, final int expirationInSeconds ) {
+    public LockCandidate writeNewValue( final LockId lockId, final UUID proposed, final int expirationInSeconds ) {
+
+        final MutationBatch batch =
+            keyspace.prepareMutationBatch().withConsistencyLevel( lockConsistency.getShardWriteConsistency() );
 
+        final Id applicationId = lockId.getApplicationScope().getApplication();
+
+        final ScopedRowKey<String> rowKey = ScopedRowKey.fromKey( applicationId, lockId.generateKey() );
+
+        //put the column with expiration
+        batch.withRow( CF_MULTI_REGION_LOCKS, rowKey ).putColumn( proposed, EMPTY, expirationInSeconds );
+
+
+        try {
+            batch.execute();
+        }
+        catch ( ConnectionException e ) {
+            throw new RuntimeException( "Unable to connect to cassandra", e );
+        }
+
+
+        return readState( rowKey );
     }
 
 
     @Override
-    public Proposal getProposal( final LockId lockId ) {
-        return null;
+    public LockCandidate ackProposed( final LockId lockId, final UUID proposed, final UUID seen,
+                                      final int expirationInSeconds ) {
+
+        final MutationBatch batch =
+            keyspace.prepareMutationBatch().withConsistencyLevel( lockConsistency.getShardWriteConsistency() );
+
+        final Id applicationId = lockId.getApplicationScope().getApplication();
+
+        final ScopedRowKey<String> rowKey = ScopedRowKey.fromKey( applicationId, lockId.generateKey() );
+
+
+        //put the column with expiration
+        batch.withRow( CF_MULTI_REGION_LOCKS, rowKey ).putColumn( proposed, seen, expirationInSeconds );
+
+
+        try {
+            batch.execute();
+        }
+        catch ( ConnectionException e ) {
+            throw new RuntimeException( "Unable to connect to cassandra", e );
+        }
+
+
+        return readState( rowKey );
+    }
+
+
+    /**
+     * Read the lock state from the column family
+     */
+    private LockCandidate readState( final ScopedRowKey<String> rowKey ) {
+        //read the first 2 records
+
+
+        final ColumnList<UUID> results;
+
+        try {
+            results = keyspace.prepareQuery( CF_MULTI_REGION_LOCKS ).getKey( rowKey )
+                              .withColumnRange( ( UUID ) null, null, false, 2 ).execute().getResult();
+        }
+        catch ( ConnectionException e ) {
+            throw new RuntimeException( "Unable to connect to cassandra", e );
+        }
+
+
+        //should never happen, sanity check.
+        if ( results.isEmpty() ) {
+            throw new RuntimeException(
+                "Unable to read results from cassandra.  There should be at least 1 result left" );
+        }
+
+
+        final UUID proposedLock = results.getColumnByIndex( 0 ).getName();
+
+        //we have 2 columns, populate the proposal
+        if ( results.size() == 2 ) {
+            final Column<UUID> column = results.getColumnByIndex( 1 );
+
+            final Optional<UUID> secondProposedLock = Optional.of( column.getName() );
+
+            final Optional<UUID> valueSeenBySecond;
+
+            if ( column.hasValue() ) {
+                valueSeenBySecond = Optional.of( column.getUUIDValue() );
+            }
+            else {
+                valueSeenBySecond = Optional.absent();
+            }
+
+            return new LockCandidate( proposedLock, secondProposedLock, valueSeenBySecond );
+        }
+
+        return new LockCandidate( proposedLock, Optional.absent(), Optional.absent() );
     }
 
 
     @Override
     public void delete( final LockId lockId, final UUID proposed ) {
+        final MutationBatch batch =
+            keyspace.prepareMutationBatch().withConsistencyLevel( lockConsistency.getShardWriteConsistency() );
+
+        final Id applicationId = lockId.getApplicationScope().getApplication();
+
+        final ScopedRowKey<String> rowKey = ScopedRowKey.fromKey( applicationId, lockId.generateKey() );
+
+
+        //put the column with expiration
+        batch.withRow( CF_MULTI_REGION_LOCKS, rowKey ).deleteColumn( proposed );
+
+
+        try {
+            batch.execute();
+        }
+        catch ( ConnectionException e ) {
+            throw new RuntimeException( "Unable to connect to cassandra", e );
+        }
+    }
+
+
+    @Override
+    public Collection<MultiTennantColumnFamilyDefinition> getColumnFamilies() {
+        //create the CF and sort them by uuid type so time uuid with lowest will be first
+        MultiTennantColumnFamilyDefinition cf =
+            new MultiTennantColumnFamilyDefinition( CF_MULTI_REGION_LOCKS, BytesType.class.getSimpleName(),
+                UUIDType.class.getSimpleName(), UUIDType.class.getSimpleName(),
+                MultiTennantColumnFamilyDefinition.CacheOption.ALL, Optional.of( 1 ) );
+
 
+        return Collections.singleton( cf );
     }
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/aff39356/stack/corepersistence/locks/src/main/java/org/apache/usergrid/persistence/locks/impl/Proposal.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/locks/src/main/java/org/apache/usergrid/persistence/locks/impl/Proposal.java b/stack/corepersistence/locks/src/main/java/org/apache/usergrid/persistence/locks/impl/Proposal.java
deleted file mode 100644
index 4eb91e0..0000000
--- a/stack/corepersistence/locks/src/main/java/org/apache/usergrid/persistence/locks/impl/Proposal.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.usergrid.persistence.locks.impl;
-
-
-import java.util.UUID;
-
-import com.fasterxml.uuid.UUIDComparator;
-import com.google.common.base.Optional;
-
-
-/**
- * Represents a proposed value
- */
-public class Proposal {
-
-
-    private final UUID first;
-    private final Optional<UUID> second;
-    private final Optional<UUID> secondAcked;
-
-
-    public Proposal( final UUID first, final Optional<UUID> second, final Optional<UUID> secondAcked ) {
-        this.first = first;
-        this.second = second;
-        this.secondAcked = secondAcked;
-    }
-
-
-    /**
-     * Return true if the proposedUuid is the first UUID
-     * @param proposedUuid
-     * @return
-     */
-    public boolean isFirst(final UUID proposedUuid){
-        return UUIDComparator.staticCompare( first, proposedUuid ) ==0 ;
-    }
-
-
-    /**
-     * Return trus if the proposedUuid is the
-     * @param proposedUuid
-     * @return
-     */
-    public boolean isLocked(final UUID proposedUuid){
-        if(!isFirst( proposedUuid )) {
-            return false;
-        }
-
-
-        //we have an "acked" value from a previous time uuid.  Compare them and be sure the
-        //second has recognized the first as the being first, otherwise we can't proceed.
-        if(secondAcked.isPresent()) {
-            return UUIDComparator.staticCompare( first, secondAcked.get() ) == 0;
-        }
-
-        //there is no second we have the lock
-        return true;
-    }
-
-
-    /**
-     * True if the proposed UUID is the second Id, and we haven't acked the first
-     *
-     * @param proposedUuid
-     * @return
-     */
-    public boolean shouldAck(final UUID proposedUuid){
-        //no second, or the second isn't equal to our proposed
-        if(!second.isPresent() || UUIDComparator.staticCompare( proposedUuid, second.get()) != 0){
-            return false;
-        }
-
-        /**
-         * If our second hasn't acked the first, ack it
-         */
-        return !secondAcked.isPresent();
-
-    }
-}

http://git-wip-us.apache.org/repos/asf/usergrid/blob/aff39356/stack/corepersistence/map/src/main/java/org/apache/usergrid/persistence/map/impl/MapSerializationImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/map/src/main/java/org/apache/usergrid/persistence/map/impl/MapSerializationImpl.java b/stack/corepersistence/map/src/main/java/org/apache/usergrid/persistence/map/impl/MapSerializationImpl.java
index 825d636..dda1b2a 100644
--- a/stack/corepersistence/map/src/main/java/org/apache/usergrid/persistence/map/impl/MapSerializationImpl.java
+++ b/stack/corepersistence/map/src/main/java/org/apache/usergrid/persistence/map/impl/MapSerializationImpl.java
@@ -26,6 +26,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 
+import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import org.apache.cassandra.db.marshal.BytesType;
 import org.apache.cassandra.db.marshal.UTF8Type;
@@ -349,14 +350,14 @@ public class MapSerializationImpl implements MapSerialization {
                        BytesType.class.getSimpleName(),
                        BytesType.class.getSimpleName(),
                        BytesType.class.getSimpleName(),
-                       MultiTennantColumnFamilyDefinition.CacheOption.KEYS );
+                       MultiTennantColumnFamilyDefinition.CacheOption.KEYS, Optional.absent() );
 
         final MultiTennantColumnFamilyDefinition mapKeys =
                 new MultiTennantColumnFamilyDefinition( MAP_KEYS,
                         BytesType.class.getSimpleName(),
                         UTF8Type.class.getSimpleName(),
                         BytesType.class.getSimpleName(),
-                        MultiTennantColumnFamilyDefinition.CacheOption.KEYS );
+                        MultiTennantColumnFamilyDefinition.CacheOption.KEYS, Optional.absent() );
 
         return Arrays.asList( mapEntries, mapKeys );
     }


Mime
View raw message