Package org.jclouds.http

Examples of org.jclouds.http.HttpCommand


    *            if the time limit is reached
    * @see TimeLimiter#callWithTimeout(Callable, long, TimeUnit, boolean)
    */
   public Object invokeWithTimeout(final Invocation invocation, final long limitNanos) {
      String commandName = config.getCommandName(invocation);
      HttpCommand command = toCommand(commandName, invocation);
      org.jclouds.Fallback<?> fallback = getFallback(commandName, invocation, command);

      logger.debug(">> blocking on %s for %s", invocation, limitNanos);
      try {
         return timeLimiter
View Full Code Here


   private HttpCommand toCommand(String commandName, Invocation invocation) {
      logger.trace(">> converting %s", commandName);
      HttpRequest request = annotationProcessor.apply(invocation);
      logger.trace("<< converted %s to %s", commandName, request.getRequestLine());
      return new HttpCommand(request);
   }
View Full Code Here

    * applies a {@link #getFallback(String, Invocation, HttpCommand) fallback}
    * if a {@code Throwable} is encountered.
    */
   public Object invoke(Invocation invocation) {
      String commandName = config.getCommandName(invocation);
      HttpCommand command = toCommand(commandName, invocation);
      Function<HttpResponse, ?> transformer = getTransformer(commandName, command);
      org.jclouds.Fallback<?> fallback = getFallback(commandName, invocation, command);

      logger.debug(">> invoking %s", commandName);
      try {
View Full Code Here

    *            if the time limit is reached
    * @see TimeLimiter#callWithTimeout(Callable, long, TimeUnit, boolean)
    */
   public Object invokeWithTimeout(final Invocation invocation, final long limitNanos) {
      String commandName = config.getCommandName(invocation);
      HttpCommand command = toCommand(commandName, invocation);
      org.jclouds.Fallback<?> fallback = getFallback(commandName, invocation, command);

      logger.debug(">> blocking on %s for %s", invocation, limitNanos);
      try {
         return timeLimiter
View Full Code Here

   private HttpCommand toCommand(String commandName, Invocation invocation) {
      logger.trace(">> converting %s", commandName);
      HttpRequest request = annotationProcessor.apply(invocation);
      logger.trace("<< converted %s to %s", commandName, request.getRequestLine());
      return new HttpCommand(request);
   }
View Full Code Here

   private void assertCodeMakes(String method, URI uri, int statusCode, String message, String contentType,
            String content, Class<? extends Exception> expected, String exceptionMessage) {

      T function = Guice.createInjector().getInstance(getClassToTest());

      HttpCommand command = createMock(HttpCommand.class);
      HttpRequest request = HttpRequest.builder().method(method).endpoint(uri).build();
      HttpResponse response = HttpResponse.builder()
                                          .statusCode(statusCode)
                                          .message(message)
                                          .payload(content).build();
      response.getPayload().getContentMetadata().setContentType(contentType);

      expect(command.getCurrentRequest()).andReturn(request).atLeastOnce();
      command.setException(exceptionEq(expected, exceptionMessage));

      replay(command);

      function.handleError(command, response);
View Full Code Here

   }

   @Test
   void testClosesInputStream() throws InterruptedException, IOException, SecurityException, NoSuchMethodException {
      HttpCommand command = createCommand();

      HttpResponse response = HttpResponse.builder().statusCode(400).build();

      InputStream inputStream = new InputStream() {
         boolean isOpen = true;
View Full Code Here

         .getInstance(RestAnnotationProcessor.class);

   private HttpCommand createCommand() throws SecurityException, NoSuchMethodException {
      Invokable<IntegrationTestAsyncClient, String> method = method(IntegrationTestAsyncClient.class, "download", String.class);

      return new HttpCommand(processor.apply(Invocation.create(method, ImmutableList.<Object> of("1"))));
   }
View Full Code Here

      return new HttpCommand(processor.apply(Invocation.create(method, ImmutableList.<Object> of("1"))));
   }

   @Test
   void testIncrementsFailureCount() throws InterruptedException, IOException, SecurityException, NoSuchMethodException {
      HttpCommand command = createCommand();
      HttpResponse response = HttpResponse.builder().statusCode(400).build();

      handler.shouldRetryRequest(command, response);
      assertEquals(command.getFailureCount(), 1);

      handler.shouldRetryRequest(command, response);
      assertEquals(command.getFailureCount(), 2);

      handler.shouldRetryRequest(command, response);
      assertEquals(command.getFailureCount(), 3);
   }
View Full Code Here

   }

   @Test
   void testDisallowsExcessiveRetries() throws InterruptedException, IOException, SecurityException,
            NoSuchMethodException {
      HttpCommand command = createCommand();
      HttpResponse response = HttpResponse.builder().statusCode(400).build();

      assertEquals(handler.shouldRetryRequest(command, response), true); // Failure 1

      assertEquals(handler.shouldRetryRequest(command, response), true); // Failure 2
View Full Code Here

TOP

Related Classes of org.jclouds.http.HttpCommand

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.