diff --git a/elasticsearch/x-pack/license-plugin/src/main/java/org/elasticsearch/license/plugin/core/LicensesService.java b/elasticsearch/x-pack/license-plugin/src/main/java/org/elasticsearch/license/plugin/core/LicensesService.java index 4368267727b..3438fdbda8d 100644 --- a/elasticsearch/x-pack/license-plugin/src/main/java/org/elasticsearch/license/plugin/core/LicensesService.java +++ b/elasticsearch/x-pack/license-plugin/src/main/java/org/elasticsearch/license/plugin/core/LicensesService.java @@ -415,7 +415,7 @@ public class LicensesService extends AbstractLifecycleComponent long issueDate = System.currentTimeMillis(); License.Builder specBuilder = License.builder() .uid(UUID.randomUUID().toString()) - .issuedTo(clusterService.state().getClusterName().value()) + .issuedTo(clusterService.getClusterName().value()) .maxNodes(trialLicenseMaxNodes) .issueDate(issueDate) .expiryDate(issueDate + trialLicenseDuration.getMillis()); diff --git a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/collector/cluster/ClusterStatsCollector.java b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/collector/cluster/ClusterStatsCollector.java index 96ea090dcf4..cff6259308a 100644 --- a/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/collector/cluster/ClusterStatsCollector.java +++ b/elasticsearch/x-pack/marvel/src/main/java/org/elasticsearch/marvel/agent/collector/cluster/ClusterStatsCollector.java @@ -41,17 +41,15 @@ public class ClusterStatsCollector extends AbstractCollector {}); clusterService.start(); - transportService = new TransportService(Settings.EMPTY, transport, threadPool, clusterService.state().getClusterName()); + transportService = new TransportService(clusterService.getSettings(), transport, threadPool); transportService.start(); transportService.acceptIncomingRequests(); exportService = new CapturingExporters(); diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/cluster/ClusterStatsCollectorTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/cluster/ClusterStatsCollectorTests.java index 84d2bbe2e5f..25f47c6a74d 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/cluster/ClusterStatsCollectorTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/collector/cluster/ClusterStatsCollectorTests.java @@ -134,8 +134,7 @@ public class ClusterStatsCollectorTests extends AbstractCollectorTestCase { internalCluster().getInstance(MonitoringSettings.class, nodeId), internalCluster().getInstance(MonitoringLicensee.class, nodeId), securedClient(nodeId), - internalCluster().getInstance(LicensesManagerService.class, nodeId), - internalCluster().getInstance(ClusterName.class, nodeId)); + internalCluster().getInstance(LicensesManagerService.class, nodeId)); } private void assertCanCollect(AbstractCollector collector, Class... classes) { diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/exporter/ExportersTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/exporter/ExportersTests.java index 7ed76f5c9f8..c9c2ef39aba 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/exporter/ExportersTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/exporter/ExportersTests.java @@ -223,7 +223,8 @@ public class ExportersTests extends ESTestCase { DiscoveryNodes nodes = mock(DiscoveryNodes.class); when(nodes.isLocalNodeElectedMaster()).thenReturn(true); - when(clusterService.state()).thenReturn(ClusterState.builder(ClusterName.DEFAULT).nodes(nodes).build()); + when(clusterService.state()).thenReturn(ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)) + .nodes(nodes).build()); ExportBulk bulk = exporters.openBulk(); assertThat(bulk, notNullValue()); @@ -247,7 +248,8 @@ public class ExportersTests extends ESTestCase { DiscoveryNodes nodes = mock(DiscoveryNodes.class); when(nodes.isLocalNodeElectedMaster()).thenReturn(false); - when(clusterService.state()).thenReturn(ClusterState.builder(ClusterName.DEFAULT).nodes(nodes).build()); + when(clusterService.state()).thenReturn(ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)) + .nodes(nodes).build()); ExportBulk bulk = exporters.openBulk(); assertThat(bulk, notNullValue()); diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/cluster/ClusterInfoResolverTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/cluster/ClusterInfoResolverTests.java index 514f75351fa..d0982ec6705 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/cluster/ClusterInfoResolverTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/cluster/ClusterInfoResolverTests.java @@ -9,6 +9,7 @@ import org.elasticsearch.Version; import org.elasticsearch.action.admin.cluster.stats.ClusterStatsResponse; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.node.DiscoveryNode; +import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.transport.DummyTransportAddress; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.xcontent.XContentType; @@ -45,8 +46,8 @@ public class ClusterInfoResolverTests extends MonitoringIndexNameResolverTestCas doc.setVersion(randomFrom(Version.V_2_0_0, Version.CURRENT).toString()); doc.setLicense(licenseBuilder.build()); doc.setClusterName(randomAsciiOfLength(5)); - doc.setClusterStats(new ClusterStatsResponse(Math.abs(randomLong()), ClusterName.DEFAULT, - randomAsciiOfLength(5), Collections.emptyList(), Collections.emptyList())); + doc.setClusterStats(new ClusterStatsResponse(Math.abs(randomLong()), ClusterName.CLUSTER_NAME_SETTING + .getDefault(Settings.EMPTY), randomAsciiOfLength(5), Collections.emptyList(), Collections.emptyList())); return doc; } catch (Exception e) { throw new IllegalStateException("Failed to generated random ClusterInfoMarvelDoc", e); diff --git a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/cluster/ClusterStatsResolverTests.java b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/cluster/ClusterStatsResolverTests.java index 80beba90765..5aafcd04f46 100644 --- a/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/cluster/ClusterStatsResolverTests.java +++ b/elasticsearch/x-pack/marvel/src/test/java/org/elasticsearch/marvel/agent/resolver/cluster/ClusterStatsResolverTests.java @@ -97,8 +97,8 @@ public class ClusterStatsResolverTests extends MonitoringIndexNameResolverTestCa emptyMap(), emptySet(), Version.CURRENT), ClusterHealthStatus.GREEN, randomNodeInfo(), randomNodeStats(), randomShardStats()) ); - return new ClusterStatsResponse(Math.abs(randomLong()), ClusterName.DEFAULT, UUID.randomUUID().toString(), - responses, Collections.emptyList()); + return new ClusterStatsResponse(Math.abs(randomLong()), ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY), + UUID.randomUUID().toString(), responses, Collections.emptyList()); } /** diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/action/realm/TransportClearRealmCacheAction.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/action/realm/TransportClearRealmCacheAction.java index c2a4c81a63b..99d8dc32889 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/action/realm/TransportClearRealmCacheAction.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/action/realm/TransportClearRealmCacheAction.java @@ -9,7 +9,6 @@ import org.elasticsearch.ElasticsearchException; import org.elasticsearch.action.FailedNodeException; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.nodes.TransportNodesAction; -import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.common.inject.Inject; @@ -31,11 +30,11 @@ public class TransportClearRealmCacheAction extends TransportNodesAction responses, List failures) { - return new ClearRealmCacheResponse(clusterName, responses, failures); + return new ClearRealmCacheResponse(clusterService.getClusterName(), responses, failures); } @Override diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/action/role/TransportClearRolesCacheAction.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/action/role/TransportClearRolesCacheAction.java index 0d1498ac9ff..b029b6de167 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/action/role/TransportClearRolesCacheAction.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/action/role/TransportClearRolesCacheAction.java @@ -8,7 +8,6 @@ package org.elasticsearch.shield.action.role; import org.elasticsearch.action.FailedNodeException; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.nodes.TransportNodesAction; -import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; import org.elasticsearch.common.inject.Inject; @@ -28,10 +27,10 @@ public class TransportClearRolesCacheAction extends TransportNodesAction responses, List failures) { - return new ClearRolesCacheResponse(clusterName, responses, failures); + return new ClearRolesCacheResponse(clusterService.getClusterName(), responses, failures); } @Override diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/transport/ShieldClientTransportService.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/transport/ShieldClientTransportService.java index c4320ab973e..73dede2f854 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/transport/ShieldClientTransportService.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/transport/ShieldClientTransportService.java @@ -5,7 +5,6 @@ */ package org.elasticsearch.shield.transport; -import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -24,8 +23,8 @@ public class ShieldClientTransportService extends TransportService { @Inject public ShieldClientTransportService(Settings settings, Transport transport, ThreadPool threadPool, - ClusterName clusterName, ClientTransportFilter clientFilter) { - super(settings, transport, threadPool, clusterName); + ClientTransportFilter clientFilter) { + super(settings, transport, threadPool); this.clientFilter = clientFilter; } diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/transport/ShieldServerTransportService.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/transport/ShieldServerTransportService.java index 8f5baa4ae33..918bc6e7a8e 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/transport/ShieldServerTransportService.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/transport/ShieldServerTransportService.java @@ -5,7 +5,6 @@ */ package org.elasticsearch.shield.transport; -import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.inject.Inject; import org.elasticsearch.common.settings.Settings; @@ -56,13 +55,12 @@ public class ShieldServerTransportService extends TransportService { @Inject public ShieldServerTransportService(Settings settings, Transport transport, ThreadPool threadPool, - ClusterName clusterName, AuthenticationService authcService, AuthorizationService authzService, ShieldActionMapper actionMapper, ClientTransportFilter clientTransportFilter, SecurityLicenseState licenseState) { - super(settings, transport, threadPool, clusterName); + super(settings, transport, threadPool); this.authcService = authcService; this.authzService = authzService; this.actionMapper = actionMapper; diff --git a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/transport/TransportFilterTests.java b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/transport/TransportFilterTests.java index 06f6912c6d7..e711500990f 100644 --- a/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/transport/TransportFilterTests.java +++ b/elasticsearch/x-pack/shield/src/test/java/org/elasticsearch/shield/transport/TransportFilterTests.java @@ -290,9 +290,9 @@ public class TransportFilterTests extends ESIntegTestCase { @Inject public InternalPluginServerTransportService(Settings settings, Transport transport, ThreadPool threadPool, - ClusterName clusterName, AuthenticationService authcService, AuthorizationService authzService, + AuthenticationService authcService, AuthorizationService authzService, ShieldActionMapper actionMapper, ClientTransportFilter clientTransportFilter) { - super(settings, transport, threadPool, clusterName, authcService, authzService, actionMapper, clientTransportFilter, + super(settings, transport, threadPool, authcService, authzService, actionMapper, clientTransportFilter, mock(SecurityLicenseState.class)); when(licenseState.authenticationAndAuthorizationEnabled()).thenReturn(true); }