usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mru...@apache.org
Subject usergrid git commit: Disable reading from shard cache when obtaining read shard groups so it's always accurate.
Date Wed, 23 Mar 2016 20:00:10 GMT
Repository: usergrid
Updated Branches:
  refs/heads/release-2.1.1 e64fa3503 -> b9e808841


Disable reading from shard cache when obtaining read shard groups so it's always accurate.


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

Branch: refs/heads/release-2.1.1
Commit: b9e808841d61688e9b752649130119f0afb1e079
Parents: e64fa35
Author: Michael Russo <mrusso@apigee.com>
Authored: Wed Mar 23 13:00:07 2016 -0700
Committer: Michael Russo <mrusso@apigee.com>
Committed: Wed Mar 23 13:00:07 2016 -0700

----------------------------------------------------------------------
 .../usergrid/persistence/graph/GraphFig.java    |  9 +++++++++
 .../impl/shard/impl/NodeShardCacheImpl.java     | 21 ++++++++++++--------
 2 files changed, 22 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/b9e80884/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/GraphFig.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/GraphFig.java
b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/GraphFig.java
index 5968097..573e911 100644
--- a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/GraphFig.java
+++ b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/GraphFig.java
@@ -55,6 +55,11 @@ public interface GraphFig extends GuicyFig {
     String SHARD_CACHE_TIMEOUT = "usergrid.graph.shard.cache.timeout";
 
     /**
+     * Provide the ability to default disable the cache for obtaining the read shard group
+     */
+    String SHARD_READ_CACHE_ENABLED = "usergrid.graph.shard.read.cache.enabled";
+
+    /**
      * Number of worker threads to refresh the cache
      */
     String SHARD_CACHE_REFRESH_WORKERS = "usergrid.graph.shard.refresh.worker.count";
@@ -118,6 +123,10 @@ public interface GraphFig extends GuicyFig {
     @Key(SHARD_CACHE_TIMEOUT)
     long getShardCacheTimeout();
 
+    @Default("false")
+    @Key(SHARD_READ_CACHE_ENABLED)
+    boolean getShardReadCacheEnabled();
+
     @Default("90000")
     @Key(SHARD_MIN_DELTA)
     long getShardMinDelta();

http://git-wip-us.apache.org/repos/asf/usergrid/blob/b9e80884/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/NodeShardCacheImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/NodeShardCacheImpl.java
b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/NodeShardCacheImpl.java
index bbc0431..545ac37 100644
--- a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/NodeShardCacheImpl.java
+++ b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/serialization/impl/shard/impl/NodeShardCacheImpl.java
@@ -164,18 +164,23 @@ public class NodeShardCacheImpl implements NodeShardCache {
         final CacheKey key = new CacheKey( scope, directedEdgeMeta );
         CacheEntry entry;
 
-        try {
-            entry = this.graphs.get( key );
-        }
-        catch ( ExecutionException e ) {
-            throw new GraphRuntimeException( "Unable to load shard key for graph", e );
-        }
+        if( graphFig.getShardReadCacheEnabled() ) {
 
-        // do this if wanting to bypass the cache for getting the read shards
-        //entry = new CacheEntry(nodeShardAllocation.getShards( key.scope, Optional.<Shard>absent(),
key.directedEdgeMeta ));
+            try {
+                entry = this.graphs.get(key);
+            } catch (ExecutionException e) {
+                throw new GraphRuntimeException("Unable to load shard key for graph", e);
+            }
+
+        } else {
+
+            entry = new CacheEntry(nodeShardAllocation.getShards( key.scope, Optional.<Shard>absent(),
key.directedEdgeMeta ));
+
+        }
 
         Iterator<ShardEntryGroup> iterator = entry.getShards( maxTimestamp );
 
+
         if ( iterator == null ) {
             return Collections.<ShardEntryGroup>emptyList().iterator();
         }


Mime
View raw message