Package com.amazonaws

Examples of com.amazonaws.AmazonServiceException


        String errorCode = parseErrorCode(in, xpath);
        String errorType = asString("ErrorResponse/Error/Type", in, xpath);
        String requestId = asString("ErrorResponse/RequestId", in, xpath);
        String message = asString("ErrorResponse/Error/Message", in, xpath);

        AmazonServiceException ase = newException(message);
        ase.setErrorCode(errorCode);
        ase.setRequestId(requestId);

        if (errorType == null) {
            ase.setErrorType(ErrorType.Unknown);
        } else if (errorType.equalsIgnoreCase("Receiver")) {
            ase.setErrorType(ErrorType.Service);
        } else if (errorType.equalsIgnoreCase("Sender")) {
            ase.setErrorType(ErrorType.Client);
        }

        return ase;
    }
View Full Code Here


        String message = asString("Response/Errors/Error/Message", in, xpath);
        String requestId = asString("Response/RequestID", in, xpath);
        String errorType = asString("Response/Errors/Error/Type", in, xpath);

        Constructor<? extends AmazonServiceException> constructor = exceptionClass.getConstructor(String.class);
        AmazonServiceException ase = constructor.newInstance(message);
        ase.setErrorCode(errorCode);
        ase.setRequestId(requestId);

        if (errorType == null) {
            ase.setErrorType(ErrorType.Unknown);
        } else if (errorType.equalsIgnoreCase("server")) {
            ase.setErrorType(ErrorType.Service);
        } else if (errorType.equalsIgnoreCase("client")) {
            ase.setErrorType(ErrorType.Client);
        }

        return ase;
    }
View Full Code Here

            // Always retry on client exceptions caused by IOException
            if (exception.getCause() instanceof IOException) return true;
           
            // Only retry on a subset of service exceptions
            if (exception instanceof AmazonServiceException) {
                AmazonServiceException ase = (AmazonServiceException)exception;

                /*
                 * For 500 internal server errors and 503 service
                 * unavailable errors, we want to retry, but we need to use
                 * an exponential back-off strategy so that we don't overload
                 * a server with a flood of retries.
                 */
                if (ase.getStatusCode() == HttpStatus.SC_INTERNAL_SERVER_ERROR
                    || ase.getStatusCode() == HttpStatus.SC_SERVICE_UNAVAILABLE) {
                    return true;
                }

                /*
                 * Throttling is reported as a 400 error from newer services. To try
View Full Code Here

        httpClient.getHttpConnectionManager().closeIdleConnections(1000 * 30);

        requestLog.info("Sending Request: " + request.toString());

        int retries = 0;
        AmazonServiceException exception = null;
        while (true) {
            try {
                if (retries > 0) pauseExponentially(retries, exception);
                exception = null;
                retries++;
View Full Code Here

            return true;
        }


        if (exception instanceof AmazonServiceException) {
            AmazonServiceException ase = (AmazonServiceException)exception;

            /*
             * For 500 internal server errors and 503 service
             * unavailable errors, we want to retry, but we need to use
             * an exponential back-off strategy so that we don't overload
             * a server with a flood of retries. If we've surpassed our
             * retry limit we handle the error response as a non-retryable
             * error and go ahead and throw it back to the user as an exception.
             */
            if (ase.getStatusCode() == HttpStatus.SC_INTERNAL_SERVER_ERROR
                || ase.getStatusCode() == HttpStatus.SC_SERVICE_UNAVAILABLE) {
                return true;
            }

            /*
             * Throttling is reported as a 400 error from newer services. To try
View Full Code Here

        HttpResponse response = createResponse(method, request);
        if (errorResponseHandler.needsConnectionLeftOpen()) {
            response.setContent(new HttpMethodReleaseInputStream(method));
        }

        AmazonServiceException exception = null;

        try {
            exception = errorResponseHandler.handle(response);
            requestLog.info("Received error response: " + exception.toString());
        } catch (Exception e) {
            String errorMessage = "Unable to unmarshall error response (" + e.getMessage() + "): "
                                + method.getResponseBodyAsString();
            log.error(errorMessage, e);
            throw new AmazonClientException(errorMessage, e);
        }

        exception.setStatusCode(status);
        exception.setServiceName(request.getServiceName());
        exception.fillInStackTrace();
        return exception;
    }
View Full Code Here

   * this as you would any other HadoopJarStepConfig.
   * @return HadoopJarStepConfig configured to perform the specified actions.
   */
  public HadoopJarStepConfig toHadoopJarStepConfig() {
    if (args.size() == 0) {
      throw new AmazonServiceException("Cannot create a ResizeJobFlowStep with no resize actions.");
    }

    if (wait == false) {
      args.add("--no-wait");
    }
View Full Code Here

      return this;
    }

    public List<String> getArgs() {
      if (instanceGroup == null) {
        throw new AmazonServiceException("InstanceGroup must not be null.");
      }
      if (instanceCount == null) {
        throw new AmazonServiceException("InstanceCount must not be null.");
      }

      List<String> args = new ArrayList<String>();
      args.add("--modify-instance-group");
      args.add(instanceGroup);
View Full Code Here

      return this;
    }

    public List<String> getArgs() {
      if (instanceGroup == null) {
        throw new AmazonServiceException("InstanceGroup must not be null.");
      }
      if (instanceCount == null) {
        throw new AmazonServiceException("InstanceCount must not be null.");
      }
      if (instanceType == null) {
        throw new AmazonServiceException("InstanceType must not be null.");
      }

      List<String> args = new ArrayList<String>();
      args.add("--add-instance-group");
      args.add(instanceGroup);
View Full Code Here

                    awsRequestMetrics.addProperty(Field.RedirectLocation, redirectedLocation);
                    awsRequestMetrics.addProperty(Field.AWSRequestID, null);

                } else {
                    leaveHttpConnectionOpen = errorResponseHandler.needsConnectionLeftOpen();
                    AmazonServiceException ase = handleErrorResponse(request, errorResponseHandler, httpRequest, apacheResponse);
                    awsRequestMetrics.addProperty(Field.AWSRequestID, ase.getRequestId());
                    awsRequestMetrics.addProperty(Field.AWSErrorCode, ase.getErrorCode());
                    awsRequestMetrics.addProperty(Field.StatusCode, ase.getStatusCode());
                   
                    if (!shouldRetry(request.getOriginalRequest(),
                                     httpRequest,
                                     ase,
                                     requestCount,
View Full Code Here

TOP

Related Classes of com.amazonaws.AmazonServiceException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.