Java 类com.amazonaws.services.elasticmapreduce.model.DescribeClusterRequest 实例源码

项目:herd    文件:EmrDaoImpl.java   
@Override
public Cluster getEmrClusterById(String clusterId, AwsParamsDto awsParams)
{
    Cluster cluster = null;
    if (StringUtils.isNotBlank(clusterId))
    {
        DescribeClusterResult describeClusterResult =
            emrOperations.describeClusterRequest(getEmrClient(awsParams), new DescribeClusterRequest().withClusterId(clusterId));
        if (describeClusterResult != null && describeClusterResult.getCluster() != null)
        {
            cluster = describeClusterResult.getCluster();
        }
    }

    return cluster;
}
项目:aws-big-data-blog    文件:LambdaContainer.java   
protected List<String> getActiveTaggedClusters() throws Exception{
    AmazonElasticMapReduceClient emrClient = new AmazonElasticMapReduceClient();
    List<String> waitingClusters = new ArrayList<String>();
    ListClustersResult clusterResult = emrClient.listClusters(new ListClustersRequest().withClusterStates(ClusterState.WAITING));

    DescribeClusterRequest specifcTagDescribe = new DescribeClusterRequest();
    specifcTagDescribe.putCustomQueryParameter("Cluster.Tags",null);
     for( ClusterSummary cluster : clusterResult.getClusters()){
            System.out.println("list cluster id "+cluster.getId());
            List<Tag> tagList = emrClient.describeCluster(specifcTagDescribe.withClusterId(cluster.getId())).getCluster().getTags();
            for(Tag tag:tagList){
                if(tag.getKey().equals(props.getProperty("edba.cluster.tag.key"))){
                    waitingClusters.add(cluster.getId());
                }
            }

    }
    return waitingClusters;

}
项目:aws-big-data-blog    文件:EMRUtils.java   
/**
 * Helper method to determine if an Amazon EMR cluster exists
 * 
 * @param client
 *        The {@link AmazonElasticMapReduceClient} with read permissions
 * @param clusterIdentifier
 *        The Amazon EMR cluster to check
 * @return true if the Amazon EMR cluster exists, otherwise false
 */
public static boolean clusterExists(AmazonElasticMapReduce client, String clusterIdentifier) {
    if (clusterIdentifier != null && !clusterIdentifier.isEmpty()) {
        ListClustersResult clustersList = client.listClusters();
        ListIterator<ClusterSummary> iterator = clustersList.getClusters().listIterator();
        ClusterSummary summary;
        for (summary = iterator.next() ; iterator.hasNext();summary = iterator.next()) {
            if (summary.getId().equals(clusterIdentifier)) {
                DescribeClusterRequest describeClusterRequest = new DescribeClusterRequest().withClusterId(clusterIdentifier);  
                DescribeClusterResult result = client.describeCluster(describeClusterRequest);  
                if (result != null) {
                    Cluster cluster = result.getCluster();
                    //check if HBase is installed on this cluster
                    if (isHBaseInstalled(client, cluster.getId())) return false;
                    String state = cluster.getStatus().getState();
                    LOG.info(clusterIdentifier + " is " + state + ". ");
                    if (state.equalsIgnoreCase("RUNNING") ||state.equalsIgnoreCase("WAITING"))  {
                        LOG.info("The cluster with id " + clusterIdentifier + " exists and is " + state);   
                        return true;
                    }
                }
            }       
        }                   
    }
    LOG.info("The cluster with id " + clusterIdentifier + " does not exist");
    return false;  
}
项目:digdag    文件:EmrOperatorFactory.java   
private Optional<String> checkClusterBootStatus(AmazonElasticMapReduce emr, NewCluster cluster, TaskState state)
{
    // Only creating a cluster, with no steps?
    boolean createOnly = cluster.steps() == 0;

    DescribeClusterResult describeClusterResult = pollingRetryExecutor(state, "describe-cluster")
            .withRetryInterval(DurationInterval.of(Duration.ofSeconds(30), Duration.ofMinutes(5)))
            .retryUnless(AmazonServiceException.class, Aws::isDeterministicException)
            .run(ds -> emr.describeCluster(new DescribeClusterRequest().withClusterId(cluster.id())));

    ClusterStatus clusterStatus = describeClusterResult.getCluster().getStatus();
    String clusterState = clusterStatus.getState();

    switch (clusterState) {
        case "STARTING":
            logger.info("EMR cluster starting: {}", cluster.id());
            return Optional.absent();
        case "BOOTSTRAPPING":
            logger.info("EMR cluster bootstrapping: {}", cluster.id());
            return Optional.absent();

        case "RUNNING":
        case "WAITING":
            logger.info("EMR cluster up: {}", cluster.id());
            return Optional.of(clusterState);

        case "TERMINATED_WITH_ERRORS":
            if (createOnly) {
                // TODO: log more information about the errors
                // TODO: inspect state change reason to figure out whether it was the boot that failed or e.g. steps submitted by another agent
                throw new TaskExecutionException("EMR boot failed: " + cluster.id());
            }
            return Optional.of(clusterState);

        case "TERMINATING":
            if (createOnly) {
                // Keep waiting for the final state
                // TODO: inspect state change reason and bail early here
                return Optional.absent();
            }
            return Optional.of(clusterState);

        case "TERMINATED":
            return Optional.of(clusterState);

        default:
            throw new RuntimeException("Unknown EMR cluster state: " + clusterState);
    }
}
项目:aws-big-data-blog    文件:EMRUtils.java   
/**
 * Helper method to determine the Amazon EMR cluster state
 * 
 * @param client
 *        The {@link AmazonElasticMapReduceClient} with read permissions
 * @param clusterIdentifier
 *        The Amazon EMR cluster to get the state of - e.g. j-2A98VJHDSU48M
 * @return The String representation of the Amazon EMR cluster state
 */
public static String clusterState(AmazonElasticMapReduce client, String clusterIdentifier) {
    DescribeClusterRequest describeClusterRequest = new DescribeClusterRequest().withClusterId(clusterIdentifier);
    DescribeClusterResult result= client.describeCluster(describeClusterRequest);
    if (result != null) {
        return result.getCluster().getStatus().getState();
    }
    return null;
}