usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdun...@apache.org
Subject usergrid git commit: Add astayanax drop keyspace during test setup, because there seems to be a race condition between Hector dropping keyspace and Astayanax detecting it.
Date Fri, 04 Aug 2017 18:30:39 GMT
Repository: usergrid
Updated Branches:
  refs/heads/hotfix-20170728 4d312f8d4 -> 4e6116e35


Add astayanax drop keyspace during test setup, because there seems to be a race condition
between Hector dropping keyspace and Astayanax detecting it.


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

Branch: refs/heads/hotfix-20170728
Commit: 4e6116e3543bb3404699e7338cc71c0ef6cc3e2c
Parents: 4d312f8
Author: Mike Dunker <mdunker@google.com>
Authored: Fri Aug 4 11:11:14 2017 -0700
Committer: Mike Dunker <mdunker@google.com>
Committed: Fri Aug 4 11:11:14 2017 -0700

----------------------------------------------------------------------
 .../apache/usergrid/corepersistence/CpSetup.java  | 12 +++++++++---
 .../usergrid/persistence/cassandra/Setup.java     |  8 ++++++++
 .../usergrid/persistence/CoreSchemaManager.java   |  6 ++++++
 .../core/migration/schema/MigrationManager.java   |  5 +++++
 .../migration/schema/MigrationManagerImpl.java    | 18 ++++++++++++++++++
 .../apache/usergrid/cassandra/SchemaManager.java  |  3 +++
 .../usergrid/cassandra/FakeSchemaManager.java     |  7 ++++++-
 7 files changed, 55 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/4e6116e3/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 623400d..8213a35 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
