Skip to content

Commit

Permalink
Drop deprecationLogger from AbstractComponent (#34859)
Browse files Browse the repository at this point in the history
Drops the `deprecationLogger` from `AbstractComponent`, moving it to
places where we need it. This saves us from building a bunch of
`DeprecationLogger`s that we don't need.

Relates to #34488
  • Loading branch information
nik9000 committed Oct 27, 2018
1 parent a893697 commit 987b827
Show file tree
Hide file tree
Showing 36 changed files with 185 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,14 @@
import io.netty.handler.codec.http.HttpResponseEncoder;
import io.netty.handler.timeout.ReadTimeoutException;
import io.netty.handler.timeout.ReadTimeoutHandler;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.message.ParameterizedMessage;
import org.apache.logging.log4j.util.Supplier;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.component.AbstractLifecycleComponent;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.network.NetworkAddress;
import org.elasticsearch.common.network.NetworkService;
import org.elasticsearch.common.settings.Setting;
Expand Down Expand Up @@ -122,6 +125,8 @@
import static org.elasticsearch.http.netty4.cors.Netty4CorsHandler.ANY_ORIGIN;

public class Netty4HttpServerTransport extends AbstractLifecycleComponent implements HttpServerTransport {
private static final Logger logger = LogManager.getLogger(Netty4HttpServerTransport.class);
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(logger);

static {
Netty4Utils.setup();
Expand Down Expand Up @@ -619,7 +624,7 @@ protected void initChannel(Channel ch) throws Exception {
ch.pipeline().addLast("cors", new Netty4CorsHandler(transport.getCorsConfig()));
}
if (transport.pipelining) {
ch.pipeline().addLast("pipelining", new HttpPipeliningHandler(transport.logger, transport.pipeliningMaxEvents));
ch.pipeline().addLast("pipelining", new HttpPipeliningHandler(logger, transport.pipeliningMaxEvents));
}
ch.pipeline().addLast("handler", requestHandler);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@
package org.elasticsearch.repositories.s3;

import com.amazonaws.auth.BasicAWSCredentials;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.elasticsearch.cluster.metadata.RepositoryMetaData;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.blobstore.BlobPath;
import org.elasticsearch.common.blobstore.BlobStore;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.settings.SecureSetting;
import org.elasticsearch.common.settings.SecureString;
import org.elasticsearch.common.settings.Setting;
Expand Down Expand Up @@ -51,6 +54,8 @@
* </dl>
*/
class S3Repository extends BlobStoreRepository {
private static final Logger logger = LogManager.getLogger(S3Repository.class);
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(logger);

static final String TYPE = "s3";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
*/
package org.elasticsearch.http;

import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentBuilder;
Expand All @@ -42,6 +45,8 @@
* and returns their values.
*/
public class TestDeprecationHeaderRestAction extends BaseRestHandler {
private static final Logger logger = LogManager.getLogger(TestDeprecationHeaderRestAction.class);
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(logger);

public static final Setting<Boolean> TEST_DEPRECATED_SETTING_TRUE1 =
Setting.boolSetting("test.setting.deprecated.true1", true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.message.ParameterizedMessage;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.ResourceAlreadyExistsException;
Expand Down Expand Up @@ -54,7 +55,6 @@
import org.elasticsearch.common.compress.CompressedXContent;
import org.elasticsearch.common.io.PathUtils;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.logging.Loggers;
import org.elasticsearch.common.settings.IndexScopedSettings;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
Expand Down Expand Up @@ -100,8 +100,8 @@
* Service responsible for submitting create index requests
*/
public class MetaDataCreateIndexService extends AbstractComponent {

private static final DeprecationLogger deprecationLogger = new DeprecationLogger(Loggers.getLogger(MetaDataCreateIndexService.class));
private static final Logger logger = LogManager.getLogger(MetaDataCreateIndexService.class);
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(logger);

public static final int MAX_INDEX_NAME_BYTES = 255;

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

package org.elasticsearch.cluster.metadata;

import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.Version;
import org.elasticsearch.action.ActionListener;
Expand Down Expand Up @@ -59,6 +61,8 @@
* Service responsible for submitting open/close index requests
*/
public class MetaDataIndexStateService extends AbstractComponent {
private static final Logger logger = LogManager.getLogger(MetaDataIndexStateService.class);
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(logger);

public static final ClusterBlock INDEX_CLOSED_BLOCK = new ClusterBlock(4, "index closed", false,
false, false, RestStatus.FORBIDDEN, ClusterBlockLevel.READ_WRITE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

package org.elasticsearch.cluster.metadata;

import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.Version;
import org.elasticsearch.action.ActionListener;
Expand All @@ -37,6 +39,7 @@
import org.elasticsearch.common.collect.Tuple;
import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.regex.Regex;
import org.elasticsearch.common.settings.IndexScopedSettings;
import org.elasticsearch.common.settings.Setting;
Expand All @@ -60,6 +63,8 @@
* Service responsible for submitting update index settings requests
*/
public class MetaDataUpdateSettingsService extends AbstractComponent {
private static final Logger logger = LogManager.getLogger(MetaDataUpdateSettingsService.class);
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(logger);

private final ClusterService clusterService;

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

package org.elasticsearch.cluster.routing;

import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.elasticsearch.Version;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.metadata.IndexMetaData;
Expand All @@ -27,6 +29,7 @@
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.settings.ClusterSettings;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
Expand All @@ -45,6 +48,8 @@
import java.util.stream.Collectors;

public class OperationRouting extends AbstractComponent {
private static final Logger logger = LogManager.getLogger(OperationRouting.class);
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(logger);

public static final Setting<Boolean> USE_ADAPTIVE_REPLICA_SELECTION_SETTING =
Setting.boolSetting("cluster.routing.use_adaptive_replica_selection", false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,17 @@

package org.elasticsearch.common.component;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.apache.logging.log4j.LogManager;
import org.elasticsearch.common.settings.Settings;

public abstract class AbstractComponent {

protected final Logger logger;
protected final DeprecationLogger deprecationLogger;
protected final Settings settings;

public AbstractComponent(Settings settings) {
this.logger = LogManager.getLogger(getClass());
this.deprecationLogger = new DeprecationLogger(logger);
this.settings = settings;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@

package org.elasticsearch.discovery.zen;

import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.message.ParameterizedMessage;
import org.elasticsearch.common.component.AbstractComponent;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.TransportAddress;

Expand All @@ -45,6 +48,8 @@
* 67.81.244.15:9400
*/
public class FileBasedUnicastHostsProvider extends AbstractComponent implements UnicastHostsProvider {
private static final Logger logger = LogManager.getLogger(FileBasedUnicastHostsProvider.class);
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(logger);

public static final String UNICAST_HOSTS_FILE = "unicast_hosts.txt";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@

package org.elasticsearch.rest.action;

import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.elasticsearch.action.fieldcaps.FieldCapabilitiesRequest;
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.rest.BaseRestHandler;
Expand All @@ -35,6 +38,9 @@
import static org.elasticsearch.rest.RestRequest.Method.POST;

public class RestFieldCapabilitiesAction extends BaseRestHandler {
private static final Logger logger = LogManager.getLogger(RestFieldCapabilitiesAction.class);
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(logger);

public RestFieldCapabilitiesAction(Settings settings, RestController controller) {
super(settings);
controller.registerHandler(GET, "/_field_caps", this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@

package org.elasticsearch.rest.action.admin.cluster;

import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsRequest;
import org.elasticsearch.action.admin.indices.stats.CommonStatsFlags;
import org.elasticsearch.action.admin.indices.stats.CommonStatsFlags.Flag;
import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.RestController;
Expand All @@ -42,6 +45,9 @@
import static org.elasticsearch.rest.RestRequest.Method.GET;

public class RestNodesStatsAction extends BaseRestHandler {
private static final Logger logger = LogManager.getLogger(RestNodesStatsAction.class);
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(logger);

public RestNodesStatsAction(Settings settings, RestController controller) {
super(settings);
controller.registerHandler(GET, "/_nodes/stats", this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@
package org.elasticsearch.rest.action.admin.indices;

import com.carrotsearch.hppc.cursors.ObjectCursor;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsRequest;
import org.elasticsearch.action.admin.indices.mapping.get.GetMappingsResponse;
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.cluster.metadata.MappingMetaData;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.collect.ImmutableOpenMap;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.regex.Regex;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.set.Sets;
Expand Down Expand Up @@ -55,6 +58,8 @@
import static org.elasticsearch.rest.RestRequest.Method.HEAD;

public class RestGetMappingAction extends BaseRestHandler {
private static final Logger logger = LogManager.getLogger(RestGetMappingAction.class);
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(logger);

public RestGetMappingAction(final Settings settings, final RestController controller) {
super(settings);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@

package org.elasticsearch.rest.action.admin.indices;

import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.elasticsearch.action.admin.indices.stats.IndicesStatsRequest;
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.RestController;
Expand All @@ -41,6 +44,9 @@
import static org.elasticsearch.rest.RestRequest.Method.GET;

public class RestIndicesStatsAction extends BaseRestHandler {
private static final Logger logger = LogManager.getLogger(RestIndicesStatsAction.class);
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(logger);

public RestIndicesStatsAction(Settings settings, RestController controller) {
super(settings);
controller.registerHandler(GET, "/_stats", this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@

package org.elasticsearch.rest.action.admin.indices;

import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.elasticsearch.action.admin.indices.shrink.ResizeRequest;
import org.elasticsearch.action.admin.indices.shrink.ResizeType;
import org.elasticsearch.action.support.ActiveShardCount;
import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.Booleans;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.RestController;
Expand All @@ -33,6 +36,8 @@
import java.io.IOException;

public abstract class RestResizeHandler extends BaseRestHandler {
private static final Logger logger = LogManager.getLogger(RestResizeHandler.class);
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(logger);

RestResizeHandler(final Settings settings) {
super(settings);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
*/
package org.elasticsearch.license;

import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.protocol.xpack.license.DeleteLicenseRequest;
import org.elasticsearch.rest.RestController;
Expand All @@ -18,6 +21,9 @@
import static org.elasticsearch.rest.RestRequest.Method.DELETE;

public class RestDeleteLicenseAction extends XPackRestHandler {
private static final Logger logger = LogManager.getLogger(RestDeleteLicenseAction.class);
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(logger);

public RestDeleteLicenseAction(Settings settings, RestController controller) {
super(settings);
// @deprecated Remove deprecations in 6.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
*/
package org.elasticsearch.license;

import org.elasticsearch.common.inject.Inject;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
Expand All @@ -27,8 +29,9 @@
import static org.elasticsearch.rest.RestStatus.OK;

public class RestGetLicenseAction extends XPackRestHandler {
private static final Logger logger = LogManager.getLogger(RestGetLicenseAction.class);
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(logger);

@Inject
public RestGetLicenseAction(Settings settings, RestController controller) {
super(settings);
// @deprecated Remove deprecations in 6.0
Expand Down
Loading

0 comments on commit 987b827

Please sign in to comment.