com.amazonaws.services.dlm.AmazonDLMAsyncClient Maven / Gradle / Ivy
/*
* Copyright 2019-2024 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.dlm;
import javax.annotation.Generated;
import com.amazonaws.services.dlm.model.*;
import com.amazonaws.client.AwsAsyncClientParams;
import com.amazonaws.annotation.ThreadSafe;
import java.util.concurrent.ExecutorService;
/**
* Client for accessing Amazon DLM 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 Data Lifecycle Manager
*
* With Amazon Data Lifecycle Manager, you can manage the lifecycle of your Amazon Web Services resources. You create
* lifecycle policies, which are used to automate operations on the specified resources.
*
*
* Amazon Data Lifecycle Manager supports Amazon EBS volumes and snapshots. For information about using Amazon Data
* Lifecycle Manager with Amazon EBS, see Amazon Data Lifecycle Manager
* in the Amazon EC2 User Guide.
*
*/
@ThreadSafe
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class AmazonDLMAsyncClient extends AmazonDLMClient implements AmazonDLMAsync {
private static final int DEFAULT_THREAD_POOL_SIZE = 50;
private final java.util.concurrent.ExecutorService executorService;
public static AmazonDLMAsyncClientBuilder asyncBuilder() {
return AmazonDLMAsyncClientBuilder.standard();
}
/**
* Constructs a new asynchronous client to invoke service methods on Amazon DLM using the specified parameters.
*
* @param asyncClientParams
* Object providing client parameters.
*/
AmazonDLMAsyncClient(AwsAsyncClientParams asyncClientParams) {
this(asyncClientParams, false);
}
/**
* Constructs a new asynchronous client to invoke service methods on Amazon DLM using the specified parameters.
*
* @param asyncClientParams
* Object providing client parameters.
* @param endpointDiscoveryEnabled
* true will enable endpoint discovery if the service supports it.
*/
AmazonDLMAsyncClient(AwsAsyncClientParams asyncClientParams, boolean endpointDiscoveryEnabled) {
super(asyncClientParams, endpointDiscoveryEnabled);
this.executorService = asyncClientParams.getExecutor();
}
/**
* 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 ExecutorService getExecutorService() {
return executorService;
}
@Override
public java.util.concurrent.Future createLifecyclePolicyAsync(CreateLifecyclePolicyRequest request) {
return createLifecyclePolicyAsync(request, null);
}
@Override
public java.util.concurrent.Future createLifecyclePolicyAsync(final CreateLifecyclePolicyRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final CreateLifecyclePolicyRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public CreateLifecyclePolicyResult call() throws Exception {
CreateLifecyclePolicyResult result = null;
try {
result = executeCreateLifecyclePolicy(finalRequest);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(finalRequest, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future deleteLifecyclePolicyAsync(DeleteLifecyclePolicyRequest request) {
return deleteLifecyclePolicyAsync(request, null);
}
@Override
public java.util.concurrent.Future deleteLifecyclePolicyAsync(final DeleteLifecyclePolicyRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final DeleteLifecyclePolicyRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public DeleteLifecyclePolicyResult call() throws Exception {
DeleteLifecyclePolicyResult result = null;
try {
result = executeDeleteLifecyclePolicy(finalRequest);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(finalRequest, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future getLifecyclePoliciesAsync(GetLifecyclePoliciesRequest request) {
return getLifecyclePoliciesAsync(request, null);
}
@Override
public java.util.concurrent.Future getLifecyclePoliciesAsync(final GetLifecyclePoliciesRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final GetLifecyclePoliciesRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public GetLifecyclePoliciesResult call() throws Exception {
GetLifecyclePoliciesResult result = null;
try {
result = executeGetLifecyclePolicies(finalRequest);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(finalRequest, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future getLifecyclePolicyAsync(GetLifecyclePolicyRequest request) {
return getLifecyclePolicyAsync(request, null);
}
@Override
public java.util.concurrent.Future getLifecyclePolicyAsync(final GetLifecyclePolicyRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final GetLifecyclePolicyRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public GetLifecyclePolicyResult call() throws Exception {
GetLifecyclePolicyResult result = null;
try {
result = executeGetLifecyclePolicy(finalRequest);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(finalRequest, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future listTagsForResourceAsync(ListTagsForResourceRequest request) {
return listTagsForResourceAsync(request, null);
}
@Override
public java.util.concurrent.Future listTagsForResourceAsync(final ListTagsForResourceRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final ListTagsForResourceRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public ListTagsForResourceResult call() throws Exception {
ListTagsForResourceResult result = null;
try {
result = executeListTagsForResource(finalRequest);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(finalRequest, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future tagResourceAsync(TagResourceRequest request) {
return tagResourceAsync(request, null);
}
@Override
public java.util.concurrent.Future tagResourceAsync(final TagResourceRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final TagResourceRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public TagResourceResult call() throws Exception {
TagResourceResult result = null;
try {
result = executeTagResource(finalRequest);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(finalRequest, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future untagResourceAsync(UntagResourceRequest request) {
return untagResourceAsync(request, null);
}
@Override
public java.util.concurrent.Future untagResourceAsync(final UntagResourceRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final UntagResourceRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public UntagResourceResult call() throws Exception {
UntagResourceResult result = null;
try {
result = executeUntagResource(finalRequest);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(finalRequest, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future updateLifecyclePolicyAsync(UpdateLifecyclePolicyRequest request) {
return updateLifecyclePolicyAsync(request, null);
}
@Override
public java.util.concurrent.Future updateLifecyclePolicyAsync(final UpdateLifecyclePolicyRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final UpdateLifecyclePolicyRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public UpdateLifecyclePolicyResult call() throws Exception {
UpdateLifecyclePolicyResult result = null;
try {
result = executeUpdateLifecyclePolicy(finalRequest);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(finalRequest, 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();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy