com.amazonaws.AbortedException Java Examples

The following examples show how to use com.amazonaws.AbortedException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SQSSpanProcessor.java    From zipkin-aws with Apache License 2.0 6 votes vote down vote up
@Override
public void run() {
  while (!closed.get()) {
    try {
      process(client.receiveMessage(request).getMessages());
      status.lazySet(CheckResult.OK);
      failureBackoff = DEFAULT_BACKOFF;
    } catch (AbortedException ae) {
      status.lazySet(CheckResult.failed(ae));
    } catch (Exception e) {
      logger.log(Level.WARNING, "sqs receive failed", e);
      status.lazySet(CheckResult.failed(e));

      // backoff on failures to avoid pinging SQS in a tight loop if there are failures.
      try {
        Thread.sleep(failureBackoff);
      } catch (InterruptedException ie) {
      } finally {
        failureBackoff = Math.max(failureBackoff * 2, MAX_BACKOFF);
      }
    }
  }
}
 
Example #2
Source File: PrestoS3FileSystem.java    From presto with Apache License 2.0 5 votes vote down vote up
private static void abortStream(InputStream in)
{
    try {
        if (in instanceof S3ObjectInputStream) {
            ((S3ObjectInputStream) in).abort();
        }
        else {
            in.close();
        }
    }
    catch (IOException | AbortedException ignored) {
        // thrown if the current thread is in the interrupted state
    }
}
 
Example #3
Source File: PrestoS3FileSystemStats.java    From presto with Apache License 2.0 5 votes vote down vote up
public void newReadError(Throwable t)
{
    if (t instanceof SocketException) {
        socketExceptions.update(1);
    }
    else if (t instanceof SocketTimeoutException) {
        socketTimeoutExceptions.update(1);
    }
    else if (t instanceof AbortedException) {
        awsAbortedExceptions.update(1);
    }
    else {
        otherReadErrors.update(1);
    }
}
 
Example #4
Source File: CloudWatchMeterRegistry.java    From micrometer with Apache License 2.0 5 votes vote down vote up
void sendMetricData(List<MetricDatum> metricData) throws InterruptedException {
    PutMetricDataRequest putMetricDataRequest = new PutMetricDataRequest()
            .withNamespace(config.namespace())
            .withMetricData(metricData);
    CountDownLatch latch = new CountDownLatch(1);
    amazonCloudWatchAsync.putMetricDataAsync(putMetricDataRequest, new AsyncHandler<PutMetricDataRequest, PutMetricDataResult>() {
        @Override
        public void onError(Exception exception) {
            if (exception instanceof AbortedException) {
                logger.warn("sending metric data was aborted: {}", exception.getMessage());
            } else {
                logger.error("error sending metric data.", exception);
            }
            latch.countDown();
        }

        @Override
        public void onSuccess(PutMetricDataRequest request, PutMetricDataResult result) {
            logger.debug("published metric with namespace:{}", request.getNamespace());
            latch.countDown();
        }
    });
    try {
        @SuppressWarnings("deprecation")
        long readTimeoutMillis = config.readTimeout().toMillis();
        latch.await(readTimeoutMillis, TimeUnit.MILLISECONDS);
    } catch (InterruptedException e) {
        logger.warn("metrics push to cloudwatch took longer than expected");
        throw e;
    }
}
 
Example #5
Source File: KMSProviderBuilderIntegrationTests.java    From aws-encryption-sdk-java with Apache License 2.0 5 votes vote down vote up
@Test
public void whenShortTimeoutSet_timesOut() throws Exception {
    // By setting a timeout of 1ms, it's not physically possible to complete both the us-west-2 and eu-central-1
    // requests due to speed of light limits.
    KmsMasterKeyProvider mkp = KmsMasterKeyProvider.builder()
                                                   .withClientBuilder(
                                                           AWSKMSClientBuilder.standard()
                                                            .withClientConfiguration(
                                                                    new ClientConfiguration()
                                                                        .withRequestTimeout(1)
                                                            )
                                                   )
                                                   .withKeysForEncryption(Arrays.asList(KMSTestFixtures.TEST_KEY_IDS))
                                                   .build();

    try {
        new AwsCrypto().encryptData(mkp, new byte[1]);
        fail("Expected exception");
    } catch (Exception e) {
        if (e instanceof AbortedException) {
            // ok - one manifestation of a timeout
        } else if (e.getCause() instanceof HttpRequestTimeoutException) {
            // ok - another kind of timeout
        } else {
            throw e;
        }
    }
}