com.amazonaws.services.braket.AWSBraketAsyncClient Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aws-java-sdk-braket Show documentation
Show all versions of aws-java-sdk-braket Show documentation
The AWS Java SDK for Braket module holds the client classes that are used for communicating with Braket Service
The newest version!
/*
* 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.braket;
import javax.annotation.Generated;
import com.amazonaws.services.braket.model.*;
import com.amazonaws.client.AwsAsyncClientParams;
import com.amazonaws.annotation.ThreadSafe;
import java.util.concurrent.ExecutorService;
/**
* Client for accessing Braket 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.
*
*
* The Amazon Braket API Reference provides information about the operations and structures supported in Amazon Braket.
*
*
* Additional Resources:
*
*
* -
*
*
*
*/
@ThreadSafe
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class AWSBraketAsyncClient extends AWSBraketClient implements AWSBraketAsync {
private static final int DEFAULT_THREAD_POOL_SIZE = 50;
private final java.util.concurrent.ExecutorService executorService;
public static AWSBraketAsyncClientBuilder asyncBuilder() {
return AWSBraketAsyncClientBuilder.standard();
}
/**
* Constructs a new asynchronous client to invoke service methods on Braket using the specified parameters.
*
* @param asyncClientParams
* Object providing client parameters.
*/
AWSBraketAsyncClient(AwsAsyncClientParams asyncClientParams) {
this(asyncClientParams, false);
}
/**
* Constructs a new asynchronous client to invoke service methods on Braket using the specified parameters.
*
* @param asyncClientParams
* Object providing client parameters.
* @param endpointDiscoveryEnabled
* true will enable endpoint discovery if the service supports it.
*/
AWSBraketAsyncClient(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 cancelJobAsync(CancelJobRequest request) {
return cancelJobAsync(request, null);
}
@Override
public java.util.concurrent.Future cancelJobAsync(final CancelJobRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final CancelJobRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public CancelJobResult call() throws Exception {
CancelJobResult result = null;
try {
result = executeCancelJob(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 cancelQuantumTaskAsync(CancelQuantumTaskRequest request) {
return cancelQuantumTaskAsync(request, null);
}
@Override
public java.util.concurrent.Future cancelQuantumTaskAsync(final CancelQuantumTaskRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final CancelQuantumTaskRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public CancelQuantumTaskResult call() throws Exception {
CancelQuantumTaskResult result = null;
try {
result = executeCancelQuantumTask(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 createJobAsync(CreateJobRequest request) {
return createJobAsync(request, null);
}
@Override
public java.util.concurrent.Future createJobAsync(final CreateJobRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final CreateJobRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public CreateJobResult call() throws Exception {
CreateJobResult result = null;
try {
result = executeCreateJob(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 createQuantumTaskAsync(CreateQuantumTaskRequest request) {
return createQuantumTaskAsync(request, null);
}
@Override
public java.util.concurrent.Future createQuantumTaskAsync(final CreateQuantumTaskRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final CreateQuantumTaskRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public CreateQuantumTaskResult call() throws Exception {
CreateQuantumTaskResult result = null;
try {
result = executeCreateQuantumTask(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 getDeviceAsync(GetDeviceRequest request) {
return getDeviceAsync(request, null);
}
@Override
public java.util.concurrent.Future getDeviceAsync(final GetDeviceRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final GetDeviceRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public GetDeviceResult call() throws Exception {
GetDeviceResult result = null;
try {
result = executeGetDevice(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 getJobAsync(GetJobRequest request) {
return getJobAsync(request, null);
}
@Override
public java.util.concurrent.Future getJobAsync(final GetJobRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final GetJobRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public GetJobResult call() throws Exception {
GetJobResult result = null;
try {
result = executeGetJob(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 getQuantumTaskAsync(GetQuantumTaskRequest request) {
return getQuantumTaskAsync(request, null);
}
@Override
public java.util.concurrent.Future getQuantumTaskAsync(final GetQuantumTaskRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final GetQuantumTaskRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public GetQuantumTaskResult call() throws Exception {
GetQuantumTaskResult result = null;
try {
result = executeGetQuantumTask(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 searchDevicesAsync(SearchDevicesRequest request) {
return searchDevicesAsync(request, null);
}
@Override
public java.util.concurrent.Future searchDevicesAsync(final SearchDevicesRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final SearchDevicesRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public SearchDevicesResult call() throws Exception {
SearchDevicesResult result = null;
try {
result = executeSearchDevices(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 searchJobsAsync(SearchJobsRequest request) {
return searchJobsAsync(request, null);
}
@Override
public java.util.concurrent.Future searchJobsAsync(final SearchJobsRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final SearchJobsRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public SearchJobsResult call() throws Exception {
SearchJobsResult result = null;
try {
result = executeSearchJobs(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 searchQuantumTasksAsync(SearchQuantumTasksRequest request) {
return searchQuantumTasksAsync(request, null);
}
@Override
public java.util.concurrent.Future searchQuantumTasksAsync(final SearchQuantumTasksRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final SearchQuantumTasksRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public SearchQuantumTasksResult call() throws Exception {
SearchQuantumTasksResult result = null;
try {
result = executeSearchQuantumTasks(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;
}
});
}
/**
* 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