com.amazonaws.services.ecs.AmazonECSAsyncClient Maven / Gradle / Ivy
/*
* Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights
* Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package com.amazonaws.services.ecs;
import com.amazonaws.services.ecs.model.*;
import com.amazonaws.annotation.ThreadSafe;
/**
* Interface for accessing Amazon ECS asynchronously. Each asynchronous method
* will return a Java Future object representing the asynchronous operation;
* overloads which accept an {@code AsyncHandler} can be used to receive
* notification when an asynchronous operation completes.
*
*
* Amazon EC2 Container Service (Amazon ECS) is a highly scalable, fast,
* container management service that makes it easy to run, stop, and manage
* Docker containers on a cluster of EC2 instances. Amazon ECS lets you launch
* and stop container-enabled applications with simple API calls, allows you to
* get the state of your cluster from a centralized service, and gives you
* access to many familiar Amazon EC2 features like security groups, Amazon EBS
* volumes, and IAM roles.
*
*
* You can use Amazon ECS to schedule the placement of containers across your
* cluster based on your resource needs, isolation policies, and availability
* requirements. Amazon EC2 Container Service eliminates the need for you to
* operate your own cluster management and configuration management systems or
* worry about scaling your management infrastructure.
*
*/
@ThreadSafe
public class AmazonECSAsyncClient extends AmazonECSClient implements
AmazonECSAsync {
private static final int DEFAULT_THREAD_POOL_SIZE = 50;
private final java.util.concurrent.ExecutorService executorService;
/**
* Constructs a new asynchronous client to invoke service methods on Amazon
* ECS. A credentials provider chain will be used that searches for
* credentials in this order:
*
* - Environment Variables - AWS_ACCESS_KEY_ID and AWS_SECRET_KEY
* - Java System Properties - aws.accessKeyId and aws.secretKey
* - Credential profiles file at the default location (~/.aws/credentials)
* shared by all AWS SDKs and the AWS CLI
* - Instance profile credentials delivered through the Amazon EC2
* metadata service
*
*
* Asynchronous methods are delegated to a fixed-size thread pool containing
* 50 threads (to match the default maximum number of concurrent connections
* to the service).
*
* @see com.amazonaws.auth.DefaultAWSCredentialsProviderChain
* @see java.util.concurrent.Executors#newFixedThreadPool(int)
*/
public AmazonECSAsyncClient() {
this(new com.amazonaws.auth.DefaultAWSCredentialsProviderChain());
}
/**
* Constructs a new asynchronous client to invoke service methods on Amazon
* ECS. A credentials provider chain will be used that searches for
* credentials in this order:
*
* - Environment Variables - AWS_ACCESS_KEY_ID and AWS_SECRET_KEY
* - Java System Properties - aws.accessKeyId and aws.secretKey
* - Credential profiles file at the default location (~/.aws/credentials)
* shared by all AWS SDKs and the AWS CLI
* - Instance profile credentials delivered through the Amazon EC2
* metadata service
*
*
* Asynchronous methods are delegated to a fixed-size thread pool containing
* a number of threads equal to the maximum number of concurrent connections
* configured via {@code ClientConfiguration.getMaxConnections()}.
*
* @param clientConfiguration
* The client configuration options controlling how this client
* connects to Amazon ECS (ex: proxy settings, retry counts, etc).
*
* @see com.amazonaws.auth.DefaultAWSCredentialsProviderChain
* @see java.util.concurrent.Executors#newFixedThreadPool(int)
*/
public AmazonECSAsyncClient(
com.amazonaws.ClientConfiguration clientConfiguration) {
this(new com.amazonaws.auth.DefaultAWSCredentialsProviderChain(),
clientConfiguration, java.util.concurrent.Executors
.newFixedThreadPool(clientConfiguration
.getMaxConnections()));
}
/**
* Constructs a new asynchronous client to invoke service methods on Amazon
* ECS using the specified AWS account credentials.
*
* Asynchronous methods are delegated to a fixed-size thread pool containing
* 50 threads (to match the default maximum number of concurrent connections
* to the service).
*
* @param awsCredentials
* The AWS credentials (access key ID and secret key) to use when
* authenticating with AWS services.
* @see java.util.concurrent.Executors#newFixedThreadPool(int)
*/
public AmazonECSAsyncClient(com.amazonaws.auth.AWSCredentials awsCredentials) {
this(awsCredentials, java.util.concurrent.Executors
.newFixedThreadPool(DEFAULT_THREAD_POOL_SIZE));
}
/**
* Constructs a new asynchronous client to invoke service methods on Amazon
* ECS using the specified AWS account credentials and executor service.
* Default client settings will be used.
*
* @param awsCredentials
* The AWS credentials (access key ID and secret key) to use when
* authenticating with AWS services.
* @param executorService
* The executor service by which all asynchronous requests will be
* executed.
*/
public AmazonECSAsyncClient(
com.amazonaws.auth.AWSCredentials awsCredentials,
java.util.concurrent.ExecutorService executorService) {
this(awsCredentials, configFactory.getConfig(), executorService);
}
/**
* Constructs a new asynchronous client to invoke service methods on Amazon
* ECS using the specified AWS account credentials, executor service, and
* client configuration options.
*
* @param awsCredentials
* The AWS credentials (access key ID and secret key) to use when
* authenticating with AWS services.
* @param clientConfiguration
* Client configuration options (ex: max retry limit, proxy settings,
* etc).
* @param executorService
* The executor service by which all asynchronous requests will be
* executed.
*/
public AmazonECSAsyncClient(
com.amazonaws.auth.AWSCredentials awsCredentials,
com.amazonaws.ClientConfiguration clientConfiguration,
java.util.concurrent.ExecutorService executorService) {
super(awsCredentials, clientConfiguration);
this.executorService = executorService;
}
/**
* Constructs a new asynchronous client to invoke service methods on Amazon
* ECS using the specified AWS account credentials provider. Default client
* settings will be used.
*
* Asynchronous methods are delegated to a fixed-size thread pool containing
* 50 threads (to match the default maximum number of concurrent connections
* to the service).
*
* @param awsCredentialsProvider
* The AWS credentials provider which will provide credentials to
* authenticate requests with AWS services.
* @see java.util.concurrent.Executors#newFixedThreadPool(int)
*/
public AmazonECSAsyncClient(
com.amazonaws.auth.AWSCredentialsProvider awsCredentialsProvider) {
this(awsCredentialsProvider, java.util.concurrent.Executors
.newFixedThreadPool(DEFAULT_THREAD_POOL_SIZE));
}
/**
* Constructs a new asynchronous client to invoke service methods on Amazon
* ECS using the provided AWS account credentials provider and client
* configuration options.
*
* Asynchronous methods are delegated to a fixed-size thread pool containing
* a number of threads equal to the maximum number of concurrent connections
* configured via {@code ClientConfiguration.getMaxConnections()}.
*
* @param awsCredentialsProvider
* The AWS credentials provider which will provide credentials to
* authenticate requests with AWS services.
* @param clientConfiguration
* Client configuration options (ex: max retry limit, proxy settings,
* etc).
*
* @see com.amazonaws.auth.DefaultAWSCredentialsProviderChain
* @see java.util.concurrent.Executors#newFixedThreadPool(int)
*/
public AmazonECSAsyncClient(
com.amazonaws.auth.AWSCredentialsProvider awsCredentialsProvider,
com.amazonaws.ClientConfiguration clientConfiguration) {
this(awsCredentialsProvider, clientConfiguration,
java.util.concurrent.Executors
.newFixedThreadPool(clientConfiguration
.getMaxConnections()));
}
/**
* Constructs a new asynchronous client to invoke service methods on Amazon
* ECS using the specified AWS account credentials provider and executor
* service. Default client settings will be used.
*
* @param awsCredentialsProvider
* The AWS credentials provider which will provide credentials to
* authenticate requests with AWS services.
* @param executorService
* The executor service by which all asynchronous requests will be
* executed.
*/
public AmazonECSAsyncClient(
com.amazonaws.auth.AWSCredentialsProvider awsCredentialsProvider,
java.util.concurrent.ExecutorService executorService) {
this(awsCredentialsProvider, configFactory.getConfig(), executorService);
}
/**
* Constructs a new asynchronous client to invoke service methods on Amazon
* ECS using the specified AWS account credentials provider, executor
* service, and client configuration options.
*
* @param awsCredentialsProvider
* The AWS credentials provider which will provide credentials to
* authenticate requests with AWS services.
* @param clientConfiguration
* Client configuration options (ex: max retry limit, proxy settings,
* etc).
* @param executorService
* The executor service by which all asynchronous requests will be
* executed.
*/
public AmazonECSAsyncClient(
com.amazonaws.auth.AWSCredentialsProvider awsCredentialsProvider,
com.amazonaws.ClientConfiguration clientConfiguration,
java.util.concurrent.ExecutorService executorService) {
super(awsCredentialsProvider, clientConfiguration);
this.executorService = executorService;
}
/**
* Returns the executor service used by this client to execute async
* requests.
*
* @return The executor service used by this client to execute async
* requests.
*/
public java.util.concurrent.ExecutorService getExecutorService() {
return executorService;
}
@Override
public java.util.concurrent.Future createClusterAsync(
CreateClusterRequest request) {
return createClusterAsync(request, null);
}
@Override
public java.util.concurrent.Future createClusterAsync(
final CreateClusterRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
return executorService
.submit(new java.util.concurrent.Callable() {
@Override
public CreateClusterResult call() throws Exception {
CreateClusterResult result;
try {
result = createCluster(request);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(request, result);
}
return result;
}
});
}
/**
* Simplified method form for invoking the CreateCluster operation.
*
* @see #createClusterAsync(CreateClusterRequest)
*/
@Override
public java.util.concurrent.Future createClusterAsync() {
return createClusterAsync(new CreateClusterRequest());
}
/**
* Simplified method form for invoking the CreateCluster operation with an
* AsyncHandler.
*
* @see #createClusterAsync(CreateClusterRequest,
* com.amazonaws.handlers.AsyncHandler)
*/
public java.util.concurrent.Future createClusterAsync(
com.amazonaws.handlers.AsyncHandler asyncHandler) {
return createClusterAsync(new CreateClusterRequest(), asyncHandler);
}
@Override
public java.util.concurrent.Future createServiceAsync(
CreateServiceRequest request) {
return createServiceAsync(request, null);
}
@Override
public java.util.concurrent.Future createServiceAsync(
final CreateServiceRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
return executorService
.submit(new java.util.concurrent.Callable() {
@Override
public CreateServiceResult call() throws Exception {
CreateServiceResult result;
try {
result = createService(request);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(request, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future deleteClusterAsync(
DeleteClusterRequest request) {
return deleteClusterAsync(request, null);
}
@Override
public java.util.concurrent.Future deleteClusterAsync(
final DeleteClusterRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
return executorService
.submit(new java.util.concurrent.Callable() {
@Override
public DeleteClusterResult call() throws Exception {
DeleteClusterResult result;
try {
result = deleteCluster(request);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(request, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future deleteServiceAsync(
DeleteServiceRequest request) {
return deleteServiceAsync(request, null);
}
@Override
public java.util.concurrent.Future deleteServiceAsync(
final DeleteServiceRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
return executorService
.submit(new java.util.concurrent.Callable() {
@Override
public DeleteServiceResult call() throws Exception {
DeleteServiceResult result;
try {
result = deleteService(request);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(request, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future deregisterContainerInstanceAsync(
DeregisterContainerInstanceRequest request) {
return deregisterContainerInstanceAsync(request, null);
}
@Override
public java.util.concurrent.Future deregisterContainerInstanceAsync(
final DeregisterContainerInstanceRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
return executorService
.submit(new java.util.concurrent.Callable() {
@Override
public DeregisterContainerInstanceResult call()
throws Exception {
DeregisterContainerInstanceResult result;
try {
result = deregisterContainerInstance(request);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(request, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future deregisterTaskDefinitionAsync(
DeregisterTaskDefinitionRequest request) {
return deregisterTaskDefinitionAsync(request, null);
}
@Override
public java.util.concurrent.Future deregisterTaskDefinitionAsync(
final DeregisterTaskDefinitionRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
return executorService
.submit(new java.util.concurrent.Callable() {
@Override
public DeregisterTaskDefinitionResult call()
throws Exception {
DeregisterTaskDefinitionResult result;
try {
result = deregisterTaskDefinition(request);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(request, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future describeClustersAsync(
DescribeClustersRequest request) {
return describeClustersAsync(request, null);
}
@Override
public java.util.concurrent.Future describeClustersAsync(
final DescribeClustersRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
return executorService
.submit(new java.util.concurrent.Callable() {
@Override
public DescribeClustersResult call() throws Exception {
DescribeClustersResult result;
try {
result = describeClusters(request);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(request, result);
}
return result;
}
});
}
/**
* Simplified method form for invoking the DescribeClusters operation.
*
* @see #describeClustersAsync(DescribeClustersRequest)
*/
@Override
public java.util.concurrent.Future describeClustersAsync() {
return describeClustersAsync(new DescribeClustersRequest());
}
/**
* Simplified method form for invoking the DescribeClusters operation with
* an AsyncHandler.
*
* @see #describeClustersAsync(DescribeClustersRequest,
* com.amazonaws.handlers.AsyncHandler)
*/
public java.util.concurrent.Future describeClustersAsync(
com.amazonaws.handlers.AsyncHandler asyncHandler) {
return describeClustersAsync(new DescribeClustersRequest(),
asyncHandler);
}
@Override
public java.util.concurrent.Future describeContainerInstancesAsync(
DescribeContainerInstancesRequest request) {
return describeContainerInstancesAsync(request, null);
}
@Override
public java.util.concurrent.Future describeContainerInstancesAsync(
final DescribeContainerInstancesRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
return executorService
.submit(new java.util.concurrent.Callable() {
@Override
public DescribeContainerInstancesResult call()
throws Exception {
DescribeContainerInstancesResult result;
try {
result = describeContainerInstances(request);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(request, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future describeServicesAsync(
DescribeServicesRequest request) {
return describeServicesAsync(request, null);
}
@Override
public java.util.concurrent.Future describeServicesAsync(
final DescribeServicesRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
return executorService
.submit(new java.util.concurrent.Callable() {
@Override
public DescribeServicesResult call() throws Exception {
DescribeServicesResult result;
try {
result = describeServices(request);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(request, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future describeTaskDefinitionAsync(
DescribeTaskDefinitionRequest request) {
return describeTaskDefinitionAsync(request, null);
}
@Override
public java.util.concurrent.Future describeTaskDefinitionAsync(
final DescribeTaskDefinitionRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
return executorService
.submit(new java.util.concurrent.Callable() {
@Override
public DescribeTaskDefinitionResult call() throws Exception {
DescribeTaskDefinitionResult result;
try {
result = describeTaskDefinition(request);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(request, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future describeTasksAsync(
DescribeTasksRequest request) {
return describeTasksAsync(request, null);
}
@Override
public java.util.concurrent.Future describeTasksAsync(
final DescribeTasksRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
return executorService
.submit(new java.util.concurrent.Callable() {
@Override
public DescribeTasksResult call() throws Exception {
DescribeTasksResult result;
try {
result = describeTasks(request);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(request, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future discoverPollEndpointAsync(
DiscoverPollEndpointRequest request) {
return discoverPollEndpointAsync(request, null);
}
@Override
public java.util.concurrent.Future discoverPollEndpointAsync(
final DiscoverPollEndpointRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
return executorService
.submit(new java.util.concurrent.Callable() {
@Override
public DiscoverPollEndpointResult call() throws Exception {
DiscoverPollEndpointResult result;
try {
result = discoverPollEndpoint(request);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(request, result);
}
return result;
}
});
}
/**
* Simplified method form for invoking the DiscoverPollEndpoint operation.
*
* @see #discoverPollEndpointAsync(DiscoverPollEndpointRequest)
*/
@Override
public java.util.concurrent.Future discoverPollEndpointAsync() {
return discoverPollEndpointAsync(new DiscoverPollEndpointRequest());
}
/**
* Simplified method form for invoking the DiscoverPollEndpoint operation
* with an AsyncHandler.
*
* @see #discoverPollEndpointAsync(DiscoverPollEndpointRequest,
* com.amazonaws.handlers.AsyncHandler)
*/
public java.util.concurrent.Future discoverPollEndpointAsync(
com.amazonaws.handlers.AsyncHandler asyncHandler) {
return discoverPollEndpointAsync(new DiscoverPollEndpointRequest(),
asyncHandler);
}
@Override
public java.util.concurrent.Future listClustersAsync(
ListClustersRequest request) {
return listClustersAsync(request, null);
}
@Override
public java.util.concurrent.Future listClustersAsync(
final ListClustersRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
return executorService
.submit(new java.util.concurrent.Callable() {
@Override
public ListClustersResult call() throws Exception {
ListClustersResult result;
try {
result = listClusters(request);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(request, result);
}
return result;
}
});
}
/**
* Simplified method form for invoking the ListClusters operation.
*
* @see #listClustersAsync(ListClustersRequest)
*/
@Override
public java.util.concurrent.Future listClustersAsync() {
return listClustersAsync(new ListClustersRequest());
}
/**
* Simplified method form for invoking the ListClusters operation with an
* AsyncHandler.
*
* @see #listClustersAsync(ListClustersRequest,
* com.amazonaws.handlers.AsyncHandler)
*/
public java.util.concurrent.Future listClustersAsync(
com.amazonaws.handlers.AsyncHandler asyncHandler) {
return listClustersAsync(new ListClustersRequest(), asyncHandler);
}
@Override
public java.util.concurrent.Future listContainerInstancesAsync(
ListContainerInstancesRequest request) {
return listContainerInstancesAsync(request, null);
}
@Override
public java.util.concurrent.Future listContainerInstancesAsync(
final ListContainerInstancesRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
return executorService
.submit(new java.util.concurrent.Callable() {
@Override
public ListContainerInstancesResult call() throws Exception {
ListContainerInstancesResult result;
try {
result = listContainerInstances(request);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(request, result);
}
return result;
}
});
}
/**
* Simplified method form for invoking the ListContainerInstances operation.
*
* @see #listContainerInstancesAsync(ListContainerInstancesRequest)
*/
@Override
public java.util.concurrent.Future listContainerInstancesAsync() {
return listContainerInstancesAsync(new ListContainerInstancesRequest());
}
/**
* Simplified method form for invoking the ListContainerInstances operation
* with an AsyncHandler.
*
* @see #listContainerInstancesAsync(ListContainerInstancesRequest,
* com.amazonaws.handlers.AsyncHandler)
*/
public java.util.concurrent.Future listContainerInstancesAsync(
com.amazonaws.handlers.AsyncHandler asyncHandler) {
return listContainerInstancesAsync(new ListContainerInstancesRequest(),
asyncHandler);
}
@Override
public java.util.concurrent.Future listServicesAsync(
ListServicesRequest request) {
return listServicesAsync(request, null);
}
@Override
public java.util.concurrent.Future listServicesAsync(
final ListServicesRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
return executorService
.submit(new java.util.concurrent.Callable() {
@Override
public ListServicesResult call() throws Exception {
ListServicesResult result;
try {
result = listServices(request);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(request, result);
}
return result;
}
});
}
/**
* Simplified method form for invoking the ListServices operation.
*
* @see #listServicesAsync(ListServicesRequest)
*/
@Override
public java.util.concurrent.Future listServicesAsync() {
return listServicesAsync(new ListServicesRequest());
}
/**
* Simplified method form for invoking the ListServices operation with an
* AsyncHandler.
*
* @see #listServicesAsync(ListServicesRequest,
* com.amazonaws.handlers.AsyncHandler)
*/
public java.util.concurrent.Future listServicesAsync(
com.amazonaws.handlers.AsyncHandler asyncHandler) {
return listServicesAsync(new ListServicesRequest(), asyncHandler);
}
@Override
public java.util.concurrent.Future listTaskDefinitionFamiliesAsync(
ListTaskDefinitionFamiliesRequest request) {
return listTaskDefinitionFamiliesAsync(request, null);
}
@Override
public java.util.concurrent.Future listTaskDefinitionFamiliesAsync(
final ListTaskDefinitionFamiliesRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
return executorService
.submit(new java.util.concurrent.Callable() {
@Override
public ListTaskDefinitionFamiliesResult call()
throws Exception {
ListTaskDefinitionFamiliesResult result;
try {
result = listTaskDefinitionFamilies(request);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(request, result);
}
return result;
}
});
}
/**
* Simplified method form for invoking the ListTaskDefinitionFamilies
* operation.
*
* @see #listTaskDefinitionFamiliesAsync(ListTaskDefinitionFamiliesRequest)
*/
@Override
public java.util.concurrent.Future listTaskDefinitionFamiliesAsync() {
return listTaskDefinitionFamiliesAsync(new ListTaskDefinitionFamiliesRequest());
}
/**
* Simplified method form for invoking the ListTaskDefinitionFamilies
* operation with an AsyncHandler.
*
* @see #listTaskDefinitionFamiliesAsync(ListTaskDefinitionFamiliesRequest,
* com.amazonaws.handlers.AsyncHandler)
*/
public java.util.concurrent.Future listTaskDefinitionFamiliesAsync(
com.amazonaws.handlers.AsyncHandler asyncHandler) {
return listTaskDefinitionFamiliesAsync(
new ListTaskDefinitionFamiliesRequest(), asyncHandler);
}
@Override
public java.util.concurrent.Future listTaskDefinitionsAsync(
ListTaskDefinitionsRequest request) {
return listTaskDefinitionsAsync(request, null);
}
@Override
public java.util.concurrent.Future listTaskDefinitionsAsync(
final ListTaskDefinitionsRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
return executorService
.submit(new java.util.concurrent.Callable() {
@Override
public ListTaskDefinitionsResult call() throws Exception {
ListTaskDefinitionsResult result;
try {
result = listTaskDefinitions(request);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(request, result);
}
return result;
}
});
}
/**
* Simplified method form for invoking the ListTaskDefinitions operation.
*
* @see #listTaskDefinitionsAsync(ListTaskDefinitionsRequest)
*/
@Override
public java.util.concurrent.Future listTaskDefinitionsAsync() {
return listTaskDefinitionsAsync(new ListTaskDefinitionsRequest());
}
/**
* Simplified method form for invoking the ListTaskDefinitions operation
* with an AsyncHandler.
*
* @see #listTaskDefinitionsAsync(ListTaskDefinitionsRequest,
* com.amazonaws.handlers.AsyncHandler)
*/
public java.util.concurrent.Future listTaskDefinitionsAsync(
com.amazonaws.handlers.AsyncHandler asyncHandler) {
return listTaskDefinitionsAsync(new ListTaskDefinitionsRequest(),
asyncHandler);
}
@Override
public java.util.concurrent.Future listTasksAsync(
ListTasksRequest request) {
return listTasksAsync(request, null);
}
@Override
public java.util.concurrent.Future listTasksAsync(
final ListTasksRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
return executorService
.submit(new java.util.concurrent.Callable() {
@Override
public ListTasksResult call() throws Exception {
ListTasksResult result;
try {
result = listTasks(request);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(request, result);
}
return result;
}
});
}
/**
* Simplified method form for invoking the ListTasks operation.
*
* @see #listTasksAsync(ListTasksRequest)
*/
@Override
public java.util.concurrent.Future listTasksAsync() {
return listTasksAsync(new ListTasksRequest());
}
/**
* Simplified method form for invoking the ListTasks operation with an
* AsyncHandler.
*
* @see #listTasksAsync(ListTasksRequest,
* com.amazonaws.handlers.AsyncHandler)
*/
public java.util.concurrent.Future listTasksAsync(
com.amazonaws.handlers.AsyncHandler asyncHandler) {
return listTasksAsync(new ListTasksRequest(), asyncHandler);
}
@Override
public java.util.concurrent.Future registerContainerInstanceAsync(
RegisterContainerInstanceRequest request) {
return registerContainerInstanceAsync(request, null);
}
@Override
public java.util.concurrent.Future registerContainerInstanceAsync(
final RegisterContainerInstanceRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
return executorService
.submit(new java.util.concurrent.Callable() {
@Override
public RegisterContainerInstanceResult call()
throws Exception {
RegisterContainerInstanceResult result;
try {
result = registerContainerInstance(request);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(request, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future registerTaskDefinitionAsync(
RegisterTaskDefinitionRequest request) {
return registerTaskDefinitionAsync(request, null);
}
@Override
public java.util.concurrent.Future registerTaskDefinitionAsync(
final RegisterTaskDefinitionRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
return executorService
.submit(new java.util.concurrent.Callable() {
@Override
public RegisterTaskDefinitionResult call() throws Exception {
RegisterTaskDefinitionResult result;
try {
result = registerTaskDefinition(request);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(request, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future runTaskAsync(
RunTaskRequest request) {
return runTaskAsync(request, null);
}
@Override
public java.util.concurrent.Future runTaskAsync(
final RunTaskRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
return executorService
.submit(new java.util.concurrent.Callable() {
@Override
public RunTaskResult call() throws Exception {
RunTaskResult result;
try {
result = runTask(request);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(request, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future startTaskAsync(
StartTaskRequest request) {
return startTaskAsync(request, null);
}
@Override
public java.util.concurrent.Future startTaskAsync(
final StartTaskRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
return executorService
.submit(new java.util.concurrent.Callable() {
@Override
public StartTaskResult call() throws Exception {
StartTaskResult result;
try {
result = startTask(request);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(request, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future stopTaskAsync(
StopTaskRequest request) {
return stopTaskAsync(request, null);
}
@Override
public java.util.concurrent.Future stopTaskAsync(
final StopTaskRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
return executorService
.submit(new java.util.concurrent.Callable() {
@Override
public StopTaskResult call() throws Exception {
StopTaskResult result;
try {
result = stopTask(request);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(request, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future submitContainerStateChangeAsync(
SubmitContainerStateChangeRequest request) {
return submitContainerStateChangeAsync(request, null);
}
@Override
public java.util.concurrent.Future submitContainerStateChangeAsync(
final SubmitContainerStateChangeRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
return executorService
.submit(new java.util.concurrent.Callable() {
@Override
public SubmitContainerStateChangeResult call()
throws Exception {
SubmitContainerStateChangeResult result;
try {
result = submitContainerStateChange(request);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(request, result);
}
return result;
}
});
}
/**
* Simplified method form for invoking the SubmitContainerStateChange
* operation.
*
* @see #submitContainerStateChangeAsync(SubmitContainerStateChangeRequest)
*/
@Override
public java.util.concurrent.Future submitContainerStateChangeAsync() {
return submitContainerStateChangeAsync(new SubmitContainerStateChangeRequest());
}
/**
* Simplified method form for invoking the SubmitContainerStateChange
* operation with an AsyncHandler.
*
* @see #submitContainerStateChangeAsync(SubmitContainerStateChangeRequest,
* com.amazonaws.handlers.AsyncHandler)
*/
public java.util.concurrent.Future submitContainerStateChangeAsync(
com.amazonaws.handlers.AsyncHandler asyncHandler) {
return submitContainerStateChangeAsync(
new SubmitContainerStateChangeRequest(), asyncHandler);
}
@Override
public java.util.concurrent.Future submitTaskStateChangeAsync(
SubmitTaskStateChangeRequest request) {
return submitTaskStateChangeAsync(request, null);
}
@Override
public java.util.concurrent.Future submitTaskStateChangeAsync(
final SubmitTaskStateChangeRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
return executorService
.submit(new java.util.concurrent.Callable() {
@Override
public SubmitTaskStateChangeResult call() throws Exception {
SubmitTaskStateChangeResult result;
try {
result = submitTaskStateChange(request);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(request, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future updateContainerAgentAsync(
UpdateContainerAgentRequest request) {
return updateContainerAgentAsync(request, null);
}
@Override
public java.util.concurrent.Future updateContainerAgentAsync(
final UpdateContainerAgentRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
return executorService
.submit(new java.util.concurrent.Callable() {
@Override
public UpdateContainerAgentResult call() throws Exception {
UpdateContainerAgentResult result;
try {
result = updateContainerAgent(request);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(request, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future updateServiceAsync(
UpdateServiceRequest request) {
return updateServiceAsync(request, null);
}
@Override
public java.util.concurrent.Future updateServiceAsync(
final UpdateServiceRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
return executorService
.submit(new java.util.concurrent.Callable() {
@Override
public UpdateServiceResult call() throws Exception {
UpdateServiceResult result;
try {
result = updateService(request);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(request, result);
}
return result;
}
});
}
/**
* Shuts down the client, releasing all managed resources. This includes
* forcibly terminating all pending asynchronous service calls. Clients who
* wish to give pending asynchronous service calls time to complete should
* call {@code getExecutorService().shutdown()} followed by
* {@code getExecutorService().awaitTermination()} prior to calling this
* method.
*/
@Override
public void shutdown() {
super.shutdown();
executorService.shutdownNow();
}
}