cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1073599 - in /cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra: cli/CliClient.java service/StorageProxy.java
Date Wed, 23 Feb 2011 05:12:24 GMT
Author: jbellis
Date: Wed Feb 23 05:12:24 2011
New Revision: 1073599

URL: http://svn.apache.org/viewvc?rev=1073599&view=rev
Log:
clean up cli schema version check
patch by jbellis for CASSANDRA-2187

Modified:
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/cli/CliClient.java
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/service/StorageProxy.java

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/cli/CliClient.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/cli/CliClient.java?rev=1073599&r1=1073598&r2=1073599&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/cli/CliClient.java (original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/cli/CliClient.java Wed
Feb 23 05:12:24 2011
@@ -23,6 +23,7 @@ import java.nio.charset.CharacterCodingE
 import java.util.*;
 
 import com.google.common.base.Charsets;
+import com.google.common.base.Joiner;
 
 import org.antlr.runtime.tree.Tree;
 import org.apache.cassandra.auth.SimpleAuthenticator;
@@ -30,6 +31,7 @@ import org.apache.cassandra.config.Confi
 import org.apache.cassandra.db.ColumnFamilyStoreMBean;
 import org.apache.cassandra.db.CompactionManagerMBean;
 import org.apache.cassandra.db.marshal.*;
+import org.apache.cassandra.service.StorageProxy;
 import org.apache.cassandra.thrift.*;
 import org.apache.cassandra.tools.NodeProbe;
 import org.apache.cassandra.utils.ByteBufferUtil;
@@ -2060,13 +2062,13 @@ public class CliClient extends CliUserHe
     /** validates schema is propagated to all nodes */
     private void validateSchemaIsSettled(String currentVersionId)
     {
-        Map<String, List<String>> versions;
-
-        long start = System.currentTimeMillis();
-        long limit = start + sessionState.schema_mwt;
+        sessionState.out.println("Waiting for schema agreement...");
+        Map<String, List<String>> versions = null;
 
+        long limit = System.currentTimeMillis() + sessionState.schema_mwt;
         boolean inAgreement = false;
-        while (limit - start >= 0)
+        outer:
+        while (limit - System.currentTimeMillis() >= 0 && !inAgreement)
         {
             try
             {
@@ -2078,29 +2080,23 @@ public class CliClient extends CliUserHe
                 continue;
             }
 
-            boolean currentlyInAgreement = true;
             for (String version : versions.keySet())
             {
-                if (!version.equals(currentVersionId))
-                {
-                    currentlyInAgreement = false;
-                    break; // only one disagreement is enough
-                }
-            }
-
-            if (currentlyInAgreement)
-            {
-                inAgreement = true;
-                break; // all nodes are in agreement no need to loop
+                if (!version.equals(currentVersionId) && !version.equals(StorageProxy.UNREACHABLE))
+                    continue outer;
             }
-            start = System.currentTimeMillis();
+            inAgreement = true;
         }
 
+        if (versions.containsKey(StorageProxy.UNREACHABLE))
+            sessionState.err.printf("Warning: unreachable nodes %s", Joiner.on(", ").join(versions.get(StorageProxy.UNREACHABLE)));
         if (!inAgreement)
         {
-            sessionState.err.printf("The schema has not settled in %d seconds and further
migrations are ill-advised until it does.%n", sessionState.schema_mwt / 1000);
+            sessionState.err.printf("The schema has not settled in %d seconds; further migrations
are ill-advised until it does.%nVersions are %s%n",
+                                    sessionState.schema_mwt / 1000, FBUtilities.toString(versions));
             System.exit(-1);
         }
+        sessionState.out.println("... schemas agree across the cluster");
     }
 
     private static class CfDefNamesComparator implements Comparator<CfDef>

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/service/StorageProxy.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/service/StorageProxy.java?rev=1073599&r1=1073598&r2=1073599&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/service/StorageProxy.java
(original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/service/StorageProxy.java
Wed Feb 23 05:12:24 2011
@@ -64,7 +64,7 @@ public class StorageProxy implements Sto
     private static final LatencyTracker writeStats = new LatencyTracker();
     private static boolean hintedHandoffEnabled = DatabaseDescriptor.hintedHandoffEnabled();
     private static int maxHintWindow = DatabaseDescriptor.getMaxHintWindow();
-    private static final String UNREACHABLE = "UNREACHABLE";
+    public static final String UNREACHABLE = "UNREACHABLE";
 
     public static final StorageProxy instance = new StorageProxy();
 



Mime
View raw message