Remove DiscoveryNode#masterNode in favour of existing DiscoveryNode#isMasterNode

Original commit: elastic/x-pack-elasticsearch@0bd29df7ea
This commit is contained in:
javanna 2016-03-30 14:52:53 +02:00 committed by Luca Cavanna
parent 9842e649f7
commit bd6775e0da
4 changed files with 6 additions and 9 deletions

View File

@ -109,7 +109,7 @@ public class Exporters extends AbstractLifecycleComponent<Exporters> implements
ExportBulk openBulk() { ExportBulk openBulk() {
List<ExportBulk> bulks = new ArrayList<>(); List<ExportBulk> bulks = new ArrayList<>();
for (Exporter exporter : exporters) { for (Exporter exporter : exporters) {
if (exporter.masterOnly() && !clusterService.localNode().masterNode()) { if (exporter.masterOnly() && !clusterService.localNode().isMasterNode()) {
// the exporter is supposed to only run on the master node, but we're not // the exporter is supposed to only run on the master node, but we're not
// the master node... so skipping // the master node... so skipping
continue; continue;

View File

@ -7,7 +7,6 @@ package org.elasticsearch.marvel.agent.exporter.local;
import com.carrotsearch.hppc.cursors.ObjectCursor; import com.carrotsearch.hppc.cursors.ObjectCursor;
import com.carrotsearch.hppc.cursors.ObjectObjectCursor; import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
import org.elasticsearch.Version;
import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest; import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse; import org.elasticsearch.action.admin.indices.delete.DeleteIndexResponse;
@ -24,8 +23,6 @@ import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.regex.Regex; import org.elasticsearch.common.regex.Regex;
import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.gateway.GatewayService; import org.elasticsearch.gateway.GatewayService;
import org.elasticsearch.marvel.MarvelSettings;
import org.elasticsearch.marvel.MonitoredSystem;
import org.elasticsearch.marvel.agent.exporter.ExportBulk; import org.elasticsearch.marvel.agent.exporter.ExportBulk;
import org.elasticsearch.marvel.agent.exporter.Exporter; import org.elasticsearch.marvel.agent.exporter.Exporter;
import org.elasticsearch.marvel.agent.exporter.MarvelTemplateUtils; import org.elasticsearch.marvel.agent.exporter.MarvelTemplateUtils;
@ -151,7 +148,7 @@ public class LocalExporter extends Exporter implements ClusterStateListener, Cle
// if this is not the master, we'll just look to see if the monitoring timestamped template is already // if this is not the master, we'll just look to see if the monitoring timestamped template is already
// installed and if so, if it has a compatible version. If it is (installed and compatible) // installed and if so, if it has a compatible version. If it is (installed and compatible)
// we'll be able to start this exporter. Otherwise, we'll just wait for a new cluster state. // we'll be able to start this exporter. Otherwise, we'll just wait for a new cluster state.
if (!clusterService.localNode().masterNode()) { if (!clusterService.localNode().isMasterNode()) {
// We only need to check the index template for timestamped indices // We only need to check the index template for timestamped indices
if (!templateInstalled) { if (!templateInstalled) {
// the template for timestamped indices is not yet installed in the given cluster state, we'll wait. // the template for timestamped indices is not yet installed in the given cluster state, we'll wait.
@ -253,7 +250,7 @@ public class LocalExporter extends Exporter implements ClusterStateListener, Cle
return; return;
} }
if (clusterService.localNode().masterNode()) { if (clusterService.localNode().isMasterNode()) {
// Reference date time will be compared to index.creation_date settings, // Reference date time will be compared to index.creation_date settings,
// that's why it must be in UTC // that's why it must be in UTC
DateTime expiration = new DateTime(DateTimeZone.UTC).minus(retention.millis()); DateTime expiration = new DateTime(DateTimeZone.UTC).minus(retention.millis());

View File

@ -228,7 +228,7 @@ public class ExportersTests extends ESTestCase {
exporters.start(); exporters.start();
DiscoveryNode localNode = mock(DiscoveryNode.class); DiscoveryNode localNode = mock(DiscoveryNode.class);
when(localNode.masterNode()).thenReturn(true); when(localNode.isMasterNode()).thenReturn(true);
when(clusterService.localNode()).thenReturn(localNode); when(clusterService.localNode()).thenReturn(localNode);
ExportBulk bulk = exporters.openBulk(); ExportBulk bulk = exporters.openBulk();
@ -252,7 +252,7 @@ public class ExportersTests extends ESTestCase {
exporters.start(); exporters.start();
DiscoveryNode localNode = mock(DiscoveryNode.class); DiscoveryNode localNode = mock(DiscoveryNode.class);
when(localNode.masterNode()).thenReturn(false); when(localNode.isMasterNode()).thenReturn(false);
when(clusterService.localNode()).thenReturn(localNode); when(clusterService.localNode()).thenReturn(localNode);
ExportBulk bulk = exporters.openBulk(); ExportBulk bulk = exporters.openBulk();

View File

@ -103,7 +103,7 @@ public class WatcherIndexTemplateRegistry extends AbstractComponent implements C
} }
private void updateConfig(TemplateConfig config, Settings settings) { private void updateConfig(TemplateConfig config, Settings settings) {
if (clusterService.localNode().masterNode() == false) { if (clusterService.localNode().isMasterNode() == false) {
// Only the node that runs or will run Watcher should update the templates. Otherwise unnecessary put template // Only the node that runs or will run Watcher should update the templates. Otherwise unnecessary put template
// calls would happen // calls would happen
return; return;