Reduce load on datastax control connection ( mostly for tests because the interact with the schema A LOT).
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/cd7e803d Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/cd7e803d Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/cd7e803d Branch: refs/heads/master Commit: cd7e803d1a831a7801a5f7234c600b60517c62b7 Parents: 9192095 Author: Michael Russo <mru...@apigee.com> Authored: Fri Nov 11 15:45:06 2016 -0800 Committer: Michael Russo <mru...@apigee.com> Committed: Fri Nov 11 15:45:06 2016 -0800 ---------------------------------------------------------------------- .../migration/schema/MigrationManagerImpl.java | 25 ++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/usergrid/blob/cd7e803d/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 9178bde..2205e57 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 @@ -35,6 +35,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.Collection; +import java.util.List; +import java.util.Map; import java.util.Set; @@ -134,9 +136,8 @@ public class MigrationManagerImpl implements MigrationManager { keyspace.createColumnFamily( columnFamily.getColumnFamily(), columnFamily.getOptions() ); - // creation of tables happens with the datastax driver and it auto checks schema on schema queries // the CF def creation uses Asytanax, so manually check the schema agreement - dataStaxCluster.waitForSchemaAgreement(); + astyanaxWaitForSchemaAgreement(); logger.info( "Created column family {}", columnFamily.getColumnFamily().getName() ); @@ -170,6 +171,26 @@ public class MigrationManagerImpl implements MigrationManager { } + private void astyanaxWaitForSchemaAgreement() throws ConnectionException { + + while ( true ) { + + final Map<String, List<String>> versions = keyspace.describeSchemaVersions(); + + if ( versions != null && versions.size() == 1 ) { + return; + } + + //sleep and try it again + try { + Thread.sleep( 100 ); + } + catch ( InterruptedException e ) { + //swallow + } + } + } + }