You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by im...@apache.org on 2019/03/04 21:08:51 UTC
[asterixdb] 04/09: [NO ISSUE] Make logDir use paths correctly
This is an automated email from the ASF dual-hosted git repository.
imaxon pushed a commit to branch release-0.9.4.1
in repository https://gitbox.apache.org/repos/asf/asterixdb.git
commit 17d9e49d4c96502e223f04c9915adb118e48f531
Author: Ian Maxon <im...@apache.org>
AuthorDate: Tue Feb 12 14:04:11 2019 -0800
[NO ISSUE] Make logDir use paths correctly
Change-Id: Ia9b372900c3f840d39577e049c0590f8649e2694
Reviewed-on: https://asterix-gerrit.ics.uci.edu/3185
Sonar-Qube: Jenkins <je...@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <je...@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <je...@fulliautomatix.ics.uci.edu>
Reviewed-by: Michael Blow <mb...@apache.org>
---
.../control/common/controllers/ControllerConfig.java | 5 ++++-
.../hyracks/control/nc/NCLogConfigurationFactory.java | 19 +++++++++++--------
2 files changed, 15 insertions(+), 9 deletions(-)
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 a800ac4..79ad71f 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
@@ -18,6 +18,7 @@
*/
package org.apache.hyracks.control.common.controllers;
+import java.io.File;
import java.io.Serializable;
import java.net.URL;
import java.util.function.Function;
@@ -120,6 +121,8 @@ public class ControllerConfig implements Serializable {
}
public String getLogDir() {
- return configManager.getAppConfig().getString(ControllerConfig.Option.LOG_DIR);
+ String relPath = configManager.getAppConfig().getString(ControllerConfig.Option.LOG_DIR);
+ String fullPath = new File(relPath).getAbsolutePath();
+ return fullPath;
}
}
diff --git a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/NCLogConfigurationFactory.java b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/NCLogConfigurationFactory.java
index 990d6c9..587696c 100644
--- a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/NCLogConfigurationFactory.java
+++ b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/NCLogConfigurationFactory.java
@@ -30,6 +30,7 @@ import org.apache.logging.log4j.core.config.builder.api.ConfigurationBuilder;
import org.apache.logging.log4j.core.config.builder.api.LayoutComponentBuilder;
import org.apache.logging.log4j.core.config.builder.impl.BuiltConfiguration;
+import java.io.File;
import java.net.URI;
public class NCLogConfigurationFactory extends ConfigurationFactory {
@@ -41,7 +42,7 @@ public class NCLogConfigurationFactory extends ConfigurationFactory {
public Configuration createConfiguration(ConfigurationBuilder<BuiltConfiguration> builder) {
String nodeId = config.getNodeId();
- String logDir = config.getLogDir();
+ File logDir = new File(config.getLogDir());
builder.setStatusLevel(Level.WARN);
builder.setConfigurationName("RollingBuilder");
// create a rolling file appender
@@ -50,10 +51,11 @@ public class NCLogConfigurationFactory extends ConfigurationFactory {
ComponentBuilder triggeringPolicy = builder.newComponent("Policies")
.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 + "nc-" + nodeId + ".log")
- .addAttribute("filePattern", logDir + "nc-" + nodeId + "-%d{MM-dd-yy}.log.gz")
- .add(defaultLayout).addComponent(triggeringPolicy);
+ AppenderComponentBuilder defaultRoll = builder.newAppender("default", "RollingFile")
+ .addAttribute("fileName", new File(logDir, "nc-" + nodeId + ".log").getAbsolutePath())
+ .addAttribute("filePattern",
+ new File(logDir, "nc-" + nodeId + "-%d{MM-dd-yy}.log.gz").getAbsolutePath())
+ .add(defaultLayout).addComponent(triggeringPolicy);
builder.add(defaultRoll);
// create the new logger
@@ -61,9 +63,10 @@ public class NCLogConfigurationFactory extends ConfigurationFactory {
LayoutComponentBuilder accessLayout = builder.newLayout("PatternLayout").addAttribute("pattern", "%m%n");
AppenderComponentBuilder accessRoll = builder.newAppender("access", "RollingFile")
- .addAttribute("fileName", logDir + "access-" + nodeId + ".log")
- .addAttribute("filePattern", logDir + "access-" + nodeId + "-%d{MM-dd-yy}.log.gz").add(accessLayout)
- .addComponent(triggeringPolicy);
+ .addAttribute("fileName", new File(logDir, "access-" + nodeId + ".log").getAbsolutePath())
+ .addAttribute("filePattern",
+ new File(logDir, "access-" + nodeId + "-%d{MM-dd-yy}.log.gz").getAbsolutePath())
+ .add(accessLayout).addComponent(triggeringPolicy);
builder.add(accessRoll);
builder.add(builder.newLogger("org.apache.hyracks.http.server.CLFLogger", Level.forName("ACCESS", 550))
.add(builder.newAppenderRef("access")).addAttribute("additivity", false));