You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by br...@apache.org on 2014/02/05 01:36:32 UTC

[1/8] git commit: Move handling of migration event source to solve bootstrap race. Patch by Sergio Bossa and brandonwilliams, reviewed by Tyler Hobbs for CASSANDRA-6648

Updated Branches:
  refs/heads/cassandra-1.2 814a91209 -> ed5cac1d2
  refs/heads/cassandra-2.0 723fcd193 -> 93bd89fbb
  refs/heads/trunk c947c126f -> 9d4f7c918


Move handling of migration event source to solve bootstrap race.
Patch by Sergio Bossa and brandonwilliams, reviewed by Tyler Hobbs for
CASSANDRA-6648


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

Branch: refs/heads/cassandra-1.2
Commit: ed5cac1d2ab18f03ec2fe211c46b5382729b4c4d
Parents: 814a912
Author: Brandon Williams <br...@apache.org>
Authored: Tue Feb 4 18:23:30 2014 -0600
Committer: Brandon Williams <br...@apache.org>
Committed: Tue Feb 4 18:23:30 2014 -0600

----------------------------------------------------------------------
 CHANGES.txt                                     |  3 ++
 .../cassandra/service/MigrationManager.java     | 30 ++++----------------
 .../cassandra/service/StorageService.java       |  7 ++---
 3 files changed, 10 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/ed5cac1d/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 981f977..b2e892e 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,3 +1,6 @@
+1.2.15
+ * Move handling of migration event source to solve bootstrap race (CASSANDRA-6648)
+
 1.2.14
  * Reverted code to limit CQL prepared statement cache by size (CASSANDRA-6592)
  * add cassandra.default_messaging_version property to allow easier

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ed5cac1d/src/java/org/apache/cassandra/service/MigrationManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/MigrationManager.java b/src/java/org/apache/cassandra/service/MigrationManager.java
index 3ede35e..37d5f43 100644
--- a/src/java/org/apache/cassandra/service/MigrationManager.java
+++ b/src/java/org/apache/cassandra/service/MigrationManager.java
@@ -50,7 +50,7 @@ import org.apache.cassandra.utils.FBUtilities;
 import org.apache.cassandra.utils.UUIDGen;
 import org.apache.cassandra.utils.WrappedRunnable;
 
-public class MigrationManager implements IEndpointStateChangeSubscriber
+public class MigrationManager
 {
     private static final Logger logger = LoggerFactory.getLogger(MigrationManager.class);
 
@@ -63,7 +63,7 @@ public class MigrationManager implements IEndpointStateChangeSubscriber
     public static final int MIGRATION_DELAY_IN_MS = 60000;
 
     private final List<IMigrationListener> listeners = new CopyOnWriteArrayList<IMigrationListener>();
-
+    
     private MigrationManager() {}
 
     public void register(IMigrationListener listener)
@@ -76,34 +76,14 @@ public class MigrationManager implements IEndpointStateChangeSubscriber
         listeners.remove(listener);
     }
 
-    public void onJoin(InetAddress endpoint, EndpointState epState)
-    {}
-
-    public void onChange(InetAddress endpoint, ApplicationState state, VersionedValue value)
-    {
-        if (state != ApplicationState.SCHEMA || endpoint.equals(FBUtilities.getBroadcastAddress()))
-            return;
-
-        maybeScheduleSchemaPull(UUID.fromString(value.value), endpoint);
-    }
-
-    public void onAlive(InetAddress endpoint, EndpointState state)
+    public void scheduleSchemaPull(InetAddress endpoint, EndpointState state)
     {
         VersionedValue value = state.getApplicationState(ApplicationState.SCHEMA);
 
-        if (value != null)
+        if (!endpoint.equals(FBUtilities.getBroadcastAddress()) && value != null)
             maybeScheduleSchemaPull(UUID.fromString(value.value), endpoint);
     }
 
-    public void onDead(InetAddress endpoint, EndpointState state)
-    {}
-
-    public void onRestart(InetAddress endpoint, EndpointState state)
-    {}
-
-    public void onRemove(InetAddress endpoint)
-    {}
-
     /**
      * If versions differ this node sends request with local migration list to the endpoint
      * and expecting to receive a list of migrations to apply locally.
@@ -165,7 +145,7 @@ public class MigrationManager implements IEndpointStateChangeSubscriber
 
     public static boolean isReadyForBootstrap()
     {
-        return ((ThreadPoolExecutor) StageManager.getStage(Stage.MIGRATION)).getActiveCount() == 0;
+        return Schema.instance.getVersion() != null && !Schema.emptyVersion.equals(Schema.instance.getVersion());
     }
 
     public void notifyCreateKeyspace(KSMetaData ksm)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ed5cac1d/src/java/org/apache/cassandra/service/StorageService.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/StorageService.java b/src/java/org/apache/cassandra/service/StorageService.java
index c4b1b2e..fa43154 100644
--- a/src/java/org/apache/cassandra/service/StorageService.java
+++ b/src/java/org/apache/cassandra/service/StorageService.java
@@ -185,8 +185,6 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
     private static enum Mode { NORMAL, CLIENT, JOINING, LEAVING, DECOMMISSIONED, MOVING, DRAINING, DRAINED, RELOCATING }
     private Mode operationMode;
 
-    private final MigrationManager migrationManager = MigrationManager.instance;
-
     /* Used for tracking drain progress */
     private volatile int totalCFs, remainingCFs;
 
