Follow-up to CASSANDRA-10238

call invalidateCacheRings when topology is updated

patch by Stefania Alborghetti; reviewed by Branimir Lambov for
CASSANDRA-10238
This commit is contained in:
Stefania Alborghetti 2015-09-18 08:57:53 +08:00 committed by Aleksey Yeschenko
parent 6f8e07ab06
commit c4de752758
4 changed files with 19 additions and 10 deletions

View File

@ -59,7 +59,7 @@ public class PropertyFileSnitch extends AbstractNetworkTopologySnitch
public PropertyFileSnitch() throws ConfigurationException
{
reloadConfiguration();
reloadConfiguration(false);
try
{
@ -68,8 +68,7 @@ public class PropertyFileSnitch extends AbstractNetworkTopologySnitch
{
protected void runMayThrow() throws ConfigurationException
{
reloadConfiguration();
StorageService.instance.updateTopology();
reloadConfiguration(true);
}
};
ResourceWatcher.watch(SNITCH_PROPERTIES_FILENAME, runnable, 60 * 1000);
@ -131,7 +130,7 @@ public class PropertyFileSnitch extends AbstractNetworkTopologySnitch
return info[1];
}
public void reloadConfiguration() throws ConfigurationException
public void reloadConfiguration(boolean isUpdate) throws ConfigurationException
{
HashMap<InetAddress, String[]> reloadedMap = new HashMap<InetAddress, String[]>();
@ -198,7 +197,12 @@ public class PropertyFileSnitch extends AbstractNetworkTopologySnitch
endpointMap = reloadedMap;
if (StorageService.instance != null) // null check tolerates circular dependency; see CASSANDRA-4145
StorageService.instance.getTokenMetadata().invalidateCachedRings();
{
if (isUpdate)
StorageService.instance.updateTopology();
else
StorageService.instance.getTokenMetadata().invalidateCachedRings();
}
if (gossipStarted)
StorageService.instance.gossipSnitchInfo();

View File

@ -413,6 +413,7 @@ public class TokenMetadata
{
logger.info("Updating topology for {}", endpoint);
topology.updateEndpoint(endpoint);
invalidateCachedRings();
}
finally
{
@ -431,6 +432,7 @@ public class TokenMetadata
{
logger.info("Updating topology for all endpoints that have changed");
topology.updateEndpoints();
invalidateCachedRings();
}
finally
{

View File

@ -103,7 +103,7 @@ public class YamlFileNetworkTopologySnitch
throws ConfigurationException
{
this.topologyConfigFilename = topologyConfigFilename;
loadTopologyConfiguration();
loadTopologyConfiguration(false);
try
{
@ -119,8 +119,7 @@ public class YamlFileNetworkTopologySnitch
*/
protected void runMayThrow() throws ConfigurationException
{
loadTopologyConfiguration();
StorageService.instance.updateTopology();
loadTopologyConfiguration(true);
}
};
ResourceWatcher.watch(topologyConfigFilename, runnable,
@ -202,7 +201,7 @@ public class YamlFileNetworkTopologySnitch
* @throws ConfigurationException
* on failure
*/
private synchronized void loadTopologyConfiguration()
private synchronized void loadTopologyConfiguration(boolean isUpdate)
throws ConfigurationException
{
logger.debug("Loading topology configuration from {}",
@ -354,6 +353,9 @@ public class YamlFileNetworkTopologySnitch
{
StorageService.instance.gossipSnitchInfo();
}
if (isUpdate && StorageService.instance != null)
StorageService.instance.updateTopology();
}
/**

View File

@ -1411,7 +1411,6 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
public void updateTopology()
{
getTokenMetadata().updateTopology();
}
private void updatePeerInfo(InetAddress endpoint)
@ -3670,6 +3669,8 @@ public class StorageService extends NotificationBroadcasterSupport implements IE
if (oldSnitch instanceof DynamicEndpointSnitch)
((DynamicEndpointSnitch)oldSnitch).unregisterMBean();
updateTopology();
}
/**