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 logging from elasticsearch-nio jar #30761

Merged
merged 4 commits into from
May 22, 2018
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
17 changes: 0 additions & 17 deletions libs/elasticsearch-nio/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ publishing {
}

dependencies {
compile "org.apache.logging.log4j:log4j-api:${versions.log4j}"

testCompile "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}"
testCompile "junit:junit:${versions.junit}"
testCompile "org.hamcrest:hamcrest-all:${versions.hamcrest}"
Expand Down Expand Up @@ -64,18 +62,3 @@ forbiddenApisMain {
// es-all is not checked as we connect and accept sockets
signaturesURLs = [PrecommitTasks.getResource('/forbidden/jdk-signatures.txt')]
}

//JarHell is part of es core, which we don't want to pull in
jarHell.enabled=false

thirdPartyAudit.excludes = [
'org/osgi/framework/AdaptPermission',
'org/osgi/framework/AdminPermission',
'org/osgi/framework/Bundle',
'org/osgi/framework/BundleActivator',
'org/osgi/framework/BundleContext',
'org/osgi/framework/BundleEvent',
'org/osgi/framework/SynchronousBundleListener',
'org/osgi/framework/wiring/BundleWire',
'org/osgi/framework/wiring/BundleWiring'
]
1 change: 0 additions & 1 deletion libs/elasticsearch-nio/licenses/log4j-api-2.9.1.jar.sha1

This file was deleted.

202 changes: 0 additions & 202 deletions libs/elasticsearch-nio/licenses/log4j-api-LICENSE.txt

This file was deleted.

5 changes: 0 additions & 5 deletions libs/elasticsearch-nio/licenses/log4j-api-NOTICE.txt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@

package org.elasticsearch.nio;

import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.message.ParameterizedMessage;

import java.io.IOException;
import java.nio.channels.SelectionKey;
import java.util.function.Consumer;
import java.util.function.Supplier;

/**
Expand All @@ -33,8 +31,8 @@ public class AcceptorEventHandler extends EventHandler {

private final Supplier<SocketSelector> selectorSupplier;

public AcceptorEventHandler(Logger logger, Supplier<SocketSelector> selectorSupplier) {
super(logger);
public AcceptorEventHandler(Supplier<SocketSelector> selectorSupplier, Consumer<Exception> exceptionHandler) {
super(exceptionHandler);
this.selectorSupplier = selectorSupplier;
}

Expand All @@ -58,7 +56,7 @@ protected void handleRegistration(ServerChannelContext context) throws IOExcepti
* @param exception that occurred
*/
protected void registrationException(ServerChannelContext context, Exception exception) {
logger.error(new ParameterizedMessage("failed to register server channel: {}", context.getChannel()), exception);
context.handleException(exception);
}

/**
Expand All @@ -78,7 +76,6 @@ protected void acceptChannel(ServerChannelContext context) throws IOException {
* @param exception that occurred
*/
protected void acceptException(ServerChannelContext context, Exception exception) {
logger.debug(() -> new ParameterizedMessage("exception while accepting new channel from server channel: {}",
context.getChannel()), exception);
context.handleException(exception);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void runLoop() {
try {
selector.close();
} catch (IOException e) {
eventHandler.closeSelectorException(e);
eventHandler.selectorException(e);
} finally {
runLock.unlock();
exitedLoop.countDown();
Expand Down Expand Up @@ -123,7 +123,7 @@ void singleLoop() {
throw e;
}
} catch (IOException e) {
eventHandler.selectException(e);
eventHandler.selectorException(e);
} catch (Exception e) {
eventHandler.uncaughtException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,37 +19,26 @@

package org.elasticsearch.nio;

import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.message.ParameterizedMessage;

import java.io.IOException;
import java.nio.channels.Selector;
import java.util.function.Consumer;

public abstract class EventHandler {

protected final Logger logger;

EventHandler(Logger logger) {
this.logger = logger;
}
protected final Consumer<Exception> exceptionHandler;

/**
* This method handles an IOException that was thrown during a call to {@link Selector#select(long)}.
*
* @param exception the exception
*/
protected void selectException(IOException exception) {
logger.warn(new ParameterizedMessage("io exception during select [thread={}]", Thread.currentThread().getName()), exception);
protected EventHandler(Consumer<Exception> exceptionHandler) {
this.exceptionHandler = exceptionHandler;
}

/**
* This method handles an IOException that was thrown during a call to {@link Selector#close()}.
* This method handles an IOException that was thrown during a call to {@link Selector#select(long)} or
* {@link Selector#close()}.
*
* @param exception the exception
*/
protected void closeSelectorException(IOException exception) {
logger.warn(new ParameterizedMessage("io exception while closing selector [thread={}]", Thread.currentThread().getName()),
exception);
protected void selectorException(IOException exception) {
exceptionHandler.accept(exception);
}

/**
Expand Down Expand Up @@ -79,11 +68,11 @@ protected void handleClose(ChannelContext<?> context) {
/**
* This method is called when an attempt to close a channel throws an exception.
*
* @param context that was being closed
* @param channel that was being closed
* @param exception that occurred
*/
protected void closeException(ChannelContext<?> context, Exception exception) {
logger.debug(() -> new ParameterizedMessage("exception while closing channel: {}", context.getChannel()), exception);
protected void closeException(ChannelContext<?> channel, Exception exception) {
channel.handleException(exception);
}

/**
Expand All @@ -95,6 +84,6 @@ protected void closeException(ChannelContext<?> context, Exception exception) {
* @param exception that was thrown
*/
protected void genericChannelException(ChannelContext<?> channel, Exception exception) {
logger.debug(() -> new ParameterizedMessage("exception while handling event for channel: {}", channel.getChannel()), exception);
channel.handleException(exception);
}
}
Loading