@@ -376,7 +374,6 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
 
     public void stopClient()
     {
-        Gossiper.instance.unregister(migrationManager);
         Gossiper.instance.unregister(this);
         Gossiper.instance.stop();
         MessagingService.instance().shutdown();
@@ -464,7 +461,6 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
         logger.info("Starting up client gossip");
         setMode(Mode.CLIENT, false);
         Gossiper.instance.register(this);
-        Gossiper.instance.register(migrationManager);
         Gossiper.instance.start((int) (System.currentTimeMillis() / 1000)); // needed for node-ring gathering.
         Gossiper.instance.addLocalApplicationState(ApplicationState.NET_VERSION, valueFactory.networkVersion());
 
@@ -620,7 +616,6 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
         appStates.put(ApplicationState.RELEASE_VERSION, valueFactory.releaseVersion());
         logger.info("Starting up server gossip");
         Gossiper.instance.register(this);
-        Gossiper.instance.register(migrationManager);
         Gossiper.instance.start(SystemTable.incrementAndGetGeneration(), appStates); // needed for node-ring gathering.
         // gossip snitch infos (local DC and rack)
         gossipSnitchInfo();
@@ -1981,6 +1976,7 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
         {
             onChange(endpoint, entry.getKey(), entry.getValue());
         }
+        MigrationManager.instance.scheduleSchemaPull(endpoint, epState);
     }
 
     public void onAlive(InetAddress endpoint, EndpointState state)
@@ -1999,6 +1995,7 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
             for (IEndpointLifecycleSubscriber subscriber : lifecycleSubscribers)
                 subscriber.onJoinCluster(endpoint);
         }
+        MigrationManager.instance.scheduleSchemaPull(endpoint, state);
     }
 
     public void onRemove(InetAddress endpoint)


[4/8] git commit: Merge branch 'cassandra-1.2' into cassandra-2.0

Posted by br...@apache.org.
Merge branch 'cassandra-1.2' into cassandra-2.0


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/34112efa
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/34112efa
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/34112efa

Branch: refs/heads/cassandra-2.0
Commit: 34112efa4b23db02c8c99f5bce02afbb1f98c64b
Parents: 723fcd1 ed5cac1
Author: Brandon Williams <br...@apache.org>
Authored: Tue Feb 4 18:33:33 2014 -0600
Committer: Brandon Williams <br...@apache.org>
Committed: Tue Feb 4 18:33:33 2014 -0600

----------------------------------------------------------------------

----------------------------------------------------------------------



[6/8] git commit: Move handling of migration event source to solve bootstrap race. Patch by Sergio Bossa and brandonwilliams, reviewed by Tyler Hobbs for CASSANDRA-6648

Posted by br...@apache.org.
Move handling of migration event source to solve bootstrap race.
Patch by Sergio Bossa and brandonwilliams, reviewed by Tyler Hobbs for
CASSANDRA-6648


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/93bd89fb
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/93bd89fb
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/93bd89fb

Branch: refs/heads/trunk
Commit: 93bd89fbba7d76821d3d85ae371cb2e665176b6a
Parents: 34112ef
Author: Brandon Williams <br...@apache.org>
Authored: Tue Feb 4 18:33:44 2014 -0600
Committer: Brandon Williams <br...@apache.org>
Committed: Tue Feb 4 18:33:44 2014 -0600

----------------------------------------------------------------------
 CHANGES.txt                                     |  2 ++
 .../cassandra/service/MigrationManager.java     | 33 +++-----------------
 .../cassandra/service/StorageService.java       |  7 ++---
 3 files changed, 9 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/93bd89fb/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index b1fade1..d3a78f7 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -2,6 +2,8 @@
  * Fix direct Memory on architectures that do not support unaligned long access
    (CASSANDRA-6628)
  * Let scrub optionally skip broken counter partitions (CASSANDRA-5930)
+Merged from 1.2:
+ * Move handling of migration event source to solve bootstrap race. (CASSANDRA-6648)
 
 
 2.0.5

