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 2015/02/26 17:27:39 UTC

[15/50] [abbrv] incubator-usergrid git commit: [USERGRID-409} Fixed all commit errors and merged the STATIC_APPLICATION_KEYSPACE and the SYSTEM_KEYSPACE into a single static ApplicationKeyspace. This allows us to separate a keyspace for each individual a

[USERGRID-409} Fixed all commit errors and merged the STATIC_APPLICATION_KEYSPACE and the SYSTEM_KEYSPACE into a single static ApplicationKeyspace. This allows us to separate a keyspace for each individual application on the system.


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

Branch: refs/heads/two-dot-o
Commit: f817f52437cfe3202db12c56b9f94b616ac8431c
Parents: 13da256
Author: grey <gr...@apigee.com>
Authored: Mon Feb 23 12:02:26 2015 -0800
Committer: grey <gr...@apigee.com>
Committed: Mon Feb 23 12:02:26 2015 -0800

----------------------------------------------------------------------
 .../usergrid/corepersistence/CpSetup.java       | 35 ++++++------
 .../persistence/cassandra/CassandraService.java | 58 +++++++++++---------
 .../cassandra/EntityManagerFactoryImpl.java     | 20 +++----
 .../persistence/cassandra/SetupImpl.java        | 43 +++++++--------
 .../main/resources/usergrid-core-context.xml    |  1 +
 .../core/astyanax/AstyanaxKeyspaceProvider.java |  2 +-
 .../persistence/core/astyanax/CassandraFig.java | 10 ++--
 .../tokens/cassandra/TokenServiceImpl.java      | 14 ++---
 8 files changed, 93 insertions(+), 90 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f817f524/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 a09ca49..c71c172 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
@@ -45,10 +45,9 @@ import static org.apache.usergrid.persistence.cassandra.CassandraService.DEFAULT
 import static org.apache.usergrid.persistence.cassandra.CassandraService.MANAGEMENT_APPLICATION;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.PRINCIPAL_TOKEN_CF;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.PROPERTIES_CF;
-import static org.apache.usergrid.persistence.cassandra.CassandraService.STATIC_APPLICATION_KEYSPACE;
-import static org.apache.usergrid.persistence.cassandra.CassandraService.SYSTEM_KEYSPACE;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.TOKENS_CF;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.USE_VIRTUAL_KEYSPACES;
+import static org.apache.usergrid.persistence.cassandra.CassandraService.getApplicationKeyspace;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.keyspaceForApplication;
 
 
@@ -146,17 +145,17 @@ public class CpSetup implements Setup {
 
         migrate();
 
-        cass.createColumnFamily( SYSTEM_KEYSPACE,
-            createColumnFamilyDefinition( SYSTEM_KEYSPACE, APPLICATIONS_CF, ComparatorType.BYTESTYPE ) );
+        cass.createColumnFamily( getApplicationKeyspace(),
+            createColumnFamilyDefinition( getApplicationKeyspace(), APPLICATIONS_CF, ComparatorType.BYTESTYPE ) );
 
-        cass.createColumnFamily( SYSTEM_KEYSPACE,
-            createColumnFamilyDefinition( SYSTEM_KEYSPACE, PROPERTIES_CF, ComparatorType.BYTESTYPE ) );
+        cass.createColumnFamily( getApplicationKeyspace(),
+            createColumnFamilyDefinition( getApplicationKeyspace(), PROPERTIES_CF, ComparatorType.BYTESTYPE ) );
 
-        cass.createColumnFamily( SYSTEM_KEYSPACE,
-            createColumnFamilyDefinition( SYSTEM_KEYSPACE, TOKENS_CF, ComparatorType.BYTESTYPE ) );
+        cass.createColumnFamily( getApplicationKeyspace(),
+            createColumnFamilyDefinition( getApplicationKeyspace(), TOKENS_CF, ComparatorType.BYTESTYPE ) );
 
-        cass.createColumnFamily( SYSTEM_KEYSPACE,
-            createColumnFamilyDefinition( SYSTEM_KEYSPACE, PRINCIPAL_TOKEN_CF, ComparatorType.UUIDTYPE ) );
+        cass.createColumnFamily( getApplicationKeyspace(),
+            createColumnFamilyDefinition( getApplicationKeyspace(), PRINCIPAL_TOKEN_CF, ComparatorType.UUIDTYPE ) );
 
         logger.info( "System keyspace initialized" );
     }
