2828import com .microsoft .azure .hdinsight .sdk .cluster .ClusterRawInfo ;
2929import com .microsoft .azure .hdinsight .sdk .common .AzureManagementHttpObservable ;
3030import com .microsoft .azure .hdinsight .sdk .common .errorresponse .ForbiddenHttpErrorStatus ;
31+ import com .microsoft .azure .hdinsight .sdk .common .errorresponse .GatewayTimeoutErrorStatus ;
3132import com .microsoft .azure .hdinsight .sdk .common .errorresponse .HttpErrorStatus ;
3233import com .microsoft .azure .hdinsight .sdk .common .errorresponse .NotFoundHttpErrorStatus ;
34+ import com .microsoft .azuretools .adauth .AuthException ;
3335import com .microsoft .azuretools .authmanage .AuthMethodManager ;
3436import com .microsoft .azuretools .authmanage .models .SubscriptionDetail ;
3537import com .microsoft .azuretools .azurecommons .helpers .AzureCmdException ;
3638import com .microsoft .azuretools .azurecommons .helpers .NotNull ;
3739import com .microsoft .azuretools .azurecommons .helpers .Nullable ;
40+ import com .microsoft .azuretools .sdkmanage .AzureManager ;
3841import com .microsoft .azuretools .telemetry .AppInsightsClient ;
3942import org .apache .commons .lang3 .exception .ExceptionUtils ;
4043import 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 );
0 commit comments