From d3329d28a1cf9c4bb440efb93e8f443e4369ae0d Mon Sep 17 00:00:00 2001 From: Jonathan Ellis Date: Mon, 31 Jan 2011 16:02:21 +0000 Subject: [PATCH] move initialization out of constructor where possible git-svn-id: https://svn.apache.org/repos/asf/cassandra/branches/cassandra-0.7@1065660 13f79535-47bb-0310-9956-ffa450edef68 --- conf/cassandra.yaml | 2 +- .../org/apache/cassandra/locator/TokenMetadata.java | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/conf/cassandra.yaml b/conf/cassandra.yaml index 5f4384341b..16e18df6f4 100644 --- a/conf/cassandra.yaml +++ b/conf/cassandra.yaml @@ -220,7 +220,7 @@ rpc_timeout_in_ms: 10000 # org.apache.cassandra.locator.PropertyFileSnitch: # - Proximity is determined by rack and data center, which are # explicitly configured in cassandra-topology.properties. -endpoint_snitch: org.apache.cassandra.locator.SimpleSnitch +endpoint_snitch: org.apache.cassandra.locator.PropertyFileSnitch # dynamic_snitch -- This boolean controls whether the above snitch is # wrapped with a dynamic snitch, which will monitor read latencies diff --git a/src/java/org/apache/cassandra/locator/TokenMetadata.java b/src/java/org/apache/cassandra/locator/TokenMetadata.java index 72c275e161..ec03ac00e3 100644 --- a/src/java/org/apache/cassandra/locator/TokenMetadata.java +++ b/src/java/org/apache/cassandra/locator/TokenMetadata.java @@ -50,22 +50,22 @@ public class TokenMetadata // for any nodes that boot simultaneously between same two nodes. For this we cannot simply make pending ranges a Multimap, // since that would make us unable to notice the real problem of two nodes trying to boot using the same token. // In order to do this properly, we need to know what tokens are booting at any time. - private BiMap bootstrapTokens; + private BiMap bootstrapTokens = HashBiMap.create(); // we will need to know at all times what nodes are leaving and calculate ranges accordingly. // An anonymous pending ranges list is not enough, as that does not tell which node is leaving // and/or if the ranges are there because of bootstrap or leave operation. // (See CASSANDRA-603 for more detail + examples). - private Set leavingEndpoints; + private Set leavingEndpoints = new HashSet(); - private ConcurrentMap> pendingRanges; + private ConcurrentMap> pendingRanges = new ConcurrentHashMap>(); /* Use this lock for manipulating the token map */ private final ReadWriteLock lock = new ReentrantReadWriteLock(true); private ArrayList sortedTokens; /* list of subscribers that are notified when the tokenToEndpointMap changed */ - private final CopyOnWriteArrayList subscribers; + private final CopyOnWriteArrayList subscribers = new CopyOnWriteArrayList(); public TokenMetadata() { @@ -77,11 +77,7 @@ public class TokenMetadata if (tokenToEndpointMap == null) tokenToEndpointMap = HashBiMap.create(); this.tokenToEndpointMap = tokenToEndpointMap; - bootstrapTokens = HashBiMap.create(); - leavingEndpoints = new HashSet(); - pendingRanges = new ConcurrentHashMap>(); sortedTokens = sortTokens(); - subscribers = new CopyOnWriteArrayList(); } private ArrayList sortTokens()