YARN-7407. Moving logging APIs over to slf4j in hadoop-yarn-applications. Contributed by Yeliang Cang.
This commit is contained in:
parent
fad22d8ab4
commit
785f1b0d11
@ -47,8 +47,6 @@
|
||||
import org.apache.commons.cli.HelpFormatter;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.apache.commons.cli.ParseException;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.hadoop.classification.InterfaceAudience;
|
||||
import org.apache.hadoop.classification.InterfaceAudience.Private;
|
||||
import org.apache.hadoop.classification.InterfaceStability;
|
||||
@ -113,6 +111,8 @@
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.sun.jersey.api.client.ClientHandlerException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* An ApplicationMaster for executing shell commands on a set of launched
|
||||
@ -179,7 +179,8 @@
|
||||
@InterfaceStability.Unstable
|
||||
public class ApplicationMaster {
|
||||
|
||||
private static final Log LOG = LogFactory.getLog(ApplicationMaster.class);
|
||||
private static final Logger LOG = LoggerFactory
|
||||
.getLogger(ApplicationMaster.class);
|
||||
|
||||
@VisibleForTesting
|
||||
@Private
|
||||
@ -349,7 +350,7 @@ public static void main(String[] args) {
|
||||
appMaster.run();
|
||||
result = appMaster.finish();
|
||||
} catch (Throwable t) {
|
||||
LOG.fatal("Error running ApplicationMaster", t);
|
||||
LOG.error("Error running ApplicationMaster", t);
|
||||
LogManager.shutdown();
|
||||
ExitUtil.terminate(1, t);
|
||||
}
|
||||
@ -388,7 +389,7 @@ private void dumpOutDebugInfo() {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
IOUtils.cleanup(LOG, buf);
|
||||
IOUtils.cleanupWithLogger(LOG, buf);
|
||||
}
|
||||
}
|
||||
|
||||
@ -630,7 +631,7 @@ public void run() throws YarnException, IOException, InterruptedException {
|
||||
LOG.info("Executing with tokens:");
|
||||
while (iter.hasNext()) {
|
||||
Token<?> token = iter.next();
|
||||
LOG.info(token);
|
||||
LOG.info(token.toString());
|
||||
if (token.getKind().equals(AMRMTokenIdentifier.KIND_NAME)) {
|
||||
iter.remove();
|
||||
}
|
||||
|
@ -36,8 +36,6 @@
|
||||
import org.apache.commons.cli.ParseException;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.hadoop.classification.InterfaceAudience;
|
||||
import org.apache.hadoop.classification.InterfaceStability;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
@ -85,6 +83,8 @@
|
||||
import org.apache.hadoop.yarn.exceptions.YarnException;
|
||||
import org.apache.hadoop.yarn.util.resource.Resources;
|
||||
import org.apache.hadoop.yarn.util.timeline.TimelineUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Client for Distributed Shell application submission to YARN.
|
||||
@ -121,7 +121,8 @@
|
||||
@InterfaceStability.Unstable
|
||||
public class Client {
|
||||
|
||||
private static final Log LOG = LogFactory.getLog(Client.class);
|
||||
private static final Logger LOG = LoggerFactory
|
||||
.getLogger(Client.class);
|
||||
|
||||
private static final int DEFAULT_AM_MEMORY = 100;
|
||||
private static final int DEFAULT_AM_VCORES = 1;
|
||||
@ -237,7 +238,7 @@ public static void main(String[] args) {
|
||||
}
|
||||
result = client.run();
|
||||
} catch (Throwable t) {
|
||||
LOG.fatal("Error running Client", t);
|
||||
LOG.error("Error running Client", t);
|
||||
System.exit(1);
|
||||
}
|
||||
if (result) {
|
||||
|
@ -21,14 +21,14 @@
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.hadoop.yarn.api.records.ContainerId;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class ContainerLaunchFailAppMaster extends ApplicationMaster {
|
||||
|
||||
private static final Log LOG =
|
||||
LogFactory.getLog(ContainerLaunchFailAppMaster.class);
|
||||
private static final Logger LOG =
|
||||
LoggerFactory.getLogger(ContainerLaunchFailAppMaster.class);
|
||||
|
||||
public ContainerLaunchFailAppMaster() {
|
||||
super();
|
||||
@ -69,7 +69,7 @@ public static void main(String[] args) {
|
||||
appMaster.run();
|
||||
result = appMaster.finish();
|
||||
} catch (Throwable t) {
|
||||
LOG.fatal("Error running ApplicationMaster", t);
|
||||
LOG.error("Error running ApplicationMaster", t);
|
||||
System.exit(1);
|
||||
}
|
||||
if (result) {
|
||||
|
@ -20,13 +20,14 @@
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.hadoop.yarn.exceptions.YarnException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class TestDSFailedAppMaster extends ApplicationMaster {
|
||||
|
||||
private static final Log LOG = LogFactory.getLog(TestDSFailedAppMaster.class);
|
||||
private static final Logger LOG = LoggerFactory
|
||||
.getLogger(TestDSFailedAppMaster.class);
|
||||
|
||||
@Override
|
||||
public void run() throws YarnException, IOException, InterruptedException {
|
||||
|
@ -18,12 +18,14 @@
|
||||
|
||||
package org.apache.hadoop.yarn.applications.distributedshell;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class TestDSSleepingAppMaster extends ApplicationMaster{
|
||||
|
||||
private static final Log LOG = LogFactory.getLog(TestDSSleepingAppMaster.class);
|
||||
private static final Logger LOG = LoggerFactory
|
||||
.getLogger(TestDSSleepingAppMaster.class);
|
||||
private static final long SLEEP_TIME = 5000;
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
@ -39,8 +39,6 @@
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
|
||||
import org.apache.hadoop.fs.FileContext;
|
||||
@ -96,11 +94,13 @@
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.junit.rules.Timeout;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class TestDistributedShell {
|
||||
|
||||
private static final Log LOG =
|
||||
LogFactory.getLog(TestDistributedShell.class);
|
||||
private static final Logger LOG =
|
||||
LoggerFactory.getLogger(TestDistributedShell.class);
|
||||
|
||||
protected MiniYARNCluster yarnCluster = null;
|
||||
protected MiniDFSCluster hdfsCluster = null;
|
||||
@ -892,11 +892,11 @@ public void testDSShellWithCustomLogPropertyFile() throws Exception {
|
||||
};
|
||||
|
||||
//Before run the DS, the default the log level is INFO
|
||||
final Log LOG_Client =
|
||||
LogFactory.getLog(Client.class);
|
||||
final Logger LOG_Client =
|
||||
LoggerFactory.getLogger(Client.class);
|
||||
Assert.assertTrue(LOG_Client.isInfoEnabled());
|
||||
Assert.assertFalse(LOG_Client.isDebugEnabled());
|
||||
final Log LOG_AM = LogFactory.getLog(ApplicationMaster.class);
|
||||
final Logger LOG_AM = LoggerFactory.getLogger(ApplicationMaster.class);
|
||||
Assert.assertTrue(LOG_AM.isInfoEnabled());
|
||||
Assert.assertFalse(LOG_AM.isDebugEnabled());
|
||||
|
||||
|
@ -21,8 +21,6 @@
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.yarn.api.records.NodeId;
|
||||
import org.apache.hadoop.yarn.server.nodemanager.NodeManager;
|
||||
@ -34,10 +32,12 @@
|
||||
import org.junit.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class TestDistributedShellWithNodeLabels {
|
||||
private static final Log LOG =
|
||||
LogFactory.getLog(TestDistributedShellWithNodeLabels.class);
|
||||
private static final Logger LOG =
|
||||
LoggerFactory.getLogger(TestDistributedShellWithNodeLabels.class);
|
||||
|
||||
static final int NUM_NMS = 2;
|
||||
TestDistributedShell distShellTest;
|
||||
|
@ -36,8 +36,6 @@
|
||||
import org.apache.commons.cli.HelpFormatter;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.apache.commons.cli.ParseException;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.fs.FileUtil;
|
||||
import org.apache.hadoop.security.Credentials;
|
||||
@ -60,6 +58,8 @@
|
||||
import org.apache.hadoop.yarn.exceptions.YarnException;
|
||||
import org.apache.hadoop.yarn.security.AMRMTokenIdentifier;
|
||||
import org.apache.hadoop.yarn.util.Records;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* The UnmanagedLauncher is a simple client that launches and unmanaged AM. An
|
||||
@ -75,7 +75,8 @@
|
||||
* report app completion.
|
||||
*/
|
||||
public class UnmanagedAMLauncher {
|
||||
private static final Log LOG = LogFactory.getLog(UnmanagedAMLauncher.class);
|
||||
private static final Logger LOG = LoggerFactory
|
||||
.getLogger(UnmanagedAMLauncher.class);
|
||||
|
||||
private Configuration conf;
|
||||
|
||||
@ -110,7 +111,7 @@ public static void main(String[] args) {
|
||||
}
|
||||
client.run();
|
||||
} catch (Throwable t) {
|
||||
LOG.fatal("Error running Client", t);
|
||||
LOG.error("Error running Client", t);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -28,8 +28,6 @@
|
||||
import java.io.OutputStream;
|
||||
import java.net.URL;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.net.NetUtils;
|
||||
import org.apache.hadoop.yarn.api.ApplicationMasterProtocol;
|
||||
@ -47,10 +45,12 @@
|
||||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class TestUnmanagedAMLauncher {
|
||||
private static final Log LOG = LogFactory
|
||||
.getLog(TestUnmanagedAMLauncher.class);
|
||||
private static final Logger LOG = LoggerFactory
|
||||
.getLogger(TestUnmanagedAMLauncher.class);
|
||||
|
||||
protected static MiniYARNCluster yarnCluster = null;
|
||||
protected static Configuration conf = new YarnConfiguration();
|
||||
@ -128,7 +128,7 @@ public void testUMALauncher() throws Exception {
|
||||
String classpath = getTestRuntimeClasspath();
|
||||
String javaHome = System.getenv("JAVA_HOME");
|
||||
if (javaHome == null) {
|
||||
LOG.fatal("JAVA_HOME not defined. Test not running.");
|
||||
LOG.error("JAVA_HOME not defined. Test not running.");
|
||||
return;
|
||||
}
|
||||
String[] args = {
|
||||
@ -170,7 +170,7 @@ public void testUMALauncherError() throws Exception {
|
||||
String classpath = getTestRuntimeClasspath();
|
||||
String javaHome = System.getenv("JAVA_HOME");
|
||||
if (javaHome == null) {
|
||||
LOG.fatal("JAVA_HOME not defined. Test not running.");
|
||||
LOG.error("JAVA_HOME not defined. Test not running.");
|
||||
return;
|
||||
}
|
||||
String[] args = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user