Skip to content

Remove unnecessary FeatureService dependencies #121496

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,12 @@
import org.elasticsearch.cluster.desirednodes.VersionConflictException;
import org.elasticsearch.cluster.metadata.DesiredNodes;
import org.elasticsearch.cluster.metadata.DesiredNodesMetadata;
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.routing.RerouteService;
import org.elasticsearch.cluster.routing.allocation.AllocationService;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.cluster.service.MasterServiceTaskQueue;
import org.elasticsearch.common.Priority;
import org.elasticsearch.common.util.concurrent.EsExecutors;
import org.elasticsearch.features.FeatureService;
import org.elasticsearch.injection.guice.Inject;
import org.elasticsearch.tasks.Task;
import org.elasticsearch.threadpool.ThreadPool;
Expand All @@ -42,18 +40,15 @@
public class TransportUpdateDesiredNodesAction extends TransportMasterNodeAction<UpdateDesiredNodesRequest, UpdateDesiredNodesResponse> {
private static final Logger logger = LogManager.getLogger(TransportUpdateDesiredNodesAction.class);

private final FeatureService featureService;
private final MasterServiceTaskQueue<UpdateDesiredNodesTask> taskQueue;

@Inject
public TransportUpdateDesiredNodesAction(
TransportService transportService,
ClusterService clusterService,
RerouteService rerouteService,
FeatureService featureService,
ThreadPool threadPool,
ActionFilters actionFilters,
IndexNameExpressionResolver indexNameExpressionResolver,
AllocationService allocationService
) {
super(
Expand All @@ -67,7 +62,6 @@ public TransportUpdateDesiredNodesAction(
UpdateDesiredNodesResponse::new,
EsExecutors.DIRECT_EXECUTOR_SERVICE
);
this.featureService = featureService;
this.taskQueue = clusterService.createTaskQueue(
"update-desired-nodes",
Priority.URGENT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ private static void blockForbiddenVersions(TransportVersion joiningTransportVers
* that are also present across the whole cluster as a result.
*/
private Set<String> calculateEffectiveClusterFeatures(DiscoveryNodes nodes, Map<String, Set<String>> nodeFeatures) {
if (featureService.featuresCanBeAssumedForNodes(nodes)) {
if (FeatureService.featuresCanBeAssumedForNodes(nodes)) {
Set<String> assumedFeatures = featureService.getNodeFeatures()
.values()
.stream()
Expand All @@ -382,7 +382,7 @@ private Set<String> calculateEffectiveClusterFeatures(DiscoveryNodes nodes, Map<
// add all assumed features to the featureset of all nodes of the next major version
nodeFeatures = new HashMap<>(nodeFeatures);
for (var node : nodes.getNodes().entrySet()) {
if (featureService.featuresCanBeAssumedForNode(node.getValue())) {
if (FeatureService.featuresCanBeAssumedForNode(node.getValue())) {
assert nodeFeatures.containsKey(node.getKey()) : "Node " + node.getKey() + " does not have any features";
nodeFeatures.computeIfPresent(node.getKey(), (k, v) -> {
var newFeatures = new HashSet<>(v);
Expand Down Expand Up @@ -525,7 +525,7 @@ private Set<String> enforceNodeFeatureBarrier(DiscoveryNode node, Set<String> ef
return newNodeFeatures;
}

if (featureService.featuresCanBeAssumedForNode(node)) {
if (FeatureService.featuresCanBeAssumedForNode(node)) {
// it might still be ok for this node to join if this node can have assumed features,
// and all the missing features are assumed
// we can get the NodeFeature object direct from this node's registered features
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ public Map<String, NodeFeature> getNodeFeatures() {
/**
* Returns {@code true} if {@code node} can have assumed features.
*/
public boolean featuresCanBeAssumedForNode(DiscoveryNode node) {
public static boolean featuresCanBeAssumedForNode(DiscoveryNode node) {
return ClusterFeatures.featuresCanBeAssumedForNode(node);
}

/**
* Returns {@code true} if one or more nodes in {@code nodes} can have assumed features.
*/
public boolean featuresCanBeAssumedForNodes(DiscoveryNodes nodes) {
public static boolean featuresCanBeAssumedForNodes(DiscoveryNodes nodes) {
return ClusterFeatures.featuresCanBeAssumedForNodes(nodes);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.core.Nullable;
import org.elasticsearch.core.Tuple;
import org.elasticsearch.features.FeatureService;
import org.elasticsearch.gateway.GatewayService;

import java.util.List;
Expand All @@ -50,7 +49,6 @@ public class HealthMetadataService {
private static final Logger logger = LogManager.getLogger(HealthMetadataService.class);

private final ClusterService clusterService;
private final FeatureService featureService;
private final ClusterStateListener clusterStateListener;
private final MasterServiceTaskQueue<UpsertHealthMetadataTask> taskQueue;
private volatile boolean enabled;
Expand All @@ -64,17 +62,16 @@ public class HealthMetadataService {
// ClusterState to maintain an up-to-date version of it across the cluster.
private volatile HealthMetadata localHealthMetadata;

private HealthMetadataService(ClusterService clusterService, FeatureService featureService, Settings settings) {
private HealthMetadataService(ClusterService clusterService, Settings settings) {
this.clusterService = clusterService;
this.featureService = featureService;
this.clusterStateListener = this::updateOnClusterStateChange;
this.enabled = ENABLED_SETTING.get(settings);
this.localHealthMetadata = initialHealthMetadata(settings);
this.taskQueue = clusterService.createTaskQueue("health metadata service", Priority.NORMAL, new Executor());
}

public static HealthMetadataService create(ClusterService clusterService, FeatureService featureService, Settings settings) {
HealthMetadataService healthMetadataService = new HealthMetadataService(clusterService, featureService, settings);
public static HealthMetadataService create(ClusterService clusterService, Settings settings) {
HealthMetadataService healthMetadataService = new HealthMetadataService(clusterService, settings);
healthMetadataService.registerListeners();
return healthMetadataService;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import org.elasticsearch.cluster.routing.RoutingNodes;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.util.set.Sets;
import org.elasticsearch.features.FeatureService;
import org.elasticsearch.health.Diagnosis;
import org.elasticsearch.health.HealthIndicatorDetails;
import org.elasticsearch.health.HealthIndicatorImpact;
Expand Down Expand Up @@ -73,11 +72,9 @@ public class DiskHealthIndicatorService implements HealthIndicatorService {
private static final String IMPACT_CLUSTER_FUNCTIONALITY_UNAVAILABLE_ID = "cluster_functionality_unavailable";

private final ClusterService clusterService;
private final FeatureService featureService;

public DiskHealthIndicatorService(ClusterService clusterService, FeatureService featureService) {
public DiskHealthIndicatorService(ClusterService clusterService) {
this.clusterService = clusterService;
this.featureService = featureService;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.features.FeatureService;
import org.elasticsearch.node.NodeClosedException;
import org.elasticsearch.persistent.AllocatedPersistentTask;
import org.elasticsearch.persistent.PersistentTaskParams;
Expand Down Expand Up @@ -60,22 +59,15 @@ public final class HealthNodeTaskExecutor extends PersistentTasksExecutor<Health

private final ClusterService clusterService;
private final PersistentTasksService persistentTasksService;
private final FeatureService featureService;
private final AtomicReference<HealthNode> currentTask = new AtomicReference<>();
private final ClusterStateListener taskStarter;
private final ClusterStateListener shutdownListener;
private volatile boolean enabled;

private HealthNodeTaskExecutor(
ClusterService clusterService,
PersistentTasksService persistentTasksService,
FeatureService featureService,
Settings settings
) {
private HealthNodeTaskExecutor(ClusterService clusterService, PersistentTasksService persistentTasksService, Settings settings) {
super(TASK_NAME, clusterService.threadPool().executor(ThreadPool.Names.MANAGEMENT));
this.clusterService = clusterService;
this.persistentTasksService = persistentTasksService;
this.featureService = featureService;
this.taskStarter = this::startTask;
this.shutdownListener = this::shuttingDown;
this.enabled = ENABLED_SETTING.get(settings);
Expand All @@ -84,16 +76,10 @@ private HealthNodeTaskExecutor(
public static HealthNodeTaskExecutor create(
ClusterService clusterService,
PersistentTasksService persistentTasksService,
FeatureService featureService,
Settings settings,
ClusterSettings clusterSettings
) {
HealthNodeTaskExecutor healthNodeTaskExecutor = new HealthNodeTaskExecutor(
clusterService,
persistentTasksService,
featureService,
settings
);
HealthNodeTaskExecutor healthNodeTaskExecutor = new HealthNodeTaskExecutor(clusterService, persistentTasksService, settings);
healthNodeTaskExecutor.registerListeners(clusterSettings);
return healthNodeTaskExecutor;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
import org.elasticsearch.env.NodeEnvironment;
import org.elasticsearch.env.ShardLock;
import org.elasticsearch.env.ShardLockObtainFailedException;
import org.elasticsearch.features.FeatureService;
import org.elasticsearch.gateway.MetaStateService;
import org.elasticsearch.gateway.MetadataStateFormat;
import org.elasticsearch.index.CloseUtils;
Expand Down Expand Up @@ -236,7 +235,6 @@ public class IndicesService extends AbstractLifecycleComponent
private final ScriptService scriptService;
private final ClusterService clusterService;
private final Client client;
private final FeatureService featureService;
private volatile Map<String, IndexService> indices = Map.of();
private final Map<Index, List<PendingDelete>> pendingDeletes = new HashMap<>();
private final AtomicInteger numUncompletedDeletes = new AtomicInteger();
Expand Down Expand Up @@ -309,7 +307,6 @@ protected void doStart() {
this.scriptService = builder.scriptService;
this.clusterService = builder.clusterService;
this.client = builder.client;
this.featureService = builder.featureService;
this.idFieldDataEnabled = INDICES_ID_FIELD_DATA_ENABLED_SETTING.get(clusterService.getSettings());
clusterService.getClusterSettings().addSettingsUpdateConsumer(INDICES_ID_FIELD_DATA_ENABLED_SETTING, this::setIdFieldDataEnabled);
this.indicesFieldDataCache = new IndicesFieldDataCache(settings, new IndexFieldDataCache.Listener() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.elasticsearch.common.util.BigArrays;
import org.elasticsearch.core.Nullable;
import org.elasticsearch.env.NodeEnvironment;
import org.elasticsearch.features.FeatureService;
import org.elasticsearch.gateway.MetaStateService;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.SlowLogFieldProvider;
Expand Down Expand Up @@ -67,7 +66,6 @@ public class IndicesServiceBuilder {
ScriptService scriptService;
ClusterService clusterService;
Client client;
FeatureService featureService;
MetaStateService metaStateService;
Collection<Function<IndexSettings, Optional<EngineFactory>>> engineFactoryProviders = List.of();
Map<String, IndexStorePlugin.DirectoryFactory> directoryFactories = Map.of();
Expand Down Expand Up @@ -173,11 +171,6 @@ public IndicesServiceBuilder client(Client client) {
return this;
}

public IndicesServiceBuilder featureService(FeatureService featureService) {
this.featureService = featureService;
return this;
}

public IndicesServiceBuilder metaStateService(MetaStateService metaStateService) {
this.metaStateService = metaStateService;
return this;
Expand Down Expand Up @@ -230,7 +223,6 @@ public IndicesService build() {
Objects.requireNonNull(scriptService);
Objects.requireNonNull(clusterService);
Objects.requireNonNull(client);
Objects.requireNonNull(featureService);
Objects.requireNonNull(metaStateService);
Objects.requireNonNull(engineFactoryProviders);
Objects.requireNonNull(directoryFactories);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,6 @@ public Map<String, String> searchFields() {
.scriptService(scriptService)
.clusterService(clusterService)
.client(client)
.featureService(featureService)
.metaStateService(metaStateService)
.valuesSourceRegistry(searchModule.getValuesSourceRegistry())
.requestCacheKeyDifferentiator(searchModule.getRequestCacheKeyDifferentiator())
Expand Down Expand Up @@ -1147,7 +1146,6 @@ public Map<String, String> searchFields() {
clusterService,
threadPool,
systemIndices,
featureService,
clusterModule.getIndexNameExpressionResolver(),
metadataUpdateSettingsService,
metadataCreateIndexService
Expand All @@ -1161,7 +1159,6 @@ public Map<String, String> searchFields() {
discoveryModule.getCoordinator(),
clusterService,
transportService,
featureService,
threadPool,
telemetryProvider,
repositoriesService,
Expand Down Expand Up @@ -1333,7 +1330,6 @@ private Module loadDiagnosticServices(
Coordinator coordinator,
ClusterService clusterService,
TransportService transportService,
FeatureService featureService,
ThreadPool threadPool,
TelemetryProvider telemetryProvider,
RepositoriesService repositoriesService,
Expand All @@ -1351,7 +1347,7 @@ private Module loadDiagnosticServices(
var serverHealthIndicatorServices = Stream.of(
new StableMasterHealthIndicatorService(coordinationDiagnosticsService, clusterService),
new RepositoryIntegrityHealthIndicatorService(clusterService),
new DiskHealthIndicatorService(clusterService, featureService),
new DiskHealthIndicatorService(clusterService),
new ShardsCapacityHealthIndicatorService(clusterService),
fileSettingsHealthIndicatorService
);
Expand All @@ -1369,7 +1365,7 @@ private Module loadDiagnosticServices(
healthService,
telemetryProvider
);
HealthMetadataService healthMetadataService = HealthMetadataService.create(clusterService, featureService, settings);
HealthMetadataService healthMetadataService = HealthMetadataService.create(clusterService, settings);

List<HealthTracker<?>> healthTrackers = List.of(
new DiskHealthTracker(nodeService, clusterService),
Expand Down Expand Up @@ -1644,7 +1640,6 @@ private Module loadPersistentTasksService(
ClusterService clusterService,
ThreadPool threadPool,
SystemIndices systemIndices,
FeatureService featureService,
IndexNameExpressionResolver indexNameExpressionResolver,
MetadataUpdateSettingsService metadataUpdateSettingsService,
MetadataCreateIndexService metadataCreateIndexService
Expand All @@ -1661,7 +1656,6 @@ private Module loadPersistentTasksService(
HealthNodeTaskExecutor healthNodeTaskExecutor = HealthNodeTaskExecutor.create(
clusterService,
persistentTasksService,
featureService,
settingsModule.getSettings(),
clusterService.getClusterSettings()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,24 +75,6 @@ public interface BucketOrdsEnum {
* Read the current value.
*/
void readValue(BytesRef dest);

/**
* An {@linkplain BucketOrdsEnum} that is empty.
*/
BucketOrdsEnum EMPTY = new BucketOrdsEnum() {
@Override
public boolean next() {
return false;
}

@Override
public long ord() {
return 0;
}

@Override
public void readValue(BytesRef dest) {}
};
}

/**
Expand Down
Loading