com.amazonaws.services.athena.AmazonAthenaAsyncClient Maven / Gradle / Ivy
Show all versions of aws-java-sdk-athena Show documentation
/*
* Copyright 2015-2020 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.athena;
import javax.annotation.Generated;
import com.amazonaws.services.athena.model.*;
import com.amazonaws.client.AwsAsyncClientParams;
import com.amazonaws.annotation.ThreadSafe;
import java.util.concurrent.ExecutorService;
/**
* Client for accessing Amazon Athena 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 Athena is an interactive query service that lets you use standard SQL to analyze data directly in Amazon S3.
* You can point Athena at your data in Amazon S3 and run ad-hoc queries and get results in seconds. Athena is
* serverless, so there is no infrastructure to set up or manage. You pay only for the queries you run. Athena scales
* automatically—executing queries in parallel—so results are fast, even with large datasets and complex queries. For
* more information, see What is Amazon Athena in
* the Amazon Athena User Guide.
*
*
* If you connect to Athena using the JDBC driver, use version 1.1.0 of the driver or later with the Amazon Athena API.
* Earlier version drivers do not support the API. For more information and to download the driver, see Accessing Amazon Athena with JDBC.
*
*
* For code samples using the AWS SDK for Java, see Examples and Code Samples in the Amazon
* Athena User Guide.
*
*/
@ThreadSafe
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class AmazonAthenaAsyncClient extends AmazonAthenaClient implements AmazonAthenaAsync {
private static final int DEFAULT_THREAD_POOL_SIZE = 50;
private final java.util.concurrent.ExecutorService executorService;
public static AmazonAthenaAsyncClientBuilder asyncBuilder() {
return AmazonAthenaAsyncClientBuilder.standard();
}
/**
* Constructs a new asynchronous client to invoke service methods on Amazon Athena using the specified parameters.
*
* @param asyncClientParams
* Object providing client parameters.
*/
AmazonAthenaAsyncClient(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 batchGetNamedQueryAsync(BatchGetNamedQueryRequest request) {
return batchGetNamedQueryAsync(request, null);
}
@Override
public java.util.concurrent.Future batchGetNamedQueryAsync(final BatchGetNamedQueryRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final BatchGetNamedQueryRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public BatchGetNamedQueryResult call() throws Exception {
BatchGetNamedQueryResult result = null;
try {
result = executeBatchGetNamedQuery(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 batchGetQueryExecutionAsync(BatchGetQueryExecutionRequest request) {
return batchGetQueryExecutionAsync(request, null);
}
@Override
public java.util.concurrent.Future batchGetQueryExecutionAsync(final BatchGetQueryExecutionRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final BatchGetQueryExecutionRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public BatchGetQueryExecutionResult call() throws Exception {
BatchGetQueryExecutionResult result = null;
try {
result = executeBatchGetQueryExecution(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 createNamedQueryAsync(CreateNamedQueryRequest request) {
return createNamedQueryAsync(request, null);
}
@Override
public java.util.concurrent.Future createNamedQueryAsync(final CreateNamedQueryRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final CreateNamedQueryRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public CreateNamedQueryResult call() throws Exception {
CreateNamedQueryResult result = null;
try {
result = executeCreateNamedQuery(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 createWorkGroupAsync(CreateWorkGroupRequest request) {
return createWorkGroupAsync(request, null);
}
@Override
public java.util.concurrent.Future createWorkGroupAsync(final CreateWorkGroupRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final CreateWorkGroupRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public CreateWorkGroupResult call() throws Exception {
CreateWorkGroupResult result = null;
try {
result = executeCreateWorkGroup(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 deleteNamedQueryAsync(DeleteNamedQueryRequest request) {
return deleteNamedQueryAsync(request, null);
}
@Override
public java.util.concurrent.Future deleteNamedQueryAsync(final DeleteNamedQueryRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final DeleteNamedQueryRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public DeleteNamedQueryResult call() throws Exception {
DeleteNamedQueryResult result = null;
try {
result = executeDeleteNamedQuery(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 deleteWorkGroupAsync(DeleteWorkGroupRequest request) {
return deleteWorkGroupAsync(request, null);
}
@Override
public java.util.concurrent.Future deleteWorkGroupAsync(final DeleteWorkGroupRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final DeleteWorkGroupRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public DeleteWorkGroupResult call() throws Exception {
DeleteWorkGroupResult result = null;
try {
result = executeDeleteWorkGroup(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 getNamedQueryAsync(GetNamedQueryRequest request) {
return getNamedQueryAsync(request, null);
}
@Override
public java.util.concurrent.Future getNamedQueryAsync(final GetNamedQueryRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final GetNamedQueryRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public GetNamedQueryResult call() throws Exception {
GetNamedQueryResult result = null;
try {
result = executeGetNamedQuery(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 getQueryExecutionAsync(GetQueryExecutionRequest request) {
return getQueryExecutionAsync(request, null);
}
@Override
public java.util.concurrent.Future getQueryExecutionAsync(final GetQueryExecutionRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final GetQueryExecutionRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public GetQueryExecutionResult call() throws Exception {
GetQueryExecutionResult result = null;
try {
result = executeGetQueryExecution(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 getQueryResultsAsync(GetQueryResultsRequest request) {
return getQueryResultsAsync(request, null);
}
@Override
public java.util.concurrent.Future getQueryResultsAsync(final GetQueryResultsRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final GetQueryResultsRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public GetQueryResultsResult call() throws Exception {
GetQueryResultsResult result = null;
try {
result = executeGetQueryResults(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 getWorkGroupAsync(GetWorkGroupRequest request) {
return getWorkGroupAsync(request, null);
}
@Override
public java.util.concurrent.Future getWorkGroupAsync(final GetWorkGroupRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final GetWorkGroupRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public GetWorkGroupResult call() throws Exception {
GetWorkGroupResult result = null;
try {
result = executeGetWorkGroup(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 listNamedQueriesAsync(ListNamedQueriesRequest request) {
return listNamedQueriesAsync(request, null);
}
@Override
public java.util.concurrent.Future listNamedQueriesAsync(final ListNamedQueriesRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final ListNamedQueriesRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public ListNamedQueriesResult call() throws Exception {
ListNamedQueriesResult result = null;
try {
result = executeListNamedQueries(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 listQueryExecutionsAsync(ListQueryExecutionsRequest request) {
return listQueryExecutionsAsync(request, null);
}
@Override
public java.util.concurrent.Future listQueryExecutionsAsync(final ListQueryExecutionsRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final ListQueryExecutionsRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public ListQueryExecutionsResult call() throws Exception {
ListQueryExecutionsResult result = null;
try {
result = executeListQueryExecutions(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 listWorkGroupsAsync(ListWorkGroupsRequest request) {
return listWorkGroupsAsync(request, null);
}
@Override
public java.util.concurrent.Future listWorkGroupsAsync(final ListWorkGroupsRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final ListWorkGroupsRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public ListWorkGroupsResult call() throws Exception {
ListWorkGroupsResult result = null;
try {
result = executeListWorkGroups(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 startQueryExecutionAsync(StartQueryExecutionRequest request) {
return startQueryExecutionAsync(request, null);
}
@Override
public java.util.concurrent.Future startQueryExecutionAsync(final StartQueryExecutionRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final StartQueryExecutionRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public StartQueryExecutionResult call() throws Exception {
StartQueryExecutionResult result = null;
try {
result = executeStartQueryExecution(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 stopQueryExecutionAsync(StopQueryExecutionRequest request) {
return stopQueryExecutionAsync(request, null);
}
@Override
public java.util.concurrent.Future stopQueryExecutionAsync(final StopQueryExecutionRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final StopQueryExecutionRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public StopQueryExecutionResult call() throws Exception {
StopQueryExecutionResult result = null;
try {
result = executeStopQueryExecution(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 updateWorkGroupAsync(UpdateWorkGroupRequest request) {
return updateWorkGroupAsync(request, null);
}
@Override
public java.util.concurrent.Future updateWorkGroupAsync(final UpdateWorkGroupRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final UpdateWorkGroupRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public UpdateWorkGroupResult call() throws Exception {
UpdateWorkGroupResult result = null;
try {
result = executeUpdateWorkGroup(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();
}
}