usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject [10/35] usergrid git commit: Simplify the locks consistency level and default it to LQ in case something passed cannot be parsed to a valid consistency level.
Date Mon, 25 Jan 2016 21:18:02 GMT
Simplify the locks consistency level and default it to LQ in case something passed cannot be
parsed to a valid consistency level.


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

Branch: refs/heads/USERGRID-1047
Commit: 56850926ba430c756b348195ffd013e10f09c6e8
Parents: 973f5a7
Author: Michael Russo <michaelarusso@gmail.com>
Authored: Thu Jan 14 16:36:57 2016 -0800
Committer: Michael Russo <michaelarusso@gmail.com>
Committed: Thu Jan 14 16:36:57 2016 -0800

----------------------------------------------------------------------
 .../locking/cassandra/AstyanaxLockManagerImpl.java  | 13 ++++++++++++-
 .../persistence/core/astyanax/CassandraFig.java     | 16 ++++------------
 2 files changed, 16 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/56850926/stack/core/src/main/java/org/apache/usergrid/locking/cassandra/AstyanaxLockManagerImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/locking/cassandra/AstyanaxLockManagerImpl.java
b/stack/core/src/main/java/org/apache/usergrid/locking/cassandra/AstyanaxLockManagerImpl.java
index 1786d72..f310118 100644
--- a/stack/core/src/main/java/org/apache/usergrid/locking/cassandra/AstyanaxLockManagerImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/locking/cassandra/AstyanaxLockManagerImpl.java
@@ -24,6 +24,7 @@ import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
 import com.netflix.astyanax.ddl.ColumnFamilyDefinition;
 import com.netflix.astyanax.ddl.KeyspaceDefinition;
 import com.netflix.astyanax.model.ColumnFamily;
+import com.netflix.astyanax.model.ConsistencyLevel;
 import com.netflix.astyanax.recipes.locks.ColumnPrefixDistributedRowLock;
 import com.netflix.astyanax.serializers.StringSerializer;
 import org.apache.cassandra.db.marshal.BytesType;
@@ -72,9 +73,19 @@ public class AstyanaxLockManagerImpl implements LockManager {
 
         String lockPath = LockPathBuilder.buildPath( applicationId, path );
 
+        ConsistencyLevel consistencyLevel;
+        try{
+            consistencyLevel = ConsistencyLevel.valueOf(cassandraFig.getLocksCl());
+        }catch(IllegalArgumentException e){
+
+            // just default it to local quorum if we can't parse
+            consistencyLevel = ConsistencyLevel.CL_LOCAL_QUORUM;
+        }
+
         ColumnPrefixDistributedRowLock<String> lock =
             new ColumnPrefixDistributedRowLock<>(keyspace, columnFamily, lockPath)
-                .expireLockAfter( Integer.MAX_VALUE, TimeUnit.MILLISECONDS);
+                .expireLockAfter( Integer.MAX_VALUE, TimeUnit.MILLISECONDS)
+                .withConsistencyLevel(consistencyLevel);
 
 
         return new AstyanaxLockImpl( lock );

http://git-wip-us.apache.org/repos/asf/usergrid/blob/56850926/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 d7cd57a..caee5c1 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
@@ -43,8 +43,7 @@ public interface CassandraFig extends GuicyFig {
     String LOCKS_KEYSPACE_NAME = "cassandra.lock.keyspace";
     String LOCKS_KEYSPACE_REPLICATION = "cassandra.lock.keyspace.replication";
     String LOCKS_KEYSPACE_STRATEGY = "cassandra.lock.keyspace.strategy";
-    String LOCKS_READ_CL = "cassandra.lock.readcl";
-    String LOCKS_WRITE_CL = "cassandra.lock.writecl";
+    String LOCKS_CL = "cassandra.lock.cl";
     String LOCKS_SHARED_POOL_FLAG = "cassandra.lock.use_shared_pool";
     String LOCKS_CONNECTIONS = "cassandra.lock.connections";
 
@@ -129,18 +128,11 @@ public interface CassandraFig extends GuicyFig {
     String getLocksKeyspace();
 
     /**
-     * Returns the Astyanax consistency level for reading a Lock
-     */
-    @Key( LOCKS_READ_CL )
-    @Default("CL_QUORUM")
-    String getLocksReadCl();
-
-    /**
      * Returns the Astyanax consistency level for writing a Lock
      */
-    @Key( LOCKS_WRITE_CL )
-    @Default("CL_QUORUM")
-    String getLocksWriteCl();
+    @Key(LOCKS_CL)
+    @Default("CL_LOCAL_QUORUM")
+    String getLocksCl();
 
     /**
      * Returns a flag on whether or not to share the connection pool with other keyspaces


Mime
View raw message