Java Code Examples for com.amazonaws.AmazonServiceException#getErrorType()

The following examples show how to use com.amazonaws.AmazonServiceException#getErrorType() . 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: KinesisProxy.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * Determines whether the exception is recoverable using exponential-backoff.
 *
 * @param ex Exception to inspect
 * @return <code>true</code> if the exception can be recovered from, else
 *         <code>false</code>
 */
protected static boolean isRecoverableException(AmazonServiceException ex) {
	if (ex.getErrorType() == null) {
		return false;
	}

	switch (ex.getErrorType()) {
		case Client:
			return ex instanceof ProvisionedThroughputExceededException;
		case Service:
		case Unknown:
			return true;
		default:
			return false;
	}
}
 
Example 2
Source File: KinesisProxy.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Determines whether the exception is recoverable using exponential-backoff.
 *
 * @param ex Exception to inspect
 * @return <code>true</code> if the exception can be recovered from, else
 *         <code>false</code>
 */
protected static boolean isRecoverableException(AmazonServiceException ex) {
	if (ex.getErrorType() == null) {
		return false;
	}

	switch (ex.getErrorType()) {
		case Client:
			return ex instanceof ProvisionedThroughputExceededException;
		case Service:
		case Unknown:
			return true;
		default:
			return false;
	}
}
 
Example 3
Source File: KinesisProxy.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Determines whether the exception is recoverable using exponential-backoff.
 *
 * @param ex Exception to inspect
 * @return <code>true</code> if the exception can be recovered from, else
 *         <code>false</code>
 */
protected static boolean isRecoverableException(AmazonServiceException ex) {
	if (ex.getErrorType() == null) {
		return false;
	}

	switch (ex.getErrorType()) {
		case Client:
			return ex instanceof ProvisionedThroughputExceededException;
		case Service:
		case Unknown:
			return true;
		default:
			return false;
	}
}
 
Example 4
Source File: S3URLConnection.java    From render with GNU General Public License v2.0 6 votes vote down vote up
private synchronized void connectToS3() throws IOException {
    if (! connected) {
        try {
            String s3key;
            try {
                s3key = java.net.URLDecoder.decode(s3uri.getKey(), "UTF-8");
            } catch (final UnsupportedEncodingException e) {
                LOG.warn("failed to decode key, using raw key instead", e);
                // TODO: Better error handling with badly encoded URLs?
                s3key = s3uri.getKey();
            }
            s3object = s3Client.getObject(new GetObjectRequest(s3uri.getBucket(), s3key));
            connected = true;
        } catch (final AmazonServiceException ase) {
            throw new IOException("Amazon S3 service failure for error type " + ase.getErrorType(), ase);
        } catch (final AmazonClientException ace) {
            throw new IOException("Amazon S3 client failure", ace);
        }
    }
}
 
Example 5
Source File: S3Opener.java    From render with GNU General Public License v2.0 5 votes vote down vote up
private synchronized void buildS3Handler() throws IOException {
    if (handler == null) {
        try {
            final AWSCredentialsProvider credentialsProvider = new DefaultAWSCredentialsProviderChain();
            final AmazonS3 s3Client = AmazonS3ClientBuilder.standard().withCredentials(credentialsProvider).build();
            handler = new S3Handler(s3Client);
        } catch (final AmazonServiceException ase) {
            throw new IOException("Amazon S3 service failure for error type " + ase.getErrorType(), ase);
        } catch (final AmazonClientException ace) {
            throw new IOException("Amazon S3 client failure", ace);
        }
    }
}