com.amazonaws.services.redshiftdataapi.AWSRedshiftDataAPIAsyncClient Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aws-java-sdk-redshiftdataapi Show documentation
Show all versions of aws-java-sdk-redshiftdataapi Show documentation
The AWS Java SDK for Redshift Data API module holds the client classes that are used for communicating with Redshift Data API Service
/*
* 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.redshiftdataapi;
import javax.annotation.Generated;
import com.amazonaws.services.redshiftdataapi.model.*;
import com.amazonaws.client.AwsAsyncClientParams;
import com.amazonaws.annotation.ThreadSafe;
import java.util.concurrent.ExecutorService;
/**
* Client for accessing Redshift Data API Service 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.
*
*
* You can use the Amazon Redshift Data API to run queries on Amazon Redshift tables. You can run SQL statements, which
* are committed if the statement succeeds.
*
*
* For more information about the Amazon Redshift Data API and CLI usage examples, see Using the Amazon Redshift Data API in the
* Amazon Redshift Management Guide.
*
*/
@ThreadSafe
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class AWSRedshiftDataAPIAsyncClient extends AWSRedshiftDataAPIClient implements AWSRedshiftDataAPIAsync {
private static final int DEFAULT_THREAD_POOL_SIZE = 50;
private final java.util.concurrent.ExecutorService executorService;
public static AWSRedshiftDataAPIAsyncClientBuilder asyncBuilder() {
return AWSRedshiftDataAPIAsyncClientBuilder.standard();
}
/**
* Constructs a new asynchronous client to invoke service methods on Redshift Data API Service using the specified
* parameters.
*
* @param asyncClientParams
* Object providing client parameters.
*/
AWSRedshiftDataAPIAsyncClient(AwsAsyncClientParams asyncClientParams) {
this(asyncClientParams, false);
}
/**
* Constructs a new asynchronous client to invoke service methods on Redshift Data API Service using the specified
* parameters.
*
* @param asyncClientParams
* Object providing client parameters.
* @param endpointDiscoveryEnabled
* true will enable endpoint discovery if the service supports it.
*/
AWSRedshiftDataAPIAsyncClient(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 batchExecuteStatementAsync(BatchExecuteStatementRequest request) {
return batchExecuteStatementAsync(request, null);
}
@Override
public java.util.concurrent.Future batchExecuteStatementAsync(final BatchExecuteStatementRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final BatchExecuteStatementRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public BatchExecuteStatementResult call() throws Exception {
BatchExecuteStatementResult result = null;
try {
result = executeBatchExecuteStatement(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 cancelStatementAsync(CancelStatementRequest request) {
return cancelStatementAsync(request, null);
}
@Override
public java.util.concurrent.Future cancelStatementAsync(final CancelStatementRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final CancelStatementRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public CancelStatementResult call() throws Exception {
CancelStatementResult result = null;
try {
result = executeCancelStatement(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 describeStatementAsync(DescribeStatementRequest request) {
return describeStatementAsync(request, null);
}
@Override
public java.util.concurrent.Future describeStatementAsync(final DescribeStatementRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final DescribeStatementRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public DescribeStatementResult call() throws Exception {
DescribeStatementResult result = null;
try {
result = executeDescribeStatement(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 describeTableAsync(DescribeTableRequest request) {
return describeTableAsync(request, null);
}
@Override
public java.util.concurrent.Future describeTableAsync(final DescribeTableRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final DescribeTableRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public DescribeTableResult call() throws Exception {
DescribeTableResult result = null;
try {
result = executeDescribeTable(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 executeStatementAsync(ExecuteStatementRequest request) {
return executeStatementAsync(request, null);
}
@Override
public java.util.concurrent.Future executeStatementAsync(final ExecuteStatementRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final ExecuteStatementRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public ExecuteStatementResult call() throws Exception {
ExecuteStatementResult result = null;
try {
result = executeExecuteStatement(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 getStatementResultAsync(GetStatementResultRequest request) {
return getStatementResultAsync(request, null);
}
@Override
public java.util.concurrent.Future getStatementResultAsync(final GetStatementResultRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final GetStatementResultRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public GetStatementResultResult call() throws Exception {
GetStatementResultResult result = null;
try {
result = executeGetStatementResult(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 listDatabasesAsync(ListDatabasesRequest request) {
return listDatabasesAsync(request, null);
}
@Override
public java.util.concurrent.Future listDatabasesAsync(final ListDatabasesRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final ListDatabasesRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public ListDatabasesResult call() throws Exception {
ListDatabasesResult result = null;
try {
result = executeListDatabases(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 listSchemasAsync(ListSchemasRequest request) {
return listSchemasAsync(request, null);
}
@Override
public java.util.concurrent.Future listSchemasAsync(final ListSchemasRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final ListSchemasRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public ListSchemasResult call() throws Exception {
ListSchemasResult result = null;
try {
result = executeListSchemas(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 listStatementsAsync(ListStatementsRequest request) {
return listStatementsAsync(request, null);
}
@Override
public java.util.concurrent.Future listStatementsAsync(final ListStatementsRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final ListStatementsRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public ListStatementsResult call() throws Exception {
ListStatementsResult result = null;
try {
result = executeListStatements(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 listTablesAsync(ListTablesRequest request) {
return listTablesAsync(request, null);
}
@Override
public java.util.concurrent.Future listTablesAsync(final ListTablesRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final ListTablesRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public ListTablesResult call() throws Exception {
ListTablesResult result = null;
try {
result = executeListTables(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();
}
}