You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by to...@apache.org on 2014/10/17 18:00:44 UTC

[08/13] git commit: Fixed index refresh issue.

Fixed index refresh issue.

Fixed source/target switch on entity rebuild

Added performance comments as encountered


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

Branch: refs/heads/cloudformation-update
Commit: c31c553f9b3c16deda28fc0125d5b1a86a654d14
Parents: f807627
Author: Todd Nine <to...@apache.org>
Authored: Thu Oct 16 18:22:05 2014 -0600
Committer: Todd Nine <to...@apache.org>
Committed: Thu Oct 16 18:22:05 2014 -0600

----------------------------------------------------------------------
 .../corepersistence/CpEntityManager.java        |    6 +-
 .../corepersistence/CpEntityManagerFactory.java |   13 +-
 .../corepersistence/CpRelationManager.java      | 1427 ++++++++----------
 .../usergrid/corepersistence/CpWalker.java      |   11 +-
 .../PerformanceEntityRebuildIndexTest.java      |    3 +-
 .../index/impl/EsEntityIndexImpl.java           |   44 +-
 6 files changed, 692 insertions(+), 812 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c31c553f/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 4015014..2498dda 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
@@ -514,7 +514,7 @@ public class CpEntityManager implements EntityManager {
 
         // update in all containing collections and connection indexes
         CpRelationManager rm = (CpRelationManager)getRelationManager( entity );
-        rm.updateContainingCollectionAndCollectionIndexes( entity, cpEntity );
+        rm.updateContainingCollectionAndCollectionIndexes( cpEntity );
     }
 
 
@@ -995,7 +995,7 @@ public class CpEntityManager implements EntityManager {
 //        }
 
         org.apache.usergrid.persistence.model.entity.Entity cpEntity =
-                ecm.load( entityId ).toBlockingObservable().last();
+                ecm.load( entityId ).toBlocking().last();
 
         cpEntity.removeField( propertyName );
 
@@ -1012,7 +1012,7 @@ public class CpEntityManager implements EntityManager {
 
         // update in all containing collections and connection indexes
         CpRelationManager rm = (CpRelationManager)getRelationManager( entityRef );
-        rm.updateContainingCollectionAndCollectionIndexes( get( entityRef ), cpEntity );
+        rm.updateContainingCollectionAndCollectionIndexes( cpEntity );
     }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/c31c553f/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 2514e20..e013957 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
@@ -147,6 +147,7 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
                 sysAppProps.put( PROPERTY_NAME, "systemapp");
                 em.create( SYSTEM_APP_ID, TYPE_APPLICATION, sysAppProps );
                 em.getApplication();
+                em.createIndex();
                 em.refreshIndex();
             }
 
@@ -200,7 +201,10 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
     private EntityManager _getEntityManager( UUID applicationId ) {
         EntityManager em = new CpEntityManager();
         em.init( this, applicationId );
-        //TODO T.N. Can we remove this?  Seems like we should fix our lifecycle instead...
+        //TODO PERFORMANCE  Can we remove this?  Seems like we should fix our lifecycle instead...
+        //if this is the first time we've loaded this entity manager in the JVM, create it's indexes, it may be new
+        //not sure how to handle other than this if the system dies after the application em has been created
+        //but before the create call can create the index
         em.createIndex();
         return em;
     }
@@ -286,7 +290,8 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
         EntityManager appEm = getEntityManager( applicationId );
 
         //create our ES index since we're initializing this application
-//  TODO T.N, pushed this down into the cache load      appEm.createIndex();
+//  TODO PERFORMANCE  pushed this down into the cache load can we do this here?
+//        appEm.createIndex();
 
         appEm.create( applicationId, TYPE_APPLICATION, properties );
         appEm.resetRoles();
@@ -681,10 +686,12 @@ public class CpEntityManagerFactory implements EntityManagerFactory, Application
     public void rebuildApplicationIndexes( UUID appId, ProgressObserver po ) throws Exception {
 
         EntityManager em = getEntityManager( appId );
+
+        //explicitly invoke create index, we don't know if it exists or not in ES during a rebuild.
+        em.createIndex();
         Application app = em.getApplication();
 
         em.reindex( po );
-//        em.refreshIndex();
 
         logger.info("\n\nRebuilt index for application {} id {}\n", app.getName(), appId );
     }