You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@slider.apache.org by st...@apache.org on 2014/11/06 17:55:42 UTC
[2/2] git commit: SLIDER-555 server-side log4j
SLIDER-555 server-side log4j
Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/b0a773cf
Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/b0a773cf
Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/b0a773cf
Branch: refs/heads/releases/slider-0.60
Commit: b0a773cf3d90022b5eb84a5e31bb3495c724cbc6
Parents: 3fbaa52
Author: Steve Loughran <st...@apache.org>
Authored: Thu Nov 6 16:54:19 2014 +0000
Committer: Steve Loughran <st...@apache.org>
Committed: Thu Nov 6 16:55:21 2014 +0000
----------------------------------------------------------------------
.../org/apache/slider/client/SliderClient.java | 11 ++++++++
.../org/apache/slider/common/SliderKeys.java | 9 ++++--
.../apache/slider/common/tools/SliderUtils.java | 29 +++-----------------
3 files changed, 22 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/b0a773cf/slider-core/src/main/java/org/apache/slider/client/SliderClient.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/client/SliderClient.java b/slider-core/src/main/java/org/apache/slider/client/SliderClient.java
index 676d865..b9ed2b5 100644
--- a/slider-core/src/main/java/org/apache/slider/client/SliderClient.java
+++ b/slider-core/src/main/java/org/apache/slider/client/SliderClient.java
@@ -1175,6 +1175,7 @@ public class SliderClient extends AbstractSliderLaunchedService implements RunSe
Map<String, LocalResource> localResources = amLauncher.getLocalResources();
// look for the configuration directory named on the command line
+ boolean hasServerLog4jProperties = false;
Path remoteConfPath = null;
String relativeConfDir = null;
String confdirProp =
@@ -1192,6 +1193,10 @@ public class SliderClient extends AbstractSliderLaunchedService implements RunSe
log.debug("Slider configuration directory is {}; remote to be {}",
localConfDirPath, remoteConfPath);
SliderUtils.copyDirectory(config, localConfDirPath, remoteConfPath, null);
+
+ File log4jserver =
+ new File(confDir, SliderKeys.LOG4J_SERVER_PROP_FILENAME);
+ hasServerLog4jProperties = log4jserver.isFile();
}
// the assumption here is that minimr cluster => this is a test run
// and the classpath can look after itself
@@ -1319,6 +1324,12 @@ public class SliderClient extends AbstractSliderLaunchedService implements RunSe
sliderAM.addJVMOptions(instanceDefinition, commandLine);
// enable asserts if the text option is set
commandLine.enableJavaAssertions();
+
+ // if the conf dir has a log4j-server.properties, switch to that
+ if (hasServerLog4jProperties) {
+ commandLine.sysprop(SYSPROP_LOG4_CONFIGURATION, LOG4J_SERVER_PROP_FILENAME);
+ }
+
// add the AM sevice entry point
commandLine.add(SliderAppMaster.SERVICE_CLASSNAME);
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/b0a773cf/slider-core/src/main/java/org/apache/slider/common/SliderKeys.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/common/SliderKeys.java b/slider-core/src/main/java/org/apache/slider/common/SliderKeys.java
index 1a94d83..9e721cf 100644
--- a/slider-core/src/main/java/org/apache/slider/common/SliderKeys.java
+++ b/slider-core/src/main/java/org/apache/slider/common/SliderKeys.java
@@ -133,16 +133,21 @@ public interface SliderKeys extends SliderXmlConfKeys {
String SUBMITTED_CONF_DIR = "confdir";
/**
- * Slider AM log4j file name
+ * Slider AM log4j file name : {@value}
*/
String LOG4J_SERVER_PROP_FILENAME = "log4j-server.properties";
/**
- * Standard log4j file name
+ * Standard log4j file name : {@value}
*/
String LOG4J_PROP_FILENAME = "log4j.properties";
/**
+ * Log4j sysprop to name the resource :{@value}
+ */
+ String SYSPROP_LOG4_CONFIGURATION = "log4j.configuration";
+
+ /**
* name of the Slider client resource
* loaded when the service is loaded.
*/
http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/b0a773cf/slider-core/src/main/java/org/apache/slider/common/tools/SliderUtils.java
----------------------------------------------------------------------
diff --git a/slider-core/src/main/java/org/apache/slider/common/tools/SliderUtils.java b/slider-core/src/main/java/org/apache/slider/common/tools/SliderUtils.java
index 0ff5ccb..82b17fd 100644
--- a/slider-core/src/main/java/org/apache/slider/common/tools/SliderUtils.java
+++ b/slider-core/src/main/java/org/apache/slider/common/tools/SliderUtils.java
@@ -415,9 +415,7 @@ public final class SliderUtils {
new SliderFileSystem(destFS, conf).createWithPermissions(destDirPath,
permission);
}
- // Slider AM now has its own log4j-server.properties file
- List<Path> sourcePaths = new ArrayList<Path>();
- Path serverLog4jPath = null;
+ Path[] sourcePaths = new Path[srcFileCount];
for (int i = 0; i < srcFileCount; i++) {
FileStatus e = entries[i];
Path srcFile = e.getPath();
@@ -427,32 +425,13 @@ public final class SliderUtils {
log.warn(msg);
throw new IOException(msg);
}
- if (SliderKeys.LOG4J_SERVER_PROP_FILENAME.equals(srcFile.getName())) {
- // log4j-server.properties will be copied as log4j.properties
- serverLog4jPath = srcFile;
- log.debug("copying src conf file {} as {}", srcFile,
- SliderKeys.LOG4J_PROP_FILENAME);
- continue;
- }
- if (SliderKeys.LOG4J_PROP_FILENAME.equals(srcFile.getName())) {
- // ignore log4j.properties entirely for Slider AM
- log.debug("ignoring file {}", srcFile);
- continue;
- }
log.debug("copying src conf file {}", srcFile);
- sourcePaths.add(srcFile);
+ sourcePaths[i] = srcFile;
}
- log.debug("Copying {} files from {} to dest {}",
- sourcePaths.size() + (serverLog4jPath != null ? 1 : 0),
+ log.debug("Copying {} files from {} to dest {}", srcFileCount,
srcDirPath,
destDirPath);
- FileUtil.copy(srcFS, sourcePaths.toArray(new Path[0]), destFS, destDirPath,
- false, true, conf);
- // Now copy log4j-server.properties (if exists) to dest as log4j.properties
- if (serverLog4jPath != null) {
- FileUtil.copy(srcFS, serverLog4jPath, destFS, new Path(destDirPath,
- SliderKeys.LOG4J_PROP_FILENAME), false, true, conf);
- }
+ FileUtil.copy(srcFS, sourcePaths, destFS, destDirPath, false, true, conf);
return srcFileCount;
}