Skip to content

Commit b65815d

Browse files
committed
Revert "YARN-9606. Set sslfactory for AuthenticatedURL() while creating LogsCLI#webServiceClient."
This reverts commit 7836bc4.
1 parent 27601fc commit b65815d

File tree

3 files changed

+100
-76
lines changed

3 files changed

+100
-76
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@
119119
<dependency>
120120
<groupId>org.apache.hadoop</groupId>
121121
<artifactId>hadoop-yarn-server-common</artifactId>
122+
<scope>test</scope>
122123
</dependency>
123124
<!-- 'mvn dependency:analyze' fails to detect use of this dependency -->
124125
<dependency>

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-client/src/main/java/org/apache/hadoop/yarn/client/cli/LogsCLI.java

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,17 @@
2727
import com.sun.jersey.api.client.WebResource;
2828
import com.sun.jersey.api.client.WebResource.Builder;
2929
import com.sun.jersey.api.client.filter.ClientFilter;
30+
import com.sun.jersey.client.urlconnection.HttpURLConnectionFactory;
31+
import com.sun.jersey.client.urlconnection.URLConnectionClientHandler;
3032
import java.io.File;
3133
import java.io.IOException;
3234
import java.io.InputStream;
3335
import java.io.PrintStream;
3436
import java.net.ConnectException;
37+
import java.net.HttpURLConnection;
3538
import java.net.SocketException;
3639
import java.net.SocketTimeoutException;
40+
import java.net.URL;
3741
import java.util.ArrayList;
3842
import java.util.Arrays;
3943
import java.util.Collection;
@@ -64,6 +68,8 @@
6468
import org.apache.hadoop.conf.Configuration;
6569
import org.apache.hadoop.conf.Configured;
6670
import org.apache.hadoop.security.UserGroupInformation;
71+
import org.apache.hadoop.security.authentication.client.AuthenticatedURL;
72+
import org.apache.hadoop.security.authentication.client.AuthenticationException;
6773
import org.apache.hadoop.util.Tool;
6874
import org.apache.hadoop.yarn.api.records.ApplicationAttemptReport;
6975
import org.apache.hadoop.yarn.api.records.ApplicationId;
@@ -81,7 +87,6 @@
8187
import org.apache.hadoop.yarn.logaggregation.LogCLIHelpers;
8288
import org.apache.hadoop.yarn.logaggregation.LogToolUtils;
8389
import org.apache.hadoop.yarn.server.metrics.AppAttemptMetricsConstants;
84-
import org.apache.hadoop.yarn.server.webapp.WebServiceClient;
8590
import org.apache.hadoop.yarn.util.Apps;
8691
import org.apache.hadoop.yarn.webapp.util.WebAppUtils;
8792
import org.apache.hadoop.yarn.webapp.util.YarnWebServiceUtils;
@@ -117,7 +122,7 @@ public class LogsCLI extends Configured implements Tool {
117122

118123
private PrintStream outStream = System.out;
119124
private YarnClient yarnClient = null;
120-
private Client client = null;
125+
private Client webServiceClient = null;
121126

122127
private static final int DEFAULT_MAX_RETRIES = 30;
123128
private static final long DEFAULT_RETRY_INTERVAL = 1000;
@@ -134,14 +139,28 @@ public class LogsCLI extends Configured implements Tool {
134139
@Override
135140
public int run(String[] args) throws Exception {
136141
try {
137-
client = WebServiceClient.getWebServiceClient().createClient();
142+
webServiceClient = new Client(new URLConnectionClientHandler(
143+
new HttpURLConnectionFactory() {
144+
@Override
145+
public HttpURLConnection getHttpURLConnection(URL url)
146+
throws IOException {
147+
AuthenticatedURL.Token token = new AuthenticatedURL.Token();
148+
HttpURLConnection conn = null;
149+
try {
150+
conn = new AuthenticatedURL().openConnection(url, token);
151+
} catch (AuthenticationException e) {
152+
throw new IOException(e);
153+
}
154+
return conn;
155+
}
156+
}));
138157
return runCommand(args);
139158
} finally {
140159
if (yarnClient != null) {
141160
yarnClient.close();
142161
}
143-
if (client != null) {
144-
client.destroy();
162+
if (webServiceClient != null) {
163+
webServiceClient.destroy();
145164
}
146165
}
147166
}
@@ -291,7 +310,7 @@ private int runCommand(String[] args) throws Exception {
291310
// Set up Retry WebService Client
292311
connectionRetry = new ClientConnectionRetry(maxRetries, retryInterval);
293312
ClientJerseyRetryFilter retryFilter = new ClientJerseyRetryFilter();
294-
client.addFilter(retryFilter);
313+
webServiceClient.addFilter(retryFilter);
295314

296315
LogCLIHelpers logCliHelper = new LogCLIHelpers();
297316
logCliHelper.setConf(getConf());
@@ -392,9 +411,7 @@ public static void main(String[] args) throws Exception {
392411
Configuration conf = new YarnConfiguration();
393412
LogsCLI logDumper = new LogsCLI();
394413
logDumper.setConf(conf);
395-
WebServiceClient.initialize(conf);
396414
int exitCode = logDumper.run(args);
397-
WebServiceClient.destroy();
398415
System.exit(exitCode);
399416
}
400417

@@ -419,7 +436,7 @@ private List<JSONObject> getAMContainerInfoFromRM(
419436
List<JSONObject> amContainersList = new ArrayList<JSONObject>();
420437
ClientResponse response = null;
421438
try {
422-
Builder builder = client.resource(webAppAddress)
439+
Builder builder = webServiceClient.resource(webAppAddress)
423440
.path("ws").path("v1").path("cluster")
424441
.path("apps").path(appId).path("appattempts")
425442
.accept(MediaType.APPLICATION_JSON);
@@ -444,7 +461,7 @@ private List<JSONObject> getAMContainerInfoForAHSWebService(
444461
String webAppAddress =
445462
WebAppUtils.getHttpSchemePrefix(conf)
446463
+ WebAppUtils.getAHSWebAppURLWithoutScheme(conf);
447-
WebResource webResource = client.resource(webAppAddress);
464+
WebResource webResource = webServiceClient.resource(webAppAddress);
448465

449466
ClientResponse response =
450467
webResource.path("ws").path("v1").path("applicationhistory")
@@ -494,7 +511,7 @@ private List<Pair<ContainerLogFileInfo, String>> getContainerLogFiles(
494511
List<Pair<ContainerLogFileInfo, String>> logFileInfos
495512
= new ArrayList<>();
496513
try {
497-
WebResource webResource = client
514+
WebResource webResource = webServiceClient
498515
.resource(WebAppUtils.getHttpSchemePrefix(conf) + nodeHttpAddress);
499516
ClientResponse response =
500517
webResource.path("ws").path("v1").path("node").path("containers")
@@ -582,7 +599,7 @@ public int printContainerLogsFromRunningApplication(Configuration conf,
582599
InputStream is = null;
583600
try {
584601
ClientResponse response = getResponseFromNMWebService(conf,
585-
client, request, logFile);
602+
webServiceClient, request, logFile);
586603
if (response != null && response.getStatusInfo().getStatusCode() ==
587604
ClientResponse.Status.OK.getStatusCode()) {
588605
is = response.getEntityInputStream();
@@ -794,7 +811,7 @@ protected ClientResponse getClientResponseFromTimelineReader(
794811
Configuration conf, String appId) throws IOException {
795812
String webAppAddress = WebAppUtils.getHttpSchemePrefix(conf) + WebAppUtils
796813
.getTimelineReaderWebAppURLWithoutScheme(conf);
797-
WebResource webResource = client.resource(webAppAddress);
814+
WebResource webResource = webServiceClient.resource(webAppAddress);
798815

799816
ClientResponse response =
800817
webResource.path("ws").path("v2").path("timeline").path("clusters")

0 commit comments

Comments
 (0)