Skip to content

Commit f6da92b

Browse files
authored
Merge branch 'develop' into hanxiao/dumbaware
2 parents f41b501 + 6535600 commit f6da92b

File tree

3 files changed

+57
-5
lines changed

3 files changed

+57
-5
lines changed

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

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,16 @@
2828
import com.microsoft.azure.hdinsight.sdk.cluster.ClusterRawInfo;
2929
import com.microsoft.azure.hdinsight.sdk.common.AzureManagementHttpObservable;
3030
import com.microsoft.azure.hdinsight.sdk.common.errorresponse.ForbiddenHttpErrorStatus;
31+
import com.microsoft.azure.hdinsight.sdk.common.errorresponse.GatewayTimeoutErrorStatus;
3132
import com.microsoft.azure.hdinsight.sdk.common.errorresponse.HttpErrorStatus;
3233
import com.microsoft.azure.hdinsight.sdk.common.errorresponse.NotFoundHttpErrorStatus;
34+
import com.microsoft.azuretools.adauth.AuthException;
3335
import com.microsoft.azuretools.authmanage.AuthMethodManager;
3436
import com.microsoft.azuretools.authmanage.models.SubscriptionDetail;
3537
import com.microsoft.azuretools.azurecommons.helpers.AzureCmdException;
3638
import com.microsoft.azuretools.azurecommons.helpers.NotNull;
3739
import com.microsoft.azuretools.azurecommons.helpers.Nullable;
40+
import com.microsoft.azuretools.sdkmanage.AzureManager;
3841
import com.microsoft.azuretools.telemetry.AppInsightsClient;
3942
import org.apache.commons.lang3.exception.ExceptionUtils;
4043
import org.apache.http.entity.StringEntity;
@@ -62,8 +65,18 @@ private AzureManagementHttpObservable getHttp() {
6265
return this.http;
6366
}
6467

68+
private AzureManager getAzureManager() throws IOException {
69+
AzureManager azureManager = AuthMethodManager.getInstance().getAzureManager();
70+
71+
if (azureManager == null) {
72+
throw new AuthException("Not signed in. Can't send out the request.");
73+
}
74+
75+
return azureManager;
76+
}
77+
6578
public Observable<Map> getClusterCoreSiteRequest(@NotNull final String clusterId) throws IOException {
66-
String managementURI = AuthMethodManager.getInstance().getAzureManager().getManagementURI();
79+
String managementURI = getAzureManager().getManagementURI();
6780
String url = URI.create(managementURI)
6881
.resolve(clusterId.replaceAll("/+$", "") + "/configurations/core-site").toString();
6982
return getHttp()
@@ -74,7 +87,7 @@ public Observable<Map> getClusterCoreSiteRequest(@NotNull final String clusterId
7487
private Observable<ClusterConfiguration> getClusterConfigurationRequest(
7588
@NotNull final String clusterId) {
7689
try {
77-
String managementURI = AuthMethodManager.getInstance().getAzureManager().getManagementURI();
90+
String managementURI = getAzureManager().getManagementURI();
7891
String url = URI.create(managementURI)
7992
.resolve(clusterId.replaceAll("/+$", "") + "/configurations").toString();
8093
StringEntity entity = new StringEntity("", StandardCharsets.UTF_8);
@@ -124,10 +137,13 @@ public Observable<Boolean> isProbeGetConfigurationSucceed(final ClusterRawInfo c
124137
} else {
125138
if (err instanceof HttpErrorStatus) {
126139
HDInsightNewApiUnavailableException ex = new HDInsightNewApiUnavailableException(err);
127-
if (!(err instanceof NotFoundHttpErrorStatus)) {
128-
log().error("Error getting cluster configurations with NEW HDInsight API. " + clusterId, ex);
140+
if (!(err instanceof NotFoundHttpErrorStatus
141+
|| err instanceof GatewayTimeoutErrorStatus)) {
142+
log().error(String.format(
143+
"Error getting cluster configurations with NEW HDInsight API: %s, %s",
144+
clusterId,
145+
((HttpErrorStatus) err).getErrorDetails()), ex);
129146
}
130-
log().warn(((HttpErrorStatus) err).getErrorDetails());
131147

132148
final Map<String, String> properties = new HashMap<>();
133149
properties.put("ClusterID", clusterId);

Utils/hdinsight-node-common/src/com/microsoft/azure/hdinsight/sdk/common/HttpObservable.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,8 @@ public static HttpErrorStatus classifyHttpError(@NotNull CloseableHttpResponse h
301301
return new MethodNotAllowedHttpErrorStatus(message, headers, httpEntity);
302302
} else if (statusCode == 500) {
303303
return new InternalServerErrorHttpErrorStatus(message, headers, httpEntity);
304+
} else if (statusCode == 504) {
305+
return new GatewayTimeoutErrorStatus(message, headers, httpEntity);
304306
} else {
305307
return new UnclassifiedHttpErrorStatus(statusCode, message, headers, httpEntity);
306308
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright (c) Microsoft Corporation
3+
*
4+
* All rights reserved.
5+
*
6+
* MIT License
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
9+
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation
10+
* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
11+
* to permit persons to whom the Software is furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of
14+
* the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
17+
* THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
* SOFTWARE.
21+
*/
22+
23+
package com.microsoft.azure.hdinsight.sdk.common.errorresponse;
24+
25+
import org.apache.http.Header;
26+
import org.apache.http.HttpEntity;
27+
28+
import com.microsoft.azuretools.azurecommons.helpers.Nullable;
29+
30+
public class GatewayTimeoutErrorStatus extends HttpErrorStatus {
31+
public GatewayTimeoutErrorStatus(String message, @Nullable Header[] headers, @Nullable HttpEntity entity) {
32+
super(504, message, headers, entity);
33+
}
34+
}

0 commit comments

Comments
 (0)