Skip to content

Commit aa5fd66

Browse files
t-rufanglcadzy
authored andcommitted
Fix storage account refresh error in Eclipse issue (#3117)
1 parent 7946d84 commit aa5fd66

File tree

1 file changed

+25
-20
lines changed
  • Utils/hdinsight-node-common/src/com/microsoft/azure/hdinsight/sdk/cluster

1 file changed

+25
-20
lines changed

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

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ public class ClusterDetail implements IClusterDetail, LivyCluster, YarnCluster,
6969
private IHDIStorageAccount defaultStorageAccount;
7070
private List<HDStorageAccount> additionalStorageAccounts;
7171
private boolean isConfigInfoAvailable = false;
72+
@Nullable
73+
private Map<String, String> coresiteMap = null;
7274

7375
public ClusterDetail(SubscriptionDetail paramSubscription,
7476
ClusterRawInfo paramClusterRawInfo,
@@ -275,6 +277,7 @@ public void getConfigurationInfo() throws IOException, HDIException, AzureCmdExc
275277
Map<String, String> coresSiteMap = configurations.getCoresite();
276278
ClusterIdentity clusterIdentity = configurations.getClusterIdentity();
277279
if (coresSiteMap != null) {
280+
this.coresiteMap = coresSiteMap;
278281
this.defaultStorageAccount = getDefaultStorageAccount(coresSiteMap, clusterIdentity);
279282
this.additionalStorageAccounts = getAdditionalStorageAccounts(coresSiteMap);
280283
}
@@ -288,18 +291,20 @@ public void getConfigurationInfo() throws IOException, HDIException, AzureCmdExc
288291

289292
@Nullable
290293
public String getDefaultStorageRootPath() {
291-
if (!(clusterOperation instanceof ClusterOperationNewAPIImpl)) {
292-
return null;
293-
}
294-
295294
log().info("Cluster ID: " + clusterRawInfo.getId());
296-
Map<String, String> coresiteMap = null;
295+
Map<String, String> requestedCoresiteMap = null;
296+
297297
try {
298-
coresiteMap =
299-
((ClusterOperationNewAPIImpl) clusterOperation).getClusterCoreSiteRequest(clusterRawInfo.getId())
300-
.toBlocking()
301-
.singleOrDefault(null);
302-
if (coresiteMap == null) {
298+
if (!(clusterOperation instanceof ClusterOperationNewAPIImpl)) {
299+
requestedCoresiteMap = this.coresiteMap;
300+
} else {
301+
requestedCoresiteMap =
302+
((ClusterOperationNewAPIImpl) clusterOperation).getClusterCoreSiteRequest(clusterRawInfo.getId())
303+
.toBlocking()
304+
.singleOrDefault(null);
305+
}
306+
307+
if (requestedCoresiteMap == null) {
303308
log().warn("Error getting cluster core-site. coresiteMap is null.");
304309
return null;
305310
}
@@ -309,10 +314,10 @@ public String getDefaultStorageRootPath() {
309314
}
310315

311316
String containerAddress = null;
312-
if (coresiteMap.containsKey(DefaultFS)) {
313-
containerAddress = coresiteMap.get(DefaultFS);
314-
} else if (coresiteMap.containsKey(FSDefaultName)) {
315-
containerAddress = coresiteMap.get(FSDefaultName);
317+
if (requestedCoresiteMap.containsKey(DefaultFS)) {
318+
containerAddress = requestedCoresiteMap.get(DefaultFS);
319+
} else if (requestedCoresiteMap.containsKey(FSDefaultName)) {
320+
containerAddress = requestedCoresiteMap.get(FSDefaultName);
316321
} else {
317322
log().warn("Error getting cluster default storage account. containerAddress is null.");
318323
return null;
@@ -323,11 +328,11 @@ public String getDefaultStorageRootPath() {
323328
String accountName = "";
324329
String defaultRootPath = "";
325330

326-
if (coresiteMap.containsKey(ADLS_HOME_HOST_NAME)) {
327-
accountName = coresiteMap.get(ADLS_HOME_HOST_NAME).split("\\.")[0];
331+
if (requestedCoresiteMap.containsKey(ADLS_HOME_HOST_NAME)) {
332+
accountName = requestedCoresiteMap.get(ADLS_HOME_HOST_NAME).split("\\.")[0];
328333
}
329-
if (coresiteMap.containsKey(ADLS_HOME_MOUNTPOINT)) {
330-
defaultRootPath = coresiteMap.get(ADLS_HOME_MOUNTPOINT);
334+
if (requestedCoresiteMap.containsKey(ADLS_HOME_MOUNTPOINT)) {
335+
defaultRootPath = requestedCoresiteMap.get(ADLS_HOME_MOUNTPOINT);
331336
}
332337

333338
return URI.create(String.format("%s://%s.azuredatalakestore.net", scheme, accountName))
@@ -339,7 +344,7 @@ public String getDefaultStorageRootPath() {
339344
} else {
340345
final Map<String, String> properties = new HashMap<>();
341346
properties.put("ErrorType", "Unknown HDInsight default storage type");
342-
properties.put("coreSiteMap", StringUtils.join(coresiteMap));
347+
properties.put("coreSiteMap", StringUtils.join(requestedCoresiteMap));
343348
properties.put("containerAddress", containerAddress);
344349
properties.put("ClusterID", this.clusterRawInfo.getId());
345350
AppInsightsClient.createByType(AppInsightsClient.EventType.Error, this.getClass().getSimpleName(), null, properties);
@@ -352,7 +357,7 @@ public String getDefaultStorageRootPath() {
352357
private IHDIStorageAccount getDefaultStorageAccount(Map<String, String> coresiteMap, ClusterIdentity clusterIdentity) throws HDIException {
353358
String defaultStorageRootPath = getDefaultStorageRootPath();
354359
if (defaultStorageRootPath == null) {
355-
throw new HDIException("Failed to get default storage account");
360+
throw new HDIException("Failed to get default storage root path");
356361
}
357362

358363
StoragePathInfo pathInfo = new StoragePathInfo(defaultStorageRootPath);

0 commit comments

Comments
 (0)