@SdkInternalApi
    final SetTerminationProtectionResult executeSetTerminationProtection(SetTerminationProtectionRequest setTerminationProtectionRequest) {

        ExecutionContext executionContext = createExecutionContext(setTerminationProtectionRequest);
        AWSRequestMetrics awsRequestMetrics = executionContext.getAwsRequestMetrics();
        awsRequestMetrics.startEvent(Field.ClientExecuteTime);
        Request<SetTerminationProtectionRequest> request = null;
        Response<SetTerminationProtectionResult> response = null;

        try {
            awsRequestMetrics.startEvent(Field.RequestMarshallTime);
            try {
                request = new SetTerminationProtectionRequestProtocolMarshaller(protocolFactory).marshall(super
                        .beforeMarshalling(setTerminationProtectionRequest));
                // Binds the request metrics to the current request.
                request.setAWSRequestMetrics(awsRequestMetrics);
                request.addHandlerContext(HandlerContextKey.CLIENT_ENDPOINT, endpoint);
                request.addHandlerContext(HandlerContextKey.ENDPOINT_OVERRIDDEN, isEndpointOverridden());
                request.addHandlerContext(HandlerContextKey.SIGNING_REGION, getSigningRegion());
                request.addHandlerContext(HandlerContextKey.SERVICE_ID, "EMR");
                request.addHandlerContext(HandlerContextKey.OPERATION_NAME, "SetTerminationProtection");
                request.addHandlerContext(HandlerContextKey.ADVANCED_CONFIG, advancedConfig);

            } finally {
                awsRequestMetrics.endEvent(Field.RequestMarshallTime);
            }

            HttpResponseHandler<AmazonWebServiceResponse<SetTerminationProtectionResult>> responseHandler = protocolFactory.createResponseHandler(
                    new JsonOperationMetadata().withPayloadJson(true).withHasStreamingSuccessResponse(false),
                    new SetTerminationProtectionResultJsonUnmarshaller());
            response = invoke(request, responseHandler, executionContext);

            return response.getAwsResponse();

        } finally {

            endClientExecution(awsRequestMetrics, request, response);
        }
    }
<p>
SetTerminationProtection locks a cluster (job flow) so the Amazon EC2 instances in the cluster cannot be
terminated by user intervention, an API call, or in the event of a job-flow error. The cluster still terminates
upon successful completion of the job flow. Calling <code>SetTerminationProtection</code> on a cluster is similar
to calling the Amazon EC2 <code>DisableAPITermination</code> API on all Amazon EC2 instances in a cluster.
</p>
<p>
<code>SetTerminationProtection</code> is used to prevent accidental termination of a cluster and to ensure that
in the event of an error, the instances persist so that you can recover any data stored in their ephemeral
instance storage.
</p>
<p>
To terminate a cluster that has been locked by setting <code>SetTerminationProtection</code> to <code>true</code>
, you must first unlock the job flow by a subsequent call to <code>SetTerminationProtection</code> in which you
set the value to <code>false</code>.
</p>
<p>
For more information, see <a
href="https://docs.aws.amazon.com/emr/latest/ManagementGuide/UsingEMR_TerminationProtection.html">Managing
Cluster Termination</a> in the <i>Amazon EMR Management Guide</i>.
</p>

@param setTerminationProtectionRequest
       The input argument to the <a>TerminationProtection</a> operation.
@return Result of the SetTerminationProtection operation returned by the service.
@throws InternalServerErrorException
        Indicates that an error occurred while processing the request and that the request was not completed.
@sample AmazonElasticMapReduce.SetTerminationProtection
@see <a href="http://docs.aws.amazon.com/goto/WebAPI/elasticmapreduce-2009-03-31/SetTerminationProtection"
     target="_top">AWS API Documentation</a>
aws-java-sdk-emr/src/main/java/com/amazonaws/services/elasticmapreduce/AmazonElasticMapReduceClient.java