Repository: usergrid
Updated Branches:
  refs/heads/master dd46ebe8f -> 0a83ee450


Rely less on the datastax driver's metadata configuration as tests modify 
schema too much currently.


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

Branch: refs/heads/master
Commit: 0a83ee450166c67c19d50f10eb7b8f33f62c0715
Parents: dd46ebe
Author: Michael Russo <[email protected]>
Authored: Sat Nov 19 21:59:05 2016 -0800
Committer: Michael Russo <[email protected]>
Committed: Sat Nov 19 21:59:05 2016 -0800

----------------------------------------------------------------------
 .../core/datastax/impl/DataStaxClusterImpl.java     |  9 +++++++--
 .../core/migration/schema/MigrationManagerImpl.java | 16 ++++++++++++----
 2 files changed, 19 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/0a83ee45/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 2377c67..0f59688 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
@@ -175,6 +175,10 @@ public class DataStaxClusterImpl implements 
DataStaxCluster {
 
         getClusterSession().execute(createQueueMessageKeyspace);
 
+        if ( forceCheck ){
+            waitForSchemaAgreement();
+        }
+
         logger.info("Created keyspace: {}", 
cassandraConfig.getApplicationLocalKeyspace());
 
     }
@@ -239,12 +243,13 @@ public class DataStaxClusterImpl implements 
DataStaxCluster {
             .setReadTimeoutMillis( cassandraConfig.getTimeout());
 
         final QueryOptions queryOptions = new QueryOptions()
-            .setConsistencyLevel(defaultConsistencyLevel);
+            .setConsistencyLevel(defaultConsistencyLevel)
+            .setMetadataEnabled(false); // don't store metadata state in the 
driver
 
         Cluster.Builder datastaxCluster = Cluster.builder()
             .withClusterName( cassandraConfig.getClusterName())
             .addContactPoints( cassandraConfig.getHosts().split(","))
-            .withMaxSchemaAgreementWaitSeconds(30)
+            .withMaxSchemaAgreementWaitSeconds(45)
             .withCompression(ProtocolOptions.Compression.LZ4)
             .withLoadBalancingPolicy(loadBalancingPolicy)
             .withPoolingOptions(poolingOptions)

http://git-wip-us.apache.org/repos/asf/usergrid/blob/0a83ee45/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/schema/MigrationManagerImpl.java
----------------------------------------------------------------------
diff --git 
a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/schema/MigrationManagerImpl.java
 
b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/schema/MigrationManagerImpl.java
index b648e66..7d1205b 100644
--- 
a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/schema/MigrationManagerImpl.java
+++ 
b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/schema/MigrationManagerImpl.java
@@ -131,6 +131,7 @@ public class MigrationManagerImpl implements 
MigrationManager {
                 keyspaceDefinition.getColumnFamily( 
columnFamily.getColumnFamily().getName() );
 
         if ( existing != null ) {
+            logger.info("Not creating columnfamily {}, it already exists.", 
columnFamily.getColumnFamily().getName());
             return;
         }
 
@@ -145,13 +146,20 @@ public class MigrationManagerImpl implements 
MigrationManager {
 
     private void createTable(TableDefinition tableDefinition ) throws 
Exception {
 
-        KeyspaceMetadata keyspaceMetadata = 
dataStaxCluster.getClusterSession().getCluster().getMetadata()
-            .getKeyspace(CQLUtils.quote( tableDefinition.getKeyspace() ) );
+        // this snippet will use the drivers metadata info, but that doesn't 
play nice with tests
+        // use the system table to verify instead
 
-        boolean exists =  keyspaceMetadata != null
-            && keyspaceMetadata.getTable( tableDefinition.getTableName() ) != 
null;
+        //KeyspaceMetadata keyspaceMetadata = 
dataStaxCluster.getClusterSession().getCluster().getMetadata()
+        //    .getKeyspace(CQLUtils.quote( tableDefinition.getKeyspace() ) );
+        //boolean exists =  keyspaceMetadata != null
+        //    && keyspaceMetadata.getTable( tableDefinition.getTableName() ) 
!= null;
+
+        boolean exists = dataStaxCluster.getClusterSession()
+            .execute("select * from system.schema_columnfamilies where 
keyspace_name='"+tableDefinition.getKeyspace()
+                +"' and 
columnfamily_name='"+tableDefinition.getTableName()+"'").one() != null;
 
         if( exists ){
+            logger.info("Not creating table {}, it already exists.", 
tableDefinition.getTableName());
             return;
         }
 

Reply via email to