com.amazonaws.services.mediaconnect.AWSMediaConnectAsyncClient Maven / Gradle / Ivy
/*
* 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.mediaconnect;
import javax.annotation.Generated;
import com.amazonaws.services.mediaconnect.model.*;
import com.amazonaws.client.AwsAsyncClientParams;
import com.amazonaws.annotation.ThreadSafe;
import java.util.concurrent.ExecutorService;
/**
* Client for accessing AWS MediaConnect 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.
*
* API for AWS Elemental MediaConnect
*/
@ThreadSafe
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class AWSMediaConnectAsyncClient extends AWSMediaConnectClient implements AWSMediaConnectAsync {
private static final int DEFAULT_THREAD_POOL_SIZE = 50;
private final java.util.concurrent.ExecutorService executorService;
public static AWSMediaConnectAsyncClientBuilder asyncBuilder() {
return AWSMediaConnectAsyncClientBuilder.standard();
}
/**
* Constructs a new asynchronous client to invoke service methods on AWS MediaConnect using the specified
* parameters.
*
* @param asyncClientParams
* Object providing client parameters.
*/
AWSMediaConnectAsyncClient(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 addFlowOutputsAsync(AddFlowOutputsRequest request) {
return addFlowOutputsAsync(request, null);
}
@Override
public java.util.concurrent.Future addFlowOutputsAsync(final AddFlowOutputsRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final AddFlowOutputsRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public AddFlowOutputsResult call() throws Exception {
AddFlowOutputsResult result = null;
try {
result = executeAddFlowOutputs(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 createFlowAsync(CreateFlowRequest request) {
return createFlowAsync(request, null);
}
@Override
public java.util.concurrent.Future createFlowAsync(final CreateFlowRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final CreateFlowRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public CreateFlowResult call() throws Exception {
CreateFlowResult result = null;
try {
result = executeCreateFlow(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 deleteFlowAsync(DeleteFlowRequest request) {
return deleteFlowAsync(request, null);
}
@Override
public java.util.concurrent.Future deleteFlowAsync(final DeleteFlowRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final DeleteFlowRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public DeleteFlowResult call() throws Exception {
DeleteFlowResult result = null;
try {
result = executeDeleteFlow(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 describeFlowAsync(DescribeFlowRequest request) {
return describeFlowAsync(request, null);
}
@Override
public java.util.concurrent.Future describeFlowAsync(final DescribeFlowRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final DescribeFlowRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public DescribeFlowResult call() throws Exception {
DescribeFlowResult result = null;
try {
result = executeDescribeFlow(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 grantFlowEntitlementsAsync(GrantFlowEntitlementsRequest request) {
return grantFlowEntitlementsAsync(request, null);
}
@Override
public java.util.concurrent.Future grantFlowEntitlementsAsync(final GrantFlowEntitlementsRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final GrantFlowEntitlementsRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public GrantFlowEntitlementsResult call() throws Exception {
GrantFlowEntitlementsResult result = null;
try {
result = executeGrantFlowEntitlements(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 listEntitlementsAsync(ListEntitlementsRequest request) {
return listEntitlementsAsync(request, null);
}
@Override
public java.util.concurrent.Future listEntitlementsAsync(final ListEntitlementsRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final ListEntitlementsRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public ListEntitlementsResult call() throws Exception {
ListEntitlementsResult result = null;
try {
result = executeListEntitlements(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 listFlowsAsync(ListFlowsRequest request) {
return listFlowsAsync(request, null);
}
@Override
public java.util.concurrent.Future listFlowsAsync(final ListFlowsRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final ListFlowsRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public ListFlowsResult call() throws Exception {
ListFlowsResult result = null;
try {
result = executeListFlows(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 removeFlowOutputAsync(RemoveFlowOutputRequest request) {
return removeFlowOutputAsync(request, null);
}
@Override
public java.util.concurrent.Future removeFlowOutputAsync(final RemoveFlowOutputRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final RemoveFlowOutputRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public RemoveFlowOutputResult call() throws Exception {
RemoveFlowOutputResult result = null;
try {
result = executeRemoveFlowOutput(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 revokeFlowEntitlementAsync(RevokeFlowEntitlementRequest request) {
return revokeFlowEntitlementAsync(request, null);
}
@Override
public java.util.concurrent.Future revokeFlowEntitlementAsync(final RevokeFlowEntitlementRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final RevokeFlowEntitlementRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public RevokeFlowEntitlementResult call() throws Exception {
RevokeFlowEntitlementResult result = null;
try {
result = executeRevokeFlowEntitlement(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 startFlowAsync(StartFlowRequest request) {
return startFlowAsync(request, null);
}
@Override
public java.util.concurrent.Future startFlowAsync(final StartFlowRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final StartFlowRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public StartFlowResult call() throws Exception {
StartFlowResult result = null;
try {
result = executeStartFlow(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 stopFlowAsync(StopFlowRequest request) {
return stopFlowAsync(request, null);
}
@Override
public java.util.concurrent.Future stopFlowAsync(final StopFlowRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final StopFlowRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public StopFlowResult call() throws Exception {
StopFlowResult result = null;
try {
result = executeStopFlow(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 updateFlowEntitlementAsync(UpdateFlowEntitlementRequest request) {
return updateFlowEntitlementAsync(request, null);
}
@Override
public java.util.concurrent.Future updateFlowEntitlementAsync(final UpdateFlowEntitlementRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final UpdateFlowEntitlementRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public UpdateFlowEntitlementResult call() throws Exception {
UpdateFlowEntitlementResult result = null;
try {
result = executeUpdateFlowEntitlement(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 updateFlowOutputAsync(UpdateFlowOutputRequest request) {
return updateFlowOutputAsync(request, null);
}
@Override
public java.util.concurrent.Future updateFlowOutputAsync(final UpdateFlowOutputRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final UpdateFlowOutputRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public UpdateFlowOutputResult call() throws Exception {
UpdateFlowOutputResult result = null;
try {
result = executeUpdateFlowOutput(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 updateFlowSourceAsync(UpdateFlowSourceRequest request) {
return updateFlowSourceAsync(request, null);
}
@Override
public java.util.concurrent.Future updateFlowSourceAsync(final UpdateFlowSourceRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final UpdateFlowSourceRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public UpdateFlowSourceResult call() throws Exception {
UpdateFlowSourceResult result = null;
try {
result = executeUpdateFlowSource(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();
}
}