Skip to content

Commit 22b88b1

Browse files
committed
Fix the issue of unmatched linked cluster not being listed
Signed-off-by: Wei Zhang <[email protected]>
1 parent f548659 commit 22b88b1

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,15 +194,23 @@ public synchronized ImmutableList<IClusterDetail> getClusterDetails() {
194194
// TODO: so far we have not a good way to judge whether it is token expired as
195195
// we have changed the way to list HDInsight clusters
196196
isListClusterSuccess = clusterDetailList.size() != 0;
197+
ArrayList<IClusterDetail> additionalCluster = new ArrayList<>(hdinsightAdditionalClusterDetails);
197198

198199
List<IClusterDetail> mergedClusters = clusterDetailList.stream()
200+
.filter(clusterDetail -> clusterDetail.getSubscription().isSelected())
199201
// replace the duplicated cluster with linked one
200-
.map(cluster -> hdinsightAdditionalClusterDetails.stream()
201-
.filter(linkedCluster -> linkedCluster.getName().equals(cluster.getName()))
202-
.findFirst()
203-
.orElse(cluster))
202+
.map(cluster -> {
203+
Optional<IClusterDetail> linkedAndInSubscriptionCluster = additionalCluster.stream()
204+
.filter(linkedCluster -> linkedCluster.getName().equals(cluster.getName()))
205+
.findFirst();
206+
207+
linkedAndInSubscriptionCluster.ifPresent(additionalCluster::remove);
208+
209+
return linkedAndInSubscriptionCluster.orElse(cluster);
210+
})
204211
.collect(Collectors.toList());
205212

213+
mergedClusters.addAll(additionalCluster);
206214
mergedClusters.addAll(emulatorClusterDetails);
207215

208216
ClusterMetaDataService.getInstance().addCachedClusters(mergedClusters);

0 commit comments

Comments
 (0)