usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g...@apache.org
Subject usergrid git commit: Initial commit adding system property called "elasticsearch" that is a boolean. That boolean can be set to true or left alone if we want to use elasticsearch in the code base or set it to false if we only want to use cassandra. Works
Date Mon, 04 Apr 2016 23:47:41 GMT
Repository: usergrid
Updated Branches:
  refs/heads/USERGRID-1272 [created] f82381d66


Initial commit adding system property called "elasticsearch" that is a boolean. That boolean
can be set to true or left alone if we want to use elasticsearch in the code base or set it
to false if we only want to use cassandra. Works for EntityManagerIT.testCreateAndDelete currently.


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

Branch: refs/heads/USERGRID-1272
Commit: f82381d66346b2610d1cc8bd2cea5ae4498cbd3a
Parents: e0931be
Author: George Reyes <grey@apache.org>
Authored: Mon Apr 4 16:47:36 2016 -0700
Committer: George Reyes <grey@apache.org>
Committed: Mon Apr 4 16:47:36 2016 -0700

----------------------------------------------------------------------
 .../corepersistence/CpEntityManagerFactory.java |  6 ++--
 .../corepersistence/CpRelationManager.java      | 10 ++++---
 .../usergrid/corepersistence/CpSetup.java       |  4 ++-
 .../service/CollectionServiceImpl.java          |  3 +-
 .../org/apache/usergrid/CoreApplication.java    | 29 ++++++++++++--------
 5 files changed, 33 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/f82381d6/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 0462ac6..0790838 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
@@ -261,8 +261,10 @@ public class CpEntityManagerFactory implements EntityManagerFactory,
Application
         }
 
         getSetup().setupApplicationKeyspace( applicationId, appName );
-        appEm.initializeIndex();
-        indexService.queueInitializeApplicationIndex(CpNamingUtils.getApplicationScope(applicationId));
+        if(System.getProperty( "elasticsearch" ).isEmpty() || System.getProperty( "elasticsearch"
).equals( "true" )) {
+            appEm.initializeIndex();
+            indexService.queueInitializeApplicationIndex( CpNamingUtils.getApplicationScope(
applicationId ) );
+        }
         if ( properties == null ) {
             properties = new TreeMap<>( CASE_INSENSITIVE_ORDER);
         }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/f82381d6/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
index cfb8dfa..12421fb 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpRelationManager.java
@@ -405,10 +405,12 @@ public class CpRelationManager implements RelationManager {
                 indexService.queueNewEdge( applicationScope, cpHeadEntity, reverseEdge );
             } );
         } ).doOnCompleted( () -> {
-            indexService.queueNewEdge( applicationScope, memberEntity, edge );
-            if ( logger.isDebugEnabled() ) {
-                logger.debug( "Added entity {}:{} to collection {}",
-                    itemRef.getUuid().toString(), itemRef.getType(), collectionName );
+            if(System.getProperty( "elasticsearch" ).isEmpty() || System.getProperty( "elasticsearch"
).equals( "true" )) {
+                indexService.queueNewEdge( applicationScope, memberEntity, edge );
+                if ( logger.isDebugEnabled() ) {
+                    logger.debug( "Added entity {}:{} to collection {}", itemRef.getUuid().toString(),
itemRef.getType(),
+                        collectionName );
+                }
             }
         } ).toBlocking().lastOrDefault( null );
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/f82381d6/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java
index e97be3f..4a24260 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpSetup.java
@@ -82,7 +82,9 @@ public class CpSetup implements Setup {
     public void initSubsystems() throws Exception {
         //a no op, creating the injector creates the connections
         //init our index if required
-        this.emf.initializeManagementIndex();
+        if(System.getProperty( "elasticsearch" ).isEmpty() || System.getProperty( "elasticsearch"
).equals( "true" )) {
+            this.emf.initializeManagementIndex();
+        }
         setupStaticKeyspace();
         setupSystemKeyspace();
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/f82381d6/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/CollectionServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/CollectionServiceImpl.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/CollectionServiceImpl.java
index fa79d09..8982ad4 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/CollectionServiceImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/service/CollectionServiceImpl.java
@@ -63,7 +63,8 @@ public class CollectionServiceImpl implements CollectionService {
 
         final EntityBuilder results;
 
-        if ( !query.isPresent()) {
+
+        if ( !query.isPresent() ||((!System.getProperty( "elasticsearch" ).isEmpty() &&
!System.getProperty( "elasticsearch" ).equals( "true" )))) {
             results = pipelineBuilder.traverseCollection( collectionName ).loadEntities();
         }
         else {

http://git-wip-us.apache.org/repos/asf/usergrid/blob/f82381d6/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java b/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
index 9046f02..62a91c4 100644
--- a/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
+++ b/stack/core/src/test/java/org/apache/usergrid/CoreApplication.java
@@ -172,11 +172,14 @@ public class CoreApplication implements Application, TestRule {
 
         em = setup.getEmf().getEntityManager(id);
         Injector injector = setup.getInjector();
-        IndexLocationStrategyFactory indexLocationStrategyFactory = injector.getInstance(IndexLocationStrategyFactory.class);
-        entityIndexFactory = injector.getInstance(EntityIndexFactory.class);
-        applicationIndex =  entityIndexFactory.createEntityIndex(
-            indexLocationStrategyFactory.getIndexLocationStrategy(CpNamingUtils.getApplicationScope(id))
-        );
+        if(System.getProperty( "elasticsearch" ).isEmpty() || System.getProperty( "elasticsearch"
).equals( "true" )) {
+
+            IndexLocationStrategyFactory indexLocationStrategyFactory =
+                injector.getInstance( IndexLocationStrategyFactory.class );
+            entityIndexFactory = injector.getInstance( EntityIndexFactory.class );
+            applicationIndex = entityIndexFactory.createEntityIndex(
+                indexLocationStrategyFactory.getIndexLocationStrategy( CpNamingUtils.getApplicationScope(
id ) ) );
+        }
         assertNotNull(em);
 
         logger.info( "Created new application {} in organization {}", appName, orgName );
@@ -226,14 +229,18 @@ public class CoreApplication implements Application, TestRule {
 
     @Override
     public synchronized void refreshIndex() {
-        //Insert test entity and find it
-        setup.getEmf().refreshIndex(CpNamingUtils.getManagementApplicationId().getUuid());
 
-        if (!em.getApplicationId().equals(CpNamingUtils.getManagementApplicationId().getUuid()))
{
-            setup.getEmf().refreshIndex(em.getApplicationId());
-        }
+        if(System.getProperty( "elasticsearch" ).isEmpty() || System.getProperty( "elasticsearch"
).equals( "true" )) {
+
+            //Insert test entity and find it
+            setup.getEmf().refreshIndex( CpNamingUtils.getManagementApplicationId().getUuid()
);
 
-        em.refreshIndex();
+            if ( !em.getApplicationId().equals( CpNamingUtils.getManagementApplicationId().getUuid()
) ) {
+                setup.getEmf().refreshIndex( em.getApplicationId() );
+            }
+
+            em.refreshIndex();
+        }
     }
 
 


Mime
View raw message