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

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

Introduction

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

Prototype

public PlacementType() 

Source Link

Document

Default constructor for PlacementType object.

Usage

From source file:datameer.awstasks.aws.emr.EmrCluster.java

License:Apache License

public synchronized void startup() throws InterruptedException {
    checkConnection(false);/*from  w  w w .j av  a2s. c o  m*/
    _clusterState = ClusterState.STARTING;
    boolean successful = false;
    try {
        EmrSettings settings = getSettings();
        if (settings.getPrivateKeyName() == null) {
            throw new NullPointerException(
                    "privateKeyName must not be null please configure settings properly");
        }
        LOG.info("Starting job flow '" + getName() + "' ...");
        if (!getRunningJobFlowDetailsByName(getName()).isEmpty()) {
            throw new IllegalStateException("Job flow with name '" + getName() + "' already running.");
        }
        boolean keepAlive = true;
        JobFlowInstancesConfig jobConfig = new JobFlowInstancesConfig();
        jobConfig.setHadoopVersion(_settings.getHadoopVersion());
        jobConfig.setMasterInstanceType(settings.getMasterInstanceType().getId());
        jobConfig.setSlaveInstanceType(settings.getNodeInstanceType().getId());
        jobConfig.setInstanceCount(settings.getInstanceCount());
        jobConfig.setEc2KeyName(settings.getPrivateKeyName());
        jobConfig.setPlacement(new PlacementType());
        jobConfig.setKeepJobFlowAliveWhenNoSteps(keepAlive);

        final RunJobFlowRequest startRequest = new RunJobFlowRequest();

        startRequest.setLogUri("s3n://" + settings.getS3Bucket() + settings.getS3LogPath());
        startRequest.setInstances(jobConfig);
        startRequest.setName(getName());
        startRequest.setAdditionalInfo(_settings.getAdditionalStartInfo());
        startRequest.setBootstrapActions(_settings.getBootstrapActions());
        if (settings.isDebugEnabled()) {
            startRequest.withSteps(DEBUG_STEP);
        }
        RunJobFlowResult startResponse = _emrWebService.runJobFlow(startRequest);
        _jobFlowId = startResponse.getJobFlowId();
        waitUntilClusterStarted(_jobFlowId);
        LOG.info("elastic cluster '" + getName() + "/" + _jobFlowId + "' started, master-host is "
                + _masterHost);
        successful = true;
    } finally {
        if (successful) {
            _clusterState = ClusterState.CONNECTED;
        } else {
            _clusterState = ClusterState.UNCONNECTED;
            _jobFlowId = null;
        }
    }
}

From source file:org.huahinframework.emanager.amazonaws.elasticmapreduce.ElasticMapReduceManager.java

License:Apache License

/**
 * @return JobFlowInstancesConfig//from  w w w. ja  va 2  s.  c  o m
 */
private JobFlowInstancesConfig setupJobFlowInstancesConfig() {
    JobFlowInstancesConfig config = new JobFlowInstancesConfig().withKeepJobFlowAliveWhenNoSteps(true)
            .withInstanceCount(emrProperties.getInstanceCount())
            .withMasterInstanceType(emrProperties.getMasterInstanceType());

    if (!isEmpty(emrProperties.getKeyPairName())) {
        config.setEc2KeyName(emrProperties.getKeyPairName());
    }

    if (!isEmpty(emrProperties.getHadoopVersion())) {
        config.setHadoopVersion(emrProperties.getHadoopVersion());
    }

    if (!isEmpty(emrProperties.getAvailabilityZone())) {
        config.setPlacement(new PlacementType().withAvailabilityZone(emrProperties.getAvailabilityZone()));
    }

    if (!isEmpty(emrProperties.getSlaveInstanceType())) {
        config.setSlaveInstanceType(emrProperties.getSlaveInstanceType());
    } else {
        config.setSlaveInstanceType(emrProperties.getMasterInstanceType());
    }

    return config;
}