http://git-wip-us.apache.org/repos/asf/cassandra/blob/93bd89fb/src/java/org/apache/cassandra/service/MigrationManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/MigrationManager.java b/src/java/org/apache/cassandra/service/MigrationManager.java
index 0ffc7c4..b463116 100644
--- a/src/java/org/apache/cassandra/service/MigrationManager.java
+++ b/src/java/org/apache/cassandra/service/MigrationManager.java
@@ -50,7 +50,7 @@ import org.apache.cassandra.utils.ByteBufferUtil;
 import org.apache.cassandra.utils.FBUtilities;
 import org.apache.cassandra.utils.WrappedRunnable;
 
-public class MigrationManager implements IEndpointStateChangeSubscriber
+public class MigrationManager
 {
     private static final Logger logger = LoggerFactory.getLogger(MigrationManager.class);
 
@@ -63,7 +63,7 @@ public class MigrationManager implements IEndpointStateChangeSubscriber
     public static final int MIGRATION_DELAY_IN_MS = 60000;
 
     private final List<IMigrationListener> listeners = new CopyOnWriteArrayList<IMigrationListener>();
-
+    
     private MigrationManager() {}
 
     public void register(IMigrationListener listener)
@@ -76,37 +76,14 @@ public class MigrationManager implements IEndpointStateChangeSubscriber
         listeners.remove(listener);
     }
 
-    public void onJoin(InetAddress endpoint, EndpointState epState)
-    {}
-    
-    public void beforeChange(InetAddress endpoint, EndpointState currentState, ApplicationState newStateKey, VersionedValue newValue) 
-    {}
-
-    public void onChange(InetAddress endpoint, ApplicationState state, VersionedValue value)
-    {
-        if (state != ApplicationState.SCHEMA || endpoint.equals(FBUtilities.getBroadcastAddress()))
-            return;
-
-        maybeScheduleSchemaPull(UUID.fromString(value.value), endpoint);
-    }
-
-    public void onAlive(InetAddress endpoint, EndpointState state)
+    public void scheduleSchemaPull(InetAddress endpoint, EndpointState state)
     {
         VersionedValue value = state.getApplicationState(ApplicationState.SCHEMA);
 
-        if (value != null)
+        if (!endpoint.equals(FBUtilities.getBroadcastAddress()) && value != null)
             maybeScheduleSchemaPull(UUID.fromString(value.value), endpoint);
     }
 
-    public void onDead(InetAddress endpoint, EndpointState state)
-    {}
-
-    public void onRestart(InetAddress endpoint, EndpointState state)
-    {}
-
-    public void onRemove(InetAddress endpoint)
-    {}
-
     /**
      * If versions differ this node sends request with local migration list to the endpoint
      * and expecting to receive a list of migrations to apply locally.
@@ -166,7 +143,7 @@ public class MigrationManager implements IEndpointStateChangeSubscriber
 
     public static boolean isReadyForBootstrap()
     {
-        return ((ThreadPoolExecutor) StageManager.getStage(Stage.MIGRATION)).getActiveCount() == 0;
+        return Schema.instance.getVersion() != null && !Schema.emptyVersion.equals(Schema.instance.getVersion());
     }
 
     public void notifyCreateKeyspace(KSMetaData ksm)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/93bd89fb/src/java/org/apache/cassandra/service/StorageService.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/StorageService.java b/src/java/org/apache/cassandra/service/StorageService.java
index 5f9657d..c222570 100644
--- a/src/java/org/apache/cassandra/service/StorageService.java
+++ b/src/java/org/apache/cassandra/service/StorageService.java
@@ -179,8 +179,6 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
     private static enum Mode { STARTING, NORMAL, CLIENT, JOINING, LEAVING, DECOMMISSIONED, MOVING, DRAINING, DRAINED, RELOCATING }
     private Mode operationMode = Mode.STARTING;
 
-    private final MigrationManager migrationManager = MigrationManager.instance;
-
     /* Used for tracking drain progress */
     private volatile int totalCFs, remainingCFs;
 
@@ -367,7 +365,6 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
 
     public void stopClient()
     {
-        Gossiper.instance.unregister(migrationManager);
         Gossiper.instance.unregister(this);
         Gossiper.instance.stop();
         MessagingService.instance().shutdown();
@@ -473,7 +470,6 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
         logger.info("Starting up client gossip");
         setMode(Mode.CLIENT, false);
         Gossiper.instance.register(this);
-        Gossiper.instance.register(migrationManager);
         Gossiper.instance.start((int) (System.currentTimeMillis() / 1000)); // needed for node-ring gathering.
         Gossiper.instance.addLocalApplicationState(ApplicationState.NET_VERSION, valueFactory.networkVersion());
 
@@ -630,7 +626,6 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
         appStates.put(ApplicationState.RELEASE_VERSION, valueFactory.releaseVersion());
         logger.info("Starting up server gossip");
         Gossiper.instance.register(this);
-        Gossiper.instance.register(migrationManager);
         Gossiper.instance.start(SystemKeyspace.incrementAndGetGeneration(), appStates); // needed for node-ring gathering.
         // gossip snitch infos (local DC and rack)
         gossipSnitchInfo();
@@ -1964,6 +1959,7 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
         {
             onChange(endpoint, entry.getKey(), entry.getValue());
         }
+        MigrationManager.instance.scheduleSchemaPull(endpoint, epState);
     }
 
     public void onAlive(InetAddress endpoint, EndpointState state)