@@ -184,7 +183,7 @@ public class CpSetup implements Setup {
             logger.info( "Creating application keyspace " + app_keyspace + " for " + applicationName + " application" );
 
             cass.createColumnFamily( app_keyspace,
-                createColumnFamilyDefinition( SYSTEM_KEYSPACE, APPLICATIONS_CF, ComparatorType.BYTESTYPE ) );
+                createColumnFamilyDefinition( getApplicationKeyspace(), APPLICATIONS_CF, ComparatorType.BYTESTYPE ) );
 
             cass.createColumnFamilies( app_keyspace, getCfDefs( ApplicationCF.class, app_keyspace ) );
 
@@ -202,17 +201,17 @@ public class CpSetup implements Setup {
 
         if ( USE_VIRTUAL_KEYSPACES ) {
 
-            logger.info( "Creating static application keyspace " + STATIC_APPLICATION_KEYSPACE );
+            logger.info( "Creating static application keyspace " + getApplicationKeyspace() );
 
-            cass.createColumnFamily( STATIC_APPLICATION_KEYSPACE,
-                createColumnFamilyDefinition( STATIC_APPLICATION_KEYSPACE, APPLICATIONS_CF,
+            cass.createColumnFamily( getApplicationKeyspace(),
+                createColumnFamilyDefinition( getApplicationKeyspace(), APPLICATIONS_CF,
                     ComparatorType.BYTESTYPE ) );
 
-            cass.createColumnFamilies( STATIC_APPLICATION_KEYSPACE,
-                getCfDefs( ApplicationCF.class, STATIC_APPLICATION_KEYSPACE ) );
+            cass.createColumnFamilies( getApplicationKeyspace(),
+                getCfDefs( ApplicationCF.class, getApplicationKeyspace() ) );
 
-            cass.createColumnFamilies( STATIC_APPLICATION_KEYSPACE,
-                getCfDefs( QueuesCF.class, STATIC_APPLICATION_KEYSPACE ) );
+            cass.createColumnFamilies( getApplicationKeyspace(),
+                getCfDefs( QueuesCF.class, getApplicationKeyspace() ) );
         }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f817f524/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/CassandraService.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/CassandraService.java b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/CassandraService.java
index 2322b95..2c74e77 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/CassandraService.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/CassandraService.java
@@ -36,9 +36,12 @@ import org.apache.usergrid.persistence.IndexBucketLocator;
 import org.apache.usergrid.persistence.IndexBucketLocator.IndexType;
 import org.apache.usergrid.persistence.cassandra.index.IndexBucketScanner;
 import org.apache.usergrid.persistence.cassandra.index.IndexScanner;
+import org.apache.usergrid.persistence.core.astyanax.CassandraFig;
 import org.apache.usergrid.persistence.hector.CountingMutator;
 import org.apache.usergrid.utils.MapUtils;
 
+import com.google.inject.Injector;
+
 import me.prettyprint.cassandra.connection.HConnectionManager;
 import me.prettyprint.cassandra.model.ConfigurableConsistencyLevel;
 import me.prettyprint.cassandra.serializers.ByteBufferSerializer;
@@ -90,10 +93,10 @@ import static org.apache.usergrid.utils.MapUtils.filter;
 
 public class CassandraService {
 
-    public static String SYSTEM_KEYSPACE = "Usergrid";
-
-    public static String STATIC_APPLICATION_KEYSPACE = "Usergrid_Applications";
+    //make the below two not static
+   // public static String SYSTEM_KEYSPACE = "Usergrid";
 
+    public static String applicationKeyspace;
     public static final boolean USE_VIRTUAL_KEYSPACES = true;
 
     public static final String APPLICATIONS_CF = "Applications";
@@ -137,14 +140,17 @@ public class CassandraService {
 
     public static final UUID NULL_ID = new UUID( 0, 0 );
 
-
+//Wire guice injector via spring here, just pass the injector in the spring
     public CassandraService( Properties properties, Cluster cluster,
-                             CassandraHostConfigurator cassandraHostConfigurator, LockManager lockManager ) {
+                             CassandraHostConfigurator cassandraHostConfigurator, LockManager lockManager,
+                           final Injector injector) {
         this.properties = properties;
         this.cluster = cluster;
         chc = cassandraHostConfigurator;
         this.lockManager = lockManager;
         db_logger.info( "" + cluster.getKnownPoolHosts( false ) );
+        //getInjector
+        applicationKeyspace  = injector.getInstance( CassandraFig.class ).getApplicationKeyspace();
     }
 
 
@@ -158,7 +164,7 @@ public class CassandraService {
         accessMap.put( "username", properties.getProperty( "cassandra.username" ) );
         accessMap.put( "password", properties.getProperty( "cassandra.password" ) );
         systemKeyspace =
-                HFactory.createKeyspace( SYSTEM_KEYSPACE, cluster, consistencyLevelPolicy, ON_FAIL_TRY_ALL_AVAILABLE,
+                HFactory.createKeyspace( getApplicationKeyspace() , cluster, consistencyLevelPolicy, ON_FAIL_TRY_ALL_AVAILABLE,
                         accessMap );
 
 
@@ -168,6 +174,9 @@ public class CassandraService {
 
     }
 
+    public static String getApplicationKeyspace() {
+        return applicationKeyspace;
+    }
 
     public Cluster getCluster() {
         return cluster;
@@ -230,7 +239,7 @@ public class CassandraService {
     /** @return keyspace for application UUID */
     public static String keyspaceForApplication( UUID applicationId ) {
         if ( USE_VIRTUAL_KEYSPACES ) {
-            return STATIC_APPLICATION_KEYSPACE;
+            return getApplicationKeyspace();
         }
         else {
             return "Application_" + applicationId.toString().replace( '-', '_' );
@@ -271,20 +280,15 @@ public class CassandraService {
 
     /** The Usergrid_Applications keyspace directly */
     public Keyspace getUsergridApplicationKeyspace() {
-        return getKeyspace( STATIC_APPLICATION_KEYSPACE, null );
-    }
-
-
-    public Keyspace getSystemKeyspace() {
-        return systemKeyspace;
+        return getKeyspace( getApplicationKeyspace(), null );
     }
 
 
     public boolean checkKeyspacesExist() {
         boolean exists = false;
         try {
-            exists = cluster.describeKeyspace( SYSTEM_KEYSPACE ) != null
-                    && cluster.describeKeyspace( STATIC_APPLICATION_KEYSPACE ) != null;
+            exists = cluster.describeKeyspace( getApplicationKeyspace() ) != null;
+
         }
         catch ( Exception ex ) {
             logger.error( "could not describe keyspaces", ex );
@@ -406,7 +410,7 @@ public class CassandraService {
     /**
      * Gets the columns.
      *
-     * @param keyspace the keyspace
+     * @param ko the keyspace
      * @param columnFamily the column family
      * @param key the key
      *
@@ -462,7 +466,7 @@ public class CassandraService {
     /**
      * Gets the columns.
      *
-     * @param keyspace the keyspace
+     * @param ko the keyspace
      * @param columnFamily the column family
      * @param key the key
      * @param start the start
@@ -584,7 +588,7 @@ public class CassandraService {
     /**
      * Gets the columns.
      *
-     * @param keyspace the keyspace
+     * @param ko the keyspace
      * @param columnFamily the column family
      * @param keys the keys
      *
@@ -623,7 +627,7 @@ public class CassandraService {
     /**
      * Gets the columns.
      *
-     * @param keyspace the keyspace
+     * @param ko the keyspace
      * @param columnFamily the column family
      * @param key the key
      * @param columnNames the column names
@@ -668,7 +672,7 @@ public class CassandraService {
     /**
      * Gets the columns.
      *
-     * @param keyspace the keyspace
+     * @param ko the keyspace
      * @param columnFamily the column family
      * @param keys the keys
      * @param columnNames the column names
@@ -711,7 +715,7 @@ public class CassandraService {
     /**
      * Gets the column.
      *
-     * @param keyspace the keyspace
+     * @param ko the keyspace
      * @param columnFamily the column family
      * @param key the key
      * @param column the column
@@ -827,7 +831,7 @@ public class CassandraService {
     /**
      * Sets the columns.
      *
-     * @param keyspace the keyspace
+     * @param ko the keyspace
      * @param columnFamily the column family
      * @param key the key
      * @param map the map
@@ -894,7 +898,7 @@ public class CassandraService {
     /**
      * Delete column.
      *
-     * @param keyspace the keyspace
+     * @param ko the keyspace
      * @param columnFamily the column family
      * @param key the key
      * @param column the column
@@ -915,7 +919,7 @@ public class CassandraService {
     /**
      * Gets the row keys.
      *
-     * @param keyspace the keyspace
+     * @param ko the keyspace
      * @param columnFamily the column family
      *
      * @return set of keys
@@ -953,7 +957,7 @@ public class CassandraService {
     /**
      * Gets the row keys as uui ds.
      *
-     * @param keyspace the keyspace
+     * @param ko the keyspace
      * @param columnFamily the column family
      *
      * @return list of row key UUIDs
@@ -985,7 +989,7 @@ public class CassandraService {
     /**
      * Delete row.
      *
-     * @param keyspace the keyspace
+     * @param ko the keyspace
      * @param columnFamily the column family
      * @param key the key
      *
@@ -1043,7 +1047,7 @@ public class CassandraService {
 
 
 
-    
+
     public void destroy() throws Exception {
     	if (cluster != null) {
     		HConnectionManager connectionManager = cluster.getConnectionManager();

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f817f524/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
index 8b5906c..9a90e59 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/EntityManagerFactoryImpl.java
@@ -192,7 +192,7 @@ public class EntityManagerFactoryImpl implements EntityManagerFactory, Applicati
         String appName = buildAppName( organizationName, name );
 
         HColumn<String, ByteBuffer> column =
-                cass.getColumn( cass.getSystemKeyspace(), APPLICATIONS_CF, appName, PROPERTY_UUID );
+                cass.getColumn( cass.getUsergridApplicationKeyspace(), APPLICATIONS_CF, appName, PROPERTY_UUID );
         if ( column != null ) {
             throw new ApplicationAlreadyExistsException( name );
             // UUID uuid = uuid(column.getValue());
@@ -236,7 +236,7 @@ public class EntityManagerFactoryImpl implements EntityManagerFactory, Applicati
 
         getSetup().setupApplicationKeyspace( applicationId, appName );
 
-        Keyspace ko = cass.getSystemKeyspace();
+        Keyspace ko = cass.getUsergridApplicationKeyspace();
         Mutator<ByteBuffer> m = CountingMutator.createFlushingMutator( ko, be );
 
         long timestamp = cass.createTimestamp();
@@ -262,7 +262,7 @@ public class EntityManagerFactoryImpl implements EntityManagerFactory, Applicati
         name = buildAppName( organizationName, name );
 
         HColumn<String, ByteBuffer> column =
-                cass.getColumn( cass.getSystemKeyspace(), APPLICATIONS_CF, name, PROPERTY_UUID );
+                cass.getColumn( cass.getUsergridApplicationKeyspace(), APPLICATIONS_CF, name, PROPERTY_UUID );
         if ( column != null ) {
             throw new ApplicationAlreadyExistsException( name );
             // UUID uuid = uuid(column.getValue());
@@ -278,7 +278,7 @@ public class EntityManagerFactoryImpl implements EntityManagerFactory, Applicati
     public UUID lookupApplication( String name ) throws Exception {
         name = name.toLowerCase();
         HColumn<String, ByteBuffer> column =
-                cass.getColumn( cass.getSystemKeyspace(), APPLICATIONS_CF, name, PROPERTY_UUID );
+                cass.getColumn( cass.getUsergridApplicationKeyspace(), APPLICATIONS_CF, name, PROPERTY_UUID );
         if ( column != null ) {
             return uuid( column.getValue() );
         }
@@ -299,7 +299,7 @@ public class EntityManagerFactoryImpl implements EntityManagerFactory, Applicati
     public Application getApplication( String name ) throws Exception {
         name = name.toLowerCase();
         HColumn<String, ByteBuffer> column =
-                cass.getColumn( cass.getSystemKeyspace(), APPLICATIONS_CF, name, PROPERTY_UUID );
+                cass.getColumn( cass.getUsergridApplicationKeyspace(), APPLICATIONS_CF, name, PROPERTY_UUID );
         if ( column == null ) {
             return null;
         }
@@ -314,7 +314,7 @@ public class EntityManagerFactoryImpl implements EntityManagerFactory, Applicati
     @Override
     public Map<String, UUID> getApplications() throws Exception {
         Map<String, UUID> applications = new TreeMap<String, UUID>( CASE_INSENSITIVE_ORDER );
-        Keyspace ko = cass.getSystemKeyspace();
+        Keyspace ko = cass.getUsergridApplicationKeyspace();
         RangeSlicesQuery<String, String, UUID> q = createRangeSlicesQuery( ko, se, se, ue );
         q.setKeys( "", "\uFFFF" );
         q.setColumnFamily( APPLICATIONS_CF );
@@ -333,7 +333,7 @@ public class EntityManagerFactoryImpl implements EntityManagerFactory, Applicati
    @Override
     public boolean setServiceProperty( String name, String value ) {
         try {
-            cass.setColumn( cass.getSystemKeyspace(), PROPERTIES_CF, PROPERTIES_CF, name, value );
+            cass.setColumn( cass.getUsergridApplicationKeyspace(), PROPERTIES_CF, PROPERTIES_CF, name, value );
             return true;
         }
         catch ( Exception e ) {
@@ -346,7 +346,7 @@ public class EntityManagerFactoryImpl implements EntityManagerFactory, Applicati
     @Override
     public boolean deleteServiceProperty( String name ) {
         try {
-            cass.deleteColumn( cass.getSystemKeyspace(), PROPERTIES_CF, PROPERTIES_CF, name );
+            cass.deleteColumn( cass.getUsergridApplicationKeyspace(), PROPERTIES_CF, PROPERTIES_CF, name );
             return true;
         }
         catch ( Exception e ) {
@@ -359,7 +359,7 @@ public class EntityManagerFactoryImpl implements EntityManagerFactory, Applicati
     @Override
     public boolean updateServiceProperties( Map<String, String> properties ) {
         try {
-            cass.setColumns( cass.getSystemKeyspace(), PROPERTIES_CF, PROPERTIES_CF.getBytes(), properties );
+            cass.setColumns( cass.getUsergridApplicationKeyspace(), PROPERTIES_CF, PROPERTIES_CF.getBytes(), properties );
             return true;
         }
         catch ( Exception e ) {
@@ -372,7 +372,7 @@ public class EntityManagerFactoryImpl implements EntityManagerFactory, Applicati
     @Override
     public Map<String, String> getServiceProperties() {
         try {
-            return asMap( cass.getAllColumns( cass.getSystemKeyspace(), PROPERTIES_CF, PROPERTIES_CF, se, se ) );
+            return asMap( cass.getAllColumns( cass.getUsergridApplicationKeyspace(), PROPERTIES_CF, PROPERTIES_CF, se, se ) );
         }
         catch ( Exception e ) {
             logger.error( "Unable to load properties: " + e.getMessage() );

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f817f524/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/SetupImpl.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/SetupImpl.java b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/SetupImpl.java
index 97a7654..775f43b 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/SetupImpl.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/SetupImpl.java
@@ -29,10 +29,9 @@ import static org.apache.usergrid.persistence.cassandra.CassandraService.DEFAULT
 import static org.apache.usergrid.persistence.cassandra.CassandraService.MANAGEMENT_APPLICATION;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.PRINCIPAL_TOKEN_CF;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.PROPERTIES_CF;
-import static org.apache.usergrid.persistence.cassandra.CassandraService.STATIC_APPLICATION_KEYSPACE;
-import static org.apache.usergrid.persistence.cassandra.CassandraService.SYSTEM_KEYSPACE;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.TOKENS_CF;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.USE_VIRTUAL_KEYSPACES;
+import static org.apache.usergrid.persistence.cassandra.CassandraService.getApplicationKeyspace;
 import static org.apache.usergrid.persistence.cassandra.CassandraService.keyspaceForApplication;
 import org.apache.usergrid.persistence.entities.Application;
 import org.slf4j.Logger;
@@ -80,17 +79,17 @@ public class SetupImpl implements Setup {
 
         logger.info( "Initialize system keyspace" );
 
-        cass.createColumnFamily( SYSTEM_KEYSPACE, createColumnFamilyDefinition(
-                SYSTEM_KEYSPACE, APPLICATIONS_CF, ComparatorType.BYTESTYPE ) );
+        cass.createColumnFamily( getApplicationKeyspace(), createColumnFamilyDefinition(
+                getApplicationKeyspace(), APPLICATIONS_CF, ComparatorType.BYTESTYPE ) );
 
-        cass.createColumnFamily( SYSTEM_KEYSPACE, createColumnFamilyDefinition(
-                SYSTEM_KEYSPACE, PROPERTIES_CF, ComparatorType.BYTESTYPE ) );
+        cass.createColumnFamily( getApplicationKeyspace(), createColumnFamilyDefinition(
+                getApplicationKeyspace(), PROPERTIES_CF, ComparatorType.BYTESTYPE ) );
 
-        cass.createColumnFamily( SYSTEM_KEYSPACE, createColumnFamilyDefinition(
-                SYSTEM_KEYSPACE, TOKENS_CF, ComparatorType.BYTESTYPE ) );
+        cass.createColumnFamily( getApplicationKeyspace(), createColumnFamilyDefinition(
+                getApplicationKeyspace(), TOKENS_CF, ComparatorType.BYTESTYPE ) );
 
-        cass.createColumnFamily( SYSTEM_KEYSPACE, createColumnFamilyDefinition(
-                SYSTEM_KEYSPACE, PRINCIPAL_TOKEN_CF, ComparatorType.UUIDTYPE ) );
+        cass.createColumnFamily( getApplicationKeyspace(), createColumnFamilyDefinition(
+                getApplicationKeyspace(), PRINCIPAL_TOKEN_CF, ComparatorType.UUIDTYPE ) );
 
         logger.info( "System keyspace initialized" );
     }
@@ -115,7 +114,7 @@ public class SetupImpl implements Setup {
                     + applicationName + " application" );
 
             cass.createColumnFamily( app_keyspace, createColumnFamilyDefinition(
-                    SYSTEM_KEYSPACE, APPLICATIONS_CF, ComparatorType.BYTESTYPE ) );
+                    getApplicationKeyspace(), APPLICATIONS_CF, ComparatorType.BYTESTYPE ) );
 
             cass.createColumnFamilies( app_keyspace, getCfDefs( ApplicationCF.class, app_keyspace));
             cass.createColumnFamilies( app_keyspace, getCfDefs( QueuesCF.class, app_keyspace ) );
@@ -127,16 +126,16 @@ public class SetupImpl implements Setup {
 
         if ( USE_VIRTUAL_KEYSPACES ) {
 
-            logger.info( "Creating static application keyspace " + STATIC_APPLICATION_KEYSPACE );
+            logger.info( "Creating static application keyspace " + getApplicationKeyspace() );
 
-            cass.createColumnFamily( STATIC_APPLICATION_KEYSPACE,
-                    createColumnFamilyDefinition( STATIC_APPLICATION_KEYSPACE, APPLICATIONS_CF,
+            cass.createColumnFamily( getApplicationKeyspace(),
+                    createColumnFamilyDefinition( getApplicationKeyspace(), APPLICATIONS_CF,
                             ComparatorType.BYTESTYPE ) );
 
-            cass.createColumnFamilies( STATIC_APPLICATION_KEYSPACE,
-                    getCfDefs( ApplicationCF.class, STATIC_APPLICATION_KEYSPACE ) );
-            cass.createColumnFamilies( STATIC_APPLICATION_KEYSPACE,
-                    getCfDefs( QueuesCF.class, STATIC_APPLICATION_KEYSPACE ) );
+            cass.createColumnFamilies( getApplicationKeyspace(),
+                    getCfDefs( ApplicationCF.class, getApplicationKeyspace() ) );
+            cass.createColumnFamilies( getApplicationKeyspace(),
+                    getCfDefs( QueuesCF.class, getApplicationKeyspace() ) );
         }
     }
 
@@ -147,13 +146,13 @@ public class SetupImpl implements Setup {
 
 
     public static void logCFPermissions() {
-        System.out.println( SYSTEM_KEYSPACE + "." + APPLICATIONS_CF + ".<rw>=usergrid" );
-        System.out.println( SYSTEM_KEYSPACE + "." + PROPERTIES_CF + ".<rw>=usergrid" );
+        System.out.println( getApplicationKeyspace() + "." + APPLICATIONS_CF + ".<rw>=usergrid" );
+        System.out.println( getApplicationKeyspace() + "." + PROPERTIES_CF + ".<rw>=usergrid" );
         for ( CFEnum cf : ApplicationCF.values() ) {
-            System.out.println( STATIC_APPLICATION_KEYSPACE + "." + cf + ".<rw>=usergrid" );
+            System.out.println( getApplicationKeyspace() + "." + cf + ".<rw>=usergrid" );
         }
         for ( CFEnum cf : QueuesCF.values() ) {
-            System.out.println( STATIC_APPLICATION_KEYSPACE + "." + cf + ".<rw>=usergrid" );
+            System.out.println( getApplicationKeyspace() + "." + cf + ".<rw>=usergrid" );
         }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f817f524/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 60f69af..f0e5bd4 100644
--- a/stack/core/src/main/resources/usergrid-core-context.xml
+++ b/stack/core/src/main/resources/usergrid-core-context.xml
@@ -105,6 +105,7 @@
 		<constructor-arg ref="cassandraCluster" />
 		<constructor-arg ref="cassandraHostConfigurator" />
 		<constructor-arg ref="lockManager" />
+        <constructor-arg ref="injector"/>
 		<property name="consistencyLevelPolicy" ref="consistencyLevelPolicy"/>
 	</bean>
 

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f817f524/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/AstyanaxKeyspaceProvider.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/AstyanaxKeyspaceProvider.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/AstyanaxKeyspaceProvider.java
index 8bd5a9f..5172331 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/AstyanaxKeyspaceProvider.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/AstyanaxKeyspaceProvider.java
@@ -73,7 +73,7 @@ public class AstyanaxKeyspaceProvider implements Provider<Keyspace> {
 
         AstyanaxContext<Keyspace> context =
                 new AstyanaxContext.Builder().forCluster( cassandraFig.getClusterName() )
-                        .forKeyspace( cassandraFig.getKeyspaceName() )
+                        .forKeyspace( cassandraFig.getApplicationKeyspace())
 
                         /*
                          * TODO tnine Filter this by adding a host supplier.  We will get token discovery from cassandra

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f817f524/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/CassandraFig.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/CassandraFig.java b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/CassandraFig.java
index df94adc..1208a1a 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/CassandraFig.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/astyanax/CassandraFig.java
@@ -53,9 +53,9 @@ public interface CassandraFig extends GuicyFig {
     @Default( "Usergrid" )
     String getClusterName();
 
-    @Key( "collections.keyspace" )
-    @Default( "Usergrid_Collections" )
-    String getKeyspaceName();
+    @Key( "cassandra.keyspace.application" )
+    @Default( "Usergrid_Applications" )
+    String getApplicationKeyspace();
 
     @Key( "cassandra.port" )
     @Default( "9160" )
@@ -71,8 +71,8 @@ public interface CassandraFig extends GuicyFig {
 
     @Key("cassandra.discovery")
     @Default( "RING_DESCRIBE" )
-    String getDiscoveryType();    
-    
+    String getDiscoveryType();
+
     @Key("cassandra.embedded")
     @Default( "false" )
     boolean isEmbedded();

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/f817f524/stack/services/src/main/java/org/apache/usergrid/security/tokens/cassandra/TokenServiceImpl.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/security/tokens/cassandra/TokenServiceImpl.java b/stack/services/src/main/java/org/apache/usergrid/security/tokens/cassandra/TokenServiceImpl.java
index 50156b5..4d8b987 100644
--- a/stack/services/src/main/java/org/apache/usergrid/security/tokens/cassandra/TokenServiceImpl.java
+++ b/stack/services/src/main/java/org/apache/usergrid/security/tokens/cassandra/TokenServiceImpl.java
@@ -261,7 +261,7 @@ public class TokenServiceImpl implements TokenService {
 
         long maxTokenTtl = getMaxTtl( TokenCategory.getFromBase64String( token ), tokenInfo.getPrincipal() );
 
-        Mutator<UUID> batch = createMutator( cassandra.getSystemKeyspace(), ue );
+        Mutator<UUID> batch = createMutator( cassandra.getUsergridApplicationKeyspace(), ue );
 
         HColumn<String, Long> col =
                 createColumn( TOKEN_ACCESSED, now, calcTokenTime( tokenInfo.getExpiration( maxTokenTtl ) ),
@@ -326,7 +326,7 @@ public class TokenServiceImpl implements TokenService {
     public void removeTokens( AuthPrincipalInfo principal ) throws Exception {
         List<UUID> tokenIds = getTokenUUIDS( principal );
 
-        Mutator<ByteBuffer> batch = createMutator( cassandra.getSystemKeyspace(), be );
+        Mutator<ByteBuffer> batch = createMutator( cassandra.getUsergridApplicationKeyspace(), be );
 
         for ( UUID tokenId : tokenIds ) {
             batch.addDeletion( bytebuffer( tokenId ), TOKENS_CF );
@@ -359,7 +359,7 @@ public class TokenServiceImpl implements TokenService {
 
         UUID tokenId = info.getUuid();
 
-        Mutator<ByteBuffer> batch = createMutator( cassandra.getSystemKeyspace(), be );
+        Mutator<ByteBuffer> batch = createMutator( cassandra.getUsergridApplicationKeyspace(), be );
 
         // clean up the link in the principal -> token index if the principal is
         // on the token
@@ -380,7 +380,7 @@ public class TokenServiceImpl implements TokenService {
             throw new InvalidTokenException( "No token specified" );
         }
         Map<String, ByteBuffer> columns = getColumnMap( cassandra
-                .getColumns( cassandra.getSystemKeyspace(), TOKENS_CF, uuid, TOKEN_PROPERTIES, se,
+                .getColumns( cassandra.getUsergridApplicationKeyspace(), TOKENS_CF, uuid, TOKEN_PROPERTIES, se,
                         be ) );
         if ( !hasKeys( columns, REQUIRED_TOKEN_PROPERTIES ) ) {
             throw new InvalidTokenException( "Token not found in database" );
@@ -415,7 +415,7 @@ public class TokenServiceImpl implements TokenService {
 
         ByteBuffer tokenUUID = bytebuffer( tokenInfo.getUuid() );
 
-        Keyspace ko = cassandra.getSystemKeyspace();
+        Keyspace ko = cassandra.getUsergridApplicationKeyspace();
 
         Mutator<ByteBuffer> m = createMutator( ko, be );
 
@@ -449,7 +449,7 @@ public class TokenServiceImpl implements TokenService {
 
       /*
        * write to the PRINCIPAL+TOKEN The format is as follow
-       * 
+       *
        * appid+principalId+principalType :{ tokenuuid: 0x00}
        */
 
@@ -473,7 +473,7 @@ public class TokenServiceImpl implements TokenService {
         ByteBuffer rowKey = principalKey( principal );
 
         List<HColumn<ByteBuffer, ByteBuffer>> cols = cassandra
-                .getColumns( cassandra.getSystemKeyspace(), PRINCIPAL_TOKEN_CF, rowKey, null, null, Integer.MAX_VALUE,
+                .getColumns( cassandra.getUsergridApplicationKeyspace(), PRINCIPAL_TOKEN_CF, rowKey, null, null, Integer.MAX_VALUE,
                         false );
 
         List<UUID> results = new ArrayList<UUID>( cols.size() );