com.amazonaws.services.globalaccelerator.AWSGlobalAcceleratorAsyncClient Maven / Gradle / Ivy
Show all versions of aws-java-sdk-globalaccelerator Show documentation
/*
* Copyright 2014-2019 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.globalaccelerator;
import javax.annotation.Generated;
import com.amazonaws.services.globalaccelerator.model.*;
import com.amazonaws.client.AwsAsyncClientParams;
import com.amazonaws.annotation.ThreadSafe;
import java.util.concurrent.ExecutorService;
/**
* Client for accessing AWS Global Accelerator 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.
*
* AWS Global Accelerator
*
* This is the AWS Global Accelerator API Reference. This guide is for developers who need detailed information
* about AWS Global Accelerator API actions, data types, and errors. For more information about Global Accelerator
* features, see the AWS Global
* Accelerator Developer Guide.
*
*
* AWS Global Accelerator is a network layer service in which you create accelerators to improve availability and
* performance for internet applications used by a global audience.
*
*
*
* You must specify the US-West-2 (Oregon) Region to create or update accelerators.
*
*
*
* Global Accelerator provides you with static IP addresses that you associate with your accelerator. These IP addresses
* are anycast from the AWS edge network and distribute incoming application traffic across multiple endpoint resources
* in multiple AWS Regions, which increases the availability of your applications. Endpoints can be Elastic IP
* addresses, Network Load Balancers, and Application Load Balancers that are located in one AWS Region or multiple
* Regions.
*
*
* Global Accelerator uses the AWS global network to route traffic to the optimal regional endpoint based on health,
* client location, and policies that you configure. The service reacts instantly to changes in health or configuration
* to ensure that internet traffic from clients is directed to only healthy endpoints.
*
*
* Global Accelerator includes components that work together to help you improve performance and availability for your
* applications:
*
*
* - Static IP address
* -
*
* AWS Global Accelerator provides you with a set of static IP addresses which are anycast from the AWS edge network and
* serve as the single fixed entry points for your clients. If you already have Elastic Load Balancing or Elastic IP
* address resources set up for your applications, you can easily add those to Global Accelerator to allow the resources
* to be accessed by a Global Accelerator static IP address.
*
*
* - Accelerator
* -
*
* An accelerator directs traffic to optimal endpoints over the AWS global network to improve availability and
* performance for your internet applications that have a global audience. Each accelerator includes one or more
* listeners.
*
*
* - Network zone
* -
*
* A network zone services the static IP addresses for your accelerator from a unique IP subnet. Similar to an AWS
* Availability Zone, a network zone is an isolated unit with its own set of physical infrastructure. When you configure
* an accelerator, Global Accelerator allocates two IPv4 addresses for it. If one IP address from a network zone becomes
* unavailable due to IP address blocking by certain client networks, or network disruptions, then client applications
* can retry on the healthy static IP address from the other isolated network zone.
*
*
* - Listener
* -
*
* A listener processes inbound connections from clients to Global Accelerator, based on the protocol and port that you
* configure. Each listener has one or more endpoint groups associated with it, and traffic is forwarded to endpoints in
* one of the groups. You associate endpoint groups with listeners by specifying the Regions that you want to distribute
* traffic to. Traffic is distributed to optimal endpoints within the endpoint groups associated with a listener.
*
*
* - Endpoint group
* -
*
* Each endpoint group is associated with a specific AWS Region. Endpoint groups include one or more endpoints in the
* Region. You can increase or reduce the percentage of traffic that would be otherwise directed to an endpoint group by
* adjusting a setting called a traffic dial. The traffic dial lets you easily do performance testing or
* blue/green deployment testing for new releases across different AWS Regions, for example.
*
*
* - Endpoint
* -
*
* An endpoint is an Elastic IP address, Network Load Balancer, or Application Load Balancer. Traffic is routed to
* endpoints based on several factors, including the geo-proximity to the user, the health of the endpoint, and the
* configuration options that you choose, such as endpoint weights. For each endpoint, you can configure weights, which
* are numbers that you can use to specify the proportion of traffic to route to each one. This can be useful, for
* example, to do performance testing within a Region.
*
*
*
*/
@ThreadSafe
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class AWSGlobalAcceleratorAsyncClient extends AWSGlobalAcceleratorClient implements AWSGlobalAcceleratorAsync {
private static final int DEFAULT_THREAD_POOL_SIZE = 50;
private final java.util.concurrent.ExecutorService executorService;
public static AWSGlobalAcceleratorAsyncClientBuilder asyncBuilder() {
return AWSGlobalAcceleratorAsyncClientBuilder.standard();
}
/**
* Constructs a new asynchronous client to invoke service methods on AWS Global Accelerator using the specified
* parameters.
*
* @param asyncClientParams
* Object providing client parameters.
*/
AWSGlobalAcceleratorAsyncClient(AwsAsyncClientParams asyncClientParams) {
super(asyncClientParams);
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 createAcceleratorAsync(CreateAcceleratorRequest request) {
return createAcceleratorAsync(request, null);
}
@Override
public java.util.concurrent.Future createAcceleratorAsync(final CreateAcceleratorRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final CreateAcceleratorRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public CreateAcceleratorResult call() throws Exception {
CreateAcceleratorResult result = null;
try {
result = executeCreateAccelerator(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 createEndpointGroupAsync(CreateEndpointGroupRequest request) {
return createEndpointGroupAsync(request, null);
}
@Override
public java.util.concurrent.Future createEndpointGroupAsync(final CreateEndpointGroupRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final CreateEndpointGroupRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public CreateEndpointGroupResult call() throws Exception {
CreateEndpointGroupResult result = null;
try {
result = executeCreateEndpointGroup(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 createListenerAsync(CreateListenerRequest request) {
return createListenerAsync(request, null);
}
@Override
public java.util.concurrent.Future createListenerAsync(final CreateListenerRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final CreateListenerRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public CreateListenerResult call() throws Exception {
CreateListenerResult result = null;
try {
result = executeCreateListener(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 deleteAcceleratorAsync(DeleteAcceleratorRequest request) {
return deleteAcceleratorAsync(request, null);
}
@Override
public java.util.concurrent.Future deleteAcceleratorAsync(final DeleteAcceleratorRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final DeleteAcceleratorRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public DeleteAcceleratorResult call() throws Exception {
DeleteAcceleratorResult result = null;
try {
result = executeDeleteAccelerator(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 deleteEndpointGroupAsync(DeleteEndpointGroupRequest request) {
return deleteEndpointGroupAsync(request, null);
}
@Override
public java.util.concurrent.Future deleteEndpointGroupAsync(final DeleteEndpointGroupRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final DeleteEndpointGroupRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public DeleteEndpointGroupResult call() throws Exception {
DeleteEndpointGroupResult result = null;
try {
result = executeDeleteEndpointGroup(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 deleteListenerAsync(DeleteListenerRequest request) {
return deleteListenerAsync(request, null);
}
@Override
public java.util.concurrent.Future deleteListenerAsync(final DeleteListenerRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final DeleteListenerRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public DeleteListenerResult call() throws Exception {
DeleteListenerResult result = null;
try {
result = executeDeleteListener(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 describeAcceleratorAsync(DescribeAcceleratorRequest request) {
return describeAcceleratorAsync(request, null);
}
@Override
public java.util.concurrent.Future describeAcceleratorAsync(final DescribeAcceleratorRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final DescribeAcceleratorRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public DescribeAcceleratorResult call() throws Exception {
DescribeAcceleratorResult result = null;
try {
result = executeDescribeAccelerator(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 describeAcceleratorAttributesAsync(DescribeAcceleratorAttributesRequest request) {
return describeAcceleratorAttributesAsync(request, null);
}
@Override
public java.util.concurrent.Future describeAcceleratorAttributesAsync(
final DescribeAcceleratorAttributesRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final DescribeAcceleratorAttributesRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public DescribeAcceleratorAttributesResult call() throws Exception {
DescribeAcceleratorAttributesResult result = null;
try {
result = executeDescribeAcceleratorAttributes(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 describeEndpointGroupAsync(DescribeEndpointGroupRequest request) {
return describeEndpointGroupAsync(request, null);
}
@Override
public java.util.concurrent.Future describeEndpointGroupAsync(final DescribeEndpointGroupRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final DescribeEndpointGroupRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public DescribeEndpointGroupResult call() throws Exception {
DescribeEndpointGroupResult result = null;
try {
result = executeDescribeEndpointGroup(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 describeListenerAsync(DescribeListenerRequest request) {
return describeListenerAsync(request, null);
}
@Override
public java.util.concurrent.Future describeListenerAsync(final DescribeListenerRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final DescribeListenerRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public DescribeListenerResult call() throws Exception {
DescribeListenerResult result = null;
try {
result = executeDescribeListener(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 listAcceleratorsAsync(ListAcceleratorsRequest request) {
return listAcceleratorsAsync(request, null);
}
@Override
public java.util.concurrent.Future listAcceleratorsAsync(final ListAcceleratorsRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final ListAcceleratorsRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public ListAcceleratorsResult call() throws Exception {
ListAcceleratorsResult result = null;
try {
result = executeListAccelerators(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 listEndpointGroupsAsync(ListEndpointGroupsRequest request) {
return listEndpointGroupsAsync(request, null);
}
@Override
public java.util.concurrent.Future listEndpointGroupsAsync(final ListEndpointGroupsRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final ListEndpointGroupsRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public ListEndpointGroupsResult call() throws Exception {
ListEndpointGroupsResult result = null;
try {
result = executeListEndpointGroups(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 listListenersAsync(ListListenersRequest request) {
return listListenersAsync(request, null);
}
@Override
public java.util.concurrent.Future listListenersAsync(final ListListenersRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final ListListenersRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public ListListenersResult call() throws Exception {
ListListenersResult result = null;
try {
result = executeListListeners(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 updateAcceleratorAsync(UpdateAcceleratorRequest request) {
return updateAcceleratorAsync(request, null);
}
@Override
public java.util.concurrent.Future updateAcceleratorAsync(final UpdateAcceleratorRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final UpdateAcceleratorRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public UpdateAcceleratorResult call() throws Exception {
UpdateAcceleratorResult result = null;
try {
result = executeUpdateAccelerator(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 updateAcceleratorAttributesAsync(UpdateAcceleratorAttributesRequest request) {
return updateAcceleratorAttributesAsync(request, null);
}
@Override
public java.util.concurrent.Future updateAcceleratorAttributesAsync(final UpdateAcceleratorAttributesRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final UpdateAcceleratorAttributesRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public UpdateAcceleratorAttributesResult call() throws Exception {
UpdateAcceleratorAttributesResult result = null;
try {
result = executeUpdateAcceleratorAttributes(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 updateEndpointGroupAsync(UpdateEndpointGroupRequest request) {
return updateEndpointGroupAsync(request, null);
}
@Override
public java.util.concurrent.Future updateEndpointGroupAsync(final UpdateEndpointGroupRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final UpdateEndpointGroupRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public UpdateEndpointGroupResult call() throws Exception {
UpdateEndpointGroupResult result = null;
try {
result = executeUpdateEndpointGroup(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 updateListenerAsync(UpdateListenerRequest request) {
return updateListenerAsync(request, null);
}
@Override
public java.util.concurrent.Future updateListenerAsync(final UpdateListenerRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final UpdateListenerRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public UpdateListenerResult call() throws Exception {
UpdateListenerResult result = null;
try {
result = executeUpdateListener(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();
}
}