@@ -1982,6 +1978,7 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
             for (IEndpointLifecycleSubscriber subscriber : lifecycleSubscribers)
                 subscriber.onJoinCluster(endpoint);
         }
+        MigrationManager.instance.scheduleSchemaPull(endpoint, state);
     }
 
     public void onRemove(InetAddress endpoint)


[5/8] git commit: Merge branch 'cassandra-1.2' into cassandra-2.0

Posted by br...@apache.org.
Merge branch 'cassandra-1.2' into cassandra-2.0


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/34112efa
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/34112efa
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/34112efa

Branch: refs/heads/trunk
Commit: 34112efa4b23db02c8c99f5bce02afbb1f98c64b
Parents: 723fcd1 ed5cac1
Author: Brandon Williams <br...@apache.org>
Authored: Tue Feb 4 18:33:33 2014 -0600
Committer: Brandon Williams <br...@apache.org>
Committed: Tue Feb 4 18:33:33 2014 -0600

----------------------------------------------------------------------

----------------------------------------------------------------------



[2/8] git commit: Move handling of migration event source to solve bootstrap race. Patch by Sergio Bossa and brandonwilliams, reviewed by Tyler Hobbs for CASSANDRA-6648

Posted by br...@apache.org.
Move handling of migration event source to solve bootstrap race.
Patch by Sergio Bossa and brandonwilliams, reviewed by Tyler Hobbs for
CASSANDRA-6648


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

Branch: refs/heads/cassandra-2.0
Commit: ed5cac1d2ab18f03ec2fe211c46b5382729b4c4d
Parents: 814a912
Author: Brandon Williams <br...@apache.org>
Authored: Tue Feb 4 18:23:30 2014 -0600
Committer: Brandon Williams <br...@apache.org>
Committed: Tue Feb 4 18:23:30 2014 -0600

----------------------------------------------------------------------
 CHANGES.txt                                     |  3 ++
 .../cassandra/service/MigrationManager.java     | 30 ++++----------------
 .../cassandra/service/StorageService.java       |  7 ++---
 3 files changed, 10 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/ed5cac1d/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 981f977..b2e892e 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,3 +1,6 @@
+1.2.15
+ * Move handling of migration event source to solve bootstrap race (CASSANDRA-6648)
+
 1.2.14
  * Reverted code to limit CQL prepared statement cache by size (CASSANDRA-6592)
  * add cassandra.default_messaging_version property to allow easier

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ed5cac1d/src/java/org/apache/cassandra/service/MigrationManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/MigrationManager.java b/src/java/org/apache/cassandra/service/MigrationManager.java
index 3ede35e..37d5f43 100644
--- a/src/java/org/apache/cassandra/service/MigrationManager.java
+++ b/src/java/org/apache/cassandra/service/MigrationManager.java
@@ -50,7 +50,7 @@ import org.apache.cassandra.utils.FBUtilities;
 import org.apache.cassandra.utils.UUIDGen;
 import org.apache.cassandra.utils.WrappedRunnable;
 
-public class MigrationManager implements IEndpointStateChangeSubscriber
+public class MigrationManager
 {
     private static final Logger logger = LoggerFactory.getLogger(MigrationManager.class);
 
@@ -63,7 +63,7 @@ public class MigrationManager implements IEndpointStateChangeSubscriber
     public static final int MIGRATION_DELAY_IN_MS = 60000;
 
     private final List<IMigrationListener> listeners = new CopyOnWriteArrayList<IMigrationListener>();
-
+    
     private MigrationManager() {}
 
     public void register(IMigrationListener listener)
@@ -76,34 +76,14 @@ public class MigrationManager implements IEndpointStateChangeSubscriber
         listeners.remove(listener);
     }
 
-    public void onJoin(InetAddress endpoint, EndpointState epState)
-    {}
-
-    public void onChange(InetAddress endpoint, ApplicationState state, VersionedValue value)
-    {
-        if (state != ApplicationState.SCHEMA || endpoint.equals(FBUtilities.getBroadcastAddress()))
-            return;
-
-        maybeScheduleSchemaPull(UUID.fromString(value.value), endpoint);
-    }
-
-    public void onAlive(InetAddress endpoint, EndpointState state)
+    public void scheduleSchemaPull(InetAddress endpoint, EndpointState state)
     {
         VersionedValue value = state.getApplicationState(ApplicationState.SCHEMA);
 
-        if (value != null)
+        if (!endpoint.equals(FBUtilities.getBroadcastAddress()) && value != null)
             maybeScheduleSchemaPull(UUID.fromString(value.value), endpoint);
     }
 
