use of com.microsoft.azure.hdinsight.sdk.common.AggregatedException in project azure-tools-for-java by Microsoft.
the class ClusterManager method getClusterDetails.
private List<IClusterDetail> getClusterDetails(List<SubscriptionDetail> subscriptions, final Object project) throws AggregatedException {
ExecutorService taskExecutor = Executors.newFixedThreadPool(MAX_CONCURRENT);
final List<IClusterDetail> cachedClusterList = new ArrayList<>();
final List<Exception> aggregateExceptions = new ArrayList<>();
for (SubscriptionDetail subscription : subscriptions) {
taskExecutor.execute(new CommonRunnable<SubscriptionDetail, Exception>(subscription) {
@Override
public void runSpecificParameter(SubscriptionDetail parameter) throws IOException, HDIException, AzureCmdException {
IClusterOperation clusterOperation = new ClusterOperationImpl(project);
List<ClusterRawInfo> clusterRawInfoList = clusterOperation.listCluster(parameter);
if (clusterRawInfoList != null) {
for (ClusterRawInfo item : clusterRawInfoList) {
IClusterDetail tempClusterDetail = new ClusterDetail(parameter, item);
synchronized (ClusterManager.class) {
cachedClusterList.add(tempClusterDetail);
}
}
}
}
@Override
public void exceptionHandle(Exception e) {
synchronized (aggregateExceptions) {
aggregateExceptions.add(e);
}
}
});
}
taskExecutor.shutdown();
try {
taskExecutor.awaitTermination(TIME_OUT, TimeUnit.SECONDS);
} catch (InterruptedException exception) {
aggregateExceptions.add(exception);
}
if (aggregateExceptions.size() > 0) {
throw new AggregatedException(aggregateExceptions);
}
return cachedClusterList;
}
Aggregations