You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by gr...@apache.org on 2015/02/26 19:18:47 UTC

[14/50] [abbrv] incubator-usergrid git commit: Added fix for circular decencies and added support for multiple key spaces.

Added fix for circular decencies and added support for multiple key spaces.


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

Branch: refs/heads/USERGRID-280
Commit: 08c1f1d08c7c6bb9ce3a4cf979e09fb0d733ef46
Parents: aac4a2f
Author: grey <gr...@apigee.com>
Authored: Mon Feb 23 16:25:31 2015 -0800
Committer: grey <gr...@apigee.com>
Committed: Mon Feb 23 16:25:31 2015 -0800

----------------------------------------------------------------------
 .../usergrid/corepersistence/GuiceFactory.java  | 25 ++++++++------------
 .../main/resources/usergrid-core-context.xml    |  4 ++--
 2 files changed, 12 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/08c1f1d0/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 77831fe..566430f 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
@@ -32,6 +32,7 @@ import org.springframework.context.ApplicationContextAware;
 import org.apache.commons.lang.StringUtils;
 
 import org.apache.usergrid.persistence.cassandra.CassandraService;
+import org.apache.usergrid.persistence.core.guice.CommonModule;
 
 import com.google.inject.Guice;
 import com.google.inject.Injector;
@@ -39,6 +40,7 @@ import com.google.inject.Singleton;
 import com.netflix.config.ConfigurationManager;
 
 import me.prettyprint.cassandra.service.CassandraHost;
+import me.prettyprint.cassandra.service.CassandraHostConfigurator;
 
 
 /**
@@ -49,8 +51,7 @@ public class GuiceFactory implements FactoryBean<Injector>, ApplicationContextAw
 
     private static final Logger logger = LoggerFactory.getLogger( GuiceFactory.class );
 
-
-    private final CassandraService cass;
+    private final CassandraHostConfigurator chc;
 
     private final Properties systemProperties;
 
@@ -61,8 +62,8 @@ public class GuiceFactory implements FactoryBean<Injector>, ApplicationContextAw
 
 
 
-    public GuiceFactory( final CassandraService cass, final Properties systemProperties ) {
-        this.cass = cass;
+    public GuiceFactory( final CassandraHostConfigurator chc, final Properties systemProperties  ) {
+        this.chc = chc;
         this.systemProperties = systemProperties;
     }
 
@@ -74,14 +75,12 @@ public class GuiceFactory implements FactoryBean<Injector>, ApplicationContextAw
             return injector;
         }
 
-
         try {
 
-            cass.init();
             logger.info( "Loading Core Persistence properties" );
 
             String hostsString = "";
-            CassandraHost[] hosts = cass.getCassandraHostConfigurator().buildCassandraHosts();
+            CassandraHost[] hosts = chc.buildCassandraHosts();
             if ( hosts.length == 0 ) {
                 throw new RuntimeException( "Fatal error: no Cassandra hosts configured" );
             }
@@ -101,9 +100,9 @@ public class GuiceFactory implements FactoryBean<Injector>, ApplicationContextAw
             // 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",  systemProperties.getProperty( "cassandra.cluster" ) );
 
-            String cassRemoteString = ( String ) cass.getProperties().get( "cassandra.use_remote" );
+            String cassRemoteString = ( String ) systemProperties.getProperty( "cassandra.use_remote" );
             if ( cassRemoteString != null && cassRemoteString.equals( "false" ) ) {
                 cpProps.put( "cassandra.embedded", "true" );
             }
@@ -112,21 +111,17 @@ public class GuiceFactory implements FactoryBean<Injector>, ApplicationContextAw
             }
 
             cpProps.put( "collections.keyspace.strategy.class",
-                cass.getProperties().get( "cassandra.keyspace.strategy" ) );
+                systemProperties.getProperty( "cassandra.keyspace.strategy" ) );
 
             cpProps.put( "collections.keyspace.strategy.options",
-                cass.getProperties().get( "cassandra.keyspace.replication" ) );
-
+                systemProperties.getProperty( "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() );
             cpProps.putAll( systemProperties );
             //logger.debug("All properties fed to Core Persistence: " + cpProps.toString() );
 
-
-
             ConfigurationManager.loadProperties( cpProps );
         }
         catch ( Exception e ) {

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/08c1f1d0/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 f0e5bd4..1c9aeb1 100644
--- a/stack/core/src/main/resources/usergrid-core-context.xml
+++ b/stack/core/src/main/resources/usergrid-core-context.xml
@@ -95,9 +95,9 @@
 
     <bean id="injector"
    		class="org.apache.usergrid.corepersistence.GuiceFactory">
-   		<constructor-arg ref="cassandraService" />
+   		<constructor-arg ref="cassandraHostConfigurator" />
         <constructor-arg ref="properties" />
-   	</bean>
+    </bean>
 
 	<bean id="cassandraService"
 		class="org.apache.usergrid.persistence.cassandra.CassandraService" init-method="init" destroy-method="destroy">