[ASTERIXDB-1564][CONF] Consistently Use Log4j2
- user model changes: no
- storage format changes: no
- interface changes: no
Details:
- Replace java.util.logging by Log4j2.
- Excluded classes due to their tests:
- IoUtil
- Tracer
Change-Id: Ic137571292f45de1f1994c61d328b97185012197
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2226
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Contrib: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Michael Blow <mblow@apache.org>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
diff --git a/hyracks-fullstack/hyracks/hyracks-api/pom.xml b/hyracks-fullstack/hyracks/hyracks-api/pom.xml
index 5e3ccf7..71bf5fc 100644
--- a/hyracks-fullstack/hyracks/hyracks-api/pom.xml
+++ b/hyracks-fullstack/hyracks/hyracks-api/pom.xml
@@ -104,5 +104,9 @@
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-api</artifactId>
+ </dependency>
</dependencies>
</project>
diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/client/impl/ActivityClusterGraphBuilder.java b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/client/impl/ActivityClusterGraphBuilder.java
index 0b2cc9b..cd6362f 100644
--- a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/client/impl/ActivityClusterGraphBuilder.java
+++ b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/client/impl/ActivityClusterGraphBuilder.java
@@ -24,8 +24,6 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.hyracks.api.dataflow.ActivityId;
@@ -35,9 +33,11 @@
import org.apache.hyracks.api.job.ActivityClusterGraph;
import org.apache.hyracks.api.job.ActivityClusterId;
import org.apache.hyracks.api.job.JobActivityGraph;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
public class ActivityClusterGraphBuilder {
- private static final Logger LOGGER = Logger.getLogger(ActivityClusterGraphBuilder.class.getName());
+ private static final Logger LOGGER = LogManager.getLogger();
public ActivityClusterGraphBuilder() {
}
@@ -146,8 +146,8 @@
}
acg.addActivityClusters(acList);
- if (LOGGER.isLoggable(Level.FINE)) {
- LOGGER.fine(acg.toJSON().asText());
+ if (LOGGER.isDebugEnabled()) {
+ LOGGER.debug(acg.toJSON().asText());
}
return acg;
}
diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/client/impl/JobActivityGraphBuilder.java b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/client/impl/JobActivityGraphBuilder.java
index 084626e..64bcf6e 100644
--- a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/client/impl/JobActivityGraphBuilder.java
+++ b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/client/impl/JobActivityGraphBuilder.java
@@ -24,8 +24,6 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.hyracks.api.dataflow.ActivityId;
@@ -37,9 +35,11 @@
import org.apache.hyracks.api.job.JobActivityGraph;
import org.apache.hyracks.api.job.JobFlag;
import org.apache.hyracks.api.job.JobSpecification;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
public class JobActivityGraphBuilder implements IActivityGraphBuilder {
- private static final Logger LOGGER = Logger.getLogger(JobActivityGraphBuilder.class.getName());
+ private static final Logger LOGGER = LogManager.getLogger();
private final Map<ActivityId, IOperatorDescriptor> activityOperatorMap;
@@ -71,8 +71,8 @@
@Override
public void addSourceEdge(int operatorInputIndex, IActivity task, int taskInputIndex) {
- if (LOGGER.isLoggable(Level.FINEST)) {
- LOGGER.finest("Adding source edge: " + task.getActivityId() + ":" + operatorInputIndex + " -> "
+ if (LOGGER.isTraceEnabled()) {
+ LOGGER.trace("Adding source edge: " + task.getActivityId() + ":" + operatorInputIndex + " -> "
+ task.getActivityId() + ":" + taskInputIndex);
}
IOperatorDescriptor op = activityOperatorMap.get(task.getActivityId());
@@ -83,8 +83,8 @@
@Override
public void addTargetEdge(int operatorOutputIndex, IActivity task, int taskOutputIndex) {
- if (LOGGER.isLoggable(Level.FINEST)) {
- LOGGER.finest("Adding target edge: " + task.getActivityId() + ":" + operatorOutputIndex + " -> "
+ if (LOGGER.isTraceEnabled()) {
+ LOGGER.trace("Adding target edge: " + task.getActivityId() + ":" + operatorOutputIndex + " -> "
+ task.getActivityId() + ":" + taskOutputIndex);
}
IOperatorDescriptor op = activityOperatorMap.get(task.getActivityId());
diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/config/IApplicationConfig.java b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/config/IApplicationConfig.java
index ddcaab3..80ff77c 100644
--- a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/config/IApplicationConfig.java
+++ b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/config/IApplicationConfig.java
@@ -22,7 +22,8 @@
import java.util.List;
import java.util.Set;
import java.util.function.Predicate;
-import java.util.logging.Level;
+
+import org.apache.logging.log4j.Level;
/**
* Accessor for the data contained in the global application configuration file.
diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/exceptions/HyracksDataException.java b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/exceptions/HyracksDataException.java
index 7ae7cbf..58b4b27 100644
--- a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/exceptions/HyracksDataException.java
+++ b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/exceptions/HyracksDataException.java
@@ -20,10 +20,11 @@
package org.apache.hyracks.api.exceptions;
import java.io.Serializable;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import org.apache.hyracks.api.util.ErrorMessageUtil;
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
/**
* The main execution time exception type for runtime errors in a hyracks environment
@@ -31,7 +32,7 @@
public class HyracksDataException extends HyracksException {
private static final long serialVersionUID = 1L;
- private static final Logger LOGGER = Logger.getLogger(HyracksDataException.class.getName());
+ private static final Logger LOGGER = LogManager.getLogger();
public static HyracksDataException create(Throwable cause) {
if (cause instanceof HyracksDataException || cause == null) {
@@ -41,7 +42,7 @@
throw (Error) cause;
} else if (cause instanceof InterruptedException && !Thread.currentThread().isInterrupted()) {
// TODO(mblow): why not force interrupt on current thread?
- LOGGER.log(Level.WARNING,
+ LOGGER.log(Level.WARN,
"Wrapping an InterruptedException in HyracksDataException and current thread is not interrupted",
cause);
}
@@ -66,7 +67,7 @@
throw (Error) th;
} else if (th instanceof InterruptedException && !Thread.currentThread().isInterrupted()) {
// TODO(mblow): why not force interrupt on current thread?
- LOGGER.log(Level.WARNING, "Suppressing an InterruptedException in a HyracksDataException and current "
+ LOGGER.log(Level.WARN, "Suppressing an InterruptedException in a HyracksDataException and current "
+ "thread is not interrupted", th);
}
root.addSuppressed(th);
diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/lifecycle/LifeCycleComponentManager.java b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/lifecycle/LifeCycleComponentManager.java
index f5b4417..6d5d246 100644
--- a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/lifecycle/LifeCycleComponentManager.java
+++ b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/lifecycle/LifeCycleComponentManager.java
@@ -25,10 +25,11 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import org.apache.hyracks.util.ExitUtil;
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
public class LifeCycleComponentManager implements ILifeCycleComponentManager {
@@ -36,7 +37,7 @@
public static final String DUMP_PATH_KEY = "DUMP_PATH";
}
- private static final Logger LOGGER = Logger.getLogger(LifeCycleComponentManager.class.getName());
+ private static final Logger LOGGER = LogManager.getLogger();
private final List<ILifeCycleComponent> components;
private boolean stopInitiated;
@@ -54,7 +55,7 @@
@Override
public void uncaughtException(Thread t, Throwable e) {
try {
- LOGGER.log(Level.SEVERE, "Uncaught Exception from thread " + t.getName() + ". Calling shutdown hook", e);
+ LOGGER.log(Level.ERROR, "Uncaught Exception from thread " + t.getName() + ". Calling shutdown hook", e);
} finally {
ExitUtil.exit(99);
}
@@ -79,7 +80,7 @@
return;
}
stopped = true;
- if (LOGGER.isLoggable(Level.INFO)) {
+ if (LOGGER.isInfoEnabled()) {
LOGGER.info("Attempting to stop " + this);
}
if (stopInitiated) {
@@ -87,14 +88,14 @@
return;
}
if (!configured) {
- if (LOGGER.isLoggable(Level.SEVERE)) {
- LOGGER.severe("Lifecycle management not configured " + this);
+ if (LOGGER.isErrorEnabled()) {
+ LOGGER.error("Lifecycle management not configured " + this);
}
return;
}
stopInitiated = true;
- LOGGER.severe("Stopping instance");
+ LOGGER.error("Stopping instance");
FileOutputStream componentDumpStream = null;
String componentDumpPath = null;
@@ -110,13 +111,13 @@
}
componentDumpStream = new FileOutputStream(f);
}
- if (LOGGER.isLoggable(Level.INFO)) {
+ if (LOGGER.isInfoEnabled()) {
LOGGER.info("Stopping component instance " + component.getClass().getName() + "; dump state: "
+ dumpState + ", dump path: " + componentDumpPath);
}
component.stop(dumpState, componentDumpStream);
} catch (Exception e) {
- LOGGER.log(Level.SEVERE, "Exception in stopping component " + component.getClass().getName(), e);
+ LOGGER.log(Level.ERROR, "Exception in stopping component " + component.getClass().getName(), e);
} finally {
if (componentDumpStream != null) {
componentDumpStream.close();
@@ -132,11 +133,11 @@
dumpPath = configuration.get(Config.DUMP_PATH_KEY);
if (dumpPath == null) {
dumpPath = System.getProperty("user.dir");
- if (LOGGER.isLoggable(Level.WARNING)) {
- LOGGER.warning("dump path not configured. Using current directory " + dumpPath);
+ if (LOGGER.isWarnEnabled()) {
+ LOGGER.warn("dump path not configured. Using current directory " + dumpPath);
}
}
- if (LOGGER.isLoggable(Level.INFO)) {
+ if (LOGGER.isInfoEnabled()) {
LOGGER.info("LifecycleComponentManager configured " + this);
}
configured = true;
diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/util/ErrorMessageUtil.java b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/util/ErrorMessageUtil.java
index e9491f3..26ce2c1 100644
--- a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/util/ErrorMessageUtil.java
+++ b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/util/ErrorMessageUtil.java
@@ -26,12 +26,14 @@
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
-import java.util.logging.Level;
-import java.util.logging.Logger;
+
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
public class ErrorMessageUtil {
- private static final Logger LOGGER = Logger.getLogger(ErrorMessageUtil.class.getName());
+ private static final Logger LOGGER = LogManager.getLogger();
public static final String NONE = "";
private static final String COMMA = ",";
@@ -99,7 +101,7 @@
return fmt.out().toString();
} catch (Exception e) {
// Do not throw further exceptions during exception processing.
- LOGGER.log(Level.WARNING, e.getLocalizedMessage(), e);
+ LOGGER.log(Level.WARN, e.getLocalizedMessage(), e);
return e.getMessage();
}
}
diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/util/SingleThreadEventProcessor.java b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/util/SingleThreadEventProcessor.java
index 21965c7..9eb3b8e 100644
--- a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/util/SingleThreadEventProcessor.java
+++ b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/util/SingleThreadEventProcessor.java
@@ -19,15 +19,16 @@
package org.apache.hyracks.api.util;
import java.util.concurrent.LinkedBlockingQueue;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import org.apache.hyracks.api.exceptions.ErrorCode;
import org.apache.hyracks.api.exceptions.HyracksDataException;
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
public abstract class SingleThreadEventProcessor<T> implements Runnable {
- private static final Logger LOGGER = Logger.getLogger(SingleThreadEventProcessor.class.getName());
+ private static final Logger LOGGER = LogManager.getLogger();
private final String name;
private final LinkedBlockingQueue<T> eventInbox;
private volatile Thread executorThread;
@@ -50,10 +51,10 @@
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
} catch (Exception e) {
- LOGGER.log(Level.SEVERE, "Error handling an event", e);
+ LOGGER.log(Level.ERROR, "Error handling an event", e);
}
}
- LOGGER.log(Level.WARNING, "Stopped " + Thread.currentThread().getName());
+ LOGGER.log(Level.WARN, "Stopped " + Thread.currentThread().getName());
}
protected abstract void handle(T event) throws Exception; //NOSONAR
@@ -71,7 +72,7 @@
int attempt = 0;
while (executorThread.isAlive()) {
attempt++;
- LOGGER.log(Level.WARNING,
+ LOGGER.log(Level.WARN,
"Failed to stop event processor after " + attempt + " attempts. Interrupted exception swallowed?");
if (attempt == 10) {
throw HyracksDataException.create(ErrorCode.FAILED_TO_SHUTDOWN_EVENT_PROCESSOR, name);