Skip to content

Commit b205713

Browse files
authored
Remove AbstractComponent from AbstractLifecycleComponent (#35560)
AbstractLifecycleComponent now no longer extends AbstractComponent. In order to accomplish this, many, many classes now instantiate their own logger.
1 parent 156b3ca commit b205713

File tree

48 files changed

+152
-25
lines changed

Some content is hidden

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

48 files changed

+152
-25
lines changed

modules/repository-url/src/main/java/org/elasticsearch/repositories/url/URLRepository.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
package org.elasticsearch.repositories.url;
2121

22+
import org.apache.logging.log4j.LogManager;
23+
import org.apache.logging.log4j.Logger;
2224
import org.elasticsearch.cluster.metadata.RepositoryMetaData;
2325
import org.elasticsearch.common.blobstore.BlobContainer;
2426
import org.elasticsearch.common.blobstore.BlobPath;
@@ -50,6 +52,7 @@
5052
* </dl>
5153
*/
5254
public class URLRepository extends BlobStoreRepository {
55+
private static final Logger logger = LogManager.getLogger(URLRepository.class);
5356

5457
public static final String TYPE = "url";
5558

modules/transport-netty4/src/main/java/org/elasticsearch/http/netty4/Netty4HttpServerTransport.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
import io.netty.handler.timeout.ReadTimeoutException;
4242
import io.netty.handler.timeout.ReadTimeoutHandler;
4343
import io.netty.util.AttributeKey;
44+
import org.apache.logging.log4j.LogManager;
45+
import org.apache.logging.log4j.Logger;
4446
import org.elasticsearch.ExceptionsHelper;
4547
import org.elasticsearch.common.Strings;
4648
import org.elasticsearch.common.network.CloseableChannel;
@@ -92,6 +94,7 @@
9294
import static org.elasticsearch.http.netty4.cors.Netty4CorsHandler.ANY_ORIGIN;
9395

9496
public class Netty4HttpServerTransport extends AbstractHttpServerTransport {
97+
private static final Logger logger = LogManager.getLogger(Netty4HttpServerTransport.class);
9598

9699
static {
97100
Netty4Utils.setup();
@@ -338,7 +341,7 @@ protected void initChannel(Channel ch) throws Exception {
338341
if (handlingSettings.isCorsEnabled()) {
339342
ch.pipeline().addLast("cors", new Netty4CorsHandler(transport.corsConfig));
340343
}
341-
ch.pipeline().addLast("pipelining", new Netty4HttpPipeliningHandler(transport.logger, transport.pipeliningMaxEvents));
344+
ch.pipeline().addLast("pipelining", new Netty4HttpPipeliningHandler(logger, transport.pipeliningMaxEvents));
342345
ch.pipeline().addLast("handler", requestHandler);
343346
transport.serverAcceptedChannel(nettyHttpChannel);
344347
}

modules/transport-netty4/src/main/java/org/elasticsearch/transport/netty4/Netty4Transport.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
import io.netty.channel.socket.nio.NioSocketChannel;
3737
import io.netty.util.AttributeKey;
3838
import io.netty.util.concurrent.Future;
39+
import org.apache.logging.log4j.LogManager;
40+
import org.apache.logging.log4j.Logger;
3941
import org.apache.logging.log4j.message.ParameterizedMessage;
4042
import org.elasticsearch.ExceptionsHelper;
4143
import org.elasticsearch.Version;
@@ -73,6 +75,7 @@
7375
* sending out ping requests to other nodes.
7476
*/
7577
public class Netty4Transport extends TcpTransport {
78+
private static final Logger logger = LogManager.getLogger(Netty4Transport.class);
7679

7780
static {
7881
Netty4Utils.setup();

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
import com.microsoft.windowsazure.management.compute.ComputeManagementService;
3434
import com.microsoft.windowsazure.management.compute.models.HostedServiceGetDetailedResponse;
3535
import com.microsoft.windowsazure.management.configuration.ManagementConfiguration;
36+
import org.apache.logging.log4j.LogManager;
37+
import org.apache.logging.log4j.Logger;
3638
import org.elasticsearch.ElasticsearchException;
3739
import org.elasticsearch.SpecialPermission;
3840
import org.elasticsearch.cloud.azure.classic.AzureServiceRemoteException;
@@ -43,6 +45,8 @@
4345

4446
public class AzureComputeServiceImpl extends AbstractLifecycleComponent
4547
implements AzureComputeService {
48+
private static final Logger logger = LogManager.getLogger(AzureComputeServiceImpl.class);
49+
4650

4751
private final ComputeManagementClient client;
4852
private final String serviceName;

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,15 @@
3030
import com.google.api.client.http.HttpHeaders;
3131
import com.google.api.client.http.HttpResponse;
3232
import com.google.api.client.http.HttpTransport;
33+
import org.apache.logging.log4j.LogManager;
34+
import org.apache.logging.log4j.Logger;
3335
import org.elasticsearch.cloud.gce.util.Access;
3436
import org.elasticsearch.common.component.AbstractLifecycleComponent;
3537
import org.elasticsearch.common.settings.Setting;
3638
import org.elasticsearch.common.settings.Settings;
3739

3840
public class GceMetadataService extends AbstractLifecycleComponent {
41+
private static final Logger logger = LogManager.getLogger(GceMetadataService.class);
3942

4043
// Forcing Google Token API URL as set in GCE SDK to
4144
// http://metadata/computeMetadata/v1/instance/service-accounts/default/token

plugins/repository-azure/src/main/java/org/elasticsearch/repositories/azure/AzureRepository.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
import com.microsoft.azure.storage.LocationMode;
2323
import com.microsoft.azure.storage.StorageException;
2424

25+
import org.apache.logging.log4j.LogManager;
26+
import org.apache.logging.log4j.Logger;
2527
import org.apache.logging.log4j.message.ParameterizedMessage;
2628
import org.elasticsearch.cluster.metadata.MetaData;
2729
import org.elasticsearch.cluster.metadata.RepositoryMetaData;
@@ -58,6 +60,7 @@
5860
* </dl>
5961
*/
6062
public class AzureRepository extends BlobStoreRepository {
63+
private static final Logger logger = LogManager.getLogger(AzureRepository.class);
6164

6265
public static final String TYPE = "azure";
6366

plugins/repository-gcs/src/main/java/org/elasticsearch/repositories/gcs/GoogleCloudStorageRepository.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
package org.elasticsearch.repositories.gcs;
2121

22+
import org.apache.logging.log4j.LogManager;
23+
import org.apache.logging.log4j.Logger;
2224
import org.elasticsearch.cluster.metadata.RepositoryMetaData;
2325
import org.elasticsearch.common.Strings;
2426
import org.elasticsearch.common.blobstore.BlobPath;
@@ -39,6 +41,7 @@
3941
import static org.elasticsearch.common.settings.Setting.simpleString;
4042

4143
class GoogleCloudStorageRepository extends BlobStoreRepository {
44+
private static final Logger logger = LogManager.getLogger(GoogleCloudStorageRepository.class);
4245

4346
// package private for testing
4447
static final ByteSizeValue MIN_CHUNK_SIZE = new ByteSizeValue(1, ByteSizeUnit.BYTES);

plugins/repository-hdfs/src/main/java/org/elasticsearch/repositories/hdfs/HdfsRepository.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252

5353
public final class HdfsRepository extends BlobStoreRepository {
5454

55-
private static final Logger LOGGER = LogManager.getLogger(HdfsRepository.class);
55+
private static final Logger logger = LogManager.getLogger(HdfsRepository.class);
5656

5757
private static final String CONF_SECURITY_PRINCIPAL = "security.principal";
5858

@@ -105,7 +105,7 @@ private HdfsBlobStore createBlobstore(URI uri, String path, Settings repositoryS
105105

106106
final Settings confSettings = repositorySettings.getByPrefix("conf.");
107107
for (String key : confSettings.keySet()) {
108-
LOGGER.debug("Adding configuration to HDFS Client Configuration : {} = {}", key, confSettings.get(key));
108+
logger.debug("Adding configuration to HDFS Client Configuration : {} = {}", key, confSettings.get(key));
109109
hadoopConfiguration.set(key, confSettings.get(key));
110110
}
111111

@@ -161,7 +161,7 @@ private UserGroupInformation login(Configuration hadoopConfiguration, Settings r
161161

162162
// Check to see if the authentication method is compatible
163163
if (kerberosPrincipal != null && authMethod.equals(AuthenticationMethod.SIMPLE)) {
164-
LOGGER.warn("Hadoop authentication method is set to [SIMPLE], but a Kerberos principal is " +
164+
logger.warn("Hadoop authentication method is set to [SIMPLE], but a Kerberos principal is " +
165165
"specified. Continuing with [KERBEROS] authentication.");
166166
SecurityUtil.setAuthenticationMethod(AuthenticationMethod.KERBEROS, hadoopConfiguration);
167167
} else if (kerberosPrincipal == null && authMethod.equals(AuthenticationMethod.KERBEROS)) {
@@ -174,15 +174,15 @@ private UserGroupInformation login(Configuration hadoopConfiguration, Settings r
174174
UserGroupInformation.setConfiguration(hadoopConfiguration);
175175

176176
// Debugging
177-
LOGGER.debug("Hadoop security enabled: [{}]", UserGroupInformation.isSecurityEnabled());
178-
LOGGER.debug("Using Hadoop authentication method: [{}]", SecurityUtil.getAuthenticationMethod(hadoopConfiguration));
177+
logger.debug("Hadoop security enabled: [{}]", UserGroupInformation.isSecurityEnabled());
178+
logger.debug("Using Hadoop authentication method: [{}]", SecurityUtil.getAuthenticationMethod(hadoopConfiguration));
179179

180180
// UserGroupInformation (UGI) instance is just a Hadoop specific wrapper around a Java Subject
181181
try {
182182
if (UserGroupInformation.isSecurityEnabled()) {
183183
String principal = preparePrincipal(kerberosPrincipal);
184184
String keytab = HdfsSecurityContext.locateKeytabFile(environment).toString();
185-
LOGGER.debug("Using kerberos principal [{}] and keytab located at [{}]", principal, keytab);
185+
logger.debug("Using kerberos principal [{}] and keytab located at [{}]", principal, keytab);
186186
return UserGroupInformation.loginUserFromKeytabAndReturnUGI(principal, keytab);
187187
}
188188
return UserGroupInformation.getCurrentUser();
@@ -203,7 +203,7 @@ private static String preparePrincipal(String originalPrincipal) {
203203
}
204204

205205
if (originalPrincipal.equals(finalPrincipal) == false) {
206-
LOGGER.debug("Found service principal. Converted original principal name [{}] to server principal [{}]",
206+
logger.debug("Found service principal. Converted original principal name [{}] to server principal [{}]",
207207
originalPrincipal, finalPrincipal);
208208
}
209209
}

plugins/transport-nio/src/main/java/org/elasticsearch/http/nio/NioHttpServerTransport.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
package org.elasticsearch.http.nio;
2121

2222
import io.netty.handler.codec.http.HttpMethod;
23+
import org.apache.logging.log4j.LogManager;
2324
import org.apache.logging.log4j.Logger;
2425
import org.elasticsearch.ElasticsearchException;
2526
import org.elasticsearch.common.Strings;
@@ -80,6 +81,7 @@
8081
import static org.elasticsearch.http.nio.cors.NioCorsHandler.ANY_ORIGIN;
8182

8283
public class NioHttpServerTransport extends AbstractHttpServerTransport {
84+
private static final Logger logger = LogManager.getLogger(NioHttpServerTransport.class);
8385

8486
public static final Setting<Integer> NIO_HTTP_ACCEPTOR_COUNT =
8587
intSetting("http.nio.acceptor_count", 1, 1, Setting.Property.NodeScope);

plugins/transport-nio/src/main/java/org/elasticsearch/transport/nio/NioTransport.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
package org.elasticsearch.transport.nio;
2121

22+
import org.apache.logging.log4j.LogManager;
23+
import org.apache.logging.log4j.Logger;
2224
import org.elasticsearch.ElasticsearchException;
2325
import org.elasticsearch.Version;
2426
import org.elasticsearch.cluster.node.DiscoveryNode;
@@ -55,6 +57,7 @@
5557
import static org.elasticsearch.common.util.concurrent.EsExecutors.daemonThreadFactory;
5658

5759
public class NioTransport extends TcpTransport {
60+
private static final Logger logger = LogManager.getLogger(NioTransport.class);
5861

5962
public static final Setting<Integer> NIO_WORKER_COUNT =
6063
new Setting<>("transport.nio.worker_count",

0 commit comments

Comments
 (0)