cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brandonwilli...@apache.org
Subject [4/9] git commit: Fix harmless NPE in MM/HHOM Patch by brandonwilliams, reviewed by Tyler Hobbs for CASSANDRA-5185
Date Tue, 22 Oct 2013 20:31:48 GMT
Fix harmless NPE in MM/HHOM
Patch by brandonwilliams, reviewed by Tyler Hobbs for CASSANDRA-5185


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

Branch: refs/heads/cassandra-1.2
Commit: 59bf44dd94939cea513a74250f6002357d1f9f2c
Parents: 12413ad
Author: Brandon Williams <brandonwilliams@apache.org>
Authored: Tue Oct 22 15:28:47 2013 -0500
Committer: Brandon Williams <brandonwilliams@apache.org>
Committed: Tue Oct 22 15:28:47 2013 -0500

----------------------------------------------------------------------
 src/java/org/apache/cassandra/db/HintedHandOffManager.java  | 8 ++++++--
 src/java/org/apache/cassandra/service/MigrationManager.java | 5 ++++-
 2 files changed, 10 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/59bf44dd/src/java/org/apache/cassandra/db/HintedHandOffManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/HintedHandOffManager.java b/src/java/org/apache/cassandra/db/HintedHandOffManager.java
index c333359..ede49e4 100644
--- a/src/java/org/apache/cassandra/db/HintedHandOffManager.java
+++ b/src/java/org/apache/cassandra/db/HintedHandOffManager.java
@@ -209,7 +209,7 @@ public class HintedHandOffManager implements HintedHandOffManagerMBean
         Gossiper gossiper = Gossiper.instance;
         int waited = 0;
         // first, wait for schema to be gossiped.
-        while (gossiper.getEndpointStateForEndpoint(endpoint).getApplicationState(ApplicationState.SCHEMA)
== null)
+        while (gossiper.getEndpointStateForEndpoint(endpoint) != null && gossiper.getEndpointStateForEndpoint(endpoint).getApplicationState(ApplicationState.SCHEMA)
== null)
         {
             try
             {
@@ -223,12 +223,14 @@ public class HintedHandOffManager implements HintedHandOffManagerMBean
             if (waited > 2 * StorageService.RING_DELAY)
                 throw new TimeoutException("Didin't receive gossiped schema from " + endpoint
+ " in " + 2 * StorageService.RING_DELAY + "ms");
         }
+        if (gossiper.getEndpointStateForEndpoint(endpoint) == null)
+            throw new TimeoutException("Node " + endpoint + " vanished while waiting for
agreement");
         waited = 0;
         // then wait for the correct schema version.
         // usually we use DD.getDefsVersion, which checks the local schema uuid as stored
in the system table.
         // here we check the one in gossip instead; this serves as a canary to warn us if
we introduce a bug that
         // causes the two to diverge (see CASSANDRA-2946)
-        while (!gossiper.getEndpointStateForEndpoint(endpoint).getApplicationState(ApplicationState.SCHEMA).value.equals(
+        while (gossiper.getEndpointStateForEndpoint(endpoint) != null && !gossiper.getEndpointStateForEndpoint(endpoint).getApplicationState(ApplicationState.SCHEMA).value.equals(
                 gossiper.getEndpointStateForEndpoint(FBUtilities.getBroadcastAddress()).getApplicationState(ApplicationState.SCHEMA).value))
         {
             try
@@ -243,6 +245,8 @@ public class HintedHandOffManager implements HintedHandOffManagerMBean
             if (waited > 2 * StorageService.RING_DELAY)
                 throw new TimeoutException("Could not reach schema agreement with " + endpoint
+ " in " + 2 * StorageService.RING_DELAY + "ms");
         }
+        if (gossiper.getEndpointStateForEndpoint(endpoint) == null)
+            throw new TimeoutException("Node " + endpoint + " vanished while waiting for
agreement");
         logger.debug("schema for {} matches local schema", endpoint);
         return waited;
     }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/59bf44dd/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 e901b61..3ede35e 100644
--- a/src/java/org/apache/cassandra/service/MigrationManager.java
+++ b/src/java/org/apache/cassandra/service/MigrationManager.java
@@ -127,7 +127,10 @@ public class MigrationManager implements IEndpointStateChangeSubscriber
                 public void run()
                 {
                     // grab the latest version of the schema since it may have changed again
since the initial scheduling
-                    VersionedValue value = Gossiper.instance.getEndpointStateForEndpoint(endpoint).getApplicationState(ApplicationState.SCHEMA);
+                    EndpointState epState = Gossiper.instance.getEndpointStateForEndpoint(endpoint);
+                    if (epState == null)
+                        return;
+                    VersionedValue value = epState.getApplicationState(ApplicationState.SCHEMA);
                     UUID currentVersion = UUID.fromString(value.value);
                     if (Schema.instance.getVersion().equals(currentVersion))
                         return;


Mime
View raw message