Author: jbellis
Date: Mon Jun 14 22:41:25 2010
New Revision: 954664

URL: http://svn.apache.org/viewvc?rev=954664&view=rev
Log:
avoid allowing endpoints computed from old token map to persist after 
clearCachedEndpoints.  patch by mdennis and jbellis for CASSANDRA-1147

Modified:
    
cassandra/trunk/src/java/org/apache/cassandra/locator/AbstractReplicationStrategy.java

Modified: 
cassandra/trunk/src/java/org/apache/cassandra/locator/AbstractReplicationStrategy.java
URL: 
http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/locator/AbstractReplicationStrategy.java?rev=954664&r1=954663&r2=954664&view=diff
==============================================================================
--- 
cassandra/trunk/src/java/org/apache/cassandra/locator/AbstractReplicationStrategy.java
 (original)
+++ 
cassandra/trunk/src/java/org/apache/cassandra/locator/AbstractReplicationStrategy.java
 Mon Jun 14 22:41:25 2010
@@ -49,16 +49,16 @@ public abstract class AbstractReplicatio
 
     private TokenMetadata tokenMetadata;
     protected final IEndpointSnitch snitch;
-    private final Map<EndpointCacheKey, ArrayList<InetAddress>> 
cachedEndpoints;
+    private volatile Map<EndpointCacheKey, ArrayList<InetAddress>> 
cachedEndpoints;
 
     AbstractReplicationStrategy(TokenMetadata tokenMetadata, IEndpointSnitch 
snitch)
     {
+        // TODO assert snitch != null some test code violates this
+        assert tokenMetadata != null;
         this.tokenMetadata = tokenMetadata;
         this.snitch = snitch;
         cachedEndpoints = new NonBlockingHashMap<EndpointCacheKey, 
ArrayList<InetAddress>>();
         this.tokenMetadata.register(this);
-        if (this.snitch != null)
-            this.snitch.register(this);
     }
 
     /**
@@ -233,7 +233,7 @@ public abstract class AbstractReplicatio
     protected void clearCachedEndpoints()
     {
         logger.debug("clearing cached endpoints");
-        cachedEndpoints.clear();
+        cachedEndpoints = new NonBlockingHashMap<EndpointCacheKey, 
ArrayList<InetAddress>>();
     }
 
     public void invalidateCachedTokenEndpointValues()


Reply via email to