use of com.amazonaws.services.elasticmapreduce.model.ListClustersResult in project herd by FINRAOS.
the class EmrDaoImpl method getActiveEmrClusterByName.
@Override
public ClusterSummary getActiveEmrClusterByName(String clusterName, AwsParamsDto awsParams) {
if (StringUtils.isNotBlank(clusterName)) {
/**
* Call AWSOperations for ListClusters API. Need to list all the active clusters that are in
* BOOTSTRAPPING/RUNNING/STARTING/WAITING states
*/
ListClustersRequest listClustersRequest = new ListClustersRequest().withClusterStates(getActiveEmrClusterStates());
/**
* ListClusterRequest returns only 50 clusters at a time. However, this returns a marker
* that can be used for subsequent calls to listClusters to get all the clusters
*/
String markerForListClusters = listClustersRequest.getMarker();
// Loop through all the available clusters and look for the given cluster id
do {
/**
* Call AWSOperations for ListClusters API.
* Need to include the Marker returned by the previous iteration
*/
ListClustersResult clusterResult = emrOperations.listEmrClusters(getEmrClient(awsParams), listClustersRequest.withMarker(markerForListClusters));
// Loop through all the active clusters returned by AWS
for (ClusterSummary clusterInstance : clusterResult.getClusters()) {
// If the cluster name matches, then return the status
if (StringUtils.isNotBlank(clusterInstance.getName()) && clusterInstance.getName().equalsIgnoreCase(clusterName)) {
return clusterInstance;
}
}
markerForListClusters = clusterResult.getMarker();
} while (markerForListClusters != null);
}
return null;
}
Aggregations