usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sfeld...@apache.org
Subject [07/11] usergrid git commit: Fixes comments and refactors map to be a cleaner read pattern
Date Tue, 20 Oct 2015 19:17:45 GMT
Fixes comments and refactors map to be a cleaner read pattern


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

Branch: refs/heads/remove-inmemory-event-service
Commit: e50835f1016a9988513a00b64337222957fa7747
Parents: fbb6c82
Author: Todd Nine <tnine@apigee.com>
Authored: Tue Oct 20 09:34:43 2015 -0600
Committer: Todd Nine <tnine@apigee.com>
Committed: Tue Oct 20 09:34:43 2015 -0600

----------------------------------------------------------------------
 .../asyncevents/AmazonAsyncEventService.java    |  2 +-
 .../core/astyanax/CassandraConfig.java          |  8 ++---
 .../core/astyanax/CassandraConfigImpl.java      |  1 +
 .../map/impl/MapSerializationImpl.java          | 37 ++++----------------
 .../queue/impl/SNSQueueManagerImpl.java         |  4 +--
 5 files changed, 14 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/e50835f1/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/AmazonAsyncEventService.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/AmazonAsyncEventService.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/AmazonAsyncEventService.java
index 38c2966..6f779b5 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/AmazonAsyncEventService.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/asyncevents/AmazonAsyncEventService.java
@@ -521,7 +521,7 @@ public class AmazonAsyncEventService implements AsyncEventService {
         final IndexOperationMessage indexOperationMessage;
 
         if(message == null){
-            logger.error( "Received message with id {} to process, unable to find it, reading
with higher consistency level",
+            logger.warn( "Received message with id {} to process, unable to find it, reading
with higher consistency level",
                 messageId);
 
             final String highConsistency =  esMapPersistence.getStringHighConsistency( messageId.toString()
);

http://git-wip-us.apache.org/repos/asf/usergrid/blob/e50835f1/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/CassandraConfig.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/CassandraConfig.java
b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/CassandraConfig.java
index 817aee2..dba3646 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/CassandraConfig.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/CassandraConfig.java
@@ -34,25 +34,25 @@ public interface CassandraConfig {
      * Get the currently configured ReadCL
      * @return
      */
-    public ConsistencyLevel getReadCL();
+    ConsistencyLevel getReadCL();
 
     /**
      * Get the currently configured ReadCL that is more consitent than getReadCL
      * @return
      */
-    public ConsistencyLevel getConsistentReadCL();
+    ConsistencyLevel getConsistentReadCL();
 
     /**
      * Get the currently configured write CL
      * @return
      */
-    public ConsistencyLevel getWriteCL();
+    ConsistencyLevel getWriteCL();
 
     /**
      * Return the number of shards that has been set in the property file
      * @return
      */
-    public int[] getShardSettings();
+    int[] getShardSettings();
 
 
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/e50835f1/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/CassandraConfigImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/CassandraConfigImpl.java
b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/CassandraConfigImpl.java
index 17b91c6..7373322 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/CassandraConfigImpl.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/CassandraConfigImpl.java
@@ -83,6 +83,7 @@ public class CassandraConfigImpl implements CassandraConfig {
     public ConsistencyLevel getConsistentReadCL() {
         return consistentCl;
     }
+
     @Override
     public ConsistencyLevel getWriteCL() {
         return writeCl;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/e50835f1/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 ffe10c9..ceeb3ad 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
@@ -129,14 +129,14 @@ public class MapSerializationImpl implements MapSerialization {
 
     @Override
     public String getString( final MapScope scope, final String key ) {
-        Column<Boolean> col = getValue( scope, key );
+        Column<Boolean> col = getValue( scope, key, cassandraConfig.getReadCL()  );
         return ( col != null ) ? col.getStringValue() : null;
     }
 
 
     @Override
     public String getStringHighConsistency( final MapScope scope, final String key ) {
-        Column<Boolean> col = getValueHighConsistency( scope, key ); // TODO: why boolean?
+        Column<Boolean> col = getValue( scope, key, cassandraConfig.getConsistentReadCL()
); // TODO: why boolean?
         return ( col != null ) ? col.getStringValue() : null;
     }
 
@@ -248,7 +248,7 @@ public class MapSerializationImpl implements MapSerialization {
     @Override
     public UUID getUuid( final MapScope scope, final String key ) {
 
-        Column<Boolean> col = getValue( scope, key );
+        Column<Boolean> col = getValue( scope, key, cassandraConfig.getReadCL() );
         return ( col != null ) ? col.getUUIDValue() : null;
     }
 
@@ -283,7 +283,7 @@ public class MapSerializationImpl implements MapSerialization {
 
     @Override
     public Long getLong( final MapScope scope, final String key ) {
-        Column<Boolean> col = getValue( scope, key );
+        Column<Boolean> col = getValue( scope, key, cassandraConfig.getReadCL() );
         return ( col != null ) ? col.getLongValue() : null;
     }
 
@@ -355,31 +355,7 @@ public class MapSerializationImpl implements MapSerialization {
     }
 
 
-    private Column<Boolean> getValue( MapScope scope, String key ) {
-
-
-        //add it to the entry
-        final ScopedRowKey<MapEntryKey> entryRowKey = MapEntryKey.fromKey( scope, key
);
-
-        //now get all columns, including the "old row key value"
-        try {
-            final Column<Boolean> result =
-                keyspace.prepareQuery( MAP_ENTRIES ).getKey( entryRowKey ).getColumn( true
).execute().getResult();
-
-            return result;
-        }
-        catch ( NotFoundException nfe ) {
-            //nothing to return
-            return null;
-        }
-        catch ( ConnectionException e ) {
-            throw new RuntimeException( "Unable to connect to cassandra", e );
-        }
-    }
-
-
-    private Column<Boolean> getValueHighConsistency( MapScope scope, String key ) {
-
+    private Column<Boolean> getValue( MapScope scope, String key, final ConsistencyLevel
consistencyLevel ) {
 
         //add it to the entry
         final ScopedRowKey<MapEntryKey> entryRowKey = MapEntryKey.fromKey( scope, key
);
@@ -387,8 +363,7 @@ public class MapSerializationImpl implements MapSerialization {
         //now get all columns, including the "old row key value"
         try {
             final Column<Boolean> result =
-                keyspace.prepareQuery( MAP_ENTRIES ).setConsistencyLevel( cassandraConfig.getConsistentReadCL()
)
-                        .getKey( entryRowKey ).getColumn( true ).execute().getResult();
+                keyspace.prepareQuery( MAP_ENTRIES ).setConsistencyLevel( consistencyLevel
).getKey( entryRowKey ).getColumn( true ).execute().getResult();
 
             return result;
         }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/e50835f1/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/SNSQueueManagerImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/SNSQueueManagerImpl.java
b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/SNSQueueManagerImpl.java
index 1bb00dc..bc5f2f1 100644
--- a/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/SNSQueueManagerImpl.java
+++ b/stack/corepersistence/queue/src/main/java/org/apache/usergrid/persistence/queue/impl/SNSQueueManagerImpl.java
@@ -438,7 +438,7 @@ public class SNSQueueManagerImpl implements QueueManager {
 
                     /**
                      * When a message originates from SNS it has a "Message"  we have to
extract
-                     * it and then process it seperately
+                     * it and then process it separately
                      */
 
 
@@ -546,7 +546,7 @@ public class SNSQueueManagerImpl implements QueueManager {
         if ( sqsAsync == null ) {
             logger.error( "SQS client is null, perhaps it failed to initialize successfully"
);
             return;
-        }   
+        }
 
         for ( Object body : bodies ) {
             sendMessage( ( Serializable ) body );


Mime
View raw message