usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject [25/36] usergrid git commit: Removed the index schema cache from the manager cache as it can and should stand alone.
Date Fri, 08 Apr 2016 20:21:12 GMT
Removed the index schema cache from the manager cache as it can and should stand alone.


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

Branch: refs/heads/release-2.1.1
Commit: 78bba1a7917ea85e88bcdf965f13505187260ff4
Parents: 0aa241d
Author: George Reyes <grey@apache.org>
Authored: Wed Mar 30 17:20:53 2016 -0700
Committer: George Reyes <grey@apache.org>
Committed: Wed Mar 30 17:20:53 2016 -0700

----------------------------------------------------------------------
 .../usergrid/corepersistence/CpEntityManager.java |  9 +++++++--
 .../corepersistence/CpEntityManagerFactory.java   |  4 +++-
 .../usergrid/corepersistence/CpManagerCache.java  | 18 ------------------
 .../usergrid/corepersistence/ManagerCache.java    |  2 --
 .../index/IndexSchemaCacheImpl.java               |  6 ++----
 .../corepersistence/index/ReIndexServiceImpl.java |  2 ++
 6 files changed, 14 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/78bba1a7/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
index e39a584..968d91d 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
@@ -40,6 +40,7 @@ import java.util.UUID;
 
 
 import org.apache.usergrid.corepersistence.index.IndexSchemaCache;
+import org.apache.usergrid.corepersistence.index.IndexSchemaCacheFactory;
 import org.apache.usergrid.corepersistence.service.CollectionService;
 import org.apache.usergrid.corepersistence.service.ConnectionService;
 import org.apache.usergrid.persistence.index.EntityIndex;
