Improve exception handling in IT to reduce excessive stack trace messages (#10955)

* Suppress logging for some exceptions to reduce excessive stack trace messages

Signed-off-by: frank chen <frank.chen021@outlook.com>

* log message for channel disconnected exception

Signed-off-by: frank chen <frank.chen021@outlook.com>
This commit is contained in:
frank chen 2021-03-11 13:27:55 +08:00 committed by GitHub
parent 4897731e37
commit b79b7e6dfb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 23 additions and 1 deletions

View File

@ -35,10 +35,12 @@ import org.apache.druid.java.util.http.client.response.StatusResponseHolder;
import org.apache.druid.server.coordinator.CoordinatorDynamicConfig; import org.apache.druid.server.coordinator.CoordinatorDynamicConfig;
import org.apache.druid.testing.IntegrationTestingConfig; import org.apache.druid.testing.IntegrationTestingConfig;
import org.apache.druid.testing.guice.TestClient; import org.apache.druid.testing.guice.TestClient;
import org.jboss.netty.channel.ChannelException;
import org.jboss.netty.handler.codec.http.HttpMethod; import org.jboss.netty.handler.codec.http.HttpMethod;
import org.jboss.netty.handler.codec.http.HttpResponseStatus; import org.jboss.netty.handler.codec.http.HttpResponseStatus;
import java.net.URL; import java.net.URL;
import java.nio.channels.ClosedChannelException;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
@ -185,7 +187,27 @@ public class DruidClusterAdminClient
return response.getStatus().equals(HttpResponseStatus.OK); return response.getStatus().equals(HttpResponseStatus.OK);
} }
catch (Throwable e) { catch (Throwable e) {
//
// supress stack trace logging for some specific exceptions
// to reduce excessive stack trace messages when waiting druid nodes to start up
//
if (e.getCause() instanceof ChannelException) {
Throwable channelException = e.getCause();
if (channelException.getCause() instanceof ClosedChannelException) {
LOG.error("Channel Closed");
} else if ("Channel disconnected".equals(channelException.getMessage())) {
// log message only
LOG.error("Channel disconnected");
} else {
// log stack trace for unknown exception
LOG.error(e, ""); LOG.error(e, "");
}
} else {
// log stack trace for unknown exception
LOG.error(e, "");
}
return false; return false;
} }
}, },