You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sn...@apache.org on 2014/11/10 15:24:05 UTC

[23/50] [abbrv] incubator-usergrid git commit: [APIBAAS-1362]External elasticsearch setup

[APIBAAS-1362]External elasticsearch setup


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

Branch: refs/heads/two-dot-o
Commit: 46d6c059f3e3b2a96624c32b3a7c02e4c7cdd217
Parents: c86d541
Author: ryan bridges <rb...@apigee.com>
Authored: Thu Nov 6 12:41:33 2014 -0500
Committer: ryan bridges <rb...@apigee.com>
Committed: Thu Nov 6 13:43:22 2014 -0500

----------------------------------------------------------------------
 .../index/impl/ElasticSearchResource.java       | 30 +++++++++++++++++---
 1 file changed, 26 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/46d6c059/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/ElasticSearchResource.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/ElasticSearchResource.java b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/ElasticSearchResource.java
index 42ab652..d4d2892 100644
--- a/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/ElasticSearchResource.java
+++ b/stack/corepersistence/queryindex/src/test/java/org/apache/usergrid/persistence/index/impl/ElasticSearchResource.java
@@ -32,13 +32,13 @@ import org.safehaus.guicyfig.EnvironResource;
 import org.safehaus.guicyfig.GuicyFigModule;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-
 import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang.ArrayUtils;
 import org.apache.commons.lang.RandomStringUtils;
-
 import org.apache.usergrid.persistence.core.util.AvailablePortFinder;
 import org.apache.usergrid.persistence.index.IndexFig;
 
+import com.amazonaws.util.StringUtils;
 import com.google.inject.Guice;
 import com.google.inject.Injector;
 
@@ -50,17 +50,37 @@ public class ElasticSearchResource extends EnvironResource {
     private static Node node;
 
     private static int port;
+    private static String host;
+    
+    private static boolean externalElasticSearch = false;
 
 
 
     public ElasticSearchResource() {
         super( Env.UNIT );
+        try {
+            Properties props = new Properties();
+            props.load( ClassLoader.getSystemResourceAsStream( "project.properties" ) );
+            host=(String)props.getProperty( "elasticsearch.host", "127.0.0.1" );
+            port=Integer.valueOf(props.getProperty( "elasticsearch.port", "9300" )).intValue();
+            String forkString = props.getProperty("elasticsearch.startup");
+            externalElasticSearch = "external".equals( forkString );
+
+        } catch (Exception ex) {
+            throw new RuntimeException("Error getting properties", ex);
+        }
     }
 
 
     @Override
     protected void before() throws Throwable {
-        startEs();
+    	if(externalElasticSearch){
+            System.setProperty( IndexFig.ELASTICSEARCH_HOSTS, host );
+            System.setProperty( IndexFig.ELASTICSEARCH_PORT, port+"" );
+    		
+    	}else{
+            startEs();
+    	}
     }
 
 
@@ -133,7 +153,9 @@ public class ElasticSearchResource extends EnvironResource {
 
 
     public static void shutdown() {
-        node.stop();
+    	if(!externalElasticSearch){
+            node.stop();
+    	}
     }