@Override public java.util.concurrent.Future<ListMetricsResult> listMetricsAsync( final ListMetricsRequest request, final com.amazonaws.handlers.AsyncHandler<ListMetricsRequest, ListMetricsResult> asyncHandler) { return executorService.submit( new java.util.concurrent.Callable<ListMetricsResult>() { @Override public ListMetricsResult call() throws Exception { ListMetricsResult result; try { result = listMetrics(request); } catch (Exception ex) { if (asyncHandler != null) { asyncHandler.onError(ex); } throw ex; } if (asyncHandler != null) { asyncHandler.onSuccess(request, result); } return result; } }); }
@Override public java.util.concurrent.Future<Void> setAlarmStateAsync( final SetAlarmStateRequest request, final com.amazonaws.handlers.AsyncHandler<SetAlarmStateRequest, Void> asyncHandler) { return executorService.submit( new java.util.concurrent.Callable<Void>() { @Override public Void call() throws Exception { Void result; try { setAlarmState(request); result = null; } catch (Exception ex) { if (asyncHandler != null) { asyncHandler.onError(ex); } throw ex; } if (asyncHandler != null) { asyncHandler.onSuccess(request, result); } return result; } }); }
@Override public java.util.concurrent.Future<DescribeAlarmsForMetricResult> describeAlarmsForMetricAsync( final DescribeAlarmsForMetricRequest request, final com.amazonaws.handlers.AsyncHandler< DescribeAlarmsForMetricRequest, DescribeAlarmsForMetricResult> asyncHandler) { return executorService.submit( new java.util.concurrent.Callable<DescribeAlarmsForMetricResult>() { @Override public DescribeAlarmsForMetricResult call() throws Exception { DescribeAlarmsForMetricResult result; try { result = describeAlarmsForMetric(request); } catch (Exception ex) { if (asyncHandler != null) { asyncHandler.onError(ex); } throw ex; } if (asyncHandler != null) { asyncHandler.onSuccess(request, 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(); }