Revert "YARN-9606. Set sslfactory for AuthenticatedURL() while creating LogsCLI#webServiceClient."
This reverts commit 7836bc4c35
.
This commit is contained in:
parent
27601fc79e
commit
b65815d691
@ -119,6 +119,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.hadoop</groupId>
|
<groupId>org.apache.hadoop</groupId>
|
||||||
<artifactId>hadoop-yarn-server-common</artifactId>
|
<artifactId>hadoop-yarn-server-common</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- 'mvn dependency:analyze' fails to detect use of this dependency -->
|
<!-- 'mvn dependency:analyze' fails to detect use of this dependency -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -27,13 +27,17 @@
|
|||||||
import com.sun.jersey.api.client.WebResource;
|
import com.sun.jersey.api.client.WebResource;
|
||||||
import com.sun.jersey.api.client.WebResource.Builder;
|
import com.sun.jersey.api.client.WebResource.Builder;
|
||||||
import com.sun.jersey.api.client.filter.ClientFilter;
|
import com.sun.jersey.api.client.filter.ClientFilter;
|
||||||
|
import com.sun.jersey.client.urlconnection.HttpURLConnectionFactory;
|
||||||
|
import com.sun.jersey.client.urlconnection.URLConnectionClientHandler;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.net.ConnectException;
|
import java.net.ConnectException;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
import java.net.SocketException;
|
import java.net.SocketException;
|
||||||
import java.net.SocketTimeoutException;
|
import java.net.SocketTimeoutException;
|
||||||
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -64,6 +68,8 @@
|
|||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
import org.apache.hadoop.conf.Configured;
|
import org.apache.hadoop.conf.Configured;
|
||||||
import org.apache.hadoop.security.UserGroupInformation;
|
import org.apache.hadoop.security.UserGroupInformation;
|
||||||
|
import org.apache.hadoop.security.authentication.client.AuthenticatedURL;
|
||||||
|
import org.apache.hadoop.security.authentication.client.AuthenticationException;
|
||||||
import org.apache.hadoop.util.Tool;
|
import org.apache.hadoop.util.Tool;
|
||||||
import org.apache.hadoop.yarn.api.records.ApplicationAttemptReport;
|
import org.apache.hadoop.yarn.api.records.ApplicationAttemptReport;
|
||||||
import org.apache.hadoop.yarn.api.records.ApplicationId;
|
import org.apache.hadoop.yarn.api.records.ApplicationId;
|
||||||
@ -81,7 +87,6 @@
|
|||||||
import org.apache.hadoop.yarn.logaggregation.LogCLIHelpers;
|
import org.apache.hadoop.yarn.logaggregation.LogCLIHelpers;
|
||||||
import org.apache.hadoop.yarn.logaggregation.LogToolUtils;
|
import org.apache.hadoop.yarn.logaggregation.LogToolUtils;
|
||||||
import org.apache.hadoop.yarn.server.metrics.AppAttemptMetricsConstants;
|
import org.apache.hadoop.yarn.server.metrics.AppAttemptMetricsConstants;
|
||||||
import org.apache.hadoop.yarn.server.webapp.WebServiceClient;
|
|
||||||
import org.apache.hadoop.yarn.util.Apps;
|
import org.apache.hadoop.yarn.util.Apps;
|
||||||
import org.apache.hadoop.yarn.webapp.util.WebAppUtils;
|
import org.apache.hadoop.yarn.webapp.util.WebAppUtils;
|
||||||
import org.apache.hadoop.yarn.webapp.util.YarnWebServiceUtils;
|
import org.apache.hadoop.yarn.webapp.util.YarnWebServiceUtils;
|
||||||
@ -117,7 +122,7 @@ public class LogsCLI extends Configured implements Tool {
|
|||||||
|
|
||||||
private PrintStream outStream = System.out;
|
private PrintStream outStream = System.out;
|
||||||
private YarnClient yarnClient = null;
|
private YarnClient yarnClient = null;
|
||||||
private Client client = null;
|
private Client webServiceClient = null;
|
||||||
|
|
||||||
private static final int DEFAULT_MAX_RETRIES = 30;
|
private static final int DEFAULT_MAX_RETRIES = 30;
|
||||||
private static final long DEFAULT_RETRY_INTERVAL = 1000;
|
private static final long DEFAULT_RETRY_INTERVAL = 1000;
|
||||||
@ -134,14 +139,28 @@ public class LogsCLI extends Configured implements Tool {
|
|||||||
@Override
|
@Override
|
||||||
public int run(String[] args) throws Exception {
|
public int run(String[] args) throws Exception {
|
||||||
try {
|
try {
|
||||||
client = WebServiceClient.getWebServiceClient().createClient();
|
webServiceClient = new Client(new URLConnectionClientHandler(
|
||||||
|
new HttpURLConnectionFactory() {
|
||||||
|
@Override
|
||||||
|
public HttpURLConnection getHttpURLConnection(URL url)
|
||||||
|
throws IOException {
|
||||||
|
AuthenticatedURL.Token token = new AuthenticatedURL.Token();
|
||||||
|
HttpURLConnection conn = null;
|
||||||
|
try {
|
||||||
|
conn = new AuthenticatedURL().openConnection(url, token);
|
||||||
|
} catch (AuthenticationException e) {
|
||||||
|
throw new IOException(e);
|
||||||
|
}
|
||||||
|
return conn;
|
||||||
|
}
|
||||||
|
}));
|
||||||
return runCommand(args);
|
return runCommand(args);
|
||||||
} finally {
|
} finally {
|
||||||
if (yarnClient != null) {
|
if (yarnClient != null) {
|
||||||
yarnClient.close();
|
yarnClient.close();
|
||||||
}
|
}
|
||||||
if (client != null) {
|
if (webServiceClient != null) {
|
||||||
client.destroy();
|
webServiceClient.destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -291,7 +310,7 @@ private int runCommand(String[] args) throws Exception {
|
|||||||
// Set up Retry WebService Client
|
// Set up Retry WebService Client
|
||||||
connectionRetry = new ClientConnectionRetry(maxRetries, retryInterval);
|
connectionRetry = new ClientConnectionRetry(maxRetries, retryInterval);
|
||||||
ClientJerseyRetryFilter retryFilter = new ClientJerseyRetryFilter();
|
ClientJerseyRetryFilter retryFilter = new ClientJerseyRetryFilter();
|
||||||
client.addFilter(retryFilter);
|
webServiceClient.addFilter(retryFilter);
|
||||||
|
|
||||||
LogCLIHelpers logCliHelper = new LogCLIHelpers();
|
LogCLIHelpers logCliHelper = new LogCLIHelpers();
|
||||||
logCliHelper.setConf(getConf());
|
logCliHelper.setConf(getConf());
|
||||||
@ -392,9 +411,7 @@ public static void main(String[] args) throws Exception {
|
|||||||
Configuration conf = new YarnConfiguration();
|
Configuration conf = new YarnConfiguration();
|
||||||
LogsCLI logDumper = new LogsCLI();
|
LogsCLI logDumper = new LogsCLI();
|
||||||
logDumper.setConf(conf);
|
logDumper.setConf(conf);
|
||||||
WebServiceClient.initialize(conf);
|
|
||||||
int exitCode = logDumper.run(args);
|
int exitCode = logDumper.run(args);
|
||||||
WebServiceClient.destroy();
|
|
||||||
System.exit(exitCode);
|
System.exit(exitCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -419,7 +436,7 @@ private List<JSONObject> getAMContainerInfoFromRM(
|
|||||||
List<JSONObject> amContainersList = new ArrayList<JSONObject>();
|
List<JSONObject> amContainersList = new ArrayList<JSONObject>();
|
||||||
ClientResponse response = null;
|
ClientResponse response = null;
|
||||||
try {
|
try {
|
||||||
Builder builder = client.resource(webAppAddress)
|
Builder builder = webServiceClient.resource(webAppAddress)
|
||||||
.path("ws").path("v1").path("cluster")
|
.path("ws").path("v1").path("cluster")
|
||||||
.path("apps").path(appId).path("appattempts")
|
.path("apps").path(appId).path("appattempts")
|
||||||
.accept(MediaType.APPLICATION_JSON);
|
.accept(MediaType.APPLICATION_JSON);
|
||||||
@ -444,7 +461,7 @@ private List<JSONObject> getAMContainerInfoForAHSWebService(
|
|||||||
String webAppAddress =
|
String webAppAddress =
|
||||||
WebAppUtils.getHttpSchemePrefix(conf)
|
WebAppUtils.getHttpSchemePrefix(conf)
|
||||||
+ WebAppUtils.getAHSWebAppURLWithoutScheme(conf);
|
+ WebAppUtils.getAHSWebAppURLWithoutScheme(conf);
|
||||||
WebResource webResource = client.resource(webAppAddress);
|
WebResource webResource = webServiceClient.resource(webAppAddress);
|
||||||
|
|
||||||
ClientResponse response =
|
ClientResponse response =
|
||||||
webResource.path("ws").path("v1").path("applicationhistory")
|
webResource.path("ws").path("v1").path("applicationhistory")
|
||||||
@ -494,7 +511,7 @@ private List<Pair<ContainerLogFileInfo, String>> getContainerLogFiles(
|
|||||||
List<Pair<ContainerLogFileInfo, String>> logFileInfos
|
List<Pair<ContainerLogFileInfo, String>> logFileInfos
|
||||||
= new ArrayList<>();
|
= new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
WebResource webResource = client
|
WebResource webResource = webServiceClient
|
||||||
.resource(WebAppUtils.getHttpSchemePrefix(conf) + nodeHttpAddress);
|
.resource(WebAppUtils.getHttpSchemePrefix(conf) + nodeHttpAddress);
|
||||||
ClientResponse response =
|
ClientResponse response =
|
||||||
webResource.path("ws").path("v1").path("node").path("containers")
|
webResource.path("ws").path("v1").path("node").path("containers")
|
||||||
@ -582,7 +599,7 @@ public int printContainerLogsFromRunningApplication(Configuration conf,
|
|||||||
InputStream is = null;
|
InputStream is = null;
|
||||||
try {
|
try {
|
||||||
ClientResponse response = getResponseFromNMWebService(conf,
|
ClientResponse response = getResponseFromNMWebService(conf,
|
||||||
client, request, logFile);
|
webServiceClient, request, logFile);
|
||||||
if (response != null && response.getStatusInfo().getStatusCode() ==
|
if (response != null && response.getStatusInfo().getStatusCode() ==
|
||||||
ClientResponse.Status.OK.getStatusCode()) {
|
ClientResponse.Status.OK.getStatusCode()) {
|
||||||
is = response.getEntityInputStream();
|
is = response.getEntityInputStream();
|
||||||
@ -794,7 +811,7 @@ protected ClientResponse getClientResponseFromTimelineReader(
|
|||||||
Configuration conf, String appId) throws IOException {
|
Configuration conf, String appId) throws IOException {
|
||||||
String webAppAddress = WebAppUtils.getHttpSchemePrefix(conf) + WebAppUtils
|
String webAppAddress = WebAppUtils.getHttpSchemePrefix(conf) + WebAppUtils
|
||||||
.getTimelineReaderWebAppURLWithoutScheme(conf);
|
.getTimelineReaderWebAppURLWithoutScheme(conf);
|
||||||
WebResource webResource = client.resource(webAppAddress);
|
WebResource webResource = webServiceClient.resource(webAppAddress);
|
||||||
|
|
||||||
ClientResponse response =
|
ClientResponse response =
|
||||||
webResource.path("ws").path("v2").path("timeline").path("clusters")
|
webResource.path("ws").path("v2").path("timeline").path("clusters")
|
||||||
|
@ -89,10 +89,8 @@
|
|||||||
import org.apache.hadoop.yarn.logaggregation.filecontroller.LogAggregationFileControllerContext;
|
import org.apache.hadoop.yarn.logaggregation.filecontroller.LogAggregationFileControllerContext;
|
||||||
import org.apache.hadoop.yarn.logaggregation.filecontroller.LogAggregationFileControllerFactory;
|
import org.apache.hadoop.yarn.logaggregation.filecontroller.LogAggregationFileControllerFactory;
|
||||||
import org.apache.hadoop.yarn.logaggregation.filecontroller.ifile.LogAggregationIndexedFileController;
|
import org.apache.hadoop.yarn.logaggregation.filecontroller.ifile.LogAggregationIndexedFileController;
|
||||||
import org.apache.hadoop.yarn.server.webapp.WebServiceClient;
|
|
||||||
import org.codehaus.jettison.json.JSONArray;
|
import org.codehaus.jettison.json.JSONArray;
|
||||||
import org.codehaus.jettison.json.JSONObject;
|
import org.codehaus.jettison.json.JSONObject;
|
||||||
import org.junit.After;
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@ -111,10 +109,8 @@ public class TestLogsCLI {
|
|||||||
ByteArrayOutputStream sysErrStream;
|
ByteArrayOutputStream sysErrStream;
|
||||||
private PrintStream sysErr;
|
private PrintStream sysErr;
|
||||||
|
|
||||||
private Configuration conf;
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() {
|
||||||
sysOutStream = new ByteArrayOutputStream();
|
sysOutStream = new ByteArrayOutputStream();
|
||||||
sysOut = new PrintStream(sysOutStream);
|
sysOut = new PrintStream(sysOutStream);
|
||||||
System.setOut(sysOut);
|
System.setOut(sysOut);
|
||||||
@ -122,17 +118,11 @@ public void setUp() throws Exception {
|
|||||||
sysErrStream = new ByteArrayOutputStream();
|
sysErrStream = new ByteArrayOutputStream();
|
||||||
sysErr = new PrintStream(sysErrStream);
|
sysErr = new PrintStream(sysErrStream);
|
||||||
System.setErr(sysErr);
|
System.setErr(sysErr);
|
||||||
conf = new YarnConfiguration();
|
|
||||||
WebServiceClient.initialize(conf);
|
|
||||||
}
|
|
||||||
|
|
||||||
@After
|
|
||||||
public void tearDown() {
|
|
||||||
WebServiceClient.destroy();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(timeout = 5000l)
|
@Test(timeout = 5000l)
|
||||||
public void testFailResultCodes() throws Exception {
|
public void testFailResultCodes() throws Exception {
|
||||||
|
Configuration conf = new YarnConfiguration();
|
||||||
conf.setClass("fs.file.impl", LocalFileSystem.class, FileSystem.class);
|
conf.setClass("fs.file.impl", LocalFileSystem.class, FileSystem.class);
|
||||||
LogCLIHelpers cliHelper = new LogCLIHelpers();
|
LogCLIHelpers cliHelper = new LogCLIHelpers();
|
||||||
cliHelper.setConf(conf);
|
cliHelper.setConf(conf);
|
||||||
@ -155,6 +145,7 @@ public void testFailResultCodes() throws Exception {
|
|||||||
|
|
||||||
@Test(timeout = 10000l)
|
@Test(timeout = 10000l)
|
||||||
public void testInvalidOpts() throws Exception {
|
public void testInvalidOpts() throws Exception {
|
||||||
|
Configuration conf = new YarnConfiguration();
|
||||||
YarnClient mockYarnClient = createMockYarnClient(
|
YarnClient mockYarnClient = createMockYarnClient(
|
||||||
YarnApplicationState.FINISHED,
|
YarnApplicationState.FINISHED,
|
||||||
UserGroupInformation.getCurrentUser().getShortUserName());
|
UserGroupInformation.getCurrentUser().getShortUserName());
|
||||||
@ -169,6 +160,7 @@ public void testInvalidOpts() throws Exception {
|
|||||||
|
|
||||||
@Test(timeout = 5000l)
|
@Test(timeout = 5000l)
|
||||||
public void testInvalidApplicationId() throws Exception {
|
public void testInvalidApplicationId() throws Exception {
|
||||||
|
Configuration conf = new YarnConfiguration();
|
||||||
YarnClient mockYarnClient = createMockYarnClient(
|
YarnClient mockYarnClient = createMockYarnClient(
|
||||||
YarnApplicationState.FINISHED,
|
YarnApplicationState.FINISHED,
|
||||||
UserGroupInformation.getCurrentUser().getShortUserName());
|
UserGroupInformation.getCurrentUser().getShortUserName());
|
||||||
@ -182,6 +174,7 @@ public void testInvalidApplicationId() throws Exception {
|
|||||||
|
|
||||||
@Test(timeout = 5000L)
|
@Test(timeout = 5000L)
|
||||||
public void testInvalidAMContainerId() throws Exception {
|
public void testInvalidAMContainerId() throws Exception {
|
||||||
|
Configuration conf = new YarnConfiguration();
|
||||||
conf.setBoolean(YarnConfiguration.APPLICATION_HISTORY_ENABLED, true);
|
conf.setBoolean(YarnConfiguration.APPLICATION_HISTORY_ENABLED, true);
|
||||||
YarnClient mockYarnClient =
|
YarnClient mockYarnClient =
|
||||||
createMockYarnClient(YarnApplicationState.FINISHED,
|
createMockYarnClient(YarnApplicationState.FINISHED,
|
||||||
@ -203,6 +196,7 @@ public void testInvalidAMContainerId() throws Exception {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAMContainerInfoFetchFromTimelineReader() throws Exception {
|
public void testAMContainerInfoFetchFromTimelineReader() throws Exception {
|
||||||
|
Configuration conf = new YarnConfiguration();
|
||||||
conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, true);
|
conf.setBoolean(YarnConfiguration.TIMELINE_SERVICE_ENABLED, true);
|
||||||
conf.set(YarnConfiguration.TIMELINE_SERVICE_VERSIONS, "2.0f");
|
conf.set(YarnConfiguration.TIMELINE_SERVICE_VERSIONS, "2.0f");
|
||||||
YarnClient mockYarnClient =
|
YarnClient mockYarnClient =
|
||||||
@ -238,6 +232,7 @@ public void testAMContainerInfoFetchFromTimelineReader() throws Exception {
|
|||||||
|
|
||||||
@Test(timeout = 5000l)
|
@Test(timeout = 5000l)
|
||||||
public void testUnknownApplicationId() throws Exception {
|
public void testUnknownApplicationId() throws Exception {
|
||||||
|
Configuration conf = new YarnConfiguration();
|
||||||
YarnClient mockYarnClient = createMockYarnClientUnknownApp();
|
YarnClient mockYarnClient = createMockYarnClientUnknownApp();
|
||||||
LogsCLI cli = new LogsCLIForTest(mockYarnClient);
|
LogsCLI cli = new LogsCLIForTest(mockYarnClient);
|
||||||
cli.setConf(conf);
|
cli.setConf(conf);
|
||||||
@ -253,6 +248,7 @@ public void testUnknownApplicationId() throws Exception {
|
|||||||
|
|
||||||
@Test (timeout = 10000)
|
@Test (timeout = 10000)
|
||||||
public void testHelpMessage() throws Exception {
|
public void testHelpMessage() throws Exception {
|
||||||
|
Configuration conf = new YarnConfiguration();
|
||||||
YarnClient mockYarnClient = createMockYarnClient(
|
YarnClient mockYarnClient = createMockYarnClient(
|
||||||
YarnApplicationState.FINISHED,
|
YarnApplicationState.FINISHED,
|
||||||
UserGroupInformation.getCurrentUser().getShortUserName());
|
UserGroupInformation.getCurrentUser().getShortUserName());
|
||||||
@ -376,12 +372,13 @@ public void testHelpMessage() throws Exception {
|
|||||||
@Test (timeout = 15000)
|
@Test (timeout = 15000)
|
||||||
public void testFetchFinishedApplictionLogs() throws Exception {
|
public void testFetchFinishedApplictionLogs() throws Exception {
|
||||||
String remoteLogRootDir = "target/logs/";
|
String remoteLogRootDir = "target/logs/";
|
||||||
conf.setBoolean(YarnConfiguration.LOG_AGGREGATION_ENABLED, true);
|
Configuration configuration = new YarnConfiguration();
|
||||||
conf
|
configuration.setBoolean(YarnConfiguration.LOG_AGGREGATION_ENABLED, true);
|
||||||
|
configuration
|
||||||
.set(YarnConfiguration.NM_REMOTE_APP_LOG_DIR, remoteLogRootDir);
|
.set(YarnConfiguration.NM_REMOTE_APP_LOG_DIR, remoteLogRootDir);
|
||||||
conf.setBoolean(YarnConfiguration.YARN_ACL_ENABLE, true);
|
configuration.setBoolean(YarnConfiguration.YARN_ACL_ENABLE, true);
|
||||||
conf.set(YarnConfiguration.YARN_ADMIN_ACL, "admin");
|
configuration.set(YarnConfiguration.YARN_ADMIN_ACL, "admin");
|
||||||
FileSystem fs = FileSystem.get(conf);
|
FileSystem fs = FileSystem.get(configuration);
|
||||||
|
|
||||||
UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
|
UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
|
||||||
ApplicationId appId = ApplicationId.newInstance(0, 1);
|
ApplicationId appId = ApplicationId.newInstance(0, 1);
|
||||||
@ -434,15 +431,15 @@ public void testFetchFinishedApplictionLogs() throws Exception {
|
|||||||
// the first two logs is empty. When we try to read first two logs,
|
// the first two logs is empty. When we try to read first two logs,
|
||||||
// we will meet EOF exception, but it will not impact other logs.
|
// we will meet EOF exception, but it will not impact other logs.
|
||||||
// Other logs should be read successfully.
|
// Other logs should be read successfully.
|
||||||
uploadEmptyContainerLogIntoRemoteDir(ugi, conf, rootLogDirs, nodeId,
|
uploadEmptyContainerLogIntoRemoteDir(ugi, configuration, rootLogDirs, nodeId,
|
||||||
containerId0, path, fs);
|
containerId0, path, fs);
|
||||||
uploadEmptyContainerLogIntoRemoteDir(ugi, conf, rootLogDirs, nodeId,
|
uploadEmptyContainerLogIntoRemoteDir(ugi, configuration, rootLogDirs, nodeId,
|
||||||
containerId1, path, fs);
|
containerId1, path, fs);
|
||||||
uploadContainerLogIntoRemoteDir(ugi, conf, rootLogDirs, nodeId,
|
uploadContainerLogIntoRemoteDir(ugi, configuration, rootLogDirs, nodeId,
|
||||||
containerId1, path, fs);
|
containerId1, path, fs);
|
||||||
uploadContainerLogIntoRemoteDir(ugi, conf, rootLogDirs, nodeId,
|
uploadContainerLogIntoRemoteDir(ugi, configuration, rootLogDirs, nodeId,
|
||||||
containerId2, path, fs);
|
containerId2, path, fs);
|
||||||
uploadContainerLogIntoRemoteDir(ugi, conf, rootLogDirs, nodeId,
|
uploadContainerLogIntoRemoteDir(ugi, configuration, rootLogDirs, nodeId,
|
||||||
containerId3, path, fs);
|
containerId3, path, fs);
|
||||||
|
|
||||||
YarnClient mockYarnClient =
|
YarnClient mockYarnClient =
|
||||||
@ -458,7 +455,7 @@ public ContainerReport getContainerReport(String containerIdStr)
|
|||||||
return mockReport;
|
return mockReport;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
cli.setConf(conf);
|
cli.setConf(configuration);
|
||||||
|
|
||||||
int exitCode = cli.run(new String[] { "-applicationId", appId.toString() });
|
int exitCode = cli.run(new String[] { "-applicationId", appId.toString() });
|
||||||
LOG.info(sysOutStream.toString());
|
LOG.info(sysOutStream.toString());
|
||||||
@ -684,7 +681,7 @@ public ContainerReport getContainerReport(String containerIdStr)
|
|||||||
YarnClient mockYarnClientWithException =
|
YarnClient mockYarnClientWithException =
|
||||||
createMockYarnClientWithException();
|
createMockYarnClientWithException();
|
||||||
cli = new LogsCLIForTest(mockYarnClientWithException);
|
cli = new LogsCLIForTest(mockYarnClientWithException);
|
||||||
cli.setConf(conf);
|
cli.setConf(configuration);
|
||||||
|
|
||||||
exitCode =
|
exitCode =
|
||||||
cli.run(new String[] { "-applicationId", appId.toString(),
|
cli.run(new String[] { "-applicationId", appId.toString(),
|
||||||
@ -807,7 +804,8 @@ public void testGetRunningContainerLogs() throws Exception {
|
|||||||
any(ContainerId.class));
|
any(ContainerId.class));
|
||||||
|
|
||||||
// create local logs
|
// create local logs
|
||||||
FileSystem fs = FileSystem.get(conf);
|
Configuration configuration = new YarnConfiguration();
|
||||||
|
FileSystem fs = FileSystem.get(configuration);
|
||||||
String rootLogDir = "target/LocalLogs";
|
String rootLogDir = "target/LocalLogs";
|
||||||
Path rootLogDirPath = new Path(rootLogDir);
|
Path rootLogDirPath = new Path(rootLogDir);
|
||||||
if (fs.exists(rootLogDirPath)) {
|
if (fs.exists(rootLogDirPath)) {
|
||||||
@ -966,12 +964,13 @@ public void testFetchApplictionLogsAsAnotherUser() throws Exception {
|
|||||||
UserGroupInformation testUgi = UserGroupInformation
|
UserGroupInformation testUgi = UserGroupInformation
|
||||||
.createRemoteUser(testUser);
|
.createRemoteUser(testUser);
|
||||||
|
|
||||||
conf.setBoolean(YarnConfiguration.LOG_AGGREGATION_ENABLED, true);
|
Configuration configuration = new YarnConfiguration();
|
||||||
conf
|
configuration.setBoolean(YarnConfiguration.LOG_AGGREGATION_ENABLED, true);
|
||||||
|
configuration
|
||||||
.set(YarnConfiguration.NM_REMOTE_APP_LOG_DIR, remoteLogRootDir);
|
.set(YarnConfiguration.NM_REMOTE_APP_LOG_DIR, remoteLogRootDir);
|
||||||
conf.setBoolean(YarnConfiguration.YARN_ACL_ENABLE, true);
|
configuration.setBoolean(YarnConfiguration.YARN_ACL_ENABLE, true);
|
||||||
conf.set(YarnConfiguration.YARN_ADMIN_ACL, "admin");
|
configuration.set(YarnConfiguration.YARN_ADMIN_ACL, "admin");
|
||||||
FileSystem fs = FileSystem.get(conf);
|
FileSystem fs = FileSystem.get(configuration);
|
||||||
|
|
||||||
ApplicationId appId = ApplicationId.newInstance(0, 1);
|
ApplicationId appId = ApplicationId.newInstance(0, 1);
|
||||||
ApplicationAttemptId appAttemptId =
|
ApplicationAttemptId appAttemptId =
|
||||||
@ -1011,13 +1010,13 @@ public void testFetchApplictionLogsAsAnotherUser() throws Exception {
|
|||||||
assertTrue(fs.mkdirs(path));
|
assertTrue(fs.mkdirs(path));
|
||||||
|
|
||||||
// upload container logs for app into remote dir
|
// upload container logs for app into remote dir
|
||||||
uploadContainerLogIntoRemoteDir(testUgi, conf, rootLogDirs,
|
uploadContainerLogIntoRemoteDir(testUgi, configuration, rootLogDirs,
|
||||||
nodeId, containerId, path, fs);
|
nodeId, containerId, path, fs);
|
||||||
|
|
||||||
YarnClient mockYarnClient = createMockYarnClient(
|
YarnClient mockYarnClient = createMockYarnClient(
|
||||||
YarnApplicationState.FINISHED, testUgi.getShortUserName());
|
YarnApplicationState.FINISHED, testUgi.getShortUserName());
|
||||||
LogsCLI cli = new LogsCLIForTest(mockYarnClient);
|
LogsCLI cli = new LogsCLIForTest(mockYarnClient);
|
||||||
cli.setConf(conf);
|
cli.setConf(configuration);
|
||||||
|
|
||||||
// Verify that we can get the application logs by specifying
|
// Verify that we can get the application logs by specifying
|
||||||
// a correct appOwner
|
// a correct appOwner
|
||||||
@ -1044,7 +1043,7 @@ public void testFetchApplictionLogsAsAnotherUser() throws Exception {
|
|||||||
// and can get app logs successfully.
|
// and can get app logs successfully.
|
||||||
YarnClient mockYarnClient2 = createMockYarnClientUnknownApp();
|
YarnClient mockYarnClient2 = createMockYarnClientUnknownApp();
|
||||||
cli = new LogsCLIForTest(mockYarnClient2);
|
cli = new LogsCLIForTest(mockYarnClient2);
|
||||||
cli.setConf(conf);
|
cli.setConf(configuration);
|
||||||
exitCode = cli.run(new String[] {
|
exitCode = cli.run(new String[] {
|
||||||
"-applicationId", appId.toString()});
|
"-applicationId", appId.toString()});
|
||||||
assertTrue(exitCode == 0);
|
assertTrue(exitCode == 0);
|
||||||
@ -1058,7 +1057,7 @@ public void testFetchApplictionLogsAsAnotherUser() throws Exception {
|
|||||||
fs.delete(path, true);
|
fs.delete(path, true);
|
||||||
}
|
}
|
||||||
assertTrue(fs.mkdirs(path));
|
assertTrue(fs.mkdirs(path));
|
||||||
uploadContainerLogIntoRemoteDir(testUgi, conf, rootLogDirs,
|
uploadContainerLogIntoRemoteDir(testUgi, configuration, rootLogDirs,
|
||||||
nodeId, containerId, path, fs);
|
nodeId, containerId, path, fs);
|
||||||
|
|
||||||
exitCode = cli.run(new String[] {
|
exitCode = cli.run(new String[] {
|
||||||
@ -1113,13 +1112,14 @@ public void testFetchApplictionLogsAsAnotherUser() throws Exception {
|
|||||||
public void testLogsCLIWithInvalidArgs() throws Exception {
|
public void testLogsCLIWithInvalidArgs() throws Exception {
|
||||||
String localDir = "target/SaveLogs";
|
String localDir = "target/SaveLogs";
|
||||||
Path localPath = new Path(localDir);
|
Path localPath = new Path(localDir);
|
||||||
FileSystem fs = FileSystem.get(conf);
|
Configuration configuration = new YarnConfiguration();
|
||||||
|
FileSystem fs = FileSystem.get(configuration);
|
||||||
ApplicationId appId = ApplicationId.newInstance(0, 1);
|
ApplicationId appId = ApplicationId.newInstance(0, 1);
|
||||||
YarnClient mockYarnClient =
|
YarnClient mockYarnClient =
|
||||||
createMockYarnClient(YarnApplicationState.FINISHED,
|
createMockYarnClient(YarnApplicationState.FINISHED,
|
||||||
UserGroupInformation.getCurrentUser().getShortUserName());
|
UserGroupInformation.getCurrentUser().getShortUserName());
|
||||||
LogsCLI cli = new LogsCLIForTest(mockYarnClient);
|
LogsCLI cli = new LogsCLIForTest(mockYarnClient);
|
||||||
cli.setConf(conf);
|
cli.setConf(configuration);
|
||||||
|
|
||||||
// Specify an invalid applicationId
|
// Specify an invalid applicationId
|
||||||
int exitCode = cli.run(new String[] {"-applicationId",
|
int exitCode = cli.run(new String[] {"-applicationId",
|
||||||
@ -1180,6 +1180,7 @@ public void testGuessAppOwnerWithCustomSuffix() throws Exception {
|
|||||||
String remoteLogRootDir = "target/logs/";
|
String remoteLogRootDir = "target/logs/";
|
||||||
String jobUser = "user1";
|
String jobUser = "user1";
|
||||||
String loggedUser = "user2";
|
String loggedUser = "user2";
|
||||||
|
Configuration conf = new YarnConfiguration();
|
||||||
conf.setBoolean(YarnConfiguration.LOG_AGGREGATION_ENABLED, true);
|
conf.setBoolean(YarnConfiguration.LOG_AGGREGATION_ENABLED, true);
|
||||||
conf.set(YarnConfiguration.NM_REMOTE_APP_LOG_DIR, remoteLogRootDir);
|
conf.set(YarnConfiguration.NM_REMOTE_APP_LOG_DIR, remoteLogRootDir);
|
||||||
conf.setBoolean(YarnConfiguration.YARN_ACL_ENABLE, true);
|
conf.setBoolean(YarnConfiguration.YARN_ACL_ENABLE, true);
|
||||||
@ -1225,6 +1226,7 @@ public void testGuessAppOwnerWithCustomAppLogDir() throws Exception {
|
|||||||
String remoteLogRootDir1 = "target/logs1/";
|
String remoteLogRootDir1 = "target/logs1/";
|
||||||
String jobUser = "user1";
|
String jobUser = "user1";
|
||||||
String loggedUser = "user2";
|
String loggedUser = "user2";
|
||||||
|
Configuration conf = new YarnConfiguration();
|
||||||
conf.setBoolean(YarnConfiguration.LOG_AGGREGATION_ENABLED, true);
|
conf.setBoolean(YarnConfiguration.LOG_AGGREGATION_ENABLED, true);
|
||||||
conf.set(YarnConfiguration.NM_REMOTE_APP_LOG_DIR, remoteLogRootDir);
|
conf.set(YarnConfiguration.NM_REMOTE_APP_LOG_DIR, remoteLogRootDir);
|
||||||
String controllerName = "indexed";
|
String controllerName = "indexed";
|
||||||
@ -1259,13 +1261,14 @@ public void testSaveContainerLogsLocally() throws Exception {
|
|||||||
String localDir = "target/SaveLogs";
|
String localDir = "target/SaveLogs";
|
||||||
Path localPath = new Path(localDir);
|
Path localPath = new Path(localDir);
|
||||||
|
|
||||||
conf.setBoolean(YarnConfiguration.LOG_AGGREGATION_ENABLED, true);
|
Configuration configuration = new YarnConfiguration();
|
||||||
conf
|
configuration.setBoolean(YarnConfiguration.LOG_AGGREGATION_ENABLED, true);
|
||||||
|
configuration
|
||||||
.set(YarnConfiguration.NM_REMOTE_APP_LOG_DIR, remoteLogRootDir);
|
.set(YarnConfiguration.NM_REMOTE_APP_LOG_DIR, remoteLogRootDir);
|
||||||
conf.setBoolean(YarnConfiguration.YARN_ACL_ENABLE, true);
|
configuration.setBoolean(YarnConfiguration.YARN_ACL_ENABLE, true);
|
||||||
conf.set(YarnConfiguration.YARN_ADMIN_ACL, "admin");
|
configuration.set(YarnConfiguration.YARN_ADMIN_ACL, "admin");
|
||||||
|
|
||||||
FileSystem fs = FileSystem.get(conf);
|
FileSystem fs = FileSystem.get(configuration);
|
||||||
ApplicationId appId = ApplicationId.newInstance(0, 1);
|
ApplicationId appId = ApplicationId.newInstance(0, 1);
|
||||||
ApplicationAttemptId appAttemptId =
|
ApplicationAttemptId appAttemptId =
|
||||||
ApplicationAttemptId.newInstance(appId, 1);
|
ApplicationAttemptId.newInstance(appId, 1);
|
||||||
@ -1284,14 +1287,14 @@ public void testSaveContainerLogsLocally() throws Exception {
|
|||||||
nodeIds.add(nodeId2);
|
nodeIds.add(nodeId2);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
createContainerLogs(conf, remoteLogRootDir, rootLogDir, fs,
|
createContainerLogs(configuration, remoteLogRootDir, rootLogDir, fs,
|
||||||
appId, containerIds, nodeIds);
|
appId, containerIds, nodeIds);
|
||||||
|
|
||||||
YarnClient mockYarnClient =
|
YarnClient mockYarnClient =
|
||||||
createMockYarnClient(YarnApplicationState.FINISHED,
|
createMockYarnClient(YarnApplicationState.FINISHED,
|
||||||
UserGroupInformation.getCurrentUser().getShortUserName());
|
UserGroupInformation.getCurrentUser().getShortUserName());
|
||||||
LogsCLI cli = new LogsCLIForTest(mockYarnClient);
|
LogsCLI cli = new LogsCLIForTest(mockYarnClient);
|
||||||
cli.setConf(conf);
|
cli.setConf(configuration);
|
||||||
int exitCode = cli.run(new String[] {"-applicationId",
|
int exitCode = cli.run(new String[] {"-applicationId",
|
||||||
appId.toString(),
|
appId.toString(),
|
||||||
"-out" , localPath.toString()});
|
"-out" , localPath.toString()});
|
||||||
@ -1349,12 +1352,13 @@ private String readContainerContent(Path containerPath,
|
|||||||
@Test (timeout = 15000)
|
@Test (timeout = 15000)
|
||||||
public void testPrintContainerLogMetadata() throws Exception {
|
public void testPrintContainerLogMetadata() throws Exception {
|
||||||
String remoteLogRootDir = "target/logs/";
|
String remoteLogRootDir = "target/logs/";
|
||||||
conf.setBoolean(YarnConfiguration.LOG_AGGREGATION_ENABLED, true);
|
Configuration configuration = new YarnConfiguration();
|
||||||
conf
|
configuration.setBoolean(YarnConfiguration.LOG_AGGREGATION_ENABLED, true);
|
||||||
|
configuration
|
||||||
.set(YarnConfiguration.NM_REMOTE_APP_LOG_DIR, remoteLogRootDir);
|
.set(YarnConfiguration.NM_REMOTE_APP_LOG_DIR, remoteLogRootDir);
|
||||||
conf.setBoolean(YarnConfiguration.YARN_ACL_ENABLE, true);
|
configuration.setBoolean(YarnConfiguration.YARN_ACL_ENABLE, true);
|
||||||
conf.set(YarnConfiguration.YARN_ADMIN_ACL, "admin");
|
configuration.set(YarnConfiguration.YARN_ADMIN_ACL, "admin");
|
||||||
FileSystem fs = FileSystem.get(conf);
|
FileSystem fs = FileSystem.get(configuration);
|
||||||
String rootLogDir = "target/LocalLogs";
|
String rootLogDir = "target/LocalLogs";
|
||||||
|
|
||||||
ApplicationId appId = ApplicationId.newInstance(0, 1);
|
ApplicationId appId = ApplicationId.newInstance(0, 1);
|
||||||
@ -1373,14 +1377,14 @@ public void testPrintContainerLogMetadata() throws Exception {
|
|||||||
nodeIds.add(nodeId);
|
nodeIds.add(nodeId);
|
||||||
nodeIds.add(nodeId);
|
nodeIds.add(nodeId);
|
||||||
|
|
||||||
createContainerLogs(conf, remoteLogRootDir, rootLogDir, fs,
|
createContainerLogs(configuration, remoteLogRootDir, rootLogDir, fs,
|
||||||
appId, containerIds, nodeIds);
|
appId, containerIds, nodeIds);
|
||||||
|
|
||||||
YarnClient mockYarnClient =
|
YarnClient mockYarnClient =
|
||||||
createMockYarnClient(YarnApplicationState.FINISHED,
|
createMockYarnClient(YarnApplicationState.FINISHED,
|
||||||
UserGroupInformation.getCurrentUser().getShortUserName());
|
UserGroupInformation.getCurrentUser().getShortUserName());
|
||||||
LogsCLI cli = new LogsCLIForTest(mockYarnClient);
|
LogsCLI cli = new LogsCLIForTest(mockYarnClient);
|
||||||
cli.setConf(conf);
|
cli.setConf(configuration);
|
||||||
|
|
||||||
cli.run(new String[] {"-applicationId", appId.toString(),
|
cli.run(new String[] {"-applicationId", appId.toString(),
|
||||||
"-show_container_log_info"});
|
"-show_container_log_info"});
|
||||||
@ -1453,11 +1457,12 @@ public void testPrintContainerLogMetadata() throws Exception {
|
|||||||
@Test (timeout = 15000)
|
@Test (timeout = 15000)
|
||||||
public void testListNodeInfo() throws Exception {
|
public void testListNodeInfo() throws Exception {
|
||||||
String remoteLogRootDir = "target/logs/";
|
String remoteLogRootDir = "target/logs/";
|
||||||
conf.setBoolean(YarnConfiguration.LOG_AGGREGATION_ENABLED, true);
|
Configuration configuration = new YarnConfiguration();
|
||||||
conf
|
configuration.setBoolean(YarnConfiguration.LOG_AGGREGATION_ENABLED, true);
|
||||||
|
configuration
|
||||||
.set(YarnConfiguration.NM_REMOTE_APP_LOG_DIR, remoteLogRootDir);
|
.set(YarnConfiguration.NM_REMOTE_APP_LOG_DIR, remoteLogRootDir);
|
||||||
conf.setBoolean(YarnConfiguration.YARN_ACL_ENABLE, true);
|
configuration.setBoolean(YarnConfiguration.YARN_ACL_ENABLE, true);
|
||||||
conf.set(YarnConfiguration.YARN_ADMIN_ACL, "admin");
|
configuration.set(YarnConfiguration.YARN_ADMIN_ACL, "admin");
|
||||||
|
|
||||||
ApplicationId appId = ApplicationId.newInstance(0, 1);
|
ApplicationId appId = ApplicationId.newInstance(0, 1);
|
||||||
ApplicationAttemptId appAttemptId =
|
ApplicationAttemptId appAttemptId =
|
||||||
@ -1477,16 +1482,16 @@ public void testListNodeInfo() throws Exception {
|
|||||||
nodeIds.add(nodeId2);
|
nodeIds.add(nodeId2);
|
||||||
|
|
||||||
String rootLogDir = "target/LocalLogs";
|
String rootLogDir = "target/LocalLogs";
|
||||||
FileSystem fs = FileSystem.get(conf);
|
FileSystem fs = FileSystem.get(configuration);
|
||||||
|
|
||||||
createContainerLogs(conf, remoteLogRootDir, rootLogDir, fs,
|
createContainerLogs(configuration, remoteLogRootDir, rootLogDir, fs,
|
||||||
appId, containerIds, nodeIds);
|
appId, containerIds, nodeIds);
|
||||||
|
|
||||||
YarnClient mockYarnClient =
|
YarnClient mockYarnClient =
|
||||||
createMockYarnClient(YarnApplicationState.FINISHED,
|
createMockYarnClient(YarnApplicationState.FINISHED,
|
||||||
UserGroupInformation.getCurrentUser().getShortUserName());
|
UserGroupInformation.getCurrentUser().getShortUserName());
|
||||||
LogsCLI cli = new LogsCLIForTest(mockYarnClient);
|
LogsCLI cli = new LogsCLIForTest(mockYarnClient);
|
||||||
cli.setConf(conf);
|
cli.setConf(configuration);
|
||||||
|
|
||||||
cli.run(new String[] { "-applicationId", appId.toString(),
|
cli.run(new String[] { "-applicationId", appId.toString(),
|
||||||
"-list_nodes" });
|
"-list_nodes" });
|
||||||
@ -1503,12 +1508,13 @@ public void testListNodeInfo() throws Exception {
|
|||||||
@Test (timeout = 15000)
|
@Test (timeout = 15000)
|
||||||
public void testFetchApplictionLogsHar() throws Exception {
|
public void testFetchApplictionLogsHar() throws Exception {
|
||||||
String remoteLogRootDir = "target/logs/";
|
String remoteLogRootDir = "target/logs/";
|
||||||
conf.setBoolean(YarnConfiguration.LOG_AGGREGATION_ENABLED, true);
|
Configuration configuration = new YarnConfiguration();
|
||||||
conf
|
configuration.setBoolean(YarnConfiguration.LOG_AGGREGATION_ENABLED, true);
|
||||||
|
configuration
|
||||||
.set(YarnConfiguration.NM_REMOTE_APP_LOG_DIR, remoteLogRootDir);
|
.set(YarnConfiguration.NM_REMOTE_APP_LOG_DIR, remoteLogRootDir);
|
||||||
conf.setBoolean(YarnConfiguration.YARN_ACL_ENABLE, true);
|
configuration.setBoolean(YarnConfiguration.YARN_ACL_ENABLE, true);
|
||||||
conf.set(YarnConfiguration.YARN_ADMIN_ACL, "admin");
|
configuration.set(YarnConfiguration.YARN_ADMIN_ACL, "admin");
|
||||||
FileSystem fs = FileSystem.get(conf);
|
FileSystem fs = FileSystem.get(configuration);
|
||||||
UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
|
UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
|
||||||
URL harUrl = ClassLoader.getSystemClassLoader()
|
URL harUrl = ClassLoader.getSystemClassLoader()
|
||||||
.getResource("application_1440536969523_0001.har");
|
.getResource("application_1440536969523_0001.har");
|
||||||
@ -1528,7 +1534,7 @@ public void testFetchApplictionLogsHar() throws Exception {
|
|||||||
createMockYarnClient(YarnApplicationState.FINISHED,
|
createMockYarnClient(YarnApplicationState.FINISHED,
|
||||||
ugi.getShortUserName());
|
ugi.getShortUserName());
|
||||||
LogsCLI cli = new LogsCLIForTest(mockYarnClient);
|
LogsCLI cli = new LogsCLIForTest(mockYarnClient);
|
||||||
cli.setConf(conf);
|
cli.setConf(configuration);
|
||||||
int exitCode = cli.run(new String[]{"-applicationId",
|
int exitCode = cli.run(new String[]{"-applicationId",
|
||||||
"application_1440536969523_0001"});
|
"application_1440536969523_0001"});
|
||||||
assertTrue(exitCode == 0);
|
assertTrue(exitCode == 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user