diff --git a/modules/repository-url/src/main/java/org/elasticsearch/repositories/url/URLRepository.java b/modules/repository-url/src/main/java/org/elasticsearch/repositories/url/URLRepository.java index 98b8c0a1945..8f8ae805fd1 100644 --- a/modules/repository-url/src/main/java/org/elasticsearch/repositories/url/URLRepository.java +++ b/modules/repository-url/src/main/java/org/elasticsearch/repositories/url/URLRepository.java @@ -82,21 +82,21 @@ public class URLRepository extends BlobStoreRepository { NamedXContentRegistry namedXContentRegistry) { super(metadata, environment.settings(), namedXContentRegistry); - if (URL_SETTING.exists(metadata.settings()) == false && REPOSITORIES_URL_SETTING.exists(settings) == false) { + if (URL_SETTING.exists(metadata.settings()) == false && REPOSITORIES_URL_SETTING.exists(environment.settings()) == false) { throw new RepositoryException(metadata.name(), "missing url"); } this.environment = environment; - supportedProtocols = SUPPORTED_PROTOCOLS_SETTING.get(settings); - urlWhiteList = ALLOWED_URLS_SETTING.get(settings).toArray(new URIPattern[]{}); + supportedProtocols = SUPPORTED_PROTOCOLS_SETTING.get(environment.settings()); + urlWhiteList = ALLOWED_URLS_SETTING.get(environment.settings()).toArray(new URIPattern[]{}); basePath = BlobPath.cleanPath(); url = URL_SETTING.exists(metadata.settings()) - ? URL_SETTING.get(metadata.settings()) : REPOSITORIES_URL_SETTING.get(settings); + ? URL_SETTING.get(metadata.settings()) : REPOSITORIES_URL_SETTING.get(environment.settings()); } @Override protected BlobStore createBlobStore() { URL normalizedURL = checkURL(url); - return new URLBlobStore(settings, normalizedURL); + return new URLBlobStore(environment.settings(), normalizedURL); } // only use for testing diff --git a/plugins/discovery-azure-classic/src/main/java/org/elasticsearch/discovery/azure/classic/AzureUnicastHostsProvider.java b/plugins/discovery-azure-classic/src/main/java/org/elasticsearch/discovery/azure/classic/AzureUnicastHostsProvider.java index 1a9265de2a7..a69bc6eb487 100644 --- a/plugins/discovery-azure-classic/src/main/java/org/elasticsearch/discovery/azure/classic/AzureUnicastHostsProvider.java +++ b/plugins/discovery-azure-classic/src/main/java/org/elasticsearch/discovery/azure/classic/AzureUnicastHostsProvider.java @@ -93,6 +93,7 @@ public class AzureUnicastHostsProvider extends AbstractComponent implements Unic } } + private final Settings settings; private final AzureComputeService azureComputeService; private TransportService transportService; private NetworkService networkService; @@ -108,6 +109,7 @@ public class AzureUnicastHostsProvider extends AbstractComponent implements Unic public AzureUnicastHostsProvider(Settings settings, AzureComputeService azureComputeService, TransportService transportService, NetworkService networkService) { super(settings); + this.settings = settings; this.azureComputeService = azureComputeService; this.transportService = transportService; this.networkService = networkService; diff --git a/plugins/discovery-gce/src/main/java/org/elasticsearch/cloud/gce/GceInstancesServiceImpl.java b/plugins/discovery-gce/src/main/java/org/elasticsearch/cloud/gce/GceInstancesServiceImpl.java index aab6e0c74ec..e2e55b018d2 100644 --- a/plugins/discovery-gce/src/main/java/org/elasticsearch/cloud/gce/GceInstancesServiceImpl.java +++ b/plugins/discovery-gce/src/main/java/org/elasticsearch/cloud/gce/GceInstancesServiceImpl.java @@ -94,6 +94,7 @@ public class GceInstancesServiceImpl extends AbstractComponent implements GceIns return instances; } + private final Settings settings; private Compute client; private TimeValue refreshInterval = null; private long lastRefresh; @@ -108,6 +109,7 @@ public class GceInstancesServiceImpl extends AbstractComponent implements GceIns public GceInstancesServiceImpl(Settings settings) { super(settings); + this.settings = settings; this.validateCerts = GCE_VALIDATE_CERTIFICATES.get(settings); this.project = resolveProject(); this.zones = resolveZones(); diff --git a/plugins/discovery-gce/src/main/java/org/elasticsearch/cloud/gce/GceMetadataService.java b/plugins/discovery-gce/src/main/java/org/elasticsearch/cloud/gce/GceMetadataService.java index c736862d426..ca25fde7429 100644 --- a/plugins/discovery-gce/src/main/java/org/elasticsearch/cloud/gce/GceMetadataService.java +++ b/plugins/discovery-gce/src/main/java/org/elasticsearch/cloud/gce/GceMetadataService.java @@ -44,11 +44,14 @@ public class GceMetadataService extends AbstractLifecycleComponent { public static final Setting GCE_HOST = new Setting<>("cloud.gce.host", "http://metadata.google.internal", Function.identity(), Setting.Property.NodeScope); + private final Settings settings; + /** Global instance of the HTTP transport. */ private HttpTransport gceHttpTransport; public GceMetadataService(Settings settings) { super(settings); + this.settings = settings; } protected synchronized HttpTransport getGceHttpTransport() throws GeneralSecurityException, IOException { diff --git a/plugins/discovery-gce/src/main/java/org/elasticsearch/discovery/gce/GceUnicastHostsProvider.java b/plugins/discovery-gce/src/main/java/org/elasticsearch/discovery/gce/GceUnicastHostsProvider.java index 36f8aa36b34..9f90ef3a308 100644 --- a/plugins/discovery-gce/src/main/java/org/elasticsearch/discovery/gce/GceUnicastHostsProvider.java +++ b/plugins/discovery-gce/src/main/java/org/elasticsearch/discovery/gce/GceUnicastHostsProvider.java @@ -58,6 +58,7 @@ public class GceUnicastHostsProvider extends AbstractComponent implements Unicas private static final String TERMINATED = "TERMINATED"; } + private final Settings settings; private final GceInstancesService gceInstancesService; private TransportService transportService; private NetworkService networkService; @@ -74,6 +75,7 @@ public class GceUnicastHostsProvider extends AbstractComponent implements Unicas TransportService transportService, NetworkService networkService) { super(settings); + this.settings = settings; this.gceInstancesService = gceInstancesService; this.transportService = transportService; this.networkService = networkService; diff --git a/plugins/repository-gcs/src/main/java/org/elasticsearch/repositories/gcs/GoogleCloudStorageRepository.java b/plugins/repository-gcs/src/main/java/org/elasticsearch/repositories/gcs/GoogleCloudStorageRepository.java index fe6c8889bd2..bfe48038eef 100644 --- a/plugins/repository-gcs/src/main/java/org/elasticsearch/repositories/gcs/GoogleCloudStorageRepository.java +++ b/plugins/repository-gcs/src/main/java/org/elasticsearch/repositories/gcs/GoogleCloudStorageRepository.java @@ -23,6 +23,7 @@ import org.elasticsearch.cluster.metadata.RepositoryMetaData; import org.elasticsearch.common.Strings; import org.elasticsearch.common.blobstore.BlobPath; import org.elasticsearch.common.settings.Setting; +import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.ByteSizeUnit; import org.elasticsearch.common.unit.ByteSizeValue; import org.elasticsearch.common.xcontent.NamedXContentRegistry; @@ -55,6 +56,7 @@ class GoogleCloudStorageRepository extends BlobStoreRepository { byteSizeSetting("chunk_size", MAX_CHUNK_SIZE, MIN_CHUNK_SIZE, MAX_CHUNK_SIZE, Property.NodeScope, Property.Dynamic); static final Setting CLIENT_NAME = new Setting<>("client", "default", Function.identity()); + private final Settings settings; private final GoogleCloudStorageService storageService; private final BlobPath basePath; private final boolean compress; @@ -66,6 +68,7 @@ class GoogleCloudStorageRepository extends BlobStoreRepository { NamedXContentRegistry namedXContentRegistry, GoogleCloudStorageService storageService) { super(metadata, environment.settings(), namedXContentRegistry); + this.settings = environment.settings(); this.storageService = storageService; String basePath = BASE_PATH.get(metadata.settings()); diff --git a/plugins/repository-s3/src/main/java/org/elasticsearch/repositories/s3/S3Repository.java b/plugins/repository-s3/src/main/java/org/elasticsearch/repositories/s3/S3Repository.java index a2f600a34ae..2fbb7bb56d6 100644 --- a/plugins/repository-s3/src/main/java/org/elasticsearch/repositories/s3/S3Repository.java +++ b/plugins/repository-s3/src/main/java/org/elasticsearch/repositories/s3/S3Repository.java @@ -148,6 +148,8 @@ class S3Repository extends BlobStoreRepository { */ static final Setting BASE_PATH_SETTING = Setting.simpleString("base_path"); + private final Settings settings; + private final S3Service service; private final String bucket; @@ -178,6 +180,7 @@ class S3Repository extends BlobStoreRepository { final NamedXContentRegistry namedXContentRegistry, final S3Service service) { super(metadata, settings, namedXContentRegistry); + this.settings = settings; this.service = service; // Parse and validate the user's S3 Storage Class setting diff --git a/qa/smoke-test-http/src/test/java/org/elasticsearch/http/TestDeprecationHeaderRestAction.java b/qa/smoke-test-http/src/test/java/org/elasticsearch/http/TestDeprecationHeaderRestAction.java index ad38d89654a..27b2f18b091 100644 --- a/qa/smoke-test-http/src/test/java/org/elasticsearch/http/TestDeprecationHeaderRestAction.java +++ b/qa/smoke-test-http/src/test/java/org/elasticsearch/http/TestDeprecationHeaderRestAction.java @@ -58,7 +58,7 @@ public class TestDeprecationHeaderRestAction extends BaseRestHandler { Setting.boolSetting("test.setting.not_deprecated", false, Setting.Property.NodeScope, Setting.Property.Dynamic); - private static final Map> SETTINGS; + private static final Map> SETTINGS_MAP; static { Map> settingsMap = new HashMap<>(3); @@ -67,14 +67,17 @@ public class TestDeprecationHeaderRestAction extends BaseRestHandler { settingsMap.put(TEST_DEPRECATED_SETTING_TRUE2.getKey(), TEST_DEPRECATED_SETTING_TRUE2); settingsMap.put(TEST_NOT_DEPRECATED_SETTING.getKey(), TEST_NOT_DEPRECATED_SETTING); - SETTINGS = Collections.unmodifiableMap(settingsMap); + SETTINGS_MAP = Collections.unmodifiableMap(settingsMap); } public static final String DEPRECATED_ENDPOINT = "[/_test_cluster/deprecated_settings] exists for deprecated tests"; public static final String DEPRECATED_USAGE = "[deprecated_settings] usage is deprecated. use [settings] instead"; + private final Settings settings; + public TestDeprecationHeaderRestAction(Settings settings, RestController controller) { super(settings); + this.settings = settings; controller.registerAsDeprecatedHandler(RestRequest.Method.GET, "/_test_cluster/deprecated_settings", this, DEPRECATED_ENDPOINT, deprecationLogger); @@ -107,7 +110,7 @@ public class TestDeprecationHeaderRestAction extends BaseRestHandler { builder.startObject().startArray("settings"); for (String setting : settings) { - builder.startObject().field(setting, SETTINGS.get(setting).getRaw(this.settings)).endObject(); + builder.startObject().field(setting, SETTINGS_MAP.get(setting).getRaw(this.settings)).endObject(); } builder.endArray().endObject(); channel.sendResponse(new BytesRestResponse(RestStatus.OK, builder)); diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/analyze/TransportAnalyzeAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/analyze/TransportAnalyzeAction.java index 786f8935dba..361fe91ac7e 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/analyze/TransportAnalyzeAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/analyze/TransportAnalyzeAction.java @@ -79,6 +79,7 @@ import java.util.function.Function; */ public class TransportAnalyzeAction extends TransportSingleShardAction { + private final Settings settings; private final IndicesService indicesService; private final Environment environment; @@ -88,6 +89,7 @@ public class TransportAnalyzeAction extends TransportSingleShardAction { + private final String nodeName; private final ClusterService clusterService; @Inject public TransportMainAction(Settings settings, TransportService transportService, ActionFilters actionFilters, ClusterService clusterService) { super(settings, MainAction.NAME, transportService, actionFilters, MainRequest::new); + this.nodeName = Node.NODE_NAME_SETTING.get(settings); this.clusterService = clusterService; } @Override protected void doExecute(Task task, MainRequest request, ActionListener listener) { ClusterState clusterState = clusterService.state(); - assert Node.NODE_NAME_SETTING.exists(settings); listener.onResponse( - new MainResponse(Node.NODE_NAME_SETTING.get(settings), Version.CURRENT, clusterState.getClusterName(), + new MainResponse(nodeName, Version.CURRENT, clusterState.getClusterName(), clusterState.metaData().clusterUUID(), Build.CURRENT)); } } diff --git a/server/src/main/java/org/elasticsearch/action/support/replication/TransportReplicationAction.java b/server/src/main/java/org/elasticsearch/action/support/replication/TransportReplicationAction.java index 820ab0300d6..8976ce5d507 100644 --- a/server/src/main/java/org/elasticsearch/action/support/replication/TransportReplicationAction.java +++ b/server/src/main/java/org/elasticsearch/action/support/replication/TransportReplicationAction.java @@ -147,7 +147,7 @@ public abstract class TransportReplicationAction< this.transportReplicaAction = actionName + "[r]"; registerRequestHandlers(actionName, transportService, request, replicaRequest, executor); - this.transportOptions = transportOptions(); + this.transportOptions = transportOptions(settings); this.syncGlobalCheckpointAfterOperation = syncGlobalCheckpointAfterOperation; } @@ -231,7 +231,7 @@ public abstract class TransportReplicationAction< return true; } - protected TransportRequestOptions transportOptions() { + protected TransportRequestOptions transportOptions(Settings settings) { return TransportRequestOptions.EMPTY; } diff --git a/server/src/main/java/org/elasticsearch/client/support/AbstractClient.java b/server/src/main/java/org/elasticsearch/client/support/AbstractClient.java index e5450c320f4..58c32cf28b6 100644 --- a/server/src/main/java/org/elasticsearch/client/support/AbstractClient.java +++ b/server/src/main/java/org/elasticsearch/client/support/AbstractClient.java @@ -344,12 +344,14 @@ import java.util.Map; public abstract class AbstractClient extends AbstractComponent implements Client { + protected final Settings settings; private final ThreadPool threadPool; private final Admin admin; private final ThreadedActionListener.Wrapper threadedWrapper; public AbstractClient(Settings settings, ThreadPool threadPool) { super(settings); + this.settings = settings; this.threadPool = threadPool; this.admin = new Admin(this); this.threadedWrapper = new ThreadedActionListener.Wrapper(logger, settings, threadPool); diff --git a/server/src/main/java/org/elasticsearch/client/transport/TransportClientNodesService.java b/server/src/main/java/org/elasticsearch/client/transport/TransportClientNodesService.java index 0cfc1f5004c..b3bfe54ea8d 100644 --- a/server/src/main/java/org/elasticsearch/client/transport/TransportClientNodesService.java +++ b/server/src/main/java/org/elasticsearch/client/transport/TransportClientNodesService.java @@ -130,15 +130,15 @@ final class TransportClientNodesService extends AbstractComponent implements Clo this.threadPool = threadPool; this.minCompatibilityVersion = Version.CURRENT.minimumCompatibilityVersion(); - this.nodesSamplerInterval = TransportClient.CLIENT_TRANSPORT_NODES_SAMPLER_INTERVAL.get(this.settings); - this.pingTimeout = TransportClient.CLIENT_TRANSPORT_PING_TIMEOUT.get(this.settings).millis(); - this.ignoreClusterName = TransportClient.CLIENT_TRANSPORT_IGNORE_CLUSTER_NAME.get(this.settings); + this.nodesSamplerInterval = TransportClient.CLIENT_TRANSPORT_NODES_SAMPLER_INTERVAL.get(settings); + this.pingTimeout = TransportClient.CLIENT_TRANSPORT_PING_TIMEOUT.get(settings).millis(); + this.ignoreClusterName = TransportClient.CLIENT_TRANSPORT_IGNORE_CLUSTER_NAME.get(settings); if (logger.isDebugEnabled()) { logger.debug("node_sampler_interval[{}]", nodesSamplerInterval); } - if (TransportClient.CLIENT_TRANSPORT_SNIFF.get(this.settings)) { + if (TransportClient.CLIENT_TRANSPORT_SNIFF.get(settings)) { this.nodesSampler = new SniffNodesSampler(); } else { this.nodesSampler = new SimpleNodeSampler(); diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexService.java b/server/src/main/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexService.java index d0199e83843..41d57323a05 100644 --- a/server/src/main/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexService.java +++ b/server/src/main/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexService.java @@ -106,6 +106,7 @@ public class MetaDataCreateIndexService extends AbstractComponent { public static final int MAX_INDEX_NAME_BYTES = 255; + private final Settings settings; private final ClusterService clusterService; private final IndicesService indicesService; private final AllocationService allocationService; @@ -128,6 +129,7 @@ public class MetaDataCreateIndexService extends AbstractComponent { final NamedXContentRegistry xContentRegistry, final boolean forbidPrivateIndexSettings) { super(settings); + this.settings = settings; this.clusterService = clusterService; this.indicesService = indicesService; this.allocationService = allocationService; diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/MetaDataDeleteIndexService.java b/server/src/main/java/org/elasticsearch/cluster/metadata/MetaDataDeleteIndexService.java index a2212b5c3f0..df63e06dab2 100644 --- a/server/src/main/java/org/elasticsearch/cluster/metadata/MetaDataDeleteIndexService.java +++ b/server/src/main/java/org/elasticsearch/cluster/metadata/MetaDataDeleteIndexService.java @@ -48,7 +48,7 @@ import static java.util.stream.Collectors.toSet; * Deletes indices. */ public class MetaDataDeleteIndexService extends AbstractComponent { - + private final Settings settings; private final ClusterService clusterService; private final AllocationService allocationService; @@ -56,6 +56,7 @@ public class MetaDataDeleteIndexService extends AbstractComponent { @Inject public MetaDataDeleteIndexService(Settings settings, ClusterService clusterService, AllocationService allocationService) { super(settings); + this.settings = settings; this.clusterService = clusterService; this.allocationService = allocationService; } diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/MetaDataIndexUpgradeService.java b/server/src/main/java/org/elasticsearch/cluster/metadata/MetaDataIndexUpgradeService.java index 9bc324a4248..09da16ddd59 100644 --- a/server/src/main/java/org/elasticsearch/cluster/metadata/MetaDataIndexUpgradeService.java +++ b/server/src/main/java/org/elasticsearch/cluster/metadata/MetaDataIndexUpgradeService.java @@ -53,6 +53,7 @@ import java.util.function.UnaryOperator; */ public class MetaDataIndexUpgradeService extends AbstractComponent { + private final Settings settings; private final NamedXContentRegistry xContentRegistry; private final MapperRegistry mapperRegistry; private final IndexScopedSettings indexScopedSettings; @@ -62,6 +63,7 @@ public class MetaDataIndexUpgradeService extends AbstractComponent { IndexScopedSettings indexScopedSettings, Collection> indexMetaDataUpgraders) { super(settings); + this.settings = settings; this.xContentRegistry = xContentRegistry; this.mapperRegistry = mapperRegistry; this.indexScopedSettings = indexScopedSettings; diff --git a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/ShardsLimitAllocationDecider.java b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/ShardsLimitAllocationDecider.java index 398ee0a17ad..33ecccd3bfc 100644 --- a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/ShardsLimitAllocationDecider.java +++ b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/ShardsLimitAllocationDecider.java @@ -73,8 +73,11 @@ public class ShardsLimitAllocationDecider extends AllocationDecider { Setting.intSetting("cluster.routing.allocation.total_shards_per_node", -1, -1, Property.Dynamic, Property.NodeScope); + private final Settings settings; + public ShardsLimitAllocationDecider(Settings settings, ClusterSettings clusterSettings) { super(settings); + this.settings = settings; this.clusterShardLimit = CLUSTER_TOTAL_SHARDS_PER_NODE_SETTING.get(settings); clusterSettings.addSettingsUpdateConsumer(CLUSTER_TOTAL_SHARDS_PER_NODE_SETTING, this::setClusterShardLimit); } diff --git a/server/src/main/java/org/elasticsearch/cluster/service/ClusterApplierService.java b/server/src/main/java/org/elasticsearch/cluster/service/ClusterApplierService.java index ec45743e31d..55728982c6c 100644 --- a/server/src/main/java/org/elasticsearch/cluster/service/ClusterApplierService.java +++ b/server/src/main/java/org/elasticsearch/cluster/service/ClusterApplierService.java @@ -134,7 +134,7 @@ public class ClusterApplierService extends AbstractLifecycleComponent implements addListener(localNodeMasterListeners); threadPoolExecutor = EsExecutors.newSinglePrioritizing( nodeName + "/" + CLUSTER_UPDATE_THREAD_NAME, - daemonThreadFactory(settings, CLUSTER_UPDATE_THREAD_NAME), + daemonThreadFactory(nodeName, CLUSTER_UPDATE_THREAD_NAME), threadPool.getThreadContext(), threadPool.scheduler()); } diff --git a/server/src/main/java/org/elasticsearch/cluster/service/ClusterService.java b/server/src/main/java/org/elasticsearch/cluster/service/ClusterService.java index 94a638c2581..e3df6001179 100644 --- a/server/src/main/java/org/elasticsearch/cluster/service/ClusterService.java +++ b/server/src/main/java/org/elasticsearch/cluster/service/ClusterService.java @@ -55,6 +55,11 @@ public class ClusterService extends AbstractLifecycleComponent { public static final org.elasticsearch.common.settings.Setting.AffixSetting USER_DEFINED_META_DATA = Setting.prefixKeySetting("cluster.metadata.", (key) -> Setting.simpleString(key, Property.Dynamic, Property.NodeScope)); + /** + * The node's settings. + */ + private final Settings settings; + private final ClusterName clusterName; private final OperationRouting operationRouting; @@ -65,6 +70,7 @@ public class ClusterService extends AbstractLifecycleComponent { public ClusterService(Settings settings, ClusterSettings clusterSettings, ThreadPool threadPool) { super(settings); + this.settings = settings; this.nodeName = Node.NODE_NAME_SETTING.get(settings); this.masterService = new MasterService(nodeName, settings, threadPool); this.operationRouting = new OperationRouting(settings, clusterSettings); @@ -199,6 +205,9 @@ public class ClusterService extends AbstractLifecycleComponent { return clusterSettings; } + /** + * The node's settings. + */ public Settings getSettings() { return settings; } diff --git a/server/src/main/java/org/elasticsearch/cluster/service/MasterService.java b/server/src/main/java/org/elasticsearch/cluster/service/MasterService.java index 86fc3b54ca6..cbef687fc41 100644 --- a/server/src/main/java/org/elasticsearch/cluster/service/MasterService.java +++ b/server/src/main/java/org/elasticsearch/cluster/service/MasterService.java @@ -109,7 +109,7 @@ public class MasterService extends AbstractLifecycleComponent { Objects.requireNonNull(clusterStateSupplier, "please set a cluster state supplier before starting"); threadPoolExecutor = EsExecutors.newSinglePrioritizing( nodeName + "/" + MASTER_UPDATE_THREAD_NAME, - daemonThreadFactory(settings, MASTER_UPDATE_THREAD_NAME), + daemonThreadFactory(nodeName, MASTER_UPDATE_THREAD_NAME), threadPool.getThreadContext(), threadPool.scheduler()); taskBatcher = new Batcher(logger, threadPoolExecutor); diff --git a/server/src/main/java/org/elasticsearch/common/component/AbstractComponent.java b/server/src/main/java/org/elasticsearch/common/component/AbstractComponent.java index bbcb4b9ec42..622834d9198 100644 --- a/server/src/main/java/org/elasticsearch/common/component/AbstractComponent.java +++ b/server/src/main/java/org/elasticsearch/common/component/AbstractComponent.java @@ -26,10 +26,8 @@ import org.elasticsearch.common.settings.Settings; public abstract class AbstractComponent { protected final Logger logger; - protected final Settings settings; public AbstractComponent(Settings settings) { this.logger = LogManager.getLogger(getClass()); - this.settings = settings; } } diff --git a/server/src/main/java/org/elasticsearch/common/settings/AbstractScopedSettings.java b/server/src/main/java/org/elasticsearch/common/settings/AbstractScopedSettings.java index ab635c1d1c7..d9ecbcfa922 100644 --- a/server/src/main/java/org/elasticsearch/common/settings/AbstractScopedSettings.java +++ b/server/src/main/java/org/elasticsearch/common/settings/AbstractScopedSettings.java @@ -49,15 +49,17 @@ import java.util.stream.Collectors; */ public abstract class AbstractScopedSettings extends AbstractComponent { public static final String ARCHIVED_SETTINGS_PREFIX = "archived."; - private Settings lastSettingsApplied = Settings.EMPTY; + private static final Pattern KEY_PATTERN = Pattern.compile("^(?:[-\\w]+[.])*[-\\w]+$"); + private static final Pattern GROUP_KEY_PATTERN = Pattern.compile("^(?:[-\\w]+[.])+$"); + private static final Pattern AFFIX_KEY_PATTERN = Pattern.compile("^(?:[-\\w]+[.])+[*](?:[.][-\\w]+)+$"); + + private final Settings settings; private final List> settingUpdaters = new CopyOnWriteArrayList<>(); private final Map> complexMatchers; private final Map> keySettings; private final Map, SettingUpgrader> settingUpgraders; private final Setting.Property scope; - private static final Pattern KEY_PATTERN = Pattern.compile("^(?:[-\\w]+[.])*[-\\w]+$"); - private static final Pattern GROUP_KEY_PATTERN = Pattern.compile("^(?:[-\\w]+[.])+$"); - private static final Pattern AFFIX_KEY_PATTERN = Pattern.compile("^(?:[-\\w]+[.])+[*](?:[.][-\\w]+)+$"); + private Settings lastSettingsApplied; protected AbstractScopedSettings( final Settings settings, @@ -65,6 +67,7 @@ public abstract class AbstractScopedSettings extends AbstractComponent { final Set> settingUpgraders, final Setting.Property scope) { super(settings); + this.settings = settings; this.lastSettingsApplied = Settings.EMPTY; this.settingUpgraders = @@ -105,6 +108,7 @@ public abstract class AbstractScopedSettings extends AbstractComponent { protected AbstractScopedSettings(Settings nodeSettings, Settings scopeSettings, AbstractScopedSettings other) { super(nodeSettings); + this.settings = nodeSettings; this.lastSettingsApplied = scopeSettings; this.scope = other.scope; complexMatchers = other.complexMatchers; diff --git a/server/src/main/java/org/elasticsearch/common/util/concurrent/EsExecutors.java b/server/src/main/java/org/elasticsearch/common/util/concurrent/EsExecutors.java index abc95810ba9..44367053406 100644 --- a/server/src/main/java/org/elasticsearch/common/util/concurrent/EsExecutors.java +++ b/server/src/main/java/org/elasticsearch/common/util/concurrent/EsExecutors.java @@ -179,6 +179,11 @@ public class EsExecutors { return daemonThreadFactory(threadName(settings, namePrefix)); } + public static ThreadFactory daemonThreadFactory(String nodeName, String namePrefix) { + assert nodeName != null && false == nodeName.isEmpty(); + return daemonThreadFactory(threadName(nodeName, namePrefix)); + } + public static ThreadFactory daemonThreadFactory(Settings settings, String ... names) { return daemonThreadFactory(threadName(settings, names)); } diff --git a/server/src/main/java/org/elasticsearch/discovery/single/SingleNodeDiscovery.java b/server/src/main/java/org/elasticsearch/discovery/single/SingleNodeDiscovery.java index 462136a22fe..1ac1cf13585 100644 --- a/server/src/main/java/org/elasticsearch/discovery/single/SingleNodeDiscovery.java +++ b/server/src/main/java/org/elasticsearch/discovery/single/SingleNodeDiscovery.java @@ -47,6 +47,7 @@ import static org.elasticsearch.gateway.GatewayService.STATE_NOT_RECOVERED_BLOCK */ public class SingleNodeDiscovery extends AbstractLifecycleComponent implements Discovery { + private final ClusterName clusterName; protected final TransportService transportService; private final ClusterApplier clusterApplier; private volatile ClusterState clusterState; @@ -54,6 +55,7 @@ public class SingleNodeDiscovery extends AbstractLifecycleComponent implements D public SingleNodeDiscovery(final Settings settings, final TransportService transportService, final MasterService masterService, final ClusterApplier clusterApplier) { super(Objects.requireNonNull(settings)); + this.clusterName = ClusterName.CLUSTER_NAME_SETTING.get(settings); this.transportService = Objects.requireNonNull(transportService); masterService.setClusterStateSupplier(() -> clusterState); this.clusterApplier = clusterApplier; @@ -114,7 +116,7 @@ public class SingleNodeDiscovery extends AbstractLifecycleComponent implements D } protected ClusterState createInitialState(DiscoveryNode localNode) { - ClusterState.Builder builder = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.get(settings)); + ClusterState.Builder builder = ClusterState.builder(clusterName); return builder.nodes(DiscoveryNodes.builder().add(localNode) .localNodeId(localNode.getId()) .masterNodeId(localNode.getId()) diff --git a/server/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java b/server/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java index 398dd4088e5..5d3bd9da684 100644 --- a/server/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java +++ b/server/src/main/java/org/elasticsearch/discovery/zen/ZenDiscovery.java @@ -121,6 +121,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent implements Discover private final NodesFaultDetection nodesFD; private final PublishClusterStateAction publishClusterState; private final MembershipAction membership; + private final ClusterName clusterName; private final ThreadPool threadPool; private final TimeValue pingTimeout; @@ -172,7 +173,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent implements Discover this.maxPingsFromAnotherMaster = MAX_PINGS_FROM_ANOTHER_MASTER_SETTING.get(settings); this.sendLeaveRequest = SEND_LEAVE_REQUEST_SETTING.get(settings); this.threadPool = threadPool; - ClusterName clusterName = ClusterName.CLUSTER_NAME_SETTING.get(settings); + this.clusterName = ClusterName.CLUSTER_NAME_SETTING.get(settings); this.committedState = new AtomicReference<>(); this.masterElectionIgnoreNonMasters = MASTER_ELECTION_IGNORE_NON_MASTER_PINGS_SETTING.get(settings); @@ -252,7 +253,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent implements Discover // set initial state assert committedState.get() == null; assert localNode != null; - ClusterState.Builder builder = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.get(settings)); + ClusterState.Builder builder = ClusterState.builder(clusterName); ClusterState initialState = builder .blocks(ClusterBlocks.builder() .addGlobalBlock(STATE_NOT_RECOVERED_BLOCK) diff --git a/server/src/main/java/org/elasticsearch/gateway/Gateway.java b/server/src/main/java/org/elasticsearch/gateway/Gateway.java index 77d2c553c2c..dc44688e6cb 100644 --- a/server/src/main/java/org/elasticsearch/gateway/Gateway.java +++ b/server/src/main/java/org/elasticsearch/gateway/Gateway.java @@ -23,7 +23,6 @@ import com.carrotsearch.hppc.ObjectFloatHashMap; import com.carrotsearch.hppc.cursors.ObjectCursor; import org.apache.logging.log4j.message.ParameterizedMessage; import org.elasticsearch.action.FailedNodeException; -import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.metadata.MetaData; @@ -153,7 +152,7 @@ public class Gateway extends AbstractComponent { clusterSettings.upgradeSettings(metaDataBuilder.transientSettings()), e -> logUnknownSetting("transient", e), (e, ex) -> logInvalidSetting("transient", e, ex))); - ClusterState.Builder builder = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.get(settings)); + ClusterState.Builder builder = ClusterState.builder(clusterService.getClusterName()); builder.metaData(metaDataBuilder); return builder; } diff --git a/server/src/main/java/org/elasticsearch/gateway/GatewayService.java b/server/src/main/java/org/elasticsearch/gateway/GatewayService.java index e8e442ab64b..e19e8367f16 100644 --- a/server/src/main/java/org/elasticsearch/gateway/GatewayService.java +++ b/server/src/main/java/org/elasticsearch/gateway/GatewayService.java @@ -101,22 +101,22 @@ public class GatewayService extends AbstractLifecycleComponent implements Cluste this.clusterService = clusterService; this.threadPool = threadPool; // allow to control a delay of when indices will get created - this.expectedNodes = EXPECTED_NODES_SETTING.get(this.settings); - this.expectedDataNodes = EXPECTED_DATA_NODES_SETTING.get(this.settings); - this.expectedMasterNodes = EXPECTED_MASTER_NODES_SETTING.get(this.settings); + this.expectedNodes = EXPECTED_NODES_SETTING.get(settings); + this.expectedDataNodes = EXPECTED_DATA_NODES_SETTING.get(settings); + this.expectedMasterNodes = EXPECTED_MASTER_NODES_SETTING.get(settings); - if (RECOVER_AFTER_TIME_SETTING.exists(this.settings)) { - recoverAfterTime = RECOVER_AFTER_TIME_SETTING.get(this.settings); + if (RECOVER_AFTER_TIME_SETTING.exists(settings)) { + recoverAfterTime = RECOVER_AFTER_TIME_SETTING.get(settings); } else if (expectedNodes >= 0 || expectedDataNodes >= 0 || expectedMasterNodes >= 0) { recoverAfterTime = DEFAULT_RECOVER_AFTER_TIME_IF_EXPECTED_NODES_IS_SET; } else { recoverAfterTime = null; } - this.recoverAfterNodes = RECOVER_AFTER_NODES_SETTING.get(this.settings); - this.recoverAfterDataNodes = RECOVER_AFTER_DATA_NODES_SETTING.get(this.settings); + this.recoverAfterNodes = RECOVER_AFTER_NODES_SETTING.get(settings); + this.recoverAfterDataNodes = RECOVER_AFTER_DATA_NODES_SETTING.get(settings); // default the recover after master nodes to the minimum master nodes in the discovery - if (RECOVER_AFTER_MASTER_NODES_SETTING.exists(this.settings)) { - recoverAfterMasterNodes = RECOVER_AFTER_MASTER_NODES_SETTING.get(this.settings); + if (RECOVER_AFTER_MASTER_NODES_SETTING.exists(settings)) { + recoverAfterMasterNodes = RECOVER_AFTER_MASTER_NODES_SETTING.get(settings); } else { // TODO: change me once the minimum_master_nodes is changed too recoverAfterMasterNodes = settings.getAsInt("discovery.zen.minimum_master_nodes", -1); diff --git a/server/src/main/java/org/elasticsearch/gateway/TransportNodesListGatewayStartedShards.java b/server/src/main/java/org/elasticsearch/gateway/TransportNodesListGatewayStartedShards.java index c3cbfea9141..752b1faadcf 100644 --- a/server/src/main/java/org/elasticsearch/gateway/TransportNodesListGatewayStartedShards.java +++ b/server/src/main/java/org/elasticsearch/gateway/TransportNodesListGatewayStartedShards.java @@ -67,6 +67,7 @@ public class TransportNodesListGatewayStartedShards extends TransportNodesListGatewayStartedShards.NodeGatewayStartedShards> { public static final String ACTION_NAME = "internal:gateway/local/started_shards"; + private final Settings settings; private final NodeEnvironment nodeEnv; private final IndicesService indicesService; private final NamedXContentRegistry namedXContentRegistry; @@ -78,6 +79,7 @@ public class TransportNodesListGatewayStartedShards extends NamedXContentRegistry namedXContentRegistry) { super(settings, ACTION_NAME, threadPool, clusterService, transportService, actionFilters, Request::new, NodeRequest::new, ThreadPool.Names.FETCH_SHARD_STARTED, NodeGatewayStartedShards.class); + this.settings = settings; this.nodeEnv = env; this.indicesService = indicesService; this.namedXContentRegistry = namedXContentRegistry; diff --git a/server/src/main/java/org/elasticsearch/http/AbstractHttpServerTransport.java b/server/src/main/java/org/elasticsearch/http/AbstractHttpServerTransport.java index 622020d6451..2327db1d78a 100644 --- a/server/src/main/java/org/elasticsearch/http/AbstractHttpServerTransport.java +++ b/server/src/main/java/org/elasticsearch/http/AbstractHttpServerTransport.java @@ -63,7 +63,7 @@ import static org.elasticsearch.http.HttpTransportSettings.SETTING_HTTP_PUBLISH_ import static org.elasticsearch.http.HttpTransportSettings.SETTING_HTTP_PUBLISH_PORT; public abstract class AbstractHttpServerTransport extends AbstractLifecycleComponent implements HttpServerTransport { - + protected final Settings settings; public final HttpHandlingSettings handlingSettings; protected final NetworkService networkService; protected final BigArrays bigArrays; @@ -84,6 +84,7 @@ public abstract class AbstractHttpServerTransport extends AbstractLifecycleCompo protected AbstractHttpServerTransport(Settings settings, NetworkService networkService, BigArrays bigArrays, ThreadPool threadPool, NamedXContentRegistry xContentRegistry, Dispatcher dispatcher) { super(settings); + this.settings = settings; this.networkService = networkService; this.bigArrays = bigArrays; this.threadPool = threadPool; diff --git a/server/src/main/java/org/elasticsearch/indices/IndexingMemoryController.java b/server/src/main/java/org/elasticsearch/indices/IndexingMemoryController.java index ac5a5047464..46acd5155ff 100644 --- a/server/src/main/java/org/elasticsearch/indices/IndexingMemoryController.java +++ b/server/src/main/java/org/elasticsearch/indices/IndexingMemoryController.java @@ -103,8 +103,8 @@ public class IndexingMemoryController extends AbstractComponent implements Index // null means we used the default (10%) if (indexingBufferSetting == null || indexingBufferSetting.endsWith("%")) { // We only apply the min/max when % value was used for the index buffer: - ByteSizeValue minIndexingBuffer = MIN_INDEX_BUFFER_SIZE_SETTING.get(this.settings); - ByteSizeValue maxIndexingBuffer = MAX_INDEX_BUFFER_SIZE_SETTING.get(this.settings); + ByteSizeValue minIndexingBuffer = MIN_INDEX_BUFFER_SIZE_SETTING.get(settings); + ByteSizeValue maxIndexingBuffer = MAX_INDEX_BUFFER_SIZE_SETTING.get(settings); if (indexingBuffer.getBytes() < minIndexingBuffer.getBytes()) { indexingBuffer = minIndexingBuffer; } @@ -114,9 +114,9 @@ public class IndexingMemoryController extends AbstractComponent implements Index } this.indexingBuffer = indexingBuffer; - this.inactiveTime = SHARD_INACTIVE_TIME_SETTING.get(this.settings); + this.inactiveTime = SHARD_INACTIVE_TIME_SETTING.get(settings); // we need to have this relatively small to free up heap quickly enough - this.interval = SHARD_MEMORY_INTERVAL_TIME_SETTING.get(this.settings); + this.interval = SHARD_MEMORY_INTERVAL_TIME_SETTING.get(settings); this.statusChecker = new ShardsIndicesStatusChecker(); diff --git a/server/src/main/java/org/elasticsearch/indices/IndicesService.java b/server/src/main/java/org/elasticsearch/indices/IndicesService.java index 206b9e7165a..07f50dc30fa 100644 --- a/server/src/main/java/org/elasticsearch/indices/IndicesService.java +++ b/server/src/main/java/org/elasticsearch/indices/IndicesService.java @@ -173,6 +173,10 @@ public class IndicesService extends AbstractLifecycleComponent } } + /** + * The node's settings. + */ + private final Settings settings; private final PluginsService pluginsService; private final NodeEnvironment nodeEnv; private final NamedXContentRegistry xContentRegistry; @@ -215,6 +219,7 @@ public class IndicesService extends AbstractLifecycleComponent Collection>> engineFactoryProviders, Map> indexStoreFactories) { super(settings); + this.settings = settings; this.threadPool = threadPool; this.pluginsService = pluginsService; this.nodeEnv = nodeEnv; @@ -483,7 +488,7 @@ public class IndicesService extends AbstractLifecycleComponent IndicesFieldDataCache indicesFieldDataCache, List builtInListeners, IndexingOperationListener... indexingOperationListeners) throws IOException { - final IndexSettings idxSettings = new IndexSettings(indexMetaData, this.settings, indexScopedSettings); + final IndexSettings idxSettings = new IndexSettings(indexMetaData, settings, indexScopedSettings); // we ignore private settings since they are not registered settings indexScopedSettings.validate(indexMetaData.getSettings(), true, true, true); logger.debug("creating Index [{}], shards [{}]/[{}] - reason [{}]", diff --git a/server/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java b/server/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java index 561a8e8c742..cd32c415ea5 100644 --- a/server/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java +++ b/server/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java @@ -107,6 +107,7 @@ public class IndicesClusterStateService extends AbstractLifecycleComponent imple private static final ShardStateAction.Listener SHARD_STATE_ACTION_LISTENER = new ShardStateAction.Listener() { }; + private final Settings settings; // a list of shards that failed during recovery // we keep track of these shards in order to prevent repeated recovery of these shards on each cluster state update final ConcurrentMap failedShardsCache = ConcurrentCollections.newConcurrentMap(); @@ -156,6 +157,7 @@ public class IndicesClusterStateService extends AbstractLifecycleComponent imple PrimaryReplicaSyncer primaryReplicaSyncer, Consumer globalCheckpointSyncer) { super(settings); + this.settings = settings; this.buildInIndexListener = Arrays.asList( peerRecoverySourceService, @@ -172,7 +174,7 @@ public class IndicesClusterStateService extends AbstractLifecycleComponent imple this.repositoriesService = repositoriesService; this.primaryReplicaSyncer = primaryReplicaSyncer; this.globalCheckpointSyncer = globalCheckpointSyncer; - this.sendRefreshMapping = this.settings.getAsBoolean("indices.cluster.send_refresh_mapping", true); + this.sendRefreshMapping = settings.getAsBoolean("indices.cluster.send_refresh_mapping", true); } @Override diff --git a/server/src/main/java/org/elasticsearch/indices/store/IndicesStore.java b/server/src/main/java/org/elasticsearch/indices/store/IndicesStore.java index f62618ec91e..8f387c5f7f0 100644 --- a/server/src/main/java/org/elasticsearch/indices/store/IndicesStore.java +++ b/server/src/main/java/org/elasticsearch/indices/store/IndicesStore.java @@ -78,6 +78,7 @@ public class IndicesStore extends AbstractComponent implements ClusterStateListe Property.NodeScope); public static final String ACTION_SHARD_EXISTS = "internal:index/shard/exists"; private static final EnumSet ACTIVE_STATES = EnumSet.of(IndexShardState.STARTED); + private final Settings settings; private final IndicesService indicesService; private final ClusterService clusterService; private final TransportService transportService; @@ -92,6 +93,7 @@ public class IndicesStore extends AbstractComponent implements ClusterStateListe public IndicesStore(Settings settings, IndicesService indicesService, ClusterService clusterService, TransportService transportService, ThreadPool threadPool) { super(settings); + this.settings = settings; this.indicesService = indicesService; this.clusterService = clusterService; this.transportService = transportService; diff --git a/server/src/main/java/org/elasticsearch/indices/store/TransportNodesListShardStoreMetaData.java b/server/src/main/java/org/elasticsearch/indices/store/TransportNodesListShardStoreMetaData.java index 62f5dba9825..7cf7f3141aa 100644 --- a/server/src/main/java/org/elasticsearch/indices/store/TransportNodesListShardStoreMetaData.java +++ b/server/src/main/java/org/elasticsearch/indices/store/TransportNodesListShardStoreMetaData.java @@ -66,6 +66,7 @@ public class TransportNodesListShardStoreMetaData extends TransportNodesAction> plugins; private final PluginsAndModules info; + public static final Setting> MANDATORY_SETTING = Setting.listSetting("plugin.mandatory", Collections.emptyList(), Function.identity(), Property.NodeScope); @@ -99,7 +101,7 @@ public class PluginsService extends AbstractComponent { */ public PluginsService(Settings settings, Path configPath, Path modulesDirectory, Path pluginsDirectory, Collection> classpathPlugins) { super(settings); - + this.settings = settings; this.configPath = configPath; List> pluginsLoaded = new ArrayList<>(); diff --git a/server/src/main/java/org/elasticsearch/repositories/blobstore/BlobStoreRepository.java b/server/src/main/java/org/elasticsearch/repositories/blobstore/BlobStoreRepository.java index df80dd473f1..6dca8179652 100644 --- a/server/src/main/java/org/elasticsearch/repositories/blobstore/BlobStoreRepository.java +++ b/server/src/main/java/org/elasticsearch/repositories/blobstore/BlobStoreRepository.java @@ -204,6 +204,8 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent imp private static final String DATA_BLOB_PREFIX = "__"; + private final Settings settings; + private final RateLimiter snapshotRateLimiter; private final RateLimiter restoreRateLimiter; @@ -234,10 +236,11 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent imp * Constructs new BlobStoreRepository * * @param metadata The metadata for this repository including name and settings - * @param globalSettings Settings for the node this repository object is created on + * @param settings Settings for the node this repository object is created on */ - protected BlobStoreRepository(RepositoryMetaData metadata, Settings globalSettings, NamedXContentRegistry namedXContentRegistry) { - super(globalSettings); + protected BlobStoreRepository(RepositoryMetaData metadata, Settings settings, NamedXContentRegistry namedXContentRegistry) { + super(settings); + this.settings = settings; this.metadata = metadata; this.namedXContentRegistry = namedXContentRegistry; snapshotRateLimiter = getRateLimiter(metadata.settings(), "max_snapshot_bytes_per_sec", new ByteSizeValue(40, ByteSizeUnit.MB)); diff --git a/server/src/main/java/org/elasticsearch/repositories/fs/FsRepository.java b/server/src/main/java/org/elasticsearch/repositories/fs/FsRepository.java index 643ff2bc93d..7abddafac4e 100644 --- a/server/src/main/java/org/elasticsearch/repositories/fs/FsRepository.java +++ b/server/src/main/java/org/elasticsearch/repositories/fs/FsRepository.java @@ -99,10 +99,10 @@ public class FsRepository extends BlobStoreRepository { if (CHUNK_SIZE_SETTING.exists(metadata.settings())) { this.chunkSize = CHUNK_SIZE_SETTING.get(metadata.settings()); } else { - this.chunkSize = REPOSITORIES_CHUNK_SIZE_SETTING.get(settings); + this.chunkSize = REPOSITORIES_CHUNK_SIZE_SETTING.get(environment.settings()); } this.compress = COMPRESS_SETTING.exists(metadata.settings()) - ? COMPRESS_SETTING.get(metadata.settings()) : REPOSITORIES_COMPRESS_SETTING.get(settings); + ? COMPRESS_SETTING.get(metadata.settings()) : REPOSITORIES_COMPRESS_SETTING.get(environment.settings()); this.basePath = BlobPath.cleanPath(); } @@ -110,7 +110,7 @@ public class FsRepository extends BlobStoreRepository { protected BlobStore createBlobStore() throws Exception { final String location = REPOSITORIES_LOCATION_SETTING.get(metadata.settings()); final Path locationFile = environment.resolveRepoFile(location); - return new FsBlobStore(settings, locationFile); + return new FsBlobStore(environment.settings(), locationFile); } @Override diff --git a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterGetSettingsAction.java b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterGetSettingsAction.java index 746bb643bf6..e1e4d921163 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterGetSettingsAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/admin/cluster/RestClusterGetSettingsAction.java @@ -43,12 +43,14 @@ import java.util.Set; public class RestClusterGetSettingsAction extends BaseRestHandler { + private final Settings settings; private final ClusterSettings clusterSettings; private final SettingsFilter settingsFilter; public RestClusterGetSettingsAction(Settings settings, RestController controller, ClusterSettings clusterSettings, SettingsFilter settingsFilter) { super(settings); + this.settings = settings; this.clusterSettings = clusterSettings; controller.registerHandler(RestRequest.Method.GET, "/_cluster/settings", this); this.settingsFilter = settingsFilter; diff --git a/server/src/main/java/org/elasticsearch/script/ScriptService.java b/server/src/main/java/org/elasticsearch/script/ScriptService.java index 6a54af8721e..98ad65aec55 100644 --- a/server/src/main/java/org/elasticsearch/script/ScriptService.java +++ b/server/src/main/java/org/elasticsearch/script/ScriptService.java @@ -109,6 +109,7 @@ public class ScriptService extends AbstractComponent implements Closeable, Clust public static final Setting> CONTEXTS_ALLOWED_SETTING = Setting.listSetting("script.allowed_contexts", Collections.emptyList(), Function.identity(), Setting.Property.NodeScope); + private final Settings settings; private final Set typesAllowed; private final Set contextsAllowed; @@ -128,8 +129,7 @@ public class ScriptService extends AbstractComponent implements Closeable, Clust public ScriptService(Settings settings, Map engines, Map> contexts) { super(settings); - - Objects.requireNonNull(settings); + this.settings = Objects.requireNonNull(settings); this.engines = Objects.requireNonNull(engines); this.contexts = Objects.requireNonNull(contexts); diff --git a/server/src/main/java/org/elasticsearch/search/SearchService.java b/server/src/main/java/org/elasticsearch/search/SearchService.java index f1a43077a62..444bfe277ce 100644 --- a/server/src/main/java/org/elasticsearch/search/SearchService.java +++ b/server/src/main/java/org/elasticsearch/search/SearchService.java @@ -34,6 +34,7 @@ import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.lucene.Lucene; import org.elasticsearch.common.settings.Setting; +import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Setting.Property; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.util.BigArrays; @@ -182,13 +183,14 @@ public class SearchService extends AbstractLifecycleComponent implements IndexEv ThreadPool threadPool, ScriptService scriptService, BigArrays bigArrays, FetchPhase fetchPhase, ResponseCollectorService responseCollectorService) { super(clusterService.getSettings()); + Settings settings = clusterService.getSettings(); this.threadPool = threadPool; this.clusterService = clusterService; this.indicesService = indicesService; this.scriptService = scriptService; this.responseCollectorService = responseCollectorService; this.bigArrays = bigArrays; - this.queryPhase = new QueryPhase(settings); + this.queryPhase = new QueryPhase(clusterService.getSettings()); this.fetchPhase = fetchPhase; this.multiBucketConsumerService = new MultiBucketConsumerService(clusterService, settings); diff --git a/server/src/main/java/org/elasticsearch/transport/RemoteClusterAware.java b/server/src/main/java/org/elasticsearch/transport/RemoteClusterAware.java index bbd02f8d8f0..f643a91fb48 100644 --- a/server/src/main/java/org/elasticsearch/transport/RemoteClusterAware.java +++ b/server/src/main/java/org/elasticsearch/transport/RemoteClusterAware.java @@ -167,7 +167,7 @@ public abstract class RemoteClusterAware extends AbstractComponent { Setting.Property.NodeScope), REMOTE_CLUSTERS_SEEDS); - + protected final Settings settings; protected final ClusterNameExpressionResolver clusterNameResolver; /** @@ -176,6 +176,7 @@ public abstract class RemoteClusterAware extends AbstractComponent { */ protected RemoteClusterAware(Settings settings) { super(settings); + this.settings = settings; this.clusterNameResolver = new ClusterNameExpressionResolver(settings); } diff --git a/server/src/main/java/org/elasticsearch/transport/RemoteClusterConnection.java b/server/src/main/java/org/elasticsearch/transport/RemoteClusterConnection.java index 48f086ad972..0cfa2abd754 100644 --- a/server/src/main/java/org/elasticsearch/transport/RemoteClusterConnection.java +++ b/server/src/main/java/org/elasticsearch/transport/RemoteClusterConnection.java @@ -93,6 +93,7 @@ final class RemoteClusterConnection extends AbstractComponent implements Transpo private volatile List> seedNodes; private volatile boolean skipUnavailable; private final ConnectHandler connectHandler; + private final TimeValue initialConnectionTimeout; private SetOnce remoteClusterName = new SetOnce<>(); /** @@ -112,9 +113,8 @@ final class RemoteClusterConnection extends AbstractComponent implements Transpo } RemoteClusterConnection(Settings settings, String clusterAlias, List> seedNodes, - TransportService transportService, ConnectionManager connectionManager, int maxNumRemoteConnections, Predicate - nodePredicate, - String proxyAddress) { + TransportService transportService, ConnectionManager connectionManager, int maxNumRemoteConnections, + Predicate nodePredicate, String proxyAddress) { super(settings); this.transportService = transportService; this.maxNumRemoteConnections = maxNumRemoteConnections; @@ -140,6 +140,7 @@ final class RemoteClusterConnection extends AbstractComponent implements Transpo // we register the transport service here as a listener to make sure we notify handlers on disconnect etc. connectionManager.addListener(transportService); this.proxyAddress = proxyAddress; + initialConnectionTimeout = RemoteClusterService.REMOTE_INITIAL_CONNECTION_TIMEOUT_SETTING.get(settings); } private static DiscoveryNode maybeAddProxyAddress(String proxyAddress, DiscoveryNode node) { @@ -679,7 +680,6 @@ final class RemoteClusterConnection extends AbstractComponent implements Transpo public RemoteConnectionInfo getConnectionInfo() { List seedNodeAddresses = seedNodes.stream().map(node -> node.get().getAddress()).collect (Collectors.toList()); - TimeValue initialConnectionTimeout = RemoteClusterService.REMOTE_INITIAL_CONNECTION_TIMEOUT_SETTING.get(settings); return new RemoteConnectionInfo(clusterAlias, seedNodeAddresses, maxNumRemoteConnections, connectedNodes.size(), initialConnectionTimeout, skipUnavailable); } diff --git a/server/src/main/java/org/elasticsearch/transport/TcpTransport.java b/server/src/main/java/org/elasticsearch/transport/TcpTransport.java index d7d57beda26..506d1a58649 100644 --- a/server/src/main/java/org/elasticsearch/transport/TcpTransport.java +++ b/server/src/main/java/org/elasticsearch/transport/TcpTransport.java @@ -179,6 +179,7 @@ public abstract class TcpTransport extends AbstractLifecycleComponent implements public static final Setting DEFAULT_FEATURES_SETTING = Setting.groupSetting(FEATURE_PREFIX + ".", Setting.Property.NodeScope); private final String[] features; + protected final Settings settings; private final CircuitBreakerService circuitBreakerService; protected final ThreadPool threadPool; private final BigArrays bigArrays; @@ -216,6 +217,7 @@ public abstract class TcpTransport extends AbstractLifecycleComponent implements CircuitBreakerService circuitBreakerService, NamedWriteableRegistry namedWriteableRegistry, NetworkService networkService) { super(settings); + this.settings = settings; this.profileSettings = getProfileSettings(settings); this.threadPool = threadPool; this.bigArrays = bigArrays; diff --git a/server/src/test/java/org/elasticsearch/indices/cluster/ClusterStateChanges.java b/server/src/test/java/org/elasticsearch/indices/cluster/ClusterStateChanges.java index 3d8b1decea4..8268d4ea5e0 100644 --- a/server/src/test/java/org/elasticsearch/indices/cluster/ClusterStateChanges.java +++ b/server/src/test/java/org/elasticsearch/indices/cluster/ClusterStateChanges.java @@ -106,6 +106,9 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; public class ClusterStateChanges extends AbstractComponent { + private static final Settings SETTINGS = Settings.builder() + .put(PATH_HOME_SETTING.getKey(), "dummy") + .build(); private final AllocationService allocationService; private final ClusterService clusterService; @@ -124,21 +127,21 @@ public class ClusterStateChanges extends AbstractComponent { private final NodeJoinController.JoinTaskExecutor joinTaskExecutor; public ClusterStateChanges(NamedXContentRegistry xContentRegistry, ThreadPool threadPool) { - super(Settings.builder().put(PATH_HOME_SETTING.getKey(), "dummy").build()); + super(SETTINGS); - ClusterSettings clusterSettings = new ClusterSettings(settings, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); - allocationService = new AllocationService(settings, new AllocationDeciders(settings, - new HashSet<>(Arrays.asList(new SameShardAllocationDecider(settings, clusterSettings), - new ReplicaAfterPrimaryActiveAllocationDecider(settings), + ClusterSettings clusterSettings = new ClusterSettings(SETTINGS, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); + allocationService = new AllocationService(SETTINGS, new AllocationDeciders(SETTINGS, + new HashSet<>(Arrays.asList(new SameShardAllocationDecider(SETTINGS, clusterSettings), + new ReplicaAfterPrimaryActiveAllocationDecider(SETTINGS), new RandomAllocationDeciderTests.RandomAllocationDecider(getRandom())))), - new TestGatewayAllocator(), new BalancedShardsAllocator(settings), + new TestGatewayAllocator(), new BalancedShardsAllocator(SETTINGS), EmptyClusterInfoService.INSTANCE); shardFailedClusterStateTaskExecutor = new ShardStateAction.ShardFailedClusterStateTaskExecutor(allocationService, null, logger); shardStartedClusterStateTaskExecutor = new ShardStateAction.ShardStartedClusterStateTaskExecutor(allocationService, logger); ActionFilters actionFilters = new ActionFilters(Collections.emptySet()); - IndexNameExpressionResolver indexNameExpressionResolver = new IndexNameExpressionResolver(settings); - DestructiveOperations destructiveOperations = new DestructiveOperations(settings, clusterSettings); - Environment environment = TestEnvironment.newEnvironment(settings); + IndexNameExpressionResolver indexNameExpressionResolver = new IndexNameExpressionResolver(SETTINGS); + DestructiveOperations destructiveOperations = new DestructiveOperations(SETTINGS, clusterSettings); + Environment environment = TestEnvironment.newEnvironment(SETTINGS); Transport transport = mock(Transport.class); // it's not used // mocks @@ -165,11 +168,11 @@ public class ClusterStateChanges extends AbstractComponent { } // services - TransportService transportService = new TransportService(settings, transport, threadPool, + TransportService transportService = new TransportService(SETTINGS, transport, threadPool, TransportService.NOOP_TRANSPORT_INTERCEPTOR, - boundAddress -> DiscoveryNode.createLocal(settings, boundAddress.publishAddress(), UUIDs.randomBase64UUID()), clusterSettings, + boundAddress -> DiscoveryNode.createLocal(SETTINGS, boundAddress.publishAddress(), UUIDs.randomBase64UUID()), clusterSettings, Collections.emptySet()); - MetaDataIndexUpgradeService metaDataIndexUpgradeService = new MetaDataIndexUpgradeService(settings, xContentRegistry, null, null, + MetaDataIndexUpgradeService metaDataIndexUpgradeService = new MetaDataIndexUpgradeService(SETTINGS, xContentRegistry, null, null, null) { // metaData upgrader should do nothing @Override @@ -177,29 +180,29 @@ public class ClusterStateChanges extends AbstractComponent { return indexMetaData; } }; - MetaDataIndexStateService indexStateService = new MetaDataIndexStateService(settings, clusterService, allocationService, + MetaDataIndexStateService indexStateService = new MetaDataIndexStateService(SETTINGS, clusterService, allocationService, metaDataIndexUpgradeService, indicesService, threadPool); - MetaDataDeleteIndexService deleteIndexService = new MetaDataDeleteIndexService(settings, clusterService, allocationService); - MetaDataUpdateSettingsService metaDataUpdateSettingsService = new MetaDataUpdateSettingsService(settings, clusterService, + MetaDataDeleteIndexService deleteIndexService = new MetaDataDeleteIndexService(SETTINGS, clusterService, allocationService); + MetaDataUpdateSettingsService metaDataUpdateSettingsService = new MetaDataUpdateSettingsService(SETTINGS, clusterService, allocationService, IndexScopedSettings.DEFAULT_SCOPED_SETTINGS, indicesService, threadPool); - MetaDataCreateIndexService createIndexService = new MetaDataCreateIndexService(settings, clusterService, indicesService, - allocationService, new AliasValidator(settings), environment, + MetaDataCreateIndexService createIndexService = new MetaDataCreateIndexService(SETTINGS, clusterService, indicesService, + allocationService, new AliasValidator(SETTINGS), environment, IndexScopedSettings.DEFAULT_SCOPED_SETTINGS, threadPool, xContentRegistry, true); - transportCloseIndexAction = new TransportCloseIndexAction(settings, transportService, clusterService, threadPool, + transportCloseIndexAction = new TransportCloseIndexAction(SETTINGS, transportService, clusterService, threadPool, indexStateService, clusterSettings, actionFilters, indexNameExpressionResolver, destructiveOperations); - transportOpenIndexAction = new TransportOpenIndexAction(settings, transportService, + transportOpenIndexAction = new TransportOpenIndexAction(SETTINGS, transportService, clusterService, threadPool, indexStateService, actionFilters, indexNameExpressionResolver, destructiveOperations); - transportDeleteIndexAction = new TransportDeleteIndexAction(settings, transportService, + transportDeleteIndexAction = new TransportDeleteIndexAction(SETTINGS, transportService, clusterService, threadPool, deleteIndexService, actionFilters, indexNameExpressionResolver, destructiveOperations); - transportUpdateSettingsAction = new TransportUpdateSettingsAction(settings, + transportUpdateSettingsAction = new TransportUpdateSettingsAction(SETTINGS, transportService, clusterService, threadPool, metaDataUpdateSettingsService, actionFilters, indexNameExpressionResolver); - transportClusterRerouteAction = new TransportClusterRerouteAction(settings, + transportClusterRerouteAction = new TransportClusterRerouteAction(SETTINGS, transportService, clusterService, threadPool, allocationService, actionFilters, indexNameExpressionResolver); - transportCreateIndexAction = new TransportCreateIndexAction(settings, + transportCreateIndexAction = new TransportCreateIndexAction(SETTINGS, transportService, clusterService, threadPool, createIndexService, actionFilters, indexNameExpressionResolver); - ElectMasterService electMasterService = new ElectMasterService(settings); + ElectMasterService electMasterService = new ElectMasterService(SETTINGS); nodeRemovalExecutor = new ZenDiscovery.NodeRemovalClusterStateTaskExecutor(allocationService, electMasterService, s -> { throw new AssertionError("rejoin not implemented"); }, logger); joinTaskExecutor = new NodeJoinController.JoinTaskExecutor(allocationService, electMasterService, logger); diff --git a/test/framework/src/main/java/org/elasticsearch/test/ClusterServiceUtils.java b/test/framework/src/main/java/org/elasticsearch/test/ClusterServiceUtils.java index 3e24384b2d1..33682b976ca 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ClusterServiceUtils.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ClusterServiceUtils.java @@ -131,8 +131,11 @@ public class ClusterServiceUtils { } public static ClusterService createClusterService(ThreadPool threadPool, DiscoveryNode localNode, ClusterSettings clusterSettings) { - ClusterService clusterService = new ClusterService(Settings.builder().put("cluster.name", "ClusterServiceTests").build(), - clusterSettings, threadPool); + Settings settings = Settings.builder() + .put("node.name", "test") + .put("cluster.name", "ClusterServiceTests") + .build(); + ClusterService clusterService = new ClusterService(settings, clusterSettings, threadPool); clusterService.setNodeConnectionsService(new NodeConnectionsService(Settings.EMPTY, null, null) { @Override public void connectToNodes(DiscoveryNodes discoveryNodes) { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/LicenseService.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/LicenseService.java index 0619aef6961..18ded8d5850 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/license/LicenseService.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/license/LicenseService.java @@ -79,6 +79,8 @@ public class LicenseService extends AbstractLifecycleComponent implements Cluste public static final long BASIC_SELF_GENERATED_LICENSE_EXPIRATION_MILLIS = XPackInfoResponse.BASIC_SELF_GENERATED_LICENSE_EXPIRATION_MILLIS; + private final Settings settings; + private final ClusterService clusterService; /** @@ -118,6 +120,7 @@ public class LicenseService extends AbstractLifecycleComponent implements Cluste public LicenseService(Settings settings, ClusterService clusterService, Clock clock, Environment env, ResourceWatcherService resourceWatcherService, XPackLicenseState licenseState) { super(settings); + this.settings = settings; this.clusterService = clusterService; this.clock = clock; this.scheduler = new SchedulerEngine(settings, clock); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ssl/SSLService.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ssl/SSLService.java index 08513ce7412..e22e09e5979 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ssl/SSLService.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ssl/SSLService.java @@ -60,6 +60,8 @@ import java.util.stream.Collectors; */ public class SSLService extends AbstractComponent { + private final Settings settings; + /** * This is a mapping from "context name" (in general use, the name of a setting key) * to a configuration. @@ -87,6 +89,7 @@ public class SSLService extends AbstractComponent { */ public SSLService(Settings settings, Environment environment) { super(settings); + this.settings = settings; this.env = environment; this.globalSSLConfiguration = new SSLConfiguration(settings.getByPrefix(XPackSettings.GLOBAL_SSL_PREFIX)); this.sslConfigurations = new HashMap<>(); @@ -96,6 +99,7 @@ public class SSLService extends AbstractComponent { private SSLService(Settings settings, Environment environment, SSLConfiguration globalSSLConfiguration, Map sslConfigurations, Map sslContexts) { super(settings); + this.settings = settings; this.env = environment; this.globalSSLConfiguration = globalSSLConfiguration; this.sslConfigurations = sslConfigurations; diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/JobManager.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/JobManager.java index 1e97e98c42c..cca5ae6c13f 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/JobManager.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/JobManager.java @@ -83,6 +83,7 @@ public class JobManager extends AbstractComponent { private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(JobManager.class)); + private final Settings settings; private final Environment environment; private final JobResultsProvider jobResultsProvider; private final ClusterService clusterService; @@ -99,6 +100,7 @@ public class JobManager extends AbstractComponent { ClusterService clusterService, Auditor auditor, Client client, UpdateJobProcessNotifier updateJobProcessNotifier) { super(settings); + this.settings = settings; this.environment = environment; this.jobResultsProvider = Objects.requireNonNull(jobResultsProvider); this.clusterService = Objects.requireNonNull(clusterService); diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectProcessManager.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectProcessManager.java index 8dbc13038c7..ea9442b8367 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectProcessManager.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectProcessManager.java @@ -108,6 +108,7 @@ public class AutodetectProcessManager extends AbstractComponent { public static final Setting MIN_DISK_SPACE_OFF_HEAP = Setting.byteSizeSetting("xpack.ml.min_disk_space_off_heap", new ByteSizeValue(5, ByteSizeUnit.GB), Property.NodeScope); + private final Settings settings; private final Client client; private final Environment environment; private final ThreadPool threadPool; @@ -137,6 +138,7 @@ public class AutodetectProcessManager extends AbstractComponent { AutodetectProcessFactory autodetectProcessFactory, NormalizerFactory normalizerFactory, NamedXContentRegistry xContentRegistry, Auditor auditor) { super(settings); + this.settings = settings; this.environment = environment; this.client = client; this.threadPool = threadPool; diff --git a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/ccr/StatsCollector.java b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/ccr/StatsCollector.java index b57c1f31ea6..948e4eb8848 100644 --- a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/ccr/StatsCollector.java +++ b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/ccr/StatsCollector.java @@ -36,6 +36,7 @@ public final class StatsCollector extends Collector { public static final Setting CCR_STATS_TIMEOUT = collectionTimeoutSetting("ccr.stats.timeout"); + private final Settings settings; private final ThreadContext threadContext; private final CcrClient ccrClient; @@ -48,12 +49,13 @@ public final class StatsCollector extends Collector { } StatsCollector( - final Settings settings, - final ClusterService clusterService, - final XPackLicenseState licenseState, - final CcrClient ccrClient, - final ThreadContext threadContext) { + final Settings settings, + final ClusterService clusterService, + final XPackLicenseState licenseState, + final CcrClient ccrClient, + final ThreadContext threadContext) { super(settings, TYPE, clusterService, CCR_STATS_TIMEOUT, licenseState); + this.settings = settings; this.ccrClient = ccrClient; this.threadContext = threadContext; } diff --git a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsCollector.java b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsCollector.java index 23fe4d46543..efe7c8ba81a 100644 --- a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsCollector.java +++ b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsCollector.java @@ -55,6 +55,7 @@ public class ClusterStatsCollector extends Collector { */ public static final Setting CLUSTER_STATS_TIMEOUT = collectionTimeoutSetting("cluster.stats.timeout"); + private final Settings settings; private final IndexNameExpressionResolver indexNameExpressionResolver; private final LicenseService licenseService; private final Client client; @@ -74,7 +75,7 @@ public class ClusterStatsCollector extends Collector { final LicenseService licenseService, final IndexNameExpressionResolver indexNameExpressionResolver) { super(settings, ClusterStatsMonitoringDoc.TYPE, clusterService, CLUSTER_STATS_TIMEOUT, licenseState); - + this.settings = settings; this.client = client; this.licenseService = licenseService; this.indexNameExpressionResolver = Objects.requireNonNull(indexNameExpressionResolver); diff --git a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/ml/JobStatsCollector.java b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/ml/JobStatsCollector.java index cfbf9b7e0a4..42f6b95a41a 100644 --- a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/ml/JobStatsCollector.java +++ b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/ml/JobStatsCollector.java @@ -42,6 +42,7 @@ public class JobStatsCollector extends Collector { */ public static final Setting JOB_STATS_TIMEOUT = collectionTimeoutSetting("ml.job.stats.timeout"); + private final Settings settings; private final ThreadContext threadContext; private final MachineLearningClient client; @@ -53,6 +54,7 @@ public class JobStatsCollector extends Collector { JobStatsCollector(final Settings settings, final ClusterService clusterService, final XPackLicenseState licenseState, final MachineLearningClient client, final ThreadContext threadContext) { super(settings, JobStatsMonitoringDoc.TYPE, clusterService, JOB_STATS_TIMEOUT, licenseState); + this.settings = settings; this.client = client; this.threadContext = threadContext; } diff --git a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/Exporters.java b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/Exporters.java index 40c95384d53..fab40bf0944 100644 --- a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/Exporters.java +++ b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/Exporters.java @@ -37,6 +37,7 @@ import static java.util.Collections.emptyMap; public class Exporters extends AbstractLifecycleComponent implements Iterable { + private final Settings settings; private final Map factories; private final AtomicReference> exporters; private final ClusterService clusterService; @@ -47,7 +48,7 @@ public class Exporters extends AbstractLifecycleComponent implements Iterable(emptyMap()); this.threadContext = Objects.requireNonNull(threadContext); diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/TransportChangePasswordAction.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/TransportChangePasswordAction.java index 5046beca1c8..2f899430550 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/TransportChangePasswordAction.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/TransportChangePasswordAction.java @@ -24,12 +24,14 @@ import org.elasticsearch.xpack.security.authc.esnative.NativeUsersStore; public class TransportChangePasswordAction extends HandledTransportAction { + private final Settings settings; private final NativeUsersStore nativeUsersStore; @Inject public TransportChangePasswordAction(Settings settings, TransportService transportService, ActionFilters actionFilters, NativeUsersStore nativeUsersStore) { super(settings, ChangePasswordAction.NAME, transportService, actionFilters, ChangePasswordRequest::new); + this.settings = settings; this.nativeUsersStore = nativeUsersStore; } diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/TransportDeleteUserAction.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/TransportDeleteUserAction.java index 36efdf3bd17..3a3d023cba3 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/TransportDeleteUserAction.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/TransportDeleteUserAction.java @@ -25,6 +25,7 @@ import java.util.function.Supplier; public class TransportDeleteUserAction extends HandledTransportAction { + private final Settings settings; private final NativeUsersStore usersStore; @Inject @@ -32,6 +33,7 @@ public class TransportDeleteUserAction extends HandledTransportAction) DeleteUserRequest::new); + this.settings = settings; this.usersStore = usersStore; } diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/TransportGetUsersAction.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/TransportGetUsersAction.java index 7e17cda75f0..63653408dd9 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/TransportGetUsersAction.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/TransportGetUsersAction.java @@ -32,6 +32,7 @@ import java.util.stream.Collectors; public class TransportGetUsersAction extends HandledTransportAction { + private final Settings settings; private final NativeUsersStore usersStore; private final ReservedRealm reservedRealm; @@ -39,6 +40,7 @@ public class TransportGetUsersAction extends HandledTransportAction { + private final Settings settings; private final NativeUsersStore usersStore; @Inject public TransportPutUserAction(Settings settings, ActionFilters actionFilters, NativeUsersStore usersStore, TransportService transportService) { super(settings, PutUserAction.NAME, transportService, actionFilters, PutUserRequest::new); + this.settings = settings; this.usersStore = usersStore; } diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/TransportSetEnabledAction.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/TransportSetEnabledAction.java index cbf505d9c67..17294e8c6f1 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/TransportSetEnabledAction.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/action/user/TransportSetEnabledAction.java @@ -27,6 +27,7 @@ import org.elasticsearch.xpack.security.authc.esnative.NativeUsersStore; */ public class TransportSetEnabledAction extends HandledTransportAction { + private final Settings settings; private final ThreadPool threadPool; private final NativeUsersStore usersStore; @@ -34,6 +35,7 @@ public class TransportSetEnabledAction extends HandledTransportAction state = new AtomicReference<>(State.INITIALIZED); + private final Settings settings; private final String nodeName; private final Client client; private final QueueConsumer queueConsumer; @@ -186,6 +187,7 @@ public class IndexAuditTrail extends AbstractComponent implements AuditTrail, Cl public IndexAuditTrail(Settings settings, Client client, ThreadPool threadPool, ClusterService clusterService) { super(settings); + this.settings = settings; this.threadPool = threadPool; this.clusterService = clusterService; this.nodeName = Node.NODE_NAME_SETTING.get(settings); diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/Realms.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/Realms.java index ce45ee2bedf..ea086ba57e5 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/Realms.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/Realms.java @@ -43,6 +43,7 @@ import org.elasticsearch.xpack.core.security.authc.kerberos.KerberosRealmSetting */ public class Realms extends AbstractComponent implements Iterable { + private final Settings settings; private final Environment env; private final Map factories; private final XPackLicenseState licenseState; @@ -59,6 +60,7 @@ public class Realms extends AbstractComponent implements Iterable { public Realms(Settings settings, Environment env, Map factories, XPackLicenseState licenseState, ThreadContext threadContext, ReservedRealm reservedRealm) throws Exception { super(settings); + this.settings = settings; this.env = env; this.factories = factories; this.licenseState = licenseState; diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/TokenService.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/TokenService.java index 8814a627087..ff9ee0fc4b8 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/TokenService.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/TokenService.java @@ -162,6 +162,7 @@ public final class TokenService extends AbstractComponent { private static final int MAX_RETRY_ATTEMPTS = 5; private final SecureRandom secureRandom = new SecureRandom(); + private final Settings settings; private final ClusterService clusterService; private final Clock clock; private final TimeValue expirationDelay; @@ -188,6 +189,7 @@ public final class TokenService extends AbstractComponent { secureRandom.nextBytes(saltArr); final SecureString tokenPassphrase = generateTokenKey(); + this.settings = settings; this.clock = clock.withZone(ZoneOffset.UTC); this.expirationDelay = TOKEN_EXPIRATION.get(settings); this.client = client; diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/esnative/NativeUsersStore.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/esnative/NativeUsersStore.java index 35912de4412..508b240afef 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/esnative/NativeUsersStore.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/esnative/NativeUsersStore.java @@ -79,6 +79,8 @@ public class NativeUsersStore extends AbstractComponent { public static final String INDEX_TYPE = "doc"; static final String USER_DOC_TYPE = "user"; public static final String RESERVED_USER_TYPE = "reserved-user"; + + private final Settings settings; private final Client client; private final ReservedUserInfo disabledDefaultUserInfo; private final ReservedUserInfo enabledDefaultUserInfo; @@ -87,6 +89,7 @@ public class NativeUsersStore extends AbstractComponent { public NativeUsersStore(Settings settings, Client client, SecurityIndexManager securityIndex) { super(settings); + this.settings = settings; this.client = client; this.securityIndex = securityIndex; final char[] emptyPasswordHash = Hasher.resolve(XPackSettings.PASSWORD_HASHING_ALGORITHM.get(settings)). diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/support/mapper/NativeRoleMappingStore.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/support/mapper/NativeRoleMappingStore.java index e41bcfbfe17..027346eadfe 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/support/mapper/NativeRoleMappingStore.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authc/support/mapper/NativeRoleMappingStore.java @@ -95,12 +95,14 @@ public class NativeRoleMappingStore extends AbstractComponent implements UserRol } }; + private final Settings settings; private final Client client; private final SecurityIndexManager securityIndex; private final List realmsToRefresh = new CopyOnWriteArrayList<>(); public NativeRoleMappingStore(Settings settings, Client client, SecurityIndexManager securityIndex) { super(settings); + this.settings = settings; this.client = client; this.securityIndex = securityIndex; } diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/FileRolesStore.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/FileRolesStore.java index ccc4f1fe3ea..83b184fce77 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/FileRolesStore.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/FileRolesStore.java @@ -57,6 +57,7 @@ public class FileRolesStore extends AbstractComponent implements BiConsumer>> listeners = new ArrayList<>(); @@ -71,6 +72,7 @@ public class FileRolesStore extends AbstractComponent implements BiConsumer> listener, XPackLicenseState licenseState) throws IOException { super(settings); + this.settings = settings; this.file = resolveFile(env); if (listener != null) { listeners.add(listener); diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/NativePrivilegeStore.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/NativePrivilegeStore.java index a1905db9599..e0b9ff7b443 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/NativePrivilegeStore.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/NativePrivilegeStore.java @@ -75,12 +75,14 @@ public class NativePrivilegeStore extends AbstractComponent { return a; }); + private final Settings settings; private final Client client; private final SecurityClient securityClient; private final SecurityIndexManager securityIndexManager; public NativePrivilegeStore(Settings settings, Client client, SecurityIndexManager securityIndexManager) { super(settings); + this.settings = settings; this.client = client; this.securityClient = new SecurityClient(client); this.securityIndexManager = securityIndexManager; diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/NativeRolesStore.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/NativeRolesStore.java index 6bbe5ac69f0..2c850bc5597 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/NativeRolesStore.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/authz/store/NativeRolesStore.java @@ -89,6 +89,7 @@ public class NativeRolesStore extends AbstractComponent implements BiConsumer