[NO ISSUE][OTH] Log directory tweak, minor perf tweaks
Change-Id: I174d4527fb2c00aed26d83a49c92872ad1ddee00
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2910
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Contrib: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Murtadha Hubail <mhubail@apache.org>
diff --git a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/CCLogConfigurationFactory.java b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/CCLogConfigurationFactory.java
index 59ef913..22dea9f 100644
--- a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/CCLogConfigurationFactory.java
+++ b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/CCLogConfigurationFactory.java
@@ -18,6 +18,9 @@
*/
package org.apache.hyracks.control.cc;
+import java.io.File;
+import java.net.URI;
+
import org.apache.hyracks.control.common.controllers.CCConfig;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.core.LoggerContext;
@@ -30,8 +33,6 @@
import org.apache.logging.log4j.core.config.builder.api.LayoutComponentBuilder;
import org.apache.logging.log4j.core.config.builder.impl.BuiltConfiguration;
-import java.net.URI;
-
public class CCLogConfigurationFactory extends ConfigurationFactory {
private CCConfig config;
@@ -40,7 +41,7 @@
}
public Configuration createConfiguration(ConfigurationBuilder<BuiltConfiguration> builder) {
- String logDir = config.getLogDir();
+ File logDir = new File(config.getLogDir());
builder.setStatusLevel(Level.WARN);
builder.setConfigurationName("RollingBuilder");
// create a rolling file appender
@@ -50,8 +51,8 @@
.addComponent(builder.newComponent("CronTriggeringPolicy").addAttribute("schedule", "0 0 0 * * ?"))
.addComponent(builder.newComponent("SizeBasedTriggeringPolicy").addAttribute("size", "50M"));
AppenderComponentBuilder defaultRoll =
- builder.newAppender("default", "RollingFile").addAttribute("fileName", logDir + "cc.log")
- .addAttribute("filePattern", logDir + "cc-%d{MM-dd-yy}.log.gz").add(defaultLayout)
+ builder.newAppender("default", "RollingFile").addAttribute("fileName", new File(logDir, "cc.log"))
+ .addAttribute("filePattern", new File(logDir, "cc-%d{MM-dd-yy}.log.gz")).add(defaultLayout)
.addComponent(triggeringPolicy);
builder.add(defaultRoll);
@@ -60,8 +61,8 @@
LayoutComponentBuilder accessLayout = builder.newLayout("PatternLayout").addAttribute("pattern", "%m%n");
AppenderComponentBuilder accessRoll =
- builder.newAppender("access", "RollingFile").addAttribute("fileName", logDir + "access.log")
- .addAttribute("filePattern", logDir + "access-%d{MM-dd-yy}.log.gz").add(accessLayout)
+ builder.newAppender("access", "RollingFile").addAttribute("fileName", new File(logDir, "access.log"))
+ .addAttribute("filePattern", new File(logDir, "access-%d{MM-dd-yy}.log.gz")).add(accessLayout)
.addComponent(triggeringPolicy);
builder.add(accessRoll);
builder.add(builder.newLogger("org.apache.hyracks.http.server.CLFLogger", Level.forName("ACCESS", 550))
diff --git a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/controllers/ControllerConfig.java b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/controllers/ControllerConfig.java
index 65c7ca5..07e61ba 100644
--- a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/controllers/ControllerConfig.java
+++ b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-common/src/main/java/org/apache/hyracks/control/common/controllers/ControllerConfig.java
@@ -45,7 +45,7 @@
LOG_DIR(
OptionTypes.STRING,
(Function<IApplicationConfig, String>) appConfig -> FileUtil
- .joinPath(appConfig.getString(ControllerConfig.Option.DEFAULT_DIR), "logs/"),
+ .joinPath(appConfig.getString(ControllerConfig.Option.DEFAULT_DIR), "logs"),
"The directory where logs for this node are written");
private final IOptionType type;
diff --git a/hyracks-fullstack/hyracks/hyracks-http/src/main/java/org/apache/hyracks/http/server/CLFLogger.java b/hyracks-fullstack/hyracks/hyracks-http/src/main/java/org/apache/hyracks/http/server/CLFLogger.java
index 70f861c..4732d71 100644
--- a/hyracks-fullstack/hyracks/hyracks-http/src/main/java/org/apache/hyracks/http/server/CLFLogger.java
+++ b/hyracks-fullstack/hyracks/hyracks-http/src/main/java/org/apache/hyracks/http/server/CLFLogger.java
@@ -44,7 +44,7 @@
public class CLFLogger extends ChannelDuplexHandler {
private static final Logger accessLogger = LogManager.getLogger();
- private static final String ACCESS_LOG_LEVEL = "ACCESS";
+ private static final Level ACCESS_LOG_LEVEL = Level.forName("ACCESS", 550);
private static final DateTimeFormatter DATE_TIME_FORMATTER =
DateTimeFormatter.ofPattern("dd/MMM/yyyy:HH:mm:ss Z").withZone(ZoneId.systemDefault());
private StringBuilder logLineBuilder;
@@ -116,6 +116,9 @@
}
private void printAndPrepare() {
+ if (!accessLogger.isEnabled(ACCESS_LOG_LEVEL)) {
+ return;
+ }
logLineBuilder.append(clientIp);
//identd value - not relevant here
logLineBuilder.append(" - ");
@@ -128,7 +131,7 @@
logLineBuilder.append(" ").append(statusCode);
logLineBuilder.append(" ").append(respSize);
logLineBuilder.append(" ").append(userAgentRef);
- accessLogger.log(Level.forName(ACCESS_LOG_LEVEL, 550), logLineBuilder.toString());
+ accessLogger.log(ACCESS_LOG_LEVEL, logLineBuilder);
respSize = 0;
logLineBuilder.setLength(0);
}
diff --git a/hyracks-fullstack/hyracks/hyracks-http/src/main/java/org/apache/hyracks/http/server/HttpServer.java b/hyracks-fullstack/hyracks/hyracks-http/src/main/java/org/apache/hyracks/http/server/HttpServer.java
index 343faa4..1a5c2fa 100644
--- a/hyracks-fullstack/hyracks/hyracks-http/src/main/java/org/apache/hyracks/http/server/HttpServer.java
+++ b/hyracks-fullstack/hyracks/hyracks-http/src/main/java/org/apache/hyracks/http/server/HttpServer.java
@@ -100,7 +100,6 @@
this.workerGroup = workerGroup;
this.port = port;
this.closedHandler = closeHandler;
- InternalLoggerFactory.setDefaultFactory(Log4J2LoggerFactory.INSTANCE);
this.config = config;
ctx = new ConcurrentHashMap<>();
servlets = new ArrayList<>();