Verify that the current node is still master before the reroute is executed and if that isn't the case skip reroute

Invoke listener when reroute fails.

Closes #6244
This commit is contained in:
Martijn van Groningen 2014-05-20 13:50:14 +02:00
parent 0e445d3aaf
commit 9494bbd9b7
1 changed files with 14 additions and 0 deletions

View File

@ -116,6 +116,19 @@ public class TransportClusterUpdateSettingsAction extends TransportMasterNodeOpe
}
private void reroute(final boolean updateSettingsAcked) {
// We're about to send a second update task, so we need to check if we're still the elected master
// For example the minimum_master_node could have been breached and we're no longer elected master,
// so we should *not* execute the reroute.
if (!clusterService.state().nodes().localNodeMaster()) {
logger.debug("Skipping reroute after cluster update settings, because node is no longer master");
listener.onResponse(new ClusterUpdateSettingsResponse(updateSettingsAcked, transientUpdates.build(), persistentUpdates.build()));
return;
}
// The reason the reroute needs to be send as separate update task, is that all the *cluster* settings are encapsulate
// in the components (e.g. FilterAllocationDecider), so the changes made by the first call aren't visible
// to the components until the ClusterStateListener instances have been invoked, but are visible after
// the first update task has been completed.
clusterService.submitStateUpdateTask("reroute_after_cluster_update_settings", Priority.URGENT, new AckedClusterStateUpdateTask() {
@Override
@ -150,6 +163,7 @@ public class TransportClusterUpdateSettingsAction extends TransportMasterNodeOpe
public void onFailure(String source, Throwable t) {
//if the reroute fails we only log
logger.debug("failed to perform [{}]", t, source);
listener.onFailure(new ElasticsearchException("reroute after update settings failed", t));
}
@Override