usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mru...@apache.org
Subject [09/15] usergrid git commit: Initial config to support defined env vars for pcf services of cassandra and elasticsearch.
Date Thu, 25 Feb 2016 19:56:55 GMT
Initial config to support defined env vars for pcf services of cassandra and elasticsearch.


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

Branch: refs/heads/master
Commit: e6003b0607c57f9650f29a5172796df5f0e5403d
Parents: 7a14d6f
Author: Michael Russo <mrusso@apigee.com>
Authored: Tue Feb 23 15:35:43 2016 -0800
Committer: Michael Russo <mrusso@apigee.com>
Committed: Tue Feb 23 15:35:43 2016 -0800

----------------------------------------------------------------------
 .../usergrid/corepersistence/GuiceFactory.java       |  6 ++++++
 .../src/main/resources/usergrid-core-context.xml     |  5 ++++-
 .../apache/usergrid/persistence/index/IndexFig.java  |  8 ++++++++
 .../usergrid/persistence/index/impl/EsProvider.java  | 15 +++++++++++++--
 4 files changed, 31 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/e6003b06/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceFactory.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceFactory.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceFactory.java
index b3ce43b..dbab22d 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceFactory.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/GuiceFactory.java
@@ -89,6 +89,12 @@ public class GuiceFactory implements FactoryBean<Injector> {
             logger.info( "Loading Core Persistence properties" );
 
             String hostsString = "";
+
+            String pcf_hosts = systemProperties.getProperty("pcf_cassandra_hosts");
+            if(pcf_hosts != null && !pcf_hosts.isEmpty()){
+                chc.setHosts(pcf_hosts);
+            }
+
             CassandraHost[] hosts = chc.buildCassandraHosts();
             if ( hosts.length == 0 ) {
                 throw new RuntimeException( "Fatal error: no Cassandra hosts configured"
);

http://git-wip-us.apache.org/repos/asf/usergrid/blob/e6003b06/stack/core/src/main/resources/usergrid-core-context.xml
----------------------------------------------------------------------
diff --git a/stack/core/src/main/resources/usergrid-core-context.xml b/stack/core/src/main/resources/usergrid-core-context.xml
index 1087f25..cb0d243 100644
--- a/stack/core/src/main/resources/usergrid-core-context.xml
+++ b/stack/core/src/main/resources/usergrid-core-context.xml
@@ -51,7 +51,10 @@
     </bean>
 
 	<bean id="cassandraHostConfigurator" class="me.prettyprint.cassandra.service.CassandraHostConfigurator">
-		<constructor-arg value="${cassandra.url}" />
+		<constructor-arg value="#{(systemProperties['pcf_cassandra_hosts'] == ''
+		|| systemProperties['pcf_cassandra_hosts'] == null ) ?
+		'${cassandra.url}' : systemProperties['pcf_cassandra_hosts'] }" />
+
         <!-- set the pool size if it's available.  If not go with 50 -->
         <property name="maxActive" value="${cassandra.connections:15}"/>
         <property name="cassandraThriftSocketTimeout" value="${cassandra.thriftSocketTimeout:5000}"
/>

http://git-wip-us.apache.org/repos/asf/usergrid/blob/e6003b06/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexFig.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexFig.java
b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexFig.java
index 33f199a..eb098d3 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexFig.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/IndexFig.java
@@ -28,8 +28,12 @@ import org.safehaus.guicyfig.Key;
 @FigSingleton
 public interface IndexFig extends GuicyFig {
 
+    String VALIDATION_DEFAULT_VALUE = "default-property";
+
     String ELASTICSEARCH_HOSTS = "elasticsearch.hosts";
 
+    String PFC_ELASTICSEARCH_HOSTS = "pcf_elasticsearch_hosts";
+
     String ELASTICSEARCH_PORT = "elasticsearch.port";
 
     String ELASTICSEARCH_CLUSTER_NAME = "elasticsearch.cluster_name";
@@ -70,6 +74,10 @@ public interface IndexFig extends GuicyFig {
     @Key( ELASTICSEARCH_HOSTS )
     String getHosts();
 
+    @Default( VALIDATION_DEFAULT_VALUE )
+    @Key( PFC_ELASTICSEARCH_HOSTS )
+    String getPfcHosts();
+
     /**
      * The port used when connecting to Elasticsearch.
      */

http://git-wip-us.apache.org/repos/asf/usergrid/blob/e6003b06/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsProvider.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsProvider.java
b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsProvider.java
index 60c41f6..5fddfe9 100644
--- a/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsProvider.java
+++ b/stack/corepersistence/queryindex/src/main/java/org/apache/usergrid/persistence/index/impl/EsProvider.java
@@ -144,8 +144,13 @@ public class EsProvider {
 
         TransportClient transportClient = new TransportClient( settings.build() );
 
+        String finalHosts = indexFig.getPfcHosts();
+        if( finalHosts == null || finalHosts.isEmpty() || finalHosts.equalsIgnoreCase(IndexFig.VALIDATION_DEFAULT_VALUE)){
+            finalHosts = indexFig.getHosts();
+        }
+        logger.info("Elasticsearch hosts used: {}", finalHosts);
         // we will connect to ES on all configured hosts
-        for ( String host : indexFig.getHosts().split( "," ) ) {
+        for ( String host : finalHosts.split( "," ) ) {
             transportClient.addTransportAddress( new InetSocketTransportAddress( host, port
) );
         }
 
@@ -171,7 +176,13 @@ public class EsProvider {
          */
         final StringBuffer hosts = new StringBuffer();
 
-        for ( String host : indexFig.getHosts().split( "," ) ) {
+        String finalHosts = indexFig.getPfcHosts();
+        if( finalHosts == null || finalHosts.isEmpty() || finalHosts.equalsIgnoreCase(IndexFig.VALIDATION_DEFAULT_VALUE)){
+            finalHosts = indexFig.getHosts();
+        }
+
+        logger.info("Elasticsearch hosts used: {}", finalHosts);
+        for ( String host : finalHosts.split( "," ) ) {
             hosts.append( host ).append( ":" ).append( port ).append( "," );
         }
 


Mime
View raw message