List of usage examples for com.amazonaws.services.kinesis.model ExpiredIteratorException getErrorType
public ErrorType getErrorType()
From source file:org.apache.beam.sdk.io.kinesis.client.SimplifiedKinesisClient.java
License:Apache License
/*** * Wraps Amazon specific exceptions into more friendly format. * * @throws IOException - in case of recoverable situation, i.e. * the request rate is too high, Kinesis remote service * failed, network issue, etc. * @throws ExpiredIteratorException - if iterator needs to be refreshed * @throws RuntimeException - in all other cases *//*from w w w .jav a 2 s. c om*/ private <T> T wrapExceptions(Callable<T> callable) throws TransientKinesisException { try { return callable.call(); } catch (ExpiredIteratorException e) { throw e; } catch (LimitExceededException | ProvisionedThroughputExceededException e) { LOG.warn("Too many requests to Kinesis", e); throw new TransientKinesisException(e); } catch (AmazonServiceException e) { if (e.getErrorType() == AmazonServiceException.ErrorType.Service) { LOG.warn("Kinesis backend failed", e); throw new TransientKinesisException(e); } LOG.error("Client side failure", e); throw new RuntimeException(e); } catch (Exception e) { LOG.error("Unknown failure", e); throw new RuntimeException(e); } }
From source file:org.apache.beam.sdk.io.kinesis.SimplifiedKinesisClient.java
License:Apache License
/** * Wraps Amazon specific exceptions into more friendly format. * * @throws TransientKinesisException - in case of recoverable situation, i.e. the request rate is * too high, Kinesis remote service failed, network issue, etc. * @throws ExpiredIteratorException - if iterator needs to be refreshed * @throws RuntimeException - in all other cases *///from w ww . j a va 2 s . c o m private <T> T wrapExceptions(Callable<T> callable) throws TransientKinesisException { try { return callable.call(); } catch (ExpiredIteratorException e) { throw e; } catch (LimitExceededException | ProvisionedThroughputExceededException e) { throw new TransientKinesisException("Too many requests to Kinesis. Wait some time and retry.", e); } catch (AmazonServiceException e) { if (e.getErrorType() == AmazonServiceException.ErrorType.Service) { throw new TransientKinesisException("Kinesis backend failed. Wait some time and retry.", e); } throw new RuntimeException("Kinesis client side failure", e); } catch (AmazonClientException e) { if (e.isRetryable()) { throw new TransientKinesisException("Retryable client failure", e); } throw new RuntimeException("Not retryable client failure", e); } catch (Exception e) { throw new RuntimeException("Unknown kinesis failure, when trying to reach kinesis", e); } }