-    public void onDead(InetAddress endpoint, EndpointState state)
-    {}
-
-    public void onRestart(InetAddress endpoint, EndpointState state)
-    {}
-
-    public void onRemove(InetAddress endpoint)
-    {}
-
     /**
      * If versions differ this node sends request with local migration list to the endpoint
      * and expecting to receive a list of migrations to apply locally.
@@ -165,7 +145,7 @@ public class MigrationManager implements IEndpointStateChangeSubscriber
 
     public static boolean isReadyForBootstrap()
     {
-        return ((ThreadPoolExecutor) StageManager.getStage(Stage.MIGRATION)).getActiveCount() == 0;
+        return Schema.instance.getVersion() != null && !Schema.emptyVersion.equals(Schema.instance.getVersion());
     }
 
     public void notifyCreateKeyspace(KSMetaData ksm)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ed5cac1d/src/java/org/apache/cassandra/service/StorageService.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/StorageService.java b/src/java/org/apache/cassandra/service/StorageService.java
index c4b1b2e..fa43154 100644
--- a/src/java/org/apache/cassandra/service/StorageService.java
+++ b/src/java/org/apache/cassandra/service/StorageService.java
@@ -185,8 +185,6 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
     private static enum Mode { NORMAL, CLIENT, JOINING, LEAVING, DECOMMISSIONED, MOVING, DRAINING, DRAINED, RELOCATING }
     private Mode operationMode;
 
-    private final MigrationManager migrationManager = MigrationManager.instance;
-
     /* Used for tracking drain progress */
     private volatile int totalCFs, remainingCFs;
 
@@ -376,7 +374,6 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
 
     public void stopClient()
     {
-        Gossiper.instance.unregister(migrationManager);
         Gossiper.instance.unregister(this);
         Gossiper.instance.stop();
         MessagingService.instance().shutdown();
@@ -464,7 +461,6 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
         logger.info("Starting up client gossip");
         setMode(Mode.CLIENT, false);
         Gossiper.instance.register(this);
-        Gossiper.instance.register(migrationManager);
         Gossiper.instance.start((int) (System.currentTimeMillis() / 1000)); // needed for node-ring gathering.
         Gossiper.instance.addLocalApplicationState(ApplicationState.NET_VERSION, valueFactory.networkVersion());
 
@@ -620,7 +616,6 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
         appStates.put(ApplicationState.RELEASE_VERSION, valueFactory.releaseVersion());
         logger.info("Starting up server gossip");
         Gossiper.instance.register(this);
-        Gossiper.instance.register(migrationManager);
         Gossiper.instance.start(SystemTable.incrementAndGetGeneration(), appStates); // needed for node-ring gathering.
         // gossip snitch infos (local DC and rack)
         gossipSnitchInfo();
@@ -1981,6 +1976,7 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
         {
             onChange(endpoint, entry.getKey(), entry.getValue());
         }
+        MigrationManager.instance.scheduleSchemaPull(endpoint, epState);
     }
 
     public void onAlive(InetAddress endpoint, EndpointState state)
@@ -1999,6 +1995,7 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
             for (IEndpointLifecycleSubscriber subscriber : lifecycleSubscribers)
                 subscriber.onJoinCluster(endpoint);
         }
+        MigrationManager.instance.scheduleSchemaPull(endpoint, state);
     }
 
     public void onRemove(InetAddress endpoint)


[7/8] git commit: Move handling of migration event source to solve bootstrap race. Patch by Sergio Bossa and brandonwilliams, reviewed by Tyler Hobbs for CASSANDRA-6648

Posted by br...@apache.org.
Move handling of migration event source to solve bootstrap race.
Patch by Sergio Bossa and brandonwilliams, reviewed by Tyler Hobbs for
CASSANDRA-6648


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/93bd89fb
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/93bd89fb
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/93bd89fb

Branch: refs/heads/cassandra-2.0
Commit: 93bd89fbba7d76821d3d85ae371cb2e665176b6a
Parents: 34112ef
Author: Brandon Williams <br...@apache.org>
Authored: Tue Feb 4 18:33:44 2014 -0600
Committer: Brandon Williams <br...@apache.org>
Committed: Tue Feb 4 18:33:44 2014 -0600

