Skip to content
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

Remove the use of AbstracLifecycleComponent constructor Backport#37488 #37522

Merged
merged 3 commits into from
Jan 17, 2019
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -52,7 +52,6 @@ public class AzureComputeServiceImpl extends AbstractLifecycleComponent
private final String serviceName;

public AzureComputeServiceImpl(Settings settings) {
super(settings);
String subscriptionId = getRequiredSetting(settings, Management.SUBSCRIPTION_ID_SETTING);

serviceName = getRequiredSetting(settings, Management.SERVICE_NAME_SETTING);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ public class GceMetadataService extends AbstractLifecycleComponent {
private HttpTransport gceHttpTransport;

public GceMetadataService(Settings settings) {
super(settings);
this.settings = settings;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ public class NodeConnectionsService extends AbstractLifecycleComponent {

@Inject
public NodeConnectionsService(Settings settings, ThreadPool threadPool, TransportService transportService) {
super(settings);
this.threadPool = threadPool;
this.transportService = transportService;
this.reconnectInterval = NodeConnectionsService.CLUSTER_NODE_RECONNECT_INTERVAL_SETTING.get(settings);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.component.AbstractLifecycleComponent;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.util.concurrent.AbstractRunnable;
import org.elasticsearch.common.util.concurrent.FutureUtils;
Expand Down Expand Up @@ -130,9 +129,8 @@ public void onFailure(String source, Exception e) {
}

@Inject
public DelayedAllocationService(Settings settings, ThreadPool threadPool, ClusterService clusterService,
public DelayedAllocationService(ThreadPool threadPool, ClusterService clusterService,
AllocationService allocationService) {
super(settings);
this.threadPool = threadPool;
this.clusterService = clusterService;
this.allocationService = allocationService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.elasticsearch.common.Priority;
import org.elasticsearch.common.component.AbstractLifecycleComponent;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;

import java.util.concurrent.atomic.AtomicBoolean;

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

@Inject
public RoutingService(Settings settings, ClusterService clusterService, AllocationService allocationService) {
super(settings);
public RoutingService(ClusterService clusterService, AllocationService allocationService) {
this.clusterService = clusterService;
this.allocationService = allocationService;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ public class ClusterApplierService extends AbstractLifecycleComponent implements

public ClusterApplierService(String nodeName, Settings settings, ClusterSettings clusterSettings, ThreadPool threadPool,
Supplier<ClusterState.Builder> stateBuilderSupplier) {
super(settings);
this.clusterSettings = clusterSettings;
this.threadPool = threadPool;
this.state = new AtomicReference<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ public class ClusterService extends AbstractLifecycleComponent {

public ClusterService(Settings settings, ClusterSettings clusterSettings, ThreadPool threadPool,
Map<String, Supplier<ClusterState.Custom>> initialClusterStateCustoms) {
super(settings);
this.settings = settings;
this.nodeName = Node.NODE_NAME_SETTING.get(settings);
this.masterService = new MasterService(nodeName, settings, threadPool);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ public class MasterService extends AbstractLifecycleComponent {
private volatile Batcher taskBatcher;

public MasterService(String nodeName, Settings settings, ThreadPool threadPool) {
super(settings);
this.nodeName = nodeName;
// TODO: introduce a dedicated setting for master service
this.slowTaskLoggingThreshold = CLUSTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING.get(settings);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ public abstract class AbstractLifecycleComponent implements LifecycleComponent {

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

protected AbstractLifecycleComponent() {}

/**
* @deprecated the settings parameters are not used, therefore the use of this constructor is deprecated.
pgomulka marked this conversation as resolved.
Show resolved Hide resolved
* Going to be removed in subsequent versions. The parameterless constructor should be used instead.
*/
@Deprecated
protected AbstractLifecycleComponent(Settings settings) {
// TODO drop settings from ctor
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,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));
Objects.requireNonNull(settings);
this.clusterName = ClusterName.CLUSTER_NAME_SETTING.get(settings);
this.transportService = Objects.requireNonNull(transportService);
masterService.setClusterStateSupplier(() -> clusterState);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ public ZenDiscovery(Settings settings, ThreadPool threadPool, TransportService t
NamedWriteableRegistry namedWriteableRegistry, MasterService masterService, ClusterApplier clusterApplier,
ClusterSettings clusterSettings, UnicastHostsProvider hostsProvider, AllocationService allocationService,
Collection<BiConsumer<DiscoveryNode, ClusterState>> onJoinValidators) {
super(settings);
this.onJoinValidators = addBuiltInJoinValidators(onJoinValidators);
this.masterService = masterService;
this.clusterApplier = clusterApplier;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ public GatewayService(Settings settings, AllocationService allocationService, Cl
ThreadPool threadPool, GatewayMetaState metaState,
TransportNodesListGatewayMetaState listGatewayMetaState,
IndicesService indicesService) {
super(settings);
this.gateway = new Gateway(settings, clusterService, listGatewayMetaState,
indicesService);
this.allocationService = allocationService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ public IndicesService(Settings settings, PluginsService pluginsService, NodeEnvi
ScriptService scriptService, Client client, MetaStateService metaStateService,
Collection<Function<IndexSettings, Optional<EngineFactory>>> engineFactoryProviders,
Map<String, Function<IndexSettings, IndexStore>> indexStoreFactories) {
super(settings);
this.settings = settings;
this.threadPool = threadPool;
this.pluginsService = pluginsService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.apache.logging.log4j.Logger;
import org.elasticsearch.common.breaker.CircuitBreaker;
import org.elasticsearch.common.component.AbstractLifecycleComponent;
import org.elasticsearch.common.settings.Settings;

/**
* Interface for Circuit Breaker services, which provide breakers to classes
Expand All @@ -32,8 +31,7 @@
public abstract class CircuitBreakerService extends AbstractLifecycleComponent {
private static final Logger logger = LogManager.getLogger(CircuitBreakerService.class);

protected CircuitBreakerService(Settings settings) {
super(settings);
protected CircuitBreakerService() {
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public class HierarchyCircuitBreakerService extends CircuitBreakerService {
private final AtomicLong parentTripCount = new AtomicLong(0);

public HierarchyCircuitBreakerService(Settings settings, ClusterSettings clusterSettings) {
super(settings);
super();
this.fielddataSettings = new BreakerSettings(CircuitBreaker.FIELDDATA,
FIELDDATA_CIRCUIT_BREAKER_LIMIT_SETTING.get(settings).getBytes(),
FIELDDATA_CIRCUIT_BREAKER_OVERHEAD_SETTING.get(settings),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import org.elasticsearch.common.breaker.CircuitBreaker;
import org.elasticsearch.common.breaker.NoopCircuitBreaker;
import org.elasticsearch.common.settings.Settings;

/**
* Class that returns a breaker that never breaks
Expand All @@ -31,7 +30,7 @@ public class NoneCircuitBreakerService extends CircuitBreakerService {
private final CircuitBreaker breaker = new NoopCircuitBreaker(CircuitBreaker.FIELDDATA);

public NoneCircuitBreakerService() {
super(Settings.EMPTY);
super();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ public IndicesClusterStateService(
final SnapshotShardsService snapshotShardsService,
final PrimaryReplicaSyncer primaryReplicaSyncer,
final Consumer<ShardId> globalCheckpointSyncer) {
super(settings);
this.settings = settings;
this.buildInIndexListener =
Arrays.asList(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public class MonitorService extends AbstractLifecycleComponent {

public MonitorService(Settings settings, NodeEnvironment nodeEnvironment, ThreadPool threadPool,
ClusterInfoService clusterInfoService) throws IOException {
super(settings);
this.jvmGcMonitorService = new JvmGcMonitorService(settings, threadPool);
this.osService = new OsService(settings);
this.processService = new ProcessService(settings);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ public String toString() {
}

public JvmGcMonitorService(Settings settings, ThreadPool threadPool) {
super(settings);
this.threadPool = threadPool;

this.enabled = ENABLED_SETTING.get(settings);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent imp
* @param settings Settings for the node this repository object is created on
*/
protected BlobStoreRepository(RepositoryMetaData metadata, Settings settings, NamedXContentRegistry namedXContentRegistry) {
super(settings);
this.settings = settings;
this.metadata = metadata;
this.namedXContentRegistry = namedXContentRegistry;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ public class SearchService extends AbstractLifecycleComponent implements IndexEv
public SearchService(ClusterService clusterService, IndicesService indicesService,
ThreadPool threadPool, ScriptService scriptService, BigArrays bigArrays, FetchPhase fetchPhase,
ResponseCollectorService responseCollectorService) {
super(clusterService.getSettings());
Settings settings = clusterService.getSettings();
this.threadPool = threadPool;
this.clusterService = clusterService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ public class SnapshotShardsService extends AbstractLifecycleComponent implements
public SnapshotShardsService(Settings settings, ClusterService clusterService, SnapshotsService snapshotsService,
ThreadPool threadPool, TransportService transportService, IndicesService indicesService,
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
super(settings);
this.settings = settings;
this.indicesService = indicesService;
this.snapshotsService = snapshotsService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ public class SnapshotsService extends AbstractLifecycleComponent implements Clus
@Inject
public SnapshotsService(Settings settings, ClusterService clusterService, IndexNameExpressionResolver indexNameExpressionResolver,
RepositoriesService repositoriesService, ThreadPool threadPool) {
super(settings);
this.clusterService = clusterService;
this.indexNameExpressionResolver = indexNameExpressionResolver;
this.repositoriesService = repositoriesService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ public abstract class TcpTransport extends AbstractLifecycleComponent implements
public TcpTransport(String transportName, Settings settings, Version version, ThreadPool threadPool,
PageCacheRecycler pageCacheRecycler, CircuitBreakerService circuitBreakerService,
NamedWriteableRegistry namedWriteableRegistry, NetworkService networkService) {
super(settings);
this.settings = settings;
this.profileSettings = getProfileSettings(settings);
this.version = version;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ public TransportService(Settings settings, Transport transport, ThreadPool threa
public TransportService(Settings settings, Transport transport, ThreadPool threadPool, TransportInterceptor transportInterceptor,
Function<BoundTransportAddress, DiscoveryNode> localNodeFactory, @Nullable ClusterSettings clusterSettings,
Set<String> taskHeaders, ConnectionManager connectionManager) {
super(settings);
// The only time we do not want to validate node connections is when this is a transport client using the simple node sampler
this.validateConnections = TransportClient.CLIENT_TYPE.equals(settings.get(Client.CLIENT_TYPE_SETTING_S.getKey())) == false ||
TransportClient.CLIENT_TRANSPORT_SNIFF.get(settings);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ public enum Frequency {

@Inject
public ResourceWatcherService(Settings settings, ThreadPool threadPool) {
super(settings);
this.enabled = ENABLED.get(settings);
this.threadPool = threadPool;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void createDelayedAllocationService() {
threadPool = new TestThreadPool(getTestName());
clusterService = mock(ClusterService.class);
allocationService = createAllocationService(Settings.EMPTY, new DelayedShardsMockGatewayAllocator());
delayedAllocationService = new TestDelayAllocationService(Settings.EMPTY, threadPool, clusterService, allocationService);
delayedAllocationService = new TestDelayAllocationService(threadPool, clusterService, allocationService);
verify(clusterService).addListener(delayedAllocationService);
}

Expand Down Expand Up @@ -464,9 +464,9 @@ public void testDelayedUnassignedScheduleRerouteRescheduledOnShorterDelay() thro
private static class TestDelayAllocationService extends DelayedAllocationService {
private volatile long nanoTimeOverride = -1L;

TestDelayAllocationService(Settings settings, ThreadPool threadPool, ClusterService clusterService,
AllocationService allocationService) {
super(settings, threadPool, clusterService, allocationService);
private TestDelayAllocationService(ThreadPool threadPool, ClusterService clusterService,
AllocationService allocationService) {
super(threadPool, clusterService, allocationService);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

package org.elasticsearch.cluster.routing;

import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.cluster.ESAllocationTestCase;
import org.junit.Before;

Expand Down Expand Up @@ -47,7 +46,7 @@ private class TestRoutingService extends RoutingService {
private AtomicBoolean rerouted = new AtomicBoolean();

TestRoutingService() {
super(Settings.EMPTY, null, null);
super(null, null);
}

public boolean hasReroutedAndClear() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,6 @@ public void tearDown() throws Exception {
}

static class FakeHttpTransport extends AbstractLifecycleComponent implements HttpServerTransport {
FakeHttpTransport() {
super(null);
}
@Override
protected void doStart() {}
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3111,7 +3111,6 @@ private abstract static class RestoreOnlyRepository extends AbstractLifecycleCom
private final String indexName;

RestoreOnlyRepository(String indexName) {
super(Settings.EMPTY);
this.indexName = indexName;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,6 @@ private static final class TestHttpServerTransport extends AbstractLifecycleComp
HttpServerTransport {

TestHttpServerTransport() {
super(Settings.EMPTY);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public Collection<Object> createComponents(
return emptyList();
}

CcrRestoreSourceService restoreSourceService = new CcrRestoreSourceService(settings);
CcrRestoreSourceService restoreSourceService = new CcrRestoreSourceService();
this.restoreSourceService.set(restoreSourceService);
return Arrays.asList(
ccrLicenseChecker,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class CcrRepositoryManager extends AbstractLifecycleComponent {
private final RemoteSettingsUpdateListener updateListener;

CcrRepositoryManager(Settings settings, ClusterService clusterService, NodeClient client) {
super(settings);
this.client = client;
updateListener = new RemoteSettingsUpdateListener(settings);
updateListener.listenForUpdates(clusterService.getClusterSettings());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ public class CcrRepository extends AbstractLifecycleComponent implements Reposit
private final CcrLicenseChecker ccrLicenseChecker;

public CcrRepository(RepositoryMetaData metadata, Client client, CcrLicenseChecker ccrLicenseChecker, Settings settings) {
super(settings);
this.metadata = metadata;
assert metadata.name().startsWith(NAME_PREFIX) : "CcrRepository metadata.name() must start with: " + NAME_PREFIX;
this.remoteClusterAlias = Strings.split(metadata.name(), NAME_PREFIX)[1];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ public class CcrRestoreSourceService extends AbstractLifecycleComponent implemen
private final CopyOnWriteArrayList<Consumer<String>> openSessionListeners = new CopyOnWriteArrayList<>();
private final CopyOnWriteArrayList<Consumer<String>> closeSessionListeners = new CopyOnWriteArrayList<>();

public CcrRestoreSourceService(Settings settings) {
super(settings);
}

@Override
public synchronized void afterIndexShardClosed(ShardId shardId, @Nullable IndexShard indexShard, Settings indexSettings) {
if (indexShard != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class CcrRestoreSourceServiceTests extends IndexShardTestCase {
@Before
public void setUp() throws Exception {
super.setUp();
restoreSourceService = new CcrRestoreSourceService(Settings.EMPTY);
restoreSourceService = new CcrRestoreSourceService();
}

public void testOpenSession() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ private static void deprecateMinusOne(final TimeValue value) {

MonitoringService(Settings settings, ClusterService clusterService, ThreadPool threadPool,
Set<Collector> collectors, Exporters exporters) {
super(settings);
this.clusterService = Objects.requireNonNull(clusterService);
this.threadPool = Objects.requireNonNull(threadPool);
this.collectors = Objects.requireNonNull(collectors);
Expand Down
Loading