stream = getClass().getClassLoader().getResourceAsStream(SNITCH_PROPERTIES_FILENAME);
properties.load(stream);
}
catch (Exception e)
{
throw new ConfigurationException("Unable to read " + SNITCH_PROPERTIES_FILENAME, e);
}
finally
{
FileUtils.closeQuietly(stream);
}
for (Map.Entry<Object, Object> entry : properties.entrySet())
{
String key = (String) entry.getKey();
String value = (String) entry.getValue();
if (key.equals("default"))
{
String[] newDefault = value.split(":");
if (newDefault.length < 2)
newDefault = new String[] { "default", "default" };
defaultDCRack = newDefault;
}
else
{
InetAddress host;
String hostString = key.replace("/", "");
try
{
host = InetAddress.getByName(hostString);
}
catch (UnknownHostException e)
{
throw new ConfigurationException("Unknown host " + hostString, e);
}
String[] token = value.split(":");
if (token.length < 2)
token = new String[] { "default", "default" };
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",
SNITCH_PROPERTIES_FILENAME, FBUtilities.getBroadcastAddress()));
logger.debug("loaded network topology {}", FBUtilities.toString(reloadedMap));
endpointMap = reloadedMap;
if (StorageService.instance != null) // null check tolerates circular dependency; see CASSANDRA-4145