Remove use of AbstractComponent in xpack (#35394)

This commit removes the use of AbstractComponent in xpack where it was
still being extended. It has been replaced with explicit logger
declarations.

See #34488
This commit is contained in:
Jay Modi 2018-11-27 11:28:26 -07:00 committed by GitHub
parent 25c416b12d
commit 2061eeb122
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
33 changed files with 122 additions and 67 deletions

View File

@ -5,14 +5,17 @@
*/
package org.elasticsearch.xpack.ml;
import org.elasticsearch.common.component.AbstractComponent;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.common.util.concurrent.AbstractRunnable;
import org.elasticsearch.license.XPackLicenseState;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.xpack.ml.datafeed.DatafeedManager;
import org.elasticsearch.xpack.ml.job.process.autodetect.AutodetectProcessManager;
public class InvalidLicenseEnforcer extends AbstractComponent {
public class InvalidLicenseEnforcer {
private static final Logger logger = LogManager.getLogger(InvalidLicenseEnforcer.class);
private final ThreadPool threadPool;
private final XPackLicenseState licenseState;

View File

@ -5,12 +5,13 @@
*/
package org.elasticsearch.xpack.ml;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.cluster.ClusterChangedEvent;
import org.elasticsearch.cluster.ClusterStateListener;
import org.elasticsearch.cluster.LocalNodeMasterListener;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.threadpool.ThreadPool;
import org.elasticsearch.xpack.core.ml.MlMetadata;
import org.elasticsearch.xpack.core.ml.action.OpenJobAction;
@ -24,7 +25,9 @@ import org.elasticsearch.xpack.ml.notifications.Auditor;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicBoolean;
public class MlAssignmentNotifier extends AbstractComponent implements ClusterStateListener, LocalNodeMasterListener {
public class MlAssignmentNotifier implements ClusterStateListener, LocalNodeMasterListener {
private static final Logger logger = LogManager.getLogger(MlAssignmentNotifier.class);
private final Auditor auditor;
private final ClusterService clusterService;

View File

@ -9,12 +9,11 @@ import org.elasticsearch.client.Client;
import org.elasticsearch.cluster.ClusterChangedEvent;
import org.elasticsearch.cluster.ClusterStateListener;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.common.component.LifecycleListener;
import org.elasticsearch.gateway.GatewayService;
import org.elasticsearch.threadpool.ThreadPool;
class MlInitializationService extends AbstractComponent implements ClusterStateListener {
class MlInitializationService implements ClusterStateListener {
private final ThreadPool threadPool;
private final ClusterService clusterService;

View File

@ -6,7 +6,6 @@
package org.elasticsearch.xpack.ml;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.common.component.LifecycleListener;
import org.elasticsearch.env.Environment;
import org.elasticsearch.xpack.ml.datafeed.DatafeedManager;
@ -16,7 +15,7 @@ import org.elasticsearch.xpack.ml.job.process.autodetect.AutodetectProcessManage
import java.io.IOException;
public class MlLifeCycleService extends AbstractComponent {
public class MlLifeCycleService {
private final Environment environment;
private final DatafeedManager datafeedManager;

View File

@ -5,6 +5,8 @@
*/
package org.elasticsearch.xpack.ml.datafeed;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.ElasticsearchStatusException;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.client.Client;
@ -12,7 +14,6 @@ import org.elasticsearch.cluster.ClusterChangedEvent;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.ClusterStateListener;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.util.concurrent.AbstractRunnable;
import org.elasticsearch.common.util.concurrent.FutureUtils;
@ -51,7 +52,9 @@ import static org.elasticsearch.xpack.core.ClientHelper.ML_ORIGIN;
import static org.elasticsearch.xpack.core.ClientHelper.executeAsyncWithOrigin;
import static org.elasticsearch.persistent.PersistentTasksService.WaitForPersistentTaskListener;
public class DatafeedManager extends AbstractComponent {
public class DatafeedManager {
private static final Logger logger = LogManager.getLogger(DatafeedManager.class);
private final Client client;
private final ClusterService clusterService;

View File

@ -6,6 +6,7 @@
package org.elasticsearch.xpack.ml.job;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.ResourceNotFoundException;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.index.IndexResponse;
@ -18,7 +19,6 @@ import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.CheckedConsumer;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.ByteSizeUnit;
@ -78,12 +78,11 @@ import java.util.stream.Collectors;
* <li>starting/stopping of datafeed jobs</li>
* </ul>
*/
public class JobManager extends AbstractComponent {
public class JobManager {
private static final DeprecationLogger deprecationLogger =
new DeprecationLogger(LogManager.getLogger(JobManager.class));
private static final Logger logger = LogManager.getLogger(JobManager.class);
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(logger);
private final Settings settings;
private final Environment environment;
private final JobResultsProvider jobResultsProvider;
private final ClusterService clusterService;
@ -99,7 +98,6 @@ public class JobManager extends AbstractComponent {
public JobManager(Environment environment, Settings settings, JobResultsProvider jobResultsProvider,
ClusterService clusterService, Auditor auditor,
Client client, UpdateJobProcessNotifier updateJobProcessNotifier) {
this.settings = settings;
this.environment = environment;
this.jobResultsProvider = Objects.requireNonNull(jobResultsProvider);
this.clusterService = Objects.requireNonNull(clusterService);

View File

@ -5,6 +5,8 @@
*/
package org.elasticsearch.xpack.ml.job.persistence;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.message.ParameterizedMessage;
import org.apache.logging.log4j.util.Supplier;
import org.elasticsearch.action.ActionListener;
@ -12,7 +14,6 @@ import org.elasticsearch.action.index.IndexAction;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.xpack.core.ml.job.persistence.AnomalyDetectorsIndex;
@ -29,7 +30,9 @@ import static org.elasticsearch.xpack.core.ClientHelper.executeAsyncWithOrigin;
* Update a job's dataCounts
* i.e. the number of processed records, fields etc.
*/
public class JobDataCountsPersister extends AbstractComponent {
public class JobDataCountsPersister {
private static final Logger logger = LogManager.getLogger(JobDataCountsPersister.class);
private final Client client;

View File

@ -5,12 +5,13 @@
*/
package org.elasticsearch.xpack.ml.job.persistence;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.message.ParameterizedMessage;
import org.elasticsearch.action.bulk.BulkRequest;
import org.elasticsearch.action.bulk.BulkResponse;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.client.Client;
import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
@ -37,7 +38,9 @@ import static org.elasticsearch.xpack.core.ml.job.persistence.ElasticsearchMappi
* <p>
* This class is NOT thread safe.
*/
public class JobRenormalizedResultsPersister extends AbstractComponent {
public class JobRenormalizedResultsPersister {
private static final Logger logger = LogManager.getLogger(JobRenormalizedResultsPersister.class);
/**
* Execute bulk requests when they reach this size

View File

@ -5,6 +5,8 @@
*/
package org.elasticsearch.xpack.ml.job.persistence;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.message.ParameterizedMessage;
import org.elasticsearch.action.ActionFuture;
import org.elasticsearch.action.ActionListener;
@ -18,7 +20,6 @@ import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.action.support.PlainActionFuture;
import org.elasticsearch.action.support.WriteRequest;
import org.elasticsearch.client.Client;
import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.common.util.concurrent.ThreadContext;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
@ -63,7 +64,9 @@ import static org.elasticsearch.xpack.core.ml.job.persistence.ElasticsearchMappi
*
* @see ElasticsearchMappings
*/
public class JobResultsPersister extends AbstractComponent {
public class JobResultsPersister {
private static final Logger logger = LogManager.getLogger(JobResultsPersister.class);
private final Client client;

View File

@ -5,8 +5,9 @@
*/
package org.elasticsearch.xpack.ml.job.process;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.xpack.core.ml.job.config.Job;
import org.elasticsearch.xpack.core.ml.job.process.autodetect.state.DataCounts;
import org.elasticsearch.xpack.ml.job.persistence.JobDataCountsPersister;
@ -33,7 +34,9 @@ import java.util.function.Function;
* changes when each of the reporting stages are passed. If the
* function returns {@code true} the usage is logged.
*/
public class DataCountsReporter extends AbstractComponent {
public class DataCountsReporter {
private static final Logger logger = LogManager.getLogger(DataCountsReporter.class);
private final Job job;
private final JobDataCountsPersister dataCountsPersister;

View File

@ -5,13 +5,14 @@
*/
package org.elasticsearch.xpack.ml.job.process.autodetect;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.message.ParameterizedMessage;
import org.elasticsearch.ElasticsearchStatusException;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.client.Client;
import org.elasticsearch.common.CheckedConsumer;
import org.elasticsearch.common.collect.Tuple;
import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.ByteSizeUnit;
@ -87,7 +88,7 @@ import static org.elasticsearch.common.settings.Setting.Property;
import static org.elasticsearch.xpack.core.ClientHelper.ML_ORIGIN;
import static org.elasticsearch.xpack.core.ClientHelper.executeAsyncWithOrigin;
public class AutodetectProcessManager extends AbstractComponent {
public class AutodetectProcessManager {
// We should be able from the job config to estimate the memory/cpu a job needs to have,
// and if we know that then we can prior to assigning a job to a node fail based on the
@ -108,7 +109,8 @@ public class AutodetectProcessManager extends AbstractComponent {
public static final Setting<ByteSizeValue> 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 static final Logger logger = LogManager.getLogger(AutodetectProcessManager.class);
private final Client client;
private final Environment environment;
private final ThreadPool threadPool;
@ -137,7 +139,6 @@ public class AutodetectProcessManager extends AbstractComponent {
JobDataCountsPersister jobDataCountsPersister,
AutodetectProcessFactory autodetectProcessFactory, NormalizerFactory normalizerFactory,
NamedXContentRegistry xContentRegistry, Auditor auditor) {
this.settings = settings;
this.environment = environment;
this.client = client;
this.threadPool = threadPool;

View File

@ -5,8 +5,9 @@
*/
package org.elasticsearch.xpack.ml.job.process.autodetect.output;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
import org.elasticsearch.common.xcontent.XContentFactory;
@ -25,7 +26,7 @@ import java.util.Iterator;
* Expects an array of buckets so the first element will always be the
* start array symbol and the data must be terminated with the end array symbol.
*/
public class AutodetectResultsParser extends AbstractComponent {
public class AutodetectResultsParser {
public Iterator<AutodetectResult> parseResults(InputStream in) throws ElasticsearchParseException {
try {
XContentParser parser = XContentFactory.xContent(XContentType.JSON)
@ -58,7 +59,9 @@ public class AutodetectResultsParser extends AbstractComponent {
}
}
private class AutodetectResultIterator implements Iterator<AutodetectResult> {
private static class AutodetectResultIterator implements Iterator<AutodetectResult> {
private static final Logger logger = LogManager.getLogger(AutodetectResultIterator.class);
private final InputStream in;
private final XContentParser parser;

View File

@ -5,6 +5,8 @@
*/
package org.elasticsearch.xpack.monitoring.collector;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.message.ParameterizedMessage;
import org.apache.logging.log4j.util.Supplier;
import org.elasticsearch.ElasticsearchTimeoutException;
@ -13,7 +15,6 @@ import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.license.XPackLicenseState;
@ -33,7 +34,7 @@ import static org.elasticsearch.common.settings.Setting.timeSetting;
/**
* {@link Collector} are used to collect monitoring data about the cluster, nodes and indices.
*/
public abstract class Collector extends AbstractComponent {
public abstract class Collector {
/**
* List of indices names whose stats will be exported (default to all indices)
@ -46,6 +47,7 @@ public abstract class Collector extends AbstractComponent {
protected final ClusterService clusterService;
protected final XPackLicenseState licenseState;
protected final Logger logger;
public Collector(final String name, final ClusterService clusterService,
final Setting<TimeValue> timeoutSetting, final XPackLicenseState licenseState) {
@ -53,6 +55,7 @@ public abstract class Collector extends AbstractComponent {
this.clusterService = clusterService;
this.collectionTimeoutSetting = timeoutSetting;
this.licenseState = licenseState;
this.logger = LogManager.getLogger(getClass());
}
public String name() {

View File

@ -10,7 +10,6 @@ import org.elasticsearch.client.Client;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.index.reindex.BulkByScrollResponse;
import org.elasticsearch.protocol.xpack.migration.UpgradeActionRequired;
import org.elasticsearch.script.Script;
@ -32,7 +31,7 @@ import java.util.function.Function;
* - reindex is performed
* - postUpgrade is called if reindex was successful
*/
public class IndexUpgradeCheck<T> extends AbstractComponent {
public class IndexUpgradeCheck<T> {
private final String name;
private final Function<IndexMetaData, UpgradeActionRequired> actionRequired;

View File

@ -5,6 +5,8 @@
*/
package org.elasticsearch.xpack.upgrade;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.Version;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.IndicesOptions;
@ -12,7 +14,6 @@ import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.metadata.MetaData;
import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.index.IndexNotFoundException;
import org.elasticsearch.index.reindex.BulkByScrollResponse;
import org.elasticsearch.protocol.xpack.migration.UpgradeActionRequired;
@ -22,7 +23,9 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class IndexUpgradeService extends AbstractComponent {
public class IndexUpgradeService {
private static final Logger logger = LogManager.getLogger(IndexUpgradeService.class);
private final List<IndexUpgradeCheck> upgradeChecks;

View File

@ -5,6 +5,8 @@
*/
package org.elasticsearch.xpack.watcher;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.message.ParameterizedMessage;
import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.cluster.ClusterChangedEvent;
@ -18,7 +20,6 @@ import org.elasticsearch.cluster.routing.Murmur3HashFunction;
import org.elasticsearch.cluster.routing.RoutingNode;
import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.common.util.set.Sets;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.index.engine.Engine;
@ -55,7 +56,9 @@ import static org.joda.time.DateTimeZone.UTC;
* the document should also be added to the local trigger service
*
*/
final class WatcherIndexingListener extends AbstractComponent implements IndexingOperationListener, ClusterStateListener {
final class WatcherIndexingListener implements IndexingOperationListener, ClusterStateListener {
private static final Logger logger = LogManager.getLogger(WatcherIndexingListener.class);
static final Configuration INACTIVE = new Configuration(null, Collections.emptyMap());

View File

@ -15,7 +15,6 @@ import org.elasticsearch.cluster.routing.RoutingNode;
import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.common.component.LifecycleListener;
import org.elasticsearch.gateway.GatewayService;
import org.elasticsearch.index.shard.ShardId;
@ -34,7 +33,7 @@ import java.util.stream.Collectors;
import static org.elasticsearch.cluster.routing.ShardRoutingState.RELOCATING;
import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
public class WatcherLifeCycleService extends AbstractComponent implements ClusterStateListener {
public class WatcherLifeCycleService implements ClusterStateListener {
private final AtomicReference<WatcherState> state = new AtomicReference<>(WatcherState.STARTED);
private final AtomicReference<List<ShardRouting>> previousShardRoutings = new AtomicReference<>(Collections.emptyList());

View File

@ -6,6 +6,8 @@
package org.elasticsearch.xpack.watcher;
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.admin.indices.refresh.RefreshRequest;
@ -22,7 +24,6 @@ import org.elasticsearch.cluster.routing.Murmur3HashFunction;
import org.elasticsearch.cluster.routing.Preference;
import org.elasticsearch.cluster.routing.RoutingNode;
import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.util.concurrent.AbstractRunnable;
@ -66,9 +67,10 @@ import static org.elasticsearch.xpack.core.ClientHelper.WATCHER_ORIGIN;
import static org.elasticsearch.xpack.core.watcher.support.Exceptions.illegalState;
import static org.elasticsearch.xpack.core.watcher.watch.Watch.INDEX;
public class WatcherService extends AbstractComponent {
public class WatcherService {
private static final String LIFECYCLE_THREADPOOL_NAME = "watcher-lifecycle";
private static final Logger logger = LogManager.getLogger(WatcherService.class);
private final TriggerService triggerService;
private final TriggeredWatchStore triggeredWatchStore;

View File

@ -33,8 +33,9 @@ import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.message.BasicNameValuePair;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.common.unit.TimeValue;
@ -59,13 +60,14 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class HttpClient extends AbstractComponent implements Closeable {
public class HttpClient implements Closeable {
private static final String SETTINGS_SSL_PREFIX = "xpack.http.ssl.";
// picking a reasonable high value here to allow for setups with lots of watch executions or many http inputs/actions
// this is also used as the value per route, if you are connecting to the same endpoint a lot, which is likely, when
// you are querying a remote Elasticsearch cluster
private static final int MAX_CONNECTIONS = 500;
private static final Logger logger = LogManager.getLogger(HttpClient.class);
private final CloseableHttpClient client;
private final HttpProxy settingsProxy;

View File

@ -6,6 +6,8 @@
package org.elasticsearch.xpack.watcher.execution;
import com.google.common.collect.Iterables;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.message.ParameterizedMessage;
import org.apache.logging.log4j.util.Supplier;
import org.elasticsearch.ExceptionsHelper;
@ -22,7 +24,6 @@ import org.elasticsearch.cluster.routing.Preference;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.collect.MapBuilder;
import org.elasticsearch.common.collect.Tuple;
import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.common.metrics.MeanMetric;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
@ -73,12 +74,14 @@ import static org.elasticsearch.xpack.core.ClientHelper.WATCHER_ORIGIN;
import static org.elasticsearch.xpack.core.ClientHelper.stashWithOrigin;
import static org.joda.time.DateTimeZone.UTC;
public class ExecutionService extends AbstractComponent {
public class ExecutionService {
public static final Setting<TimeValue> DEFAULT_THROTTLE_PERIOD_SETTING =
Setting.positiveTimeSetting("xpack.watcher.execution.default_throttle_period",
TimeValue.timeValueSeconds(5), Setting.Property.NodeScope);
private static final Logger logger = LogManager.getLogger(ExecutionService.class);
private final MeanMetric totalExecutionsTime = new MeanMetric();
private final Map<String, MeanMetric> actionByTypeExecutionTime = new HashMap<>();

View File

@ -5,6 +5,8 @@
*/
package org.elasticsearch.xpack.watcher.execution;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.admin.indices.refresh.RefreshRequest;
import org.elasticsearch.action.bulk.BulkItemResponse;
@ -22,7 +24,6 @@ import org.elasticsearch.client.Client;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.cluster.routing.Preference;
import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.ToXContent;
@ -48,7 +49,9 @@ import java.util.stream.Collectors;
import static org.elasticsearch.xpack.core.ClientHelper.WATCHER_ORIGIN;
public class TriggeredWatchStore extends AbstractComponent {
public class TriggeredWatchStore {
private static final Logger logger = LogManager.getLogger(TriggeredWatchStore.class);
private final int scrollSize;
private final Client client;

View File

@ -5,13 +5,14 @@
*/
package org.elasticsearch.xpack.watcher.history;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.message.ParameterizedMessage;
import org.apache.logging.log4j.util.Supplier;
import org.elasticsearch.action.bulk.BulkProcessor;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.xpack.core.watcher.history.HistoryStoreField;
@ -25,10 +26,12 @@ import java.io.IOException;
import static org.elasticsearch.xpack.core.watcher.support.Exceptions.ioException;
public class HistoryStore extends AbstractComponent {
public class HistoryStore {
public static final String DOC_TYPE = "doc";
private static final Logger logger = LogManager.getLogger(HistoryStore.class);
private final BulkProcessor bulkProcessor;
public HistoryStore(BulkProcessor bulkProcessor) {

View File

@ -6,7 +6,6 @@
package org.elasticsearch.xpack.watcher.notification;
import org.elasticsearch.common.collect.Tuple;
import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.common.settings.ClusterSettings;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
@ -21,7 +20,7 @@ import java.util.function.BiFunction;
/**
* Basic notification service
*/
public abstract class NotificationService<Account> extends AbstractComponent {
public abstract class NotificationService<Account> {
private final String type;
// both are guarded by this

View File

@ -5,6 +5,8 @@
*/
package org.elasticsearch.xpack.watcher.notification.email;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.settings.ClusterSettings;
import org.elasticsearch.common.settings.SecureSetting;
@ -101,6 +103,8 @@ public class EmailService extends NotificationService<Account> {
Setting.affixKeySetting("xpack.notification.email.account.", "smtp.wait_on_quit",
(key) -> Setting.boolSetting(key, true, Property.Dynamic, Property.NodeScope));
private static final Logger logger = LogManager.getLogger(EmailService.class);
private final CryptoService cryptoService;
public EmailService(Settings settings, @Nullable CryptoService cryptoService, ClusterSettings clusterSettings) {

View File

@ -5,6 +5,8 @@
*/
package org.elasticsearch.xpack.watcher.notification.hipchat;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.common.settings.ClusterSettings;
import org.elasticsearch.common.settings.SecureSetting;
import org.elasticsearch.common.settings.SecureString;
@ -60,6 +62,7 @@ public class HipChatService extends NotificationService<HipChatAccount> {
Setting.affixKeySetting("xpack.notification.hipchat.account.", "message",
(key) -> Setting.groupSetting(key + ".", Setting.Property.Dynamic, Setting.Property.NodeScope));
private static final Logger logger = LogManager.getLogger(HipChatService.class);
private final HttpClient httpClient;
private HipChatServer defaultServer;

View File

@ -5,6 +5,8 @@
*/
package org.elasticsearch.xpack.watcher.notification.slack;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.common.settings.ClusterSettings;
import org.elasticsearch.common.settings.SecureSetting;
import org.elasticsearch.common.settings.SecureString;
@ -37,6 +39,8 @@ public class SlackService extends NotificationService<SlackAccount> {
Setting.affixKeySetting("xpack.notification.slack.account.", "message_defaults",
(key) -> Setting.groupSetting(key + ".", Property.Dynamic, Property.NodeScope));
private static final Logger logger = LogManager.getLogger(SlackService.class);
private final HttpClient httpClient;
public SlackService(Settings settings, HttpClient httpClient, ClusterSettings clusterSettings) {

View File

@ -5,6 +5,8 @@
*/
package org.elasticsearch.xpack.watcher.support;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.message.ParameterizedMessage;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest;
@ -15,7 +17,6 @@ import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.ClusterStateListener;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.gateway.GatewayService;
@ -33,7 +34,7 @@ import java.util.regex.Pattern;
import static org.elasticsearch.xpack.core.ClientHelper.WATCHER_ORIGIN;
import static org.elasticsearch.xpack.core.ClientHelper.executeAsyncWithOrigin;
public class WatcherIndexTemplateRegistry extends AbstractComponent implements ClusterStateListener {
public class WatcherIndexTemplateRegistry implements ClusterStateListener {
public static final TemplateConfig TEMPLATE_CONFIG_TRIGGERED_WATCHES = new TemplateConfig(
WatcherIndexTemplateRegistryField.TRIGGERED_TEMPLATE_NAME, "triggered-watches");
@ -45,6 +46,8 @@ public class WatcherIndexTemplateRegistry extends AbstractComponent implements C
TEMPLATE_CONFIG_TRIGGERED_WATCHES, TEMPLATE_CONFIG_WATCH_HISTORY, TEMPLATE_CONFIG_WATCHES
};
private static final Logger logger = LogManager.getLogger(WatcherIndexTemplateRegistry.class);
private final Client client;
private final ThreadPool threadPool;
private final TemplateConfig[] indexTemplates;

View File

@ -7,7 +7,6 @@ package org.elasticsearch.xpack.watcher.support.search;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
import org.elasticsearch.common.xcontent.XContentFactory;
@ -30,7 +29,7 @@ import java.util.Map;
/**
* {@link WatcherSearchTemplateService} renders {@link WatcherSearchTemplateRequest} before their execution.
*/
public class WatcherSearchTemplateService extends AbstractComponent {
public class WatcherSearchTemplateService {
private final ScriptService scriptService;
private final NamedXContentRegistry xContentRegistry;

View File

@ -7,7 +7,6 @@ package org.elasticsearch.xpack.watcher.trigger;
import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.xpack.core.watcher.common.stats.Counters;
import org.elasticsearch.xpack.core.watcher.trigger.Trigger;
@ -26,7 +25,7 @@ import java.util.function.Consumer;
import static java.util.Collections.unmodifiableMap;
import static org.elasticsearch.xpack.core.watcher.support.Exceptions.illegalArgument;
public class TriggerService extends AbstractComponent {
public class TriggerService {
private final GroupedConsumer consumer = new GroupedConsumer();
private final Map<String, TriggerEngine> engines;

View File

@ -6,7 +6,6 @@
package org.elasticsearch.xpack.watcher.trigger.schedule;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.xpack.core.watcher.support.WatcherDateTimeUtils;
import org.elasticsearch.xpack.core.watcher.trigger.TriggerEvent;
@ -24,7 +23,7 @@ import java.util.function.Consumer;
import static org.elasticsearch.xpack.core.watcher.support.Exceptions.illegalArgument;
import static org.joda.time.DateTimeZone.UTC;
public abstract class ScheduleTriggerEngine extends AbstractComponent implements TriggerEngine<ScheduleTrigger, ScheduleTriggerEvent> {
public abstract class ScheduleTriggerEngine implements TriggerEngine<ScheduleTrigger, ScheduleTriggerEvent> {
public static final String TYPE = ScheduleTrigger.TYPE;

View File

@ -5,6 +5,8 @@
*/
package org.elasticsearch.xpack.watcher.trigger.schedule.engine;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Setting.Property;
import org.elasticsearch.common.settings.Settings;
@ -37,6 +39,8 @@ public class TickerScheduleTriggerEngine extends ScheduleTriggerEngine {
public static final Setting<TimeValue> TICKER_INTERVAL_SETTING =
positiveTimeSetting("xpack.watcher.trigger.schedule.ticker.tick_interval", TimeValue.timeValueMillis(500), Property.NodeScope);
private static final Logger logger = LogManager.getLogger(TickerScheduleTriggerEngine.class);
private final TimeValue tickInterval;
private final Map<String, ActiveSchedule> schedules = new ConcurrentHashMap<>();
private final Ticker ticker;

View File

@ -5,10 +5,11 @@
*/
package org.elasticsearch.xpack.watcher.watch;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.common.lucene.uid.Versions;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
@ -48,7 +49,9 @@ import static org.elasticsearch.common.unit.TimeValue.timeValueMillis;
import static org.elasticsearch.xpack.core.watcher.support.Exceptions.ioException;
import static org.joda.time.DateTimeZone.UTC;
public class WatchParser extends AbstractComponent {
public class WatchParser {
private static final Logger logger = LogManager.getLogger(WatchParser.class);
private final TriggerService triggerService;
private final ActionRegistry actionRegistry;

View File

@ -6,7 +6,6 @@
package org.elasticsearch.example.role;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.xpack.core.security.authz.RoleDescriptor;
import org.elasticsearch.xpack.core.security.authz.store.RoleRetrievalResult;
@ -19,9 +18,7 @@ import java.util.function.BiConsumer;
* A custom roles provider implementation for testing that serves
* static roles from memory.
*/
public class CustomInMemoryRolesProvider
extends AbstractComponent
implements BiConsumer<Set<String>, ActionListener<RoleRetrievalResult>> {
public class CustomInMemoryRolesProvider implements BiConsumer<Set<String>, ActionListener<RoleRetrievalResult>> {
public static final String INDEX = "foo";
public static final String ROLE_A = "roleA";