Package org.jclouds.rest

Examples of org.jclouds.rest.InsufficientResourcesException


      message = message != null ? message : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(),
            response.getStatusLine());
      switch (response.getStatusCode()) {
      case 400:
         if (message.contains("quota exceeded"))
            exception = new InsufficientResourcesException(message, exception);
         break;
      case 401:
      case 403:
         exception = new AuthorizationException(message, exception);
         break;
      case 404:
         if (!command.getCurrentRequest().getMethod().equals("DELETE")) {
            exception = new ResourceNotFoundException(message, exception);
         }
         break;
      case 413:
         exception = new InsufficientResourcesException(message, exception);
         break;
      }
      command.setException(exception);
   }
View Full Code Here


      switch (response.getStatusCode()) {
         case 400:
            if ("UnsupportedOperation".equals(errorCode))
               exception = new UnsupportedOperationException(message, exception);
            else if ("AddressLimitExceeded".equals(errorCode))
               exception = new InsufficientResourcesException(message, exception);
            else if ("TooManyBuckets".equals(errorCode))
               exception = new InsufficientResourcesException(message, exception);
            else if (errorCode != null && (errorCode.indexOf("NotFound") != -1 || errorCode.endsWith(".Unknown")))
               exception = new ResourceNotFoundException(message, exception);
            else if ("IncorrectState".equals(errorCode)
                     || (errorCode != null && (error.getCode().endsWith(".Duplicate") || error.getCode().endsWith(
                              ".InUse")))
View Full Code Here

      String errorCode = in.getError().getCode();
      String message = in.getError().getMessage();

      if (statusCode == 400) {
         if ("LimitExceeded".equals(errorCode)) {
            return new InsufficientResourcesException(message, in);
         } else if ("InvalidFormat".equals(errorCode)) {
            return new IllegalArgumentException(message, in);
         }
      }
View Full Code Here

      String requestLine = command.getCurrentRequest().getRequestLine();
      String message = content != null ? content : String.format("%s -> %s", requestLine, response.getStatusLine());
      switch (response.getStatusCode()) {
         case 400:
            if (message.indexOf("quota exceeded") != -1)
               exception = new InsufficientResourcesException(message, exception);
            else if (message.indexOf("has no fixed_ips") != -1)
               exception = new IllegalStateException(message, exception);
            else if (message.indexOf("already exists") != -1)
               exception = new IllegalStateException(message, exception);
            break;
         case 401:
         case 403:
            exception = new AuthorizationException(message, exception);
            break;
         case 404:
            if (!command.getCurrentRequest().getMethod().equals("DELETE")) {
               exception = new ResourceNotFoundException(message, exception);
            }
            break;
         case 413:
            if (content == null) {
               exception = new InsufficientResourcesException(message, exception);
               break;
            }
            exception = parseAndBuildRetryException(content, message, exception);
      }
      command.setException(exception);
View Full Code Here

      for (String value : filterKeys(overLimitParser.apply(json), in(retryFields)).values()) {
         Optional<RetryAfterException> retryException = retryAfterParser.tryCreateRetryAfterException(exception, value);
         if (retryException.isPresent())
            return retryException.get();
      }
      return new InsufficientResourcesException(message, exception);
   }
View Full Code Here

         return new AuthorizationException(message, in);
      if (statusCode == 400) {
         if (ImmutableSet.of("InvalidAction", "AccessDenied").contains(errorCode))
            return new UnsupportedOperationException(message, in);
         else if ("Throttling".equals(errorCode))
            return new InsufficientResourcesException(message, in);
         else if (message.indexOf("not found") != -1)
            return new ResourceNotFoundException(message, in);
         return new IllegalArgumentException(message, in);
      }
      return in;
View Full Code Here

               exception = new IllegalStateException(message, exception);
            }
            break;
         case 534:
            if (message.contains("Maximum number of resources of type")) {
               exception = new InsufficientResourcesException(message, exception);
            }
            break;
         case 537:
            exception = new IllegalStateException(message, exception);
            break;
View Full Code Here

      FloatingIPApi floatingIpApi = novaApi.getFloatingIPApi(regionId).get();
      Optional<Set<String>> poolNames = input.get().getNovaTemplateOptions().get().getFloatingIpPoolNames();

      Optional<FloatingIP> ip = allocateFloatingIPForNode(floatingIpApi, poolNames, node.getId());
      if (!ip.isPresent()) {
         throw new InsufficientResourcesException("Failed to allocate a FloatingIP for node(" + node.getId() + ")");
      }
      logger.debug(">> adding floatingIp(%s) to node(%s)", ip.get().getIp(), node.getId());

      floatingIpApi.addToServer(ip.get().getIp(), node.getProviderId());
      input.get().getNodeMetadata().set(NodeMetadataBuilder.fromNodeMetadata(node).publicAddresses(ImmutableSet.of(ip.get().getIp())).build());
View Full Code Here

            ImmutableSet.<TypeToken<? extends Throwable>> of());
   }

   @Test(expectedExceptions = InsufficientResourcesException.class)
   public void testPropagateStandardExceptionInsufficientResourcesException() throws Throwable {
      Exception e = new InsufficientResourcesException();
      propagateIfPossible(new RuntimeException(e), ImmutableSet.<TypeToken<? extends Throwable>> of());
   }
View Full Code Here

      message = message != null ? message : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(),
               response.getStatusLine());
      switch (response.getStatusCode()) {
         case 400:
            if (message.contains("quota exceeded"))
               exception = new InsufficientResourcesException(message, exception);
            else if (message.contains("Invalid volume"))
               exception = new IllegalStateException(message, exception);
            break;
         case 401:
         case 403:
            exception = new AuthorizationException(message, exception);
            break;
         case 404:
            if (!command.getCurrentRequest().getMethod().equals("DELETE")) {
               exception = new ResourceNotFoundException(message, exception);
            }
            break;
         case 413:
            exception = new InsufficientResourcesException(message, exception);
            break;
      }
      command.setException(exception);
   }
View Full Code Here

TOP

Related Classes of org.jclouds.rest.InsufficientResourcesException

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.