You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by jb...@apache.org on 2012/09/28 16:41:39 UTC
[2/2] git commit: add check to PropertyFileSnitch to verify presence
of location for local node patch by jbellis;
reviewed by brandonwilliams for CASSANDRA-4728
add check to PropertyFileSnitch to verify presence of location for local node
patch by jbellis; reviewed by brandonwilliams for CASSANDRA-4728
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/480cb2f5
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/480cb2f5
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/480cb2f5
Branch: refs/heads/trunk
Commit: 480cb2f5a29a271b91008becaa68a7c11caf2024
Parents: 29353b8
Author: Jonathan Ellis <jb...@apache.org>
Authored: Thu Sep 27 15:55:52 2012 -0500
Committer: Jonathan Ellis <jb...@apache.org>
Committed: Fri Sep 28 09:37:53 2012 -0500
----------------------------------------------------------------------
CHANGES.txt | 2 ++
.../cassandra/locator/PropertyFileSnitch.java | 12 ++++++++++--
2 files changed, 12 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/480cb2f5/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index bd46641..e9ebb1c 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,6 @@
1.2-beta2
+ * add check to PropertyFileSnitch to verify presence of location for
+ local node (CASSANDRA-4728)
* add PBSPredictor consistency modeler (CASSANDRA-4261)
* remove vestiges of Thrift unframed mode (CASSANDRA-4729)
* optimize single-row PK lookups (CASSANDRA-4710)
http://git-wip-us.apache.org/repos/asf/cassandra/blob/480cb2f5/src/java/org/apache/cassandra/locator/PropertyFileSnitch.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/locator/PropertyFileSnitch.java b/src/java/org/apache/cassandra/locator/PropertyFileSnitch.java
index 1c25ca8..4e9b44a 100644
--- a/src/java/org/apache/cassandra/locator/PropertyFileSnitch.java
+++ b/src/java/org/apache/cassandra/locator/PropertyFileSnitch.java
@@ -56,6 +56,7 @@ public class PropertyFileSnitch extends AbstractNetworkTopologySnitch
public PropertyFileSnitch() throws ConfigurationException
{
reloadConfiguration();
+
try
{
FBUtilities.resourceToFile(RACK_PROPERTY_FILENAME);
@@ -107,7 +108,9 @@ public class PropertyFileSnitch extends AbstractNetworkTopologySnitch
*/
public String getDatacenter(InetAddress endpoint)
{
- return getEndpointInfo(endpoint)[0];
+ String[] info = getEndpointInfo(endpoint);
+ assert info != null : "No location defined for endpoint " + endpoint;
+ return info[0];
}
/**
@@ -118,7 +121,9 @@ public class PropertyFileSnitch extends AbstractNetworkTopologySnitch
*/
public String getRack(InetAddress endpoint)
{
- return getEndpointInfo(endpoint)[1];
+ String[] info = getEndpointInfo(endpoint);
+ assert info != null : "No location defined for endpoint " + endpoint;
+ return info[1];
}
public void reloadConfiguration() throws ConfigurationException
@@ -171,6 +176,9 @@ public class PropertyFileSnitch extends AbstractNetworkTopologySnitch
reloadedMap.put(host, token);
}
}
+ if (!reloadedMap.containsKey(FBUtilities.getBroadcastAddress()))
+ throw new ConfigurationException(String.format("Snitch definitions at %s do not define a location for this node's broadcast address %s",
+ RACK_PROPERTY_FILENAME, FBUtilities.getBroadcastAddress()));
logger.debug("loaded network topology {}", FBUtilities.toString(reloadedMap));
endpointMap = reloadedMap;