com.amazonaws.services.elasticmapreduce.model.TerminateJobFlowsRequest Java Examples

The following examples show how to use com.amazonaws.services.elasticmapreduce.model.TerminateJobFlowsRequest. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EmrOperationsImpl.java    From herd with Apache License 2.0 5 votes vote down vote up
/**
 * Terminate EMR cluster, overrides terminate protection if requested.
 */
@Override
public void terminateEmrCluster(AmazonElasticMapReduceClient emrClient, String clusterId, boolean overrideTerminationProtection)
{
    // Override terminate protection if requested.
    if (overrideTerminationProtection)
    {
        // Set termination protection
        emrClient.setTerminationProtection(new SetTerminationProtectionRequest().withJobFlowIds(clusterId).withTerminationProtected(false));
    }

    // Terminate the job flow
    emrClient.terminateJobFlows(new TerminateJobFlowsRequest().withJobFlowIds(clusterId));
}
 
Example #2
Source File: EmrIT.java    From digdag with Apache License 2.0 5 votes vote down vote up
@After
public void tearDownEmrClusters()
        throws Exception
{
    if (!clusterIds.isEmpty()) {
        emr.terminateJobFlows(new TerminateJobFlowsRequest().withJobFlowIds(clusterIds));
    }
}
 
Example #3
Source File: TestEmrClusterJob.java    From datacollector with Apache License 2.0 5 votes vote down vote up
@Test
public void testTerminateCluster() {
  Properties properties = new Properties();
  EmrClusterJob emrClusterJob = new EmrClusterJob();
  EmrClusterJob.Client client = Mockito.spy(emrClusterJob.getClient(properties));
  AmazonElasticMapReduce emr = Mockito.mock(AmazonElasticMapReduce.class);
  Mockito.doReturn(emr).when(client).getEmrClient(Mockito.any(EmrClusterConfig.class));
  Mockito.doReturn(Mockito.mock(TerminateJobFlowsResult.class)).when(emr).terminateJobFlows(Mockito.any(TerminateJobFlowsRequest
      .class));
  client.terminateCluster("foo");
  Mockito.verify(emr, Mockito.times(1)).terminateJobFlows(Mockito.any(TerminateJobFlowsRequest.class));
  Mockito.verify(client, Mockito.times(1)).getEmrClient(Mockito.any(EmrClusterConfig.class));

}
 
Example #4
Source File: EmrClusterJob.java    From datacollector with Apache License 2.0 4 votes vote down vote up
@Override
public void terminateCluster(String clusterId) {
  TerminateJobFlowsRequest terminateJobFlowsRequest = new TerminateJobFlowsRequest()
      .withJobFlowIds(Arrays.asList(clusterId));
  getEmrClient(emrClusterConfig).terminateJobFlows(terminateJobFlowsRequest);
}