@@ -185,6 +186,8 @@ public class CpEntityManager implements EntityManager {
 
     private final ManagerCache managerCache;
 
+    private final IndexSchemaCacheFactory indexSchemaCacheFactory;
+
     private final ApplicationScope applicationScope;
 
     private final CassandraService cass;
@@ -246,6 +249,7 @@ public class CpEntityManager implements EntityManager {
                             final GraphManagerFactory graphManagerFactory,
                             final CollectionService collectionService,
                             final ConnectionService connectionService,
+                            final IndexSchemaCacheFactory indexSchemaCacheFactory,
                             final UUID applicationId ) {
 
         this.entityManagerFig = entityManagerFig;
@@ -269,6 +273,7 @@ public class CpEntityManager implements EntityManager {
         this.managerCache = managerCache;
         this.applicationId = applicationId;
         this.indexService = indexService;
+        this.indexSchemaCacheFactory = indexSchemaCacheFactory;
 
         applicationScope = CpNamingUtils.getApplicationScope( applicationId );
 
@@ -1763,7 +1768,7 @@ public class CpEntityManager implements EntityManager {
 
         MapManager mm = getMapManagerForTypes();
 
-        IndexSchemaCache indexSchemaCache = managerCache.getIndexSchema( mm );
+        IndexSchemaCache indexSchemaCache = indexSchemaCacheFactory.getInstance( mm );
 
         java.util.Optional<String> collectionIndexingSchema = indexSchemaCache.getCollectionSchema(
collectionName );
 
@@ -1795,7 +1800,7 @@ public class CpEntityManager implements EntityManager {
     public Object getCollectionSchema( String collectionName ){
         MapManager mm = getMapManagerForTypes();
 
-        IndexSchemaCache indexSchemaCache = managerCache.getIndexSchema( mm );
+        IndexSchemaCache indexSchemaCache = indexSchemaCacheFactory.getInstance( mm ); //managerCache.getIndexSchema(
mm );
 
         java.util.Optional<String> collectionIndexingSchema =  indexSchemaCache.getCollectionSchema(
collectionName );
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/78bba1a7/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
index 047947e..a2054d9 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
@@ -125,6 +125,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
     private final CollectionService collectionService;
     private final ConnectionService connectionService;
     private final GraphManagerFactory graphManagerFactory;
+    private final IndexSchemaCacheFactory indexSchemaCacheFactory;
 
     public CpEntityManagerFactory( final CassandraService cassandraService, final CounterUtils
counterUtils,
                                    final Injector injector ) {
@@ -140,6 +141,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
         this.graphManagerFactory = injector.getInstance( GraphManagerFactory.class );
         this.collectionService = injector.getInstance( CollectionService.class );
         this.connectionService = injector.getInstance( ConnectionService.class );
+        this.indexSchemaCacheFactory = injector.getInstance( IndexSchemaCacheFactory.class
);
 
         //this line always needs to be last due to the temporary cicular dependency until
spring is removed
 
@@ -201,7 +203,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
 
     private EntityManager _getEntityManager( UUID applicationId ) {
         EntityManager em = new CpEntityManager(cassandraService, counterUtils, indexService,
managerCache,
-            metricsFactory, entityManagerFig, graphManagerFactory,  collectionService, connectionService,
applicationId );
+            metricsFactory, entityManagerFig, graphManagerFactory,  collectionService, connectionService,indexSchemaCacheFactory,
applicationId );
 
         return em;
     }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/78bba1a7/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpManagerCache.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpManagerCache.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpManagerCache.java
index e30de0f..4e1f5e3 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpManagerCache.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpManagerCache.java
@@ -16,20 +16,13 @@
 package org.apache.usergrid.corepersistence;
 
 
-import java.util.Optional;
-
-import org.safehaus.guicyfig.Overrides;
-
 import org.apache.usergrid.corepersistence.index.IndexLocationStrategyFactory;
-import org.apache.usergrid.corepersistence.index.IndexSchemaCache;
-import org.apache.usergrid.corepersistence.index.IndexSchemaCacheFactory;
 import org.apache.usergrid.persistence.collection.EntityCollectionManager;
 import org.apache.usergrid.persistence.collection.EntityCollectionManagerFactory;
 import org.apache.usergrid.persistence.core.scope.ApplicationScope;
 import org.apache.usergrid.persistence.graph.GraphManager;
 import org.apache.usergrid.persistence.graph.GraphManagerFactory;
 import org.apache.usergrid.persistence.index.EntityIndex;
-import org.apache.usergrid.persistence.index.EntityIndex;
 import org.apache.usergrid.persistence.index.EntityIndexFactory;
 import org.apache.usergrid.persistence.index.IndexLocationStrategy;
 import org.apache.usergrid.persistence.index.impl.IndexProducer;
@@ -50,7 +43,6 @@ public class CpManagerCache implements ManagerCache {
     private final EntityIndexFactory eif;
     private final GraphManagerFactory gmf;
     private final MapManagerFactory mmf;
-    private final IndexSchemaCacheFactory indexSchemaCacheFactory;
     private final IndexLocationStrategyFactory indexLocationStrategyFactory;
     private final IndexProducer indexProducer;
 
@@ -62,7 +54,6 @@ public class CpManagerCache implements ManagerCache {
                            final EntityIndexFactory eif,
                            final GraphManagerFactory gmf,
                            final MapManagerFactory mmf,
-                           final IndexSchemaCacheFactory indexSchemaCacheFactory,
                            final IndexLocationStrategyFactory indexLocationStrategyFactory,
                            final IndexProducer indexProducer
     ) {
@@ -71,7 +62,6 @@ public class CpManagerCache implements ManagerCache {
         this.eif = eif;
         this.gmf = gmf;
         this.mmf = mmf;
-        this.indexSchemaCacheFactory = indexSchemaCacheFactory;
         this.indexLocationStrategyFactory = indexLocationStrategyFactory;
         this.indexProducer = indexProducer;
     }
@@ -103,14 +93,6 @@ public class CpManagerCache implements ManagerCache {
         return mmf.createMapManager( mapScope );
     }
 
-    //could be called an index schema manager.
-
-    @Override
-    public IndexSchemaCache getIndexSchema( MapManager mapManager ) {
-        return indexSchemaCacheFactory.getInstance( mapManager );
-    }
-
-
     @Override
     public IndexProducer getIndexProducer() {
         return indexProducer;

http://git-wip-us.apache.org/repos/asf/usergrid/blob/78bba1a7/stack/core/src/main/java/org/apache/usergrid/corepersistence/ManagerCache.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/ManagerCache.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/ManagerCache.java
index c07930c..ebfd5a4 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/ManagerCache.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/ManagerCache.java
@@ -69,8 +69,6 @@ public interface ManagerCache {
      */
     MapManager getMapManager(MapScope mapScope);
 
-    IndexSchemaCache getIndexSchema( MapManager mapManager );
-
     /**
      * gets index producer
      * @return

http://git-wip-us.apache.org/repos/asf/usergrid/blob/78bba1a7/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexSchemaCacheImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexSchemaCacheImpl.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexSchemaCacheImpl.java
index d818ce0..90c07bf 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexSchemaCacheImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/IndexSchemaCacheImpl.java
@@ -18,26 +18,24 @@
 package org.apache.usergrid.corepersistence.index;
 
 
-import java.util.Map;
 import java.util.Optional;
-import java.util.concurrent.TimeUnit;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import org.apache.usergrid.corepersistence.ManagerCache;
 import org.apache.usergrid.persistence.map.MapManager;
-import org.apache.usergrid.utils.JsonUtils;
 
 import com.google.common.cache.CacheBuilder;
 import com.google.common.cache.CacheLoader;
 import com.google.common.cache.LoadingCache;
+import com.google.inject.Singleton;
 
 
 /**
  * Cache the calls to update and get the map manager so we don't overload cassandra when
we update
  * after each call?
  */
+@Singleton
 public class IndexSchemaCacheImpl implements IndexSchemaCache {
     private static final Logger logger = LoggerFactory.getLogger(IndexSchemaCacheImpl.class
);
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/78bba1a7/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/ReIndexServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/ReIndexServiceImpl.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/ReIndexServiceImpl.java
index 1b68712..559e117 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/ReIndexServiceImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/index/ReIndexServiceImpl.java
@@ -157,7 +157,9 @@ public class ReIndexServiceImpl implements ReIndexService {
                 Map jsonMapData = ( Map ) JsonUtils.parse( jsonSchemaMap );
 
                 jsonMapData.put( "lastReindexed", Instant.now().toEpochMilli() );
+                //should probably roll this into the cache.
                 collectionMapStorage.putString( collectionName,JsonUtils.mapToJsonString(jsonMapData
)  );
+                indexSchemaCache.evictCollectionSchema( collectionName );
             }
 
         }


Mime
View raw message