Merge branch 'cassandra-2.2' into cassandra-3.0

This commit is contained in:
Aleksey Yeschenko 2015-09-18 12:43:16 +01:00
commit 3355caf153
4 changed files with 22 additions and 11 deletions

View File

@ -63,7 +63,7 @@ public class GossipingPropertyFileSnitch extends AbstractNetworkTopologySnitch//
{
snitchHelperReference = new AtomicReference<ReconnectableSnitchHelper>();
reloadConfiguration();
reloadConfiguration(false);
try
{
@ -82,8 +82,7 @@ public class GossipingPropertyFileSnitch extends AbstractNetworkTopologySnitch//
{
protected void runMayThrow() throws ConfigurationException
{
reloadConfiguration();
StorageService.instance.updateTopology(FBUtilities.getBroadcastAddress());
reloadConfiguration(true);
}
};
ResourceWatcher.watch(SnitchProperties.RACKDC_PROPERTY_FILENAME, runnable, refreshPeriodInSeconds * 1000);
@ -162,7 +161,7 @@ public class GossipingPropertyFileSnitch extends AbstractNetworkTopologySnitch//
gossipStarted = true;
}
private void reloadConfiguration() throws ConfigurationException
private void reloadConfiguration(boolean isUpdate) throws ConfigurationException
{
final SnitchProperties properties = new SnitchProperties();
@ -184,7 +183,12 @@ public class GossipingPropertyFileSnitch extends AbstractNetworkTopologySnitch//
reloadGossiperState();
if (StorageService.instance != null)
StorageService.instance.getTokenMetadata().invalidateCachedRings();
{
if (isUpdate)
StorageService.instance.updateTopology(FBUtilities.getBroadcastAddress());
else
StorageService.instance.getTokenMetadata().invalidateCachedRings();
}
if (gossipStarted)
StorageService.instance.gossipSnitchInfo();

View File

@ -60,7 +60,7 @@ public class PropertyFileSnitch extends AbstractNetworkTopologySnitch
public PropertyFileSnitch() throws ConfigurationException
{
reloadConfiguration();
reloadConfiguration(false);
try
{
@ -69,8 +69,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);
@ -132,7 +131,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[]>();
@ -193,7 +192,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

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

View File

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