Skip to content

Commit dd97d25

Browse files
Merge pull request #6958 from v-jiezhang3/endgame-202209
Endgame 202209
2 parents 3905f7e + e0a11c9 commit dd97d25

2 files changed

Lines changed: 15 additions & 26 deletions

File tree

Utils/hdinsight-node-common/src/com/microsoft/azure/hdinsight/sdk/cluster/HDInsightNewAPI/ClusterOperationNewAPIImpl.java

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,8 @@ public Observable<Map> getClusterCoreSiteRequest(@NotNull final String clusterId
5858
.get(url, null, null, Map.class);
5959
}
6060

61-
private Observable<ClusterConfiguration> getClusterConfigurationFromManagementEndpoint(
62-
@NotNull final String clusterId) {
63-
String managementURI = Azure.az(AzureCloud.class).getOrDefault().getManagementEndpoint();
61+
private Observable<ClusterConfiguration> getClusterConfigurationRequest(
62+
@NotNull final String clusterId, String managementURI) {
6463
String url = URI.create(managementURI)
6564
.resolve(clusterId.replaceAll("/+$", "") + "/configurations").toString();
6665
StringEntity entity = new StringEntity("", StandardCharsets.UTF_8);
@@ -70,22 +69,11 @@ private Observable<ClusterConfiguration> getClusterConfigurationFromManagementEn
7069
.post(url, entity, null, null, ClusterConfiguration.class);
7170
}
7271

73-
private Observable<ClusterConfiguration> getClusterConfigurationFromResourceManagerEndpoint(
74-
@NotNull final String clusterId) {
75-
String managementURI = Azure.az(AzureCloud.class).getOrDefault().getResourceManagerEndpoint();
76-
String url = URI.create(managementURI)
77-
.resolve(clusterId.replaceAll("/+$", "") + "/configurations").toString();
78-
StringEntity entity = new StringEntity("", StandardCharsets.UTF_8);
79-
entity.setContentType("application/json");
80-
return getHttp()
81-
.withUuidUserAgent()
82-
.post(url, entity, null, null, ClusterConfiguration.class);
83-
}
8472

8573
public Observable<Boolean> isProbeGetConfigurationSucceed(final ClusterRawInfo clusterRawInfo) {
8674
String clusterId = clusterRawInfo.getId();
87-
88-
return getClusterConfigurationFromResourceManagerEndpoint(clusterId)
75+
String managementURI = Azure.az(AzureCloud.class).getOrDefault().getResourceManagerEndpoint();
76+
return getClusterConfigurationRequest(clusterId,managementURI)
8977
.map(clusterConfiguration -> {
9078
if (isClusterConfigurationValid(clusterRawInfo, clusterConfiguration)) {
9179
setRoleType(HDInsightUserRoleType.OWNER);
@@ -176,13 +164,14 @@ public com.microsoft.azure.hdinsight.sdk.cluster.ClusterConfiguration getCluster
176164
try {
177165
switch (roleType) {
178166
case OWNER:
179-
return getClusterConfigurationFromManagementEndpoint(clusterId)
167+
String managementURI = Azure.az(AzureCloud.class).getOrDefault().getManagementEndpoint();
168+
return getClusterConfigurationRequest(clusterId,managementURI)
180169
// As you can see, the response class is
181170
// com.microsoft.azure.hdinsight.sdk.cluster.HDInsightNewAPI.ClusterConfiguration.
182171
// However, if we want to override method getClusterConfiguration, the method return type should be
183172
// com.microsoft.azure.hdinsight.sdk.cluster.ClusterConfiguration.
184173
// Therefore, we need to convert the new API response to old API.
185-
.map(ClusterOperationNewAPIImpl::convertConfigurationToOldAPI)
174+
.map(ClusterOperationNewAPIImpl::convertConfigurationToOldAPI)
186175
.toBlocking()
187176
.singleOrDefault(null);
188177
case READER:

Utils/hdinsight-node-common/src/com/microsoft/azure/hdinsight/spark/jobs/ActionHttpHandler.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@ public void handle(HttpExchange httpExchange) throws IOException {
2424

2525
final String path = requestDetail.getRequestPath();
2626
final String clusterConnectString = requestDetail.getCluster().getConnectionUrl();
27-
if (path.contains("yarnui")) {
28-
JobUtils.openYarnUIHistory(clusterConnectString, requestDetail.getAppId());
29-
} else if (path.contains("sparkui")) {
30-
try {
27+
try {
28+
if (path.contains("yarnui")) {
29+
JobUtils.openYarnUIHistory(clusterConnectString, requestDetail.getAppId());
30+
} else if (path.contains("sparkui")) {
3131
Application application = JobViewCacheManager.getSingleSparkApplication(new ApplicationKey(requestDetail.getCluster(), requestDetail.getAppId()));
3232
JobUtils.openSparkUIHistory(clusterConnectString, requestDetail.getAppId(), application.getLastAttemptId());
33-
JobUtils.setResponse(httpExchange, "open browser successfully");
34-
} catch (ExecutionException e) {
35-
JobUtils.setResponse(httpExchange, "open browser error", 500);
36-
DefaultLoader.getUIHelper().showError(e.getMessage(), "open browser error");
3733
}
34+
JobUtils.setResponse(httpExchange, "open browser successfully");
35+
} catch (ExecutionException e) {
36+
JobUtils.setResponse(httpExchange, "open browser error", 500);
37+
DefaultLoader.getUIHelper().showError(e.getMessage(), "open browser error");
3838
}
3939
}
4040
}

0 commit comments

Comments
 (0)