Updated Branches: refs/heads/trunk ad8ebc684 -> ccd1a3d38
Move static initialization out of the way for use of the binary protocol Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/ccd1a3d3 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/ccd1a3d3 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/ccd1a3d3 Branch: refs/heads/trunk Commit: ccd1a3d38c998d000b2ff12df9045425932adc17 Parents: ad8ebc6 Author: Sylvain Lebresne <[email protected]> Authored: Fri Sep 28 17:17:50 2012 +0200 Committer: Sylvain Lebresne <[email protected]> Committed: Fri Sep 28 17:18:00 2012 +0200 ---------------------------------------------------------------------- .../cassandra/config/DatabaseDescriptor.java | 9 +++++++++ .../org/apache/cassandra/db/ConsistencyLevel.java | 4 +--- 2 files changed, 10 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/ccd1a3d3/src/java/org/apache/cassandra/config/DatabaseDescriptor.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java index 5a5d98e..e3ce40c 100644 --- a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java +++ b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java @@ -88,6 +88,8 @@ public class DatabaseDescriptor private static long keyCacheSizeInMB; private static IRowCacheProvider rowCacheProvider; + private static String localDC; + /** * Inspect the classpath to find storage configuration file */ @@ -345,6 +347,8 @@ public class DatabaseDescriptor snitch = createEndpointSnitch(conf.endpoint_snitch); EndpointSnitchInfo.create(); + localDC = snitch.getDatacenter(FBUtilities.getBroadcastAddress()); + /* Request Scheduler setup */ requestSchedulerOptions = conf.request_scheduler_options; if (conf.request_scheduler != null) @@ -1235,6 +1239,11 @@ public class DatabaseDescriptor return conf.populate_io_cache_on_flush; } + public static String getLocalDataCenter() + { + return localDC; + } + public static Config.InternodeCompression internodeCompression() { return conf.internode_compression; http://git-wip-us.apache.org/repos/asf/cassandra/blob/ccd1a3d3/src/java/org/apache/cassandra/db/ConsistencyLevel.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/db/ConsistencyLevel.java b/src/java/org/apache/cassandra/db/ConsistencyLevel.java index c7c5136..ea7660c 100644 --- a/src/java/org/apache/cassandra/db/ConsistencyLevel.java +++ b/src/java/org/apache/cassandra/db/ConsistencyLevel.java @@ -35,8 +35,6 @@ public enum ConsistencyLevel LOCAL_QUORUM, EACH_QUORUM; - private static final String LOCAL_DC = DatabaseDescriptor.getEndpointSnitch().getDatacenter(FBUtilities.getBroadcastAddress()); - public int blockFor(String table) { NetworkTopologyStrategy strategy = null; @@ -56,7 +54,7 @@ public enum ConsistencyLevel return Table.open(table).getReplicationStrategy().getReplicationFactor(); case LOCAL_QUORUM: strategy = (NetworkTopologyStrategy) Table.open(table).getReplicationStrategy(); - return (strategy.getReplicationFactor(LOCAL_DC) / 2) + 1; + return (strategy.getReplicationFactor(DatabaseDescriptor.getLocalDataCenter()) / 2) + 1; case EACH_QUORUM: strategy = (NetworkTopologyStrategy) Table.open(table).getReplicationStrategy(); int n = 0;
