usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject [2/6] git commit: Fix creation of Cassandra and ElasticSearch host strings for case when more than one node.
Date Fri, 25 Jul 2014 17:40:40 GMT
Fix creation of Cassandra and ElasticSearch host strings for case when more than one node.


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

Branch: refs/heads/two-dot-o
Commit: 64413806276543f709665d88274f3368f92ae33f
Parents: 287ec6e
Author: Dave Johnson <dmjohnson@apigee.com>
Authored: Fri Jul 25 10:26:19 2014 -0400
Committer: Dave Johnson <dmjohnson@apigee.com>
Committed: Fri Jul 25 10:26:19 2014 -0400

----------------------------------------------------------------------
 .../usergrid/corepersistence/CpSetup.java       | 23 +++++++++++++++-----
 .../persistence/index/impl/EsProvider.java      |  6 ++---
 2 files changed, 20 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/64413806/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 46820e1..f3cc87c 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
@@ -41,6 +41,7 @@ import me.prettyprint.cassandra.service.CassandraHost;
 import me.prettyprint.hector.api.ddl.ComparatorType;
 
 import static me.prettyprint.hector.api.factory.HFactory.createColumnFamilyDefinition;
+import org.apache.commons.lang.StringUtils;
 import static org.apache.usergrid.persistence.cassandra.CassandraPersistenceUtils.getCfDefs;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.APPLICATIONS_CF;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.DEFAULT_APPLICATION;
@@ -103,24 +104,36 @@ public class CpSetup implements Setup {
             }
             String sep = "";
             for ( CassandraHost host : hosts ) {
-                hostsString = sep + host.getHost();
+                if (StringUtils.isEmpty(host.getHost())) {
+                    throw new RuntimeException("Fatal error: Cassandra hostname cannot be
empty");
+                }
+                hostsString = hostsString + sep + host.getHost();
                 sep = ",";
             }
 
-            // Translate Usergrid properties into Core Persistence properties
+            logger.info("hostsString: " + hostsString);
 
             Properties cpProps = new Properties();
+
+            // Some Usergrid properties must be mapped to Core Persistence properties
             cpProps.put("cassandra.hosts", hostsString);
             cpProps.put("cassandra.port", hosts[0].getPort());
-            cpProps.put("cassandra.cluster_name", 
-                    cass.getProperties().get("cassandra.cluster"));
+            cpProps.put("cassandra.cluster_name", cass.getProperties().get("cassandra.cluster"));
+
             cpProps.put("collections.keyspace.strategy.class", 
                     cass.getProperties().get("cassandra.keyspace.strategy"));
+
             cpProps.put("collections.keyspace.strategy.options", "replication_factor:" +
 
-                    cass.getProperties().get("cassandra.keyspace.strategy.options.replication_factor"));
+                    cass.getProperties().get("cassandra.keyspace.replication"));
+
+            cpProps.put("cassandra.keyspace.strategy.options.replication_factor",
+                    cass.getProperties().get("cassandra.keyspace.replication"));
+
             logger.debug("Set Cassandra properties for Core Persistence: " + cpProps.toString()
);
 
+            // Make all Usergrid properties into Core Persistence config
             cpProps.putAll( cass.getProperties() );
+            logger.debug("All properties fed to Core Persistence: " + cpProps.toString()
);
 
             ConfigurationManager.loadProperties( cpProps );
         }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/64413806/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 d696737..678aae2 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
@@ -101,18 +101,17 @@ public class EsProvider {
 
             } else { // build client that connects to all configured hosts
 
-                final String hosts = fig.getHosts();
-
                 String allHosts = "";
                 String SEP = "";
                 for (String host : fig.getHosts().split(",")) {
-                    allHosts = SEP + host + ":" + fig.getPort();
+                    allHosts = allHosts + SEP + host + ":" + fig.getPort();
                     SEP = ",";
                 }
 
                 Settings settings = ImmutableSettings.settingsBuilder()
                     .put("client.transport.ping_timeout", 2000) // milliseconds
                     .put("client.transport.nodes_sampler_interval", 100)
+                    .put("cluster.name", fig.getClusterName())
                     .put("http.enabled", false)
 
                     // this assumes that we're using zen for host discovery.  Putting an

@@ -123,7 +122,6 @@ public class EsProvider {
                 log.info("Creating ElasticSearch client with settings: " +  settings.getAsMap());
 
                 Node node = NodeBuilder.nodeBuilder().settings(settings)
-                    .clusterName(fig.getClusterName())
                     .client(true).node();
 
                 newClient = node.client();


Mime
View raw message