Example usage for com.amazonaws.services.elasticmapreduce.model ClusterStatus ClusterStatus

List of usage examples for com.amazonaws.services.elasticmapreduce.model ClusterStatus ClusterStatus

Introduction

In this page you can find the example usage for com.amazonaws.services.elasticmapreduce.model ClusterStatus ClusterStatus.

Prototype

ClusterStatus

Source Link

Usage

From source file:org.finra.dm.dao.impl.MockEmrOperationsImpl.java

License:Apache License

@Override
public DescribeClusterResult describeClusterRequest(AmazonElasticMapReduceClient emrClient,
        DescribeClusterRequest describeClusterRequest) {
    if (describeClusterRequest.getClusterId()
            .equalsIgnoreCase(MockAwsOperationsHelper.AMAZON_SERVICE_EXCEPTION)) {
        throw new AmazonServiceException(MockAwsOperationsHelper.AMAZON_SERVICE_EXCEPTION);
    }//from w  w  w . j a  va  2  s . c  om

    MockEmrJobFlow cluster = getClusterById(describeClusterRequest.getClusterId());
    if (cluster != null) {
        return new DescribeClusterResult()
                .withCluster(new Cluster().withId(cluster.getJobFlowId()).withName(cluster.getJobFlowName())
                        .withStatus(new ClusterStatus().withState(cluster.getStatus())));
    } else {
        return null;
    }
}

From source file:org.finra.dm.dao.impl.MockEmrOperationsImpl.java

License:Apache License

@Override
public ListClustersResult listEmrClusters(AmazonElasticMapReduceClient emrClient,
        ListClustersRequest listClustersRequest) {
    List<ClusterSummary> clusterSummaryList = new ArrayList<>();
    for (MockEmrJobFlow cluster : emrClusters.values()) {
        if (!listClustersRequest.getClusterStates().isEmpty()
                && listClustersRequest.getClusterStates().contains(cluster.getStatus())) {
            ClusterSummary clusterSummary = new ClusterSummary();
            clusterSummary.withId(cluster.getJobFlowId()).withName(cluster.getJobFlowName())
                    .withStatus(new ClusterStatus().withState(cluster.getStatus()));
            clusterSummaryList.add(clusterSummary);
        }/* www .j  av a2 s.co m*/
    }
    if (StringUtils.isBlank(listClustersRequest.getMarker())) {
        return new ListClustersResult().withClusters(clusterSummaryList).withMarker(MOCK_EMR_MAKER);
    } else {
        return new ListClustersResult().withClusters(clusterSummaryList);
    }
}

From source file:org.finra.herd.dao.impl.MockEmrOperationsImpl.java

License:Apache License

@Override
public DescribeClusterResult describeClusterRequest(AmazonElasticMapReduceClient emrClient,
        DescribeClusterRequest describeClusterRequest) {
    if (describeClusterRequest.getClusterId()
            .equalsIgnoreCase(MockAwsOperationsHelper.AMAZON_SERVICE_EXCEPTION)) {
        throw new AmazonServiceException(MockAwsOperationsHelper.AMAZON_SERVICE_EXCEPTION);
    }/*  w  w w .  j a  v a 2 s.  c  o  m*/

    MockEmrJobFlow cluster = getClusterById(describeClusterRequest.getClusterId());
    if (cluster != null) {
        return new DescribeClusterResult().withCluster(new Cluster().withId(cluster.getJobFlowId())
                .withName(cluster.getJobFlowName())
                .withStatus(new ClusterStatus().withState(cluster.getStatus())
                        .withStateChangeReason(new ClusterStateChangeReason()
                                .withCode(cluster.getStatusChangeReason().getCode())
                                .withMessage(cluster.getStatusChangeReason().getMessage()))
                        .withTimeline(new ClusterTimeline()
                                .withCreationDateTime(cluster.getStatusTimeline().getCreationTime() != null
                                        ? cluster.getStatusTimeline().getCreationTime().toGregorianCalendar()
                                                .getTime()
                                        : null)
                                .withEndDateTime(cluster.getStatusTimeline().getEndTime() != null ? cluster
                                        .getStatusTimeline().getEndTime().toGregorianCalendar().getTime()
                                        : null)
                                .withReadyDateTime(cluster.getStatusTimeline().getReadyTime() != null ? cluster
                                        .getStatusTimeline().getReadyTime().toGregorianCalendar().getTime()
                                        : null))));
    } else {
        return null;
    }
}

From source file:org.finra.herd.dao.impl.MockEmrOperationsImpl.java

License:Apache License

@Override
public ListClustersResult listEmrClusters(AmazonElasticMapReduceClient emrClient,
        ListClustersRequest listClustersRequest) {
    List<ClusterSummary> clusterSummaryList = new ArrayList<>();
    for (MockEmrJobFlow cluster : emrClusters.values()) {
        if (!listClustersRequest.getClusterStates().isEmpty()
                && listClustersRequest.getClusterStates().contains(cluster.getStatus())) {
            ClusterSummary clusterSummary = new ClusterSummary();
            clusterSummary.withId(cluster.getJobFlowId()).withName(cluster.getJobFlowName())
                    .withStatus(new ClusterStatus().withState(cluster.getStatus())
                            .withStateChangeReason(new ClusterStateChangeReason()
                                    .withCode(cluster.getStatusChangeReason().getCode())
                                    .withMessage(cluster.getStatusChangeReason().getMessage()))
                            .withTimeline(new ClusterTimeline()
                                    .withCreationDateTime(cluster.getStatusTimeline().getCreationTime() != null
                                            ? cluster.getStatusTimeline().getCreationTime()
                                                    .toGregorianCalendar().getTime()
                                            : null)
                                    .withEndDateTime(cluster.getStatusTimeline().getEndTime() != null ? cluster
                                            .getStatusTimeline().getEndTime().toGregorianCalendar().getTime()
                                            : null)
                                    .withReadyDateTime(cluster.getStatusTimeline().getReadyTime() != null
                                            ? cluster.getStatusTimeline().getReadyTime().toGregorianCalendar()
                                                    .getTime()
                                            : null)));
            clusterSummaryList.add(clusterSummary);
        }//ww  w . j av a 2s. c o  m
    }
    if (StringUtils.isBlank(listClustersRequest.getMarker())) {
        return new ListClustersResult().withClusters(clusterSummaryList).withMarker(MOCK_EMR_MAKER);
    } else {
        return new ListClustersResult().withClusters(clusterSummaryList);
    }
}