cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1126670 - in /cassandra/branches/cassandra-0.8.0: CHANGES.txt src/java/org/apache/cassandra/config/KSMetaData.java src/java/org/apache/cassandra/locator/NetworkTopologyStrategy.java
Date Mon, 23 May 2011 19:10:56 GMT
Author: jbellis
Date: Mon May 23 19:10:56 2011
New Revision: 1126670

URL: http://svn.apache.org/viewvc?rev=1126670&view=rev
Log:
onlyprovidereplication_factor to strategy_options "help" for SimpleStrategy, OldNetworkTopologyStrategy
patch by jbellis; reviewed by Jon Hermes for CASSANDRA-2678

Modified:
    cassandra/branches/cassandra-0.8.0/CHANGES.txt
    cassandra/branches/cassandra-0.8.0/src/java/org/apache/cassandra/config/KSMetaData.java
    cassandra/branches/cassandra-0.8.0/src/java/org/apache/cassandra/locator/NetworkTopologyStrategy.java

Modified: cassandra/branches/cassandra-0.8.0/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8.0/CHANGES.txt?rev=1126670&r1=1126669&r2=1126670&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8.0/CHANGES.txt (original)
+++ cassandra/branches/cassandra-0.8.0/CHANGES.txt Mon May 23 19:10:56 2011
@@ -6,6 +6,9 @@
  * fix UUIDType, IntegerType for direct buffers (CASSANDRA-2682, 2684)
  * switch to native Thrift for Hadoop map/reduce (CASSANDRA-2667)
  * fix StackOverflowError when building from eclipse (CASSANDRA-2687)
+ * only provide replication_factor to strategy_options "help" for
+   SimpleStrategy, OldNetworkTopologyStrategy (CASSANDRA-2678)
+
 
 0.8.0-rc1
  * faster flushes and compaction from fixing excessively pessimistic 

Modified: cassandra/branches/cassandra-0.8.0/src/java/org/apache/cassandra/config/KSMetaData.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8.0/src/java/org/apache/cassandra/config/KSMetaData.java?rev=1126670&r1=1126669&r2=1126670&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8.0/src/java/org/apache/cassandra/config/KSMetaData.java
(original)
+++ cassandra/branches/cassandra-0.8.0/src/java/org/apache/cassandra/config/KSMetaData.java
Mon May 23 19:10:56 2011
@@ -51,19 +51,18 @@ public final class KSMetaData
 
     public static Map<String, String> forwardsCompatibleOptions(KsDef ks_def)
     {
-        Map<String, String> options;
-        if (ks_def.isSetReplication_factor())
-        {
-            options = new HashMap<String, String>(ks_def.strategy_options == null ?
Collections.<String, String>emptyMap() : ks_def.strategy_options);
-            options.put("replication_factor", String.valueOf(ks_def.replication_factor));
-        }
-        else
-        {
-            options = ks_def.strategy_options;
-        }
+        Map<String, String> options = new HashMap<String, String>(ks_def.strategy_options);
+        maybeAddReplicationFactor(options, ks_def.strategy_class, ks_def.isSetReplication_factor()
? ks_def.replication_factor : null);
         return options;
     }
 
+    // TODO remove this for 1.0
+    private static void maybeAddReplicationFactor(Map<String, String> options, String
cls, Integer rf)
+    {
+        if (rf != null && (cls.endsWith("SimpleStrategy") || cls.endsWith("OldNetworkTopologyStrategy")))
+            options.put("replication_factor", rf.toString());
+    }
+
     public int hashCode()
     {
         return name.hashCode();
@@ -139,8 +138,7 @@ public final class KSMetaData
                 strategyOptions.put(e.getKey().toString(), e.getValue().toString());
             }
         }
-        if (ks.replication_factor != null)
-            strategyOptions.put("replication_factor", ks.replication_factor.toString());
+        maybeAddReplicationFactor(strategyOptions, ks.strategy_class.toString(), ks.replication_factor);
 
         int cfsz = ks.cf_defs.size();
         CFMetaData[] cfMetaData = new CFMetaData[cfsz];

Modified: cassandra/branches/cassandra-0.8.0/src/java/org/apache/cassandra/locator/NetworkTopologyStrategy.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8.0/src/java/org/apache/cassandra/locator/NetworkTopologyStrategy.java?rev=1126670&r1=1126669&r2=1126670&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8.0/src/java/org/apache/cassandra/locator/NetworkTopologyStrategy.java
(original)
+++ cassandra/branches/cassandra-0.8.0/src/java/org/apache/cassandra/locator/NetworkTopologyStrategy.java
Mon May 23 19:10:56 2011
@@ -63,8 +63,14 @@ public class NetworkTopologyStrategy ext
         Map<String, Integer> newDatacenters = new HashMap<String, Integer>();
         if (configOptions != null)
         {
-            for (Entry entry : configOptions.entrySet())
-                newDatacenters.put((String) entry.getKey(), Integer.valueOf((String) entry.getValue()));
+            for (Entry<String, String> entry : configOptions.entrySet())
+            {
+                String dc = entry.getKey();
+                if (dc.equalsIgnoreCase("replication_factor"))
+                    continue; // TODO remove this for 1.0
+                Integer replicas = Integer.valueOf(entry.getValue());
+                newDatacenters.put(dc, replicas);
+            }
         }
 
         datacenters = Collections.unmodifiableMap(newDatacenters);



Mime
View raw message