Skip to content

Commit c349636

Browse files
authored
Remove the use of AbstractLifecycleComponent constructor Backport#37488 (#37522)
The AbstractLifecycleComponent used to extend AbstractComponent, so it had to pass settings to the constructor of its supper class. It no longer extends the AbstractComponent so there is no need for this constructor There is also no need for AbstractLifecycleComponent subclasses to have Settings in their constructors if they were only passing it over to super constructor. This is part 1. which will be backported to 6.x with a migration guide/deprecation log. part 2 will have this constructor removed in 7 relates #35560 relates #34488
1 parent 3cdfcb4 commit c349636

File tree

41 files changed

+20
-56
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+20
-56
lines changed

plugins/discovery-azure-classic/src/main/java/org/elasticsearch/cloud/azure/classic/management/AzureComputeServiceImpl.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ public class AzureComputeServiceImpl extends AbstractLifecycleComponent
5252
private final String serviceName;
5353

5454
public AzureComputeServiceImpl(Settings settings) {
55-
super(settings);
5655
String subscriptionId = getRequiredSetting(settings, Management.SUBSCRIPTION_ID_SETTING);
5756

5857
serviceName = getRequiredSetting(settings, Management.SERVICE_NAME_SETTING);

plugins/discovery-gce/src/main/java/org/elasticsearch/cloud/gce/GceMetadataService.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ public class GceMetadataService extends AbstractLifecycleComponent {
5353
private HttpTransport gceHttpTransport;
5454

5555
public GceMetadataService(Settings settings) {
56-
super(settings);
5756
this.settings = settings;
5857
}
5958

server/src/main/java/org/elasticsearch/cluster/NodeConnectionsService.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ public class NodeConnectionsService extends AbstractLifecycleComponent {
7575

7676
@Inject
7777
public NodeConnectionsService(Settings settings, ThreadPool threadPool, TransportService transportService) {
78-
super(settings);
7978
this.threadPool = threadPool;
8079
this.transportService = transportService;
8180
this.reconnectInterval = NodeConnectionsService.CLUSTER_NODE_RECONNECT_INTERVAL_SETTING.get(settings);

server/src/main/java/org/elasticsearch/cluster/routing/DelayedAllocationService.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import org.elasticsearch.cluster.service.ClusterService;
3131
import org.elasticsearch.common.component.AbstractLifecycleComponent;
3232
import org.elasticsearch.common.inject.Inject;
33-
import org.elasticsearch.common.settings.Settings;
3433
import org.elasticsearch.common.unit.TimeValue;
3534
import org.elasticsearch.common.util.concurrent.AbstractRunnable;
3635
import org.elasticsearch.common.util.concurrent.FutureUtils;
@@ -130,9 +129,8 @@ public void onFailure(String source, Exception e) {
130129
}
131130

132131
@Inject
133-
public DelayedAllocationService(Settings settings, ThreadPool threadPool, ClusterService clusterService,
132+
public DelayedAllocationService(ThreadPool threadPool, ClusterService clusterService,
134133
AllocationService allocationService) {
135-
super(settings);
136134
this.threadPool = threadPool;
137135
this.clusterService = clusterService;
138136
this.allocationService = allocationService;

server/src/main/java/org/elasticsearch/cluster/routing/RoutingService.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import org.elasticsearch.common.Priority;
3131
import org.elasticsearch.common.component.AbstractLifecycleComponent;
3232
import org.elasticsearch.common.inject.Inject;
33-
import org.elasticsearch.common.settings.Settings;
3433

3534
import java.util.concurrent.atomic.AtomicBoolean;
3635

@@ -57,8 +56,7 @@ public class RoutingService extends AbstractLifecycleComponent {
5756
private AtomicBoolean rerouting = new AtomicBoolean();
5857

5958
@Inject
60-
public RoutingService(Settings settings, ClusterService clusterService, AllocationService allocationService) {
61-
super(settings);
59+
public RoutingService(ClusterService clusterService, AllocationService allocationService) {
6260
this.clusterService = clusterService;
6361
this.allocationService = allocationService;
6462
}

server/src/main/java/org/elasticsearch/cluster/service/ClusterApplierService.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ public class ClusterApplierService extends AbstractLifecycleComponent implements
104104

105105
public ClusterApplierService(String nodeName, Settings settings, ClusterSettings clusterSettings, ThreadPool threadPool,
106106
Supplier<ClusterState.Builder> stateBuilderSupplier) {
107-
super(settings);
108107
this.clusterSettings = clusterSettings;
109108
this.threadPool = threadPool;
110109
this.state = new AtomicReference<>();

server/src/main/java/org/elasticsearch/cluster/service/ClusterService.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ public class ClusterService extends AbstractLifecycleComponent {
7676

7777
public ClusterService(Settings settings, ClusterSettings clusterSettings, ThreadPool threadPool,
7878
Map<String, Supplier<ClusterState.Custom>> initialClusterStateCustoms) {
79-
super(settings);
8079
this.settings = settings;
8180
this.nodeName = Node.NODE_NAME_SETTING.get(settings);
8281
this.masterService = new MasterService(nodeName, settings, threadPool);

server/src/main/java/org/elasticsearch/cluster/service/MasterService.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ public class MasterService extends AbstractLifecycleComponent {
8585
private volatile Batcher taskBatcher;
8686

8787
public MasterService(String nodeName, Settings settings, ThreadPool threadPool) {
88-
super(settings);
8988
this.nodeName = nodeName;
9089
// TODO: introduce a dedicated setting for master service
9190
this.slowTaskLoggingThreshold = CLUSTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get(settings);

server/src/main/java/org/elasticsearch/common/component/AbstractLifecycleComponent.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ public abstract class AbstractLifecycleComponent implements LifecycleComponent {
3434

3535
private final List<LifecycleListener> listeners = new CopyOnWriteArrayList<>();
3636

37+
protected AbstractLifecycleComponent() {}
38+
39+
/**
40+
* @deprecated the settings parameters are not used, therefore the use of this constructor is deprecated.
41+
* Going to be removed in subsequent versions. The parameterless constructor should be used instead.
42+
*/
43+
@Deprecated
3744
protected AbstractLifecycleComponent(Settings settings) {
3845
// TODO drop settings from ctor
3946
}

server/src/main/java/org/elasticsearch/discovery/single/SingleNodeDiscovery.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public class SingleNodeDiscovery extends AbstractLifecycleComponent implements D
5757

5858
public SingleNodeDiscovery(final Settings settings, final TransportService transportService,
5959
final MasterService masterService, final ClusterApplier clusterApplier) {
60-
super(Objects.requireNonNull(settings));
60+
Objects.requireNonNull(settings);
6161
this.clusterName = ClusterName.CLUSTER_NAME_SETTING.get(settings);
6262
this.transportService = Objects.requireNonNull(transportService);
6363
masterService.setClusterStateSupplier(() -> clusterState);

0 commit comments

Comments
 (0)