Repository: usergrid
Updated Branches:
  refs/heads/master 6bd4a2023 -> 40e1c0660


Use direct queries to cassandra to see if a keyspace exists vs. the driver's 
cached metadata.


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

Branch: refs/heads/master
Commit: 40e1c0660b3df7156f32102565248a05ae86439a
Parents: 6bd4a20
Author: Michael Russo <mru...@apigee.com>
Authored: Sat Nov 19 08:37:03 2016 -0800
Committer: Michael Russo <mru...@apigee.com>
Committed: Sat Nov 19 08:37:03 2016 -0800

----------------------------------------------------------------------
 .../core/datastax/impl/DataStaxClusterImpl.java | 22 ++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/40e1c066/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/datastax/impl/DataStaxClusterImpl.java
----------------------------------------------------------------------
diff --git 
a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/datastax/impl/DataStaxClusterImpl.java
 
b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/datastax/impl/DataStaxClusterImpl.java
index 4460244..9e942d0 100644
--- 
a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/datastax/impl/DataStaxClusterImpl.java
+++ 
b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/datastax/impl/DataStaxClusterImpl.java
@@ -110,10 +110,15 @@ public class DataStaxClusterImpl implements 
DataStaxCluster {
     @Override
     public synchronized void createApplicationKeyspace() throws Exception {
 
-        boolean exists = getClusterSession().getCluster().getMetadata()
-            .getKeyspace(CQLUtils.quote( 
cassandraConfig.getApplicationKeyspace())) != null;
+        // using the datastax client seems to have stale data ( as seen in 
tests that drop keyspaces )
+        //boolean exists = getClusterSession().getCluster().getMetadata()
+        //    .getKeyspace(CQLUtils.quote( 
cassandraConfig.getApplicationKeyspace())) != null;
 
-        if(exists){
+        Row row = getClusterSession()
+            .execute("select * from system.schema_keyspaces where 
keyspace_name = '"+cassandraConfig.getApplicationKeyspace()+"'")
+            .one();
+
+        if(row != null){
             logger.info("Not creating keyspace {}, it already exists.", 
cassandraConfig.getApplicationKeyspace());
             return;
         }
@@ -140,10 +145,15 @@ public class DataStaxClusterImpl implements 
DataStaxCluster {
     @Override
     public synchronized void createApplicationLocalKeyspace() throws Exception 
{
 
-        boolean exists = getClusterSession().getCluster().getMetadata()
-            .getKeyspace(CQLUtils.quote( 
cassandraConfig.getApplicationLocalKeyspace())) != null;
+        // using the datastax client seems to have stale data ( as seen in 
tests that drop keyspaces )
+        //boolean exists = getClusterSession().getCluster().getMetadata()
+        //    .getKeyspace(CQLUtils.quote( 
cassandraConfig.getApplicationLocalKeyspace())) != null;
+
+        Row row = getClusterSession()
+            .execute("select * from system.schema_keyspaces where 
keyspace_name = '"+cassandraConfig.getApplicationLocalKeyspace()+"'")
+            .one();
 
-        if (exists) {
+        if (row != null) {
             logger.info("Not creating keyspace {}, it already exists.", 
cassandraConfig.getApplicationLocalKeyspace());
             return;
         }

Reply via email to