Permalink
Browse files

Fix Ec2Snitch regression introduced by CASSANDRA-5171

patch by vijay2win; reviewed by driftx and arya for CASSANDRA-5432
  • Loading branch information...
1 parent 45e6d91 commit 59bd0e7169c5fabc0e734ccbbbcd6964709577d0 @pcmanus pcmanus committed May 6, 2013
View
1 CHANGES.txt
@@ -21,6 +21,7 @@
* cqlsh: add CLUSTERING ORDER BY support to DESCRIBE (CASSANDRA-5528)
* Add custom secondary index support to CQL3 (CASSANDRA-5484)
* Fix repair hanging silently on unexpected error (CASSANDRA-5229)
+ * Fix Ec2Snitch regression introduced by CASSANDRA-5171 (CASSANDRA-5432)
Merged from 1.1
* Add retry mechanism to OTC for non-droppable_verbs (CASSANDRA-5393)
* Use allocator information to improve memtable memory usage estimate
View
15 src/java/org/apache/cassandra/locator/Ec2Snitch.java
@@ -23,13 +23,11 @@
import java.net.HttpURLConnection;
import java.net.InetAddress;
import java.net.URL;
-import java.util.Map;
import com.google.common.base.Charsets;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.apache.cassandra.db.SystemTable;
import org.apache.cassandra.exceptions.ConfigurationException;
import org.apache.cassandra.gms.ApplicationState;
import org.apache.cassandra.gms.EndpointState;
@@ -46,7 +44,6 @@
protected static final String ZONE_NAME_QUERY_URL = "http://169.254.169.254/latest/meta-data/placement/availability-zone";
private static final String DEFAULT_DC = "UNKNOWN-DC";
private static final String DEFAULT_RACK = "UNKNOWN-RACK";
- private Map<InetAddress, Map<String, String>> savedEndpoints;
protected String ec2zone;
protected String ec2region;
@@ -96,13 +93,7 @@ public String getRack(InetAddress endpoint)
return ec2zone;
EndpointState state = Gossiper.instance.getEndpointStateForEndpoint(endpoint);
if (state == null || state.getApplicationState(ApplicationState.RACK) == null)
- {
- if (savedEndpoints == null)
- savedEndpoints = SystemTable.loadDcRackInfo();
- if (savedEndpoints.containsKey(endpoint))
- return savedEndpoints.get(endpoint).get("rack");
return DEFAULT_RACK;
- }
return state.getApplicationState(ApplicationState.RACK).value;
}
@@ -112,13 +103,7 @@ public String getDatacenter(InetAddress endpoint)
return ec2region;
EndpointState state = Gossiper.instance.getEndpointStateForEndpoint(endpoint);
if (state == null || state.getApplicationState(ApplicationState.DC) == null)
- {
- if (savedEndpoints == null)
- savedEndpoints = SystemTable.loadDcRackInfo();
- if (savedEndpoints.containsKey(endpoint))
- return savedEndpoints.get(endpoint).get("data_center");
return DEFAULT_DC;
- }
return state.getApplicationState(ApplicationState.DC).value;
}
}
View
2 src/java/org/apache/cassandra/net/OutboundTcpConnectionPool.java
@@ -132,6 +132,8 @@ public Socket newSocket() throws IOException
InetAddress endPoint()
{
+ if (id.equals(FBUtilities.getBroadcastAddress()))
+ return FBUtilities.getLocalAddress();
return resetedEndpoint == null ? id : resetedEndpoint;
}

0 comments on commit 59bd0e7

Please sign in to comment.