From fbd3cab41078b47bfd468210f42a0719649fde11 Mon Sep 17 00:00:00 2001 From: David Turner Date: Tue, 13 Nov 2018 15:20:49 +0000 Subject: [PATCH] [Zen2] Remove AbstractComponent usage (#35483) AbstractComponent was deprecated in #35140 and is looking like it will be removed at some point by #34888. Today all it does is provide a logger. This change removes the usages of AbstractComponent that live solely in the zen2 feature branch to avoid some future merge pain, and replaces it where necessary with some directly-created loggers. --- .../cluster/coordination/CoordinationState.java | 7 +++++-- .../cluster/coordination/ElectionSchedulerFactory.java | 7 +++++-- .../cluster/coordination/FollowersChecker.java | 7 +++++-- .../elasticsearch/cluster/coordination/JoinHelper.java | 7 +++++-- .../cluster/coordination/LeaderChecker.java | 9 ++++++--- .../cluster/coordination/PreVoteCollector.java | 7 +++++-- .../elasticsearch/cluster/coordination/Publication.java | 7 +++++-- .../coordination/PublicationTransportHandler.java | 7 +++++-- .../cluster/coordination/Reconfigurator.java | 7 +++++-- .../discovery/HandshakingTransportAddressConnector.java | 7 +++++-- .../java/org/elasticsearch/discovery/PeerFinder.java | 7 +++++-- .../cluster/coordination/CoordinatorTests.java | 7 +++++-- .../cluster/coordination/DeterministicTaskQueue.java | 7 +++++-- 13 files changed, 66 insertions(+), 27 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/cluster/coordination/CoordinationState.java b/server/src/main/java/org/elasticsearch/cluster/coordination/CoordinationState.java index fc8520bbf3a..f89a6784e20 100644 --- a/server/src/main/java/org/elasticsearch/cluster/coordination/CoordinationState.java +++ b/server/src/main/java/org/elasticsearch/cluster/coordination/CoordinationState.java @@ -18,10 +18,11 @@ */ package org.elasticsearch.cluster.coordination; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.ClusterState.VotingConfiguration; import org.elasticsearch.cluster.node.DiscoveryNode; -import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.settings.Settings; import java.util.Collection; @@ -34,7 +35,9 @@ import java.util.Optional; * The core class of the cluster state coordination algorithm, directly implementing the * formal model */ -public class CoordinationState extends AbstractComponent { +public class CoordinationState { + + private static final Logger logger = LogManager.getLogger(CoordinationState.class); private final DiscoveryNode localNode; diff --git a/server/src/main/java/org/elasticsearch/cluster/coordination/ElectionSchedulerFactory.java b/server/src/main/java/org/elasticsearch/cluster/coordination/ElectionSchedulerFactory.java index 6b7a0f8db4d..64980cba8f0 100644 --- a/server/src/main/java/org/elasticsearch/cluster/coordination/ElectionSchedulerFactory.java +++ b/server/src/main/java/org/elasticsearch/cluster/coordination/ElectionSchedulerFactory.java @@ -19,9 +19,10 @@ package org.elasticsearch.cluster.coordination; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; import org.elasticsearch.common.SuppressForbidden; -import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.lease.Releasable; import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Setting.Property; @@ -43,7 +44,9 @@ import java.util.concurrent.atomic.AtomicLong; * so that if elections are failing due to a network partition that lasts for a long time then when the partition heals there is an election * attempt reasonably quickly. */ -public class ElectionSchedulerFactory extends AbstractComponent { +public class ElectionSchedulerFactory { + + private static final Logger logger = LogManager.getLogger(ElectionSchedulerFactory.class); private static final String ELECTION_INITIAL_TIMEOUT_SETTING_KEY = "cluster.election.initial_timeout"; private static final String ELECTION_BACK_OFF_TIME_SETTING_KEY = "cluster.election.back_off_time"; diff --git a/server/src/main/java/org/elasticsearch/cluster/coordination/FollowersChecker.java b/server/src/main/java/org/elasticsearch/cluster/coordination/FollowersChecker.java index 467f7f5c804..b7f99df31c0 100644 --- a/server/src/main/java/org/elasticsearch/cluster/coordination/FollowersChecker.java +++ b/server/src/main/java/org/elasticsearch/cluster/coordination/FollowersChecker.java @@ -19,13 +19,14 @@ package org.elasticsearch.cluster.coordination; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.coordination.Coordinator.Mode; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNodes; -import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.settings.Setting; @@ -62,7 +63,9 @@ import static org.elasticsearch.common.util.concurrent.ConcurrentCollections.new * considering a follower to be faulty, to allow for a brief network partition or a long GC cycle to occur without triggering the removal of * a node and the consequent shard reallocation. */ -public class FollowersChecker extends AbstractComponent { +public class FollowersChecker { + + private static final Logger logger = LogManager.getLogger(FollowersChecker.class); public static final String FOLLOWER_CHECK_ACTION_NAME = "internal:coordination/fault_detection/follower_check"; diff --git a/server/src/main/java/org/elasticsearch/cluster/coordination/JoinHelper.java b/server/src/main/java/org/elasticsearch/cluster/coordination/JoinHelper.java index fcd98f2a5a2..2b161f96775 100644 --- a/server/src/main/java/org/elasticsearch/cluster/coordination/JoinHelper.java +++ b/server/src/main/java/org/elasticsearch/cluster/coordination/JoinHelper.java @@ -18,6 +18,8 @@ */ package org.elasticsearch.cluster.coordination; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.ClusterStateTaskConfig; @@ -28,7 +30,6 @@ import org.elasticsearch.cluster.routing.allocation.AllocationService; import org.elasticsearch.cluster.service.MasterService; import org.elasticsearch.common.Priority; import org.elasticsearch.common.collect.Tuple; -import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; @@ -57,7 +58,9 @@ import java.util.function.BiConsumer; import java.util.function.Function; import java.util.function.LongSupplier; -public class JoinHelper extends AbstractComponent { +public class JoinHelper { + + private static final Logger logger = LogManager.getLogger(JoinHelper.class); public static final String JOIN_ACTION_NAME = "internal:cluster/coordination/join"; public static final String START_JOIN_ACTION_NAME = "internal:cluster/coordination/start_join"; diff --git a/server/src/main/java/org/elasticsearch/cluster/coordination/LeaderChecker.java b/server/src/main/java/org/elasticsearch/cluster/coordination/LeaderChecker.java index 7a165ceb643..cccbde35c18 100644 --- a/server/src/main/java/org/elasticsearch/cluster/coordination/LeaderChecker.java +++ b/server/src/main/java/org/elasticsearch/cluster/coordination/LeaderChecker.java @@ -19,12 +19,13 @@ package org.elasticsearch.cluster.coordination; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.common.Nullable; -import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.io.stream.StreamOutput; import org.elasticsearch.common.lease.Releasable; @@ -56,7 +57,9 @@ import java.util.concurrent.atomic.AtomicReference; * temporarily stand down on occasion, e.g. if it needs to move to a higher term. On deciding that the leader has failed a follower will * become a candidate and attempt to become a leader itself. */ -public class LeaderChecker extends AbstractComponent { +public class LeaderChecker { + + private static final Logger logger = LogManager.getLogger(LeaderChecker.class); public static final String LEADER_CHECK_ACTION_NAME = "internal:coordination/fault_detection/leader_check"; @@ -149,7 +152,7 @@ public class LeaderChecker extends AbstractComponent { * Update the "known" discovery nodes. Should be called on the leader before a new cluster state is published to reflect the new * publication targets, and also called if a leader becomes a non-leader. * TODO if heartbeats can make nodes become followers then this needs to be called before a heartbeat is sent to a new node too. - * + *

* isLocalNodeElectedMaster() should reflect whether this node is a leader, and nodeExists() * should indicate whether nodes are known publication targets or not. */ diff --git a/server/src/main/java/org/elasticsearch/cluster/coordination/PreVoteCollector.java b/server/src/main/java/org/elasticsearch/cluster/coordination/PreVoteCollector.java index f73fb6687a0..5001e3be181 100644 --- a/server/src/main/java/org/elasticsearch/cluster/coordination/PreVoteCollector.java +++ b/server/src/main/java/org/elasticsearch/cluster/coordination/PreVoteCollector.java @@ -19,13 +19,14 @@ package org.elasticsearch.cluster.coordination; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.coordination.CoordinationState.VoteCollection; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.collect.Tuple; -import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.lease.Releasable; import org.elasticsearch.threadpool.ThreadPool.Names; @@ -41,7 +42,9 @@ import java.util.function.LongConsumer; import static org.elasticsearch.cluster.coordination.CoordinationState.isElectionQuorum; import static org.elasticsearch.common.util.concurrent.ConcurrentCollections.newConcurrentSet; -public class PreVoteCollector extends AbstractComponent { +public class PreVoteCollector { + + private static final Logger logger = LogManager.getLogger(PreVoteCollector.class); public static final String REQUEST_PRE_VOTE_ACTION_NAME = "internal:cluster/request_pre_vote"; diff --git a/server/src/main/java/org/elasticsearch/cluster/coordination/Publication.java b/server/src/main/java/org/elasticsearch/cluster/coordination/Publication.java index 0eb4f98de7d..9ec8d562b81 100644 --- a/server/src/main/java/org/elasticsearch/cluster/coordination/Publication.java +++ b/server/src/main/java/org/elasticsearch/cluster/coordination/Publication.java @@ -19,13 +19,14 @@ package org.elasticsearch.cluster.coordination; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.action.ActionListener; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.coordination.ClusterStatePublisher.AckListener; import org.elasticsearch.cluster.node.DiscoveryNode; -import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.transport.TransportException; import org.elasticsearch.transport.TransportResponse; @@ -36,7 +37,9 @@ import java.util.Optional; import java.util.Set; import java.util.function.LongSupplier; -public abstract class Publication extends AbstractComponent { +public abstract class Publication { + + protected final Logger logger = LogManager.getLogger(getClass()); private final List publicationTargets; private final PublishRequest publishRequest; diff --git a/server/src/main/java/org/elasticsearch/cluster/coordination/PublicationTransportHandler.java b/server/src/main/java/org/elasticsearch/cluster/coordination/PublicationTransportHandler.java index 7c1ca0d8705..563cef30527 100644 --- a/server/src/main/java/org/elasticsearch/cluster/coordination/PublicationTransportHandler.java +++ b/server/src/main/java/org/elasticsearch/cluster/coordination/PublicationTransportHandler.java @@ -18,6 +18,8 @@ */ package org.elasticsearch.cluster.coordination; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.Version; @@ -29,7 +31,6 @@ import org.elasticsearch.cluster.IncompatibleClusterStateVersionException; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.common.bytes.BytesReference; -import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.compress.Compressor; import org.elasticsearch.common.compress.CompressorFactory; import org.elasticsearch.common.io.stream.BytesStreamOutput; @@ -61,7 +62,9 @@ import java.util.function.BiConsumer; import java.util.function.Consumer; import java.util.function.Function; -public class PublicationTransportHandler extends AbstractComponent { +public class PublicationTransportHandler { + + private static final Logger logger = LogManager.getLogger(PublicationTransportHandler.class); public static final String PUBLISH_STATE_ACTION_NAME = "internal:cluster/coordination/publish_state"; public static final String COMMIT_STATE_ACTION_NAME = "internal:cluster/coordination/commit_state"; diff --git a/server/src/main/java/org/elasticsearch/cluster/coordination/Reconfigurator.java b/server/src/main/java/org/elasticsearch/cluster/coordination/Reconfigurator.java index 2694bdf4b77..503427cdb31 100644 --- a/server/src/main/java/org/elasticsearch/cluster/coordination/Reconfigurator.java +++ b/server/src/main/java/org/elasticsearch/cluster/coordination/Reconfigurator.java @@ -19,9 +19,10 @@ package org.elasticsearch.cluster.coordination; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.node.DiscoveryNode; -import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.settings.ClusterSettings; import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Setting.Property; @@ -37,7 +38,9 @@ import java.util.stream.Stream; /** * Computes the optimal configuration of voting nodes in the cluster. */ -public class Reconfigurator extends AbstractComponent { +public class Reconfigurator { + + private static final Logger logger = LogManager.getLogger(Reconfigurator.class); /** * The cluster usually requires a vote from at least half of the master nodes in order to commit a cluster state update, and to achieve diff --git a/server/src/main/java/org/elasticsearch/discovery/HandshakingTransportAddressConnector.java b/server/src/main/java/org/elasticsearch/discovery/HandshakingTransportAddressConnector.java index 4c916cf0e18..656bfbe4f98 100644 --- a/server/src/main/java/org/elasticsearch/discovery/HandshakingTransportAddressConnector.java +++ b/server/src/main/java/org/elasticsearch/discovery/HandshakingTransportAddressConnector.java @@ -19,12 +19,13 @@ package org.elasticsearch.discovery; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.elasticsearch.Version; import org.elasticsearch.action.ActionListener; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.common.Randomness; import org.elasticsearch.common.UUIDs; -import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.transport.TransportAddress; @@ -41,7 +42,9 @@ import org.elasticsearch.transport.TransportService; import static java.util.Collections.emptyMap; import static java.util.Collections.emptySet; -public class HandshakingTransportAddressConnector extends AbstractComponent implements TransportAddressConnector { +public class HandshakingTransportAddressConnector implements TransportAddressConnector { + + private static final Logger logger = LogManager.getLogger(HandshakingTransportAddressConnector.class); // connection timeout for probes public static final Setting PROBE_CONNECT_TIMEOUT_SETTING = diff --git a/server/src/main/java/org/elasticsearch/discovery/PeerFinder.java b/server/src/main/java/org/elasticsearch/discovery/PeerFinder.java index b244ef5766f..4a5f6d05544 100644 --- a/server/src/main/java/org/elasticsearch/discovery/PeerFinder.java +++ b/server/src/main/java/org/elasticsearch/discovery/PeerFinder.java @@ -20,6 +20,8 @@ package org.elasticsearch.discovery; import com.carrotsearch.hppc.cursors.ObjectCursor; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; import org.apache.lucene.util.SetOnce; import org.elasticsearch.action.ActionListener; @@ -30,7 +32,6 @@ import org.elasticsearch.cluster.coordination.PeersResponse; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNodes; import org.elasticsearch.common.Nullable; -import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.common.settings.Setting; import org.elasticsearch.common.settings.Settings; @@ -63,7 +64,9 @@ import java.util.stream.Collectors; import static org.elasticsearch.common.util.concurrent.ConcurrentCollections.newConcurrentMap; -public abstract class PeerFinder extends AbstractComponent { +public abstract class PeerFinder { + + protected final Logger logger = LogManager.getLogger(getClass()); public static final String REQUEST_PEERS_ACTION_NAME = "internal:discovery/request_peers"; diff --git a/server/src/test/java/org/elasticsearch/cluster/coordination/CoordinatorTests.java b/server/src/test/java/org/elasticsearch/cluster/coordination/CoordinatorTests.java index ad5a3bb92ea..20e64d21abb 100644 --- a/server/src/test/java/org/elasticsearch/cluster/coordination/CoordinatorTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/coordination/CoordinatorTests.java @@ -19,6 +19,8 @@ package org.elasticsearch.cluster.coordination; import org.apache.logging.log4j.CloseableThreadContext; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.message.ParameterizedMessage; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.cluster.ClusterName; @@ -34,7 +36,6 @@ import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.service.ClusterApplier; import org.elasticsearch.common.Randomness; -import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.lease.Releasable; import org.elasticsearch.common.settings.ClusterSettings; import org.elasticsearch.common.settings.Setting; @@ -1295,7 +1296,9 @@ public class CoordinatorTests extends ESTestCase { } } - class ClusterNode extends AbstractComponent { + class ClusterNode { + private final Logger logger = LogManager.getLogger(ClusterNode.class); + private final int nodeIndex; private Coordinator coordinator; private DiscoveryNode localNode; diff --git a/test/framework/src/main/java/org/elasticsearch/cluster/coordination/DeterministicTaskQueue.java b/test/framework/src/main/java/org/elasticsearch/cluster/coordination/DeterministicTaskQueue.java index eed464a9006..035ca6b05ef 100644 --- a/test/framework/src/main/java/org/elasticsearch/cluster/coordination/DeterministicTaskQueue.java +++ b/test/framework/src/main/java/org/elasticsearch/cluster/coordination/DeterministicTaskQueue.java @@ -20,8 +20,9 @@ package org.elasticsearch.cluster.coordination; import com.carrotsearch.randomizedtesting.generators.RandomNumbers; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.apache.lucene.util.Counter; -import org.elasticsearch.common.component.AbstractComponent; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.threadpool.ThreadPool; @@ -42,7 +43,9 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Function; -public class DeterministicTaskQueue extends AbstractComponent { +public class DeterministicTaskQueue { + + private static final Logger logger = LogManager.getLogger(DeterministicTaskQueue.class); private final Settings settings; private final List runnableTasks = new ArrayList<>();