@@ -76,12 +76,18 @@ public class CpSetup implements Setup {
 
     @Override
     public void initSchema() throws Exception {
+        initSchema(false);
+    }
+
+
+    @Override
+    public void initSchema(boolean dropKeyspace) throws Exception {
 
         // Initialize the management app index in Elasticsearch
         this.emf.initializeManagementIndex();
 
         // Create the schema (including keyspace) in Cassandra
-        setupSchema();
+        setupSchema(dropKeyspace);
         setupLegacySchema();
 
     }
@@ -138,11 +144,11 @@ public class CpSetup implements Setup {
      *
      */
 
-    private void setupSchema() throws Exception {
+    private void setupSchema(boolean dropKeyspace) throws Exception {
 
         MigrationManager m = injector.getInstance( MigrationManager.class );
         try {
-            m.migrate();
+            m.migrate(dropKeyspace);
         }
         catch ( MigrationException ex ) {
             throw new RuntimeException( "Error migrating Core Persistence", ex );

http://git-wip-us.apache.org/repos/asf/usergrid/blob/4e6116e3/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/Setup.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/Setup.java
b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/Setup.java
index 697cd21..9379edd 100644
--- a/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/Setup.java
+++ b/stack/core/src/main/java/org/apache/usergrid/persistence/cassandra/Setup.java
@@ -26,6 +26,14 @@ public interface Setup {
 
 
     /**
+     * Initialize all configuration for the system setup. Creates keyspaces and elasticsearch
indexes,
+     * dropping keyspaces first if requested
+     * @throws Exception
+     */
+    void initSchema(boolean dropKeyspace) throws Exception;
+
+
+    /**
      * Bootstrap the root application to allow the system to function.
      * @throws Exception
      */

http://git-wip-us.apache.org/repos/asf/usergrid/blob/4e6116e3/stack/core/src/test/java/org/apache/usergrid/persistence/CoreSchemaManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/test/java/org/apache/usergrid/persistence/CoreSchemaManager.java
b/stack/core/src/test/java/org/apache/usergrid/persistence/CoreSchemaManager.java
index 28f2c9f..ce98735 100644
--- a/stack/core/src/test/java/org/apache/usergrid/persistence/CoreSchemaManager.java
+++ b/stack/core/src/test/java/org/apache/usergrid/persistence/CoreSchemaManager.java
@@ -50,6 +50,12 @@ public class CoreSchemaManager implements SchemaManager {
 
     @Override
     public void create() {
+        create(false);
+    }
+
+
+    @Override
+    public void create(boolean dropKeyspace) {
         try {
             setup.initSchema();
             lockManager.setup();

http://git-wip-us.apache.org/repos/asf/usergrid/blob/4e6116e3/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/schema/MigrationManager.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/schema/MigrationManager.java
b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/schema/MigrationManager.java
index df84247..80c93ba 100644
--- a/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/schema/MigrationManager.java
+++ b/stack/corepersistence/common/src/main/java/org/apache/usergrid/persistence/core/migration/schema/MigrationManager.java
@@ -31,4 +31,9 @@ public interface MigrationManager {
      * not exist
      */
     public void migrate() throws MigrationException;
+
+    /**
+     * Perform any migration necessary in the application.  Will drop keyspaces first if
requested.
+     */
+    public void migrate(boolean dropKeyspace) throws MigrationException;
 }

http://git-wip-us.apache.org/repos/asf/usergrid/blob/4e6116e3/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 f41ece9..cb62f4a 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
@@ -68,10 +68,20 @@ public class MigrationManagerImpl implements MigrationManager {
 
     @Override
     public void migrate() throws MigrationException {
+        migrate(false);
+    }
+
+
+    @Override
+    public void migrate(boolean dropKeyspace) throws MigrationException {
 
 
         try {
 
+            if (dropKeyspace) {
+                dropKeyspace();
+            }
+
             testAndCreateKeyspace();
 
             for ( Migration migration : migrations ) {
@@ -121,6 +131,14 @@ public class MigrationManagerImpl implements MigrationManager {
 
 
     /**
+     * Drop keyspace.
+     */
+    private void dropKeyspace() throws ConnectionException {
+        keyspace.dropKeyspace();
+    }
+
+
+    /**
      * Check if they keyspace exists.  If it doesn't create it
      */
     private void testAndCreateKeyspace() throws ConnectionException {

http://git-wip-us.apache.org/repos/asf/usergrid/blob/4e6116e3/stack/test-utils/src/main/java/org/apache/usergrid/cassandra/SchemaManager.java
----------------------------------------------------------------------
diff --git a/stack/test-utils/src/main/java/org/apache/usergrid/cassandra/SchemaManager.java
b/stack/test-utils/src/main/java/org/apache/usergrid/cassandra/SchemaManager.java
index 7e87ba1..2c475aa 100644
--- a/stack/test-utils/src/main/java/org/apache/usergrid/cassandra/SchemaManager.java
+++ b/stack/test-utils/src/main/java/org/apache/usergrid/cassandra/SchemaManager.java
@@ -23,6 +23,9 @@ public interface SchemaManager {
     /** Create any schema necessary for test execution. */
     void create();
 
+    /** Create any schema necessary for test execution, dropping keyspace if requested. */
+    void create(boolean dropKeyspace);
+
     /** Any breath-of-life data needed for the base system */
     void populateBaseData();
 

http://git-wip-us.apache.org/repos/asf/usergrid/blob/4e6116e3/stack/test-utils/src/test/java/org/apache/usergrid/cassandra/FakeSchemaManager.java
----------------------------------------------------------------------
diff --git a/stack/test-utils/src/test/java/org/apache/usergrid/cassandra/FakeSchemaManager.java
b/stack/test-utils/src/test/java/org/apache/usergrid/cassandra/FakeSchemaManager.java
index cdbdc9f..e9b2c32 100644
--- a/stack/test-utils/src/test/java/org/apache/usergrid/cassandra/FakeSchemaManager.java
+++ b/stack/test-utils/src/test/java/org/apache/usergrid/cassandra/FakeSchemaManager.java
@@ -23,7 +23,12 @@ public class FakeSchemaManager implements SchemaManager {
     public void create() {
 
     }
-    
+
+    @Override
+    public void create(boolean dropKeyspace) {
+
+    }
+
 
     @Override
     public void populateBaseData() {


Mime
View raw message