----------------------------------------------------------------------
 CHANGES.txt                                     |  2 ++
 .../cassandra/service/MigrationManager.java     | 33 +++-----------------
 .../cassandra/service/StorageService.java       |  7 ++---
 3 files changed, 9 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/93bd89fb/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index b1fade1..d3a78f7 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -2,6 +2,8 @@
  * Fix direct Memory on architectures that do not support unaligned long access
    (CASSANDRA-6628)
  * Let scrub optionally skip broken counter partitions (CASSANDRA-5930)
+Merged from 1.2:
+ * Move handling of migration event source to solve bootstrap race. (CASSANDRA-6648)
 
 
 2.0.5

http://git-wip-us.apache.org/repos/asf/cassandra/blob/93bd89fb/src/java/org/apache/cassandra/service/MigrationManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/MigrationManager.java b/src/java/org/apache/cassandra/service/MigrationManager.java
index 0ffc7c4..b463116 100644
--- a/src/java/org/apache/cassandra/service/MigrationManager.java
+++ b/src/java/org/apache/cassandra/service/MigrationManager.java
@@ -50,7 +50,7 @@ import org.apache.cassandra.utils.ByteBufferUtil;
 import org.apache.cassandra.utils.FBUtilities;
 import org.apache.cassandra.utils.WrappedRunnable;
 
-public class MigrationManager implements IEndpointStateChangeSubscriber
+public class MigrationManager
 {
     private static final Logger logger = LoggerFactory.getLogger(MigrationManager.class);
 
@@ -63,7 +63,7 @@ public class MigrationManager implements IEndpointStateChangeSubscriber
     public static final int MIGRATION_DELAY_IN_MS = 60000;
 
     private final List<IMigrationListener> listeners = new CopyOnWriteArrayList<IMigrationListener>();
-
+    
     private MigrationManager() {}
 
     public void register(IMigrationListener listener)
@@ -76,37 +76,14 @@ public class MigrationManager implements IEndpointStateChangeSubscriber
         listeners.remove(listener);
     }
 
-    public void onJoin(InetAddress endpoint, EndpointState epState)
-    {}
-    
-    public void beforeChange(InetAddress endpoint, EndpointState currentState, ApplicationState newStateKey, VersionedValue newValue) 
-    {}
-
-    public void onChange(InetAddress endpoint, ApplicationState state, VersionedValue value)
-    {
-        if (state != ApplicationState.SCHEMA || endpoint.equals(FBUtilities.getBroadcastAddress()))
-            return;
-
-        maybeScheduleSchemaPull(UUID.fromString(value.value), endpoint);
-    }
-
-    public void onAlive(InetAddress endpoint, EndpointState state)
+    public void scheduleSchemaPull(InetAddress endpoint, EndpointState state)
     {
         VersionedValue value = state.getApplicationState(ApplicationState.SCHEMA);
 
-        if (value != null)
+        if (!endpoint.equals(FBUtilities.getBroadcastAddress()) && value != null)
             maybeScheduleSchemaPull(UUID.fromString(value.value), endpoint);
     }
 
-    public void onDead(InetAddress endpoint, EndpointState state)
-    {}
-
-    public void onRestart(InetAddress endpoint, EndpointState state)
-    {}
-
-    public void onRemove(InetAddress endpoint)
-    {}
-
     /**
      * If versions differ this node sends request with local migration list to the endpoint
      * and expecting to receive a list of migrations to apply locally.
@@ -166,7 +143,7 @@ public class MigrationManager implements IEndpointStateChangeSubscriber
 
     public static boolean isReadyForBootstrap()
     {
-        return ((ThreadPoolExecutor) StageManager.getStage(Stage.MIGRATION)).getActiveCount() == 0;
+        return Schema.instance.getVersion() != null && !Schema.emptyVersion.equals(Schema.instance.getVersion());
     }
 
     public void notifyCreateKeyspace(KSMetaData ksm)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/93bd89fb/src/java/org/apache/cassandra/service/StorageService.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/StorageService.java b/src/java/org/apache/cassandra/service/StorageService.java
index 5f9657d..c222570 100644
--- a/src/java/org/apache/cassandra/service/StorageService.java
+++ b/src/java/org/apache/cassandra/service/StorageService.java
@@ -179,8 +179,6 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
     private static enum Mode { STARTING, NORMAL, CLIENT, JOINING, LEAVING, DECOMMISSIONED, MOVING, DRAINING, DRAINED, RELOCATING }
     private Mode operationMode = Mode.STARTING;
 
-    private final MigrationManager migrationManager = MigrationManager.instance;
-
     /* Used for tracking drain progress */
     private volatile int totalCFs, remainingCFs;
 
@@ -367,7 +365,6 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
 
     public void stopClient()
     {
-        Gossiper.instance.unregister(migrationManager);
         Gossiper.instance.unregister(this);
         Gossiper.instance.stop();
         MessagingService.instance().shutdown();
@@ -473,7 +470,6 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
         logger.info("Starting up client gossip");
         setMode(Mode.CLIENT, false);
         Gossiper.instance.register(this);
-        Gossiper.instance.register(migrationManager);
         Gossiper.instance.start((int) (System.currentTimeMillis() / 1000)); // needed for node-ring gathering.
         Gossiper.instance.addLocalApplicationState(ApplicationState.NET_VERSION, valueFactory.networkVersion());
 
@@ -630,7 +626,6 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
         appStates.put(ApplicationState.RELEASE_VERSION, valueFactory.releaseVersion());
         logger.info("Starting up server gossip");
         Gossiper.instance.register(this);
-        Gossiper.instance.register(migrationManager);
         Gossiper.instance.start(SystemKeyspace.incrementAndGetGeneration(), appStates); // needed for node-ring gathering.
         // gossip snitch infos (local DC and rack)
         gossipSnitchInfo();
@@ -1964,6 +1959,7 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
         {
             onChange(endpoint, entry.getKey(), entry.getValue());
         }
+        MigrationManager.instance.scheduleSchemaPull(endpoint, epState);
     }
 
     public void onAlive(InetAddress endpoint, EndpointState state)
@@ -1982,6 +1978,7 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
             for (IEndpointLifecycleSubscriber subscriber : lifecycleSubscribers)
                 subscriber.onJoinCluster(endpoint);
         }
+        MigrationManager.instance.scheduleSchemaPull(endpoint, state);
     }
 
     public void onRemove(InetAddress endpoint)


[3/8] git commit: Move handling of migration event source to solve bootstrap race. Patch by Sergio Bossa and brandonwilliams, reviewed by Tyler Hobbs for CASSANDRA-6648

Posted by br...@apache.org.
Move handling of migration event source to solve bootstrap race.
Patch by Sergio Bossa and brandonwilliams, reviewed by Tyler Hobbs for
CASSANDRA-6648


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

Branch: refs/heads/trunk
Commit: ed5cac1d2ab18f03ec2fe211c46b5382729b4c4d
Parents: 814a912
Author: Brandon Williams <br...@apache.org>
Authored: Tue Feb 4 18:23:30 2014 -0600
Committer: Brandon Williams <br...@apache.org>
Committed: Tue Feb 4 18:23:30 2014 -0600

----------------------------------------------------------------------
 CHANGES.txt                                     |  3 ++
 .../cassandra/service/MigrationManager.java     | 30 ++++----------------
 .../cassandra/service/StorageService.java       |  7 ++---
 3 files changed, 10 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/ed5cac1d/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 981f977..b2e892e 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,3 +1,6 @@
+1.2.15
+ * Move handling of migration event source to solve bootstrap race (CASSANDRA-6648)
+
 1.2.14
  * Reverted code to limit CQL prepared statement cache by size (CASSANDRA-6592)
  * add cassandra.default_messaging_version property to allow easier

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ed5cac1d/src/java/org/apache/cassandra/service/MigrationManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/MigrationManager.java b/src/java/org/apache/cassandra/service/MigrationManager.java
index 3ede35e..37d5f43 100644
--- a/src/java/org/apache/cassandra/service/MigrationManager.java
+++ b/src/java/org/apache/cassandra/service/MigrationManager.java
@@ -50,7 +50,7 @@ import org.apache.cassandra.utils.FBUtilities;
 import org.apache.cassandra.utils.UUIDGen;
 import org.apache.cassandra.utils.WrappedRunnable;
 
-public class MigrationManager implements IEndpointStateChangeSubscriber
+public class MigrationManager
 {
     private static final Logger logger = LoggerFactory.getLogger(MigrationManager.class);
 
@@ -63,7 +63,7 @@ public class MigrationManager implements IEndpointStateChangeSubscriber
     public static final int MIGRATION_DELAY_IN_MS = 60000;
 
     private final List<IMigrationListener> listeners = new CopyOnWriteArrayList<IMigrationListener>();
-
+    
     private MigrationManager() {}
 
     public void register(IMigrationListener listener)
@@ -76,34 +76,14 @@ public class MigrationManager implements IEndpointStateChangeSubscriber
         listeners.remove(listener);
     }
 
-    public void onJoin(InetAddress endpoint, EndpointState epState)
-    {}
-
-    public void onChange(InetAddress endpoint, ApplicationState state, VersionedValue value)
-    {
-        if (state != ApplicationState.SCHEMA || endpoint.equals(FBUtilities.getBroadcastAddress()))
-            return;
-
-        maybeScheduleSchemaPull(UUID.fromString(value.value), endpoint);
-    }
-
-    public void onAlive(InetAddress endpoint, EndpointState state)
+    public void scheduleSchemaPull(InetAddress endpoint, EndpointState state)
     {
         VersionedValue value = state.getApplicationState(ApplicationState.SCHEMA);
 
-        if (value != null)
+        if (!endpoint.equals(FBUtilities.getBroadcastAddress()) && value != null)
             maybeScheduleSchemaPull(UUID.fromString(value.value), endpoint);
     }
 
-    public void onDead(InetAddress endpoint, EndpointState state)
-    {}
-
-    public void onRestart(InetAddress endpoint, EndpointState state)
-    {}
-
-    public void onRemove(InetAddress endpoint)
-    {}
-
     /**
      * If versions differ this node sends request with local migration list to the endpoint
      * and expecting to receive a list of migrations to apply locally.
@@ -165,7 +145,7 @@ public class MigrationManager implements IEndpointStateChangeSubscriber
 
     public static boolean isReadyForBootstrap()
     {
-        return ((ThreadPoolExecutor) StageManager.getStage(Stage.MIGRATION)).getActiveCount() == 0;
+        return Schema.instance.getVersion() != null && !Schema.emptyVersion.equals(Schema.instance.getVersion());
     }
 
     public void notifyCreateKeyspace(KSMetaData ksm)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ed5cac1d/src/java/org/apache/cassandra/service/StorageService.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/StorageService.java b/src/java/org/apache/cassandra/service/StorageService.java
index c4b1b2e..fa43154 100644
--- a/src/java/org/apache/cassandra/service/StorageService.java
+++ b/src/java/org/apache/cassandra/service/StorageService.java
@@ -185,8 +185,6 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
     private static enum Mode { NORMAL, CLIENT, JOINING, LEAVING, DECOMMISSIONED, MOVING, DRAINING, DRAINED, RELOCATING }
     private Mode operationMode;
 
-    private final MigrationManager migrationManager = MigrationManager.instance;
-
     /* Used for tracking drain progress */
     private volatile int totalCFs, remainingCFs;
 
@@ -376,7 +374,6 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
 
     public void stopClient()
     {
-        Gossiper.instance.unregister(migrationManager);
         Gossiper.instance.unregister(this);
         Gossiper.instance.stop();
         MessagingService.instance().shutdown();
@@ -464,7 +461,6 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
         logger.info("Starting up client gossip");
         setMode(Mode.CLIENT, false);
         Gossiper.instance.register(this);
-        Gossiper.instance.register(migrationManager);
         Gossiper.instance.start((int) (System.currentTimeMillis() / 1000)); // needed for node-ring gathering.
         Gossiper.instance.addLocalApplicationState(ApplicationState.NET_VERSION, valueFactory.networkVersion());
 
@@ -620,7 +616,6 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
         appStates.put(ApplicationState.RELEASE_VERSION, valueFactory.releaseVersion());
         logger.info("Starting up server gossip");
         Gossiper.instance.register(this);
-        Gossiper.instance.register(migrationManager);
         Gossiper.instance.start(SystemTable.incrementAndGetGeneration(), appStates); // needed for node-ring gathering.
         // gossip snitch infos (local DC and rack)
         gossipSnitchInfo();
@@ -1981,6 +1976,7 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
         {
             onChange(endpoint, entry.getKey(), entry.getValue());
         }
+        MigrationManager.instance.scheduleSchemaPull(endpoint, epState);
     }
 
     public void onAlive(InetAddress endpoint, EndpointState state)
@@ -1999,6 +1995,7 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
             for (IEndpointLifecycleSubscriber subscriber : lifecycleSubscribers)
                 subscriber.onJoinCluster(endpoint);
         }
+        MigrationManager.instance.scheduleSchemaPull(endpoint, state);
     }
 
     public void onRemove(InetAddress endpoint)


[8/8] git commit: Merge branch 'cassandra-2.0' into trunk

Posted by br...@apache.org.
Merge branch 'cassandra-2.0' into trunk


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/9d4f7c91
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/9d4f7c91
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/9d4f7c91

Branch: refs/heads/trunk
Commit: 9d4f7c918d056afc038dcc94836e982e8b34a4f3
Parents: c947c12 93bd89f
Author: Brandon Williams <br...@apache.org>
Authored: Tue Feb 4 18:34:16 2014 -0600
Committer: Brandon Williams <br...@apache.org>
Committed: Tue Feb 4 18:34:16 2014 -0600

----------------------------------------------------------------------
 CHANGES.txt                                     |  2 ++
 .../cassandra/service/MigrationManager.java     | 33 +++-----------------
 .../cassandra/service/StorageService.java       |  7 ++---
 3 files changed, 9 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/9d4f7c91/CHANGES.txt
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9d4f7c91/src/java/org/apache/cassandra/service/MigrationManager.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/9d4f7c91/src/java/org/apache/cassandra/service/StorageService.java
----------------------------------------------------------------------