Examples of HttpClientResponse


Examples of com.netflix.niws.client.http.HttpClientResponse

              + key)
          )
          .setQueryParams(queryParams)
          .build();
     
      HttpClientResponse response = client
          .executeWithLoadBalancer(request);
     
      if (response.getStatus() != 200) { 
        logger.error("error status: {}", response.getStatus());
        throw new Exception("error status: " + response.getStatus());
      }

      return IOUtils.toString(response.getRawEntity(), Charsets.UTF_8);
    } catch (Exception exc) {
      throw new RuntimeException("Exception", exc);
    }
  }
View Full Code Here

Examples of com.netflix.niws.client.http.HttpClientResponse

              + "/"
              + key))
          //.setHeaders(headers)
          .build();
     
      HttpClientResponse response = client
          .executeWithLoadBalancer(request);

      if (response.getStatus() != 200) { 
        logger.error("error status: {}", response.getStatus());
        throw new Exception("error status: " + response.getStatus());
      }
     
      return IOUtils.toString(response.getRawEntity(), Charsets.UTF_8);
    } catch (Exception exc) {
      logger.error("Exception calling middletier while retrieving logs.", exc);
      throw new RuntimeException("Exception", exc);
    }
  }
View Full Code Here

Examples of com.netflix.niws.client.http.HttpClientResponse

     * Fetch the RSS feed content using Ribbon
     */
    private RSS fetchRSSFeed(String url) {

        RestClient client = (RestClient) ClientFactory.getNamedClient(RSSConstants.MIDDLETIER_REST_CLIENT);
        HttpClientResponse response;
        String rssData = null;

        try {
            HttpClientRequest request = HttpClientRequest.newBuilder().setUri(new URI(url)).build();
            response = client.execute(request);

            if (response != null) {
                rssData  = IOUtils.toString(response.getRawEntity(), Charsets.UTF_8);
                logger.info("Status code for " + response.getRequestedURI() + " : " + response.getStatus());
            }
        } catch (URISyntaxException e) {
            logger.error("Exception occurred when setting the URI", e);
        } catch (Exception e) {
            logger.error("Exception occurred when executing the HTTP request", e);
View Full Code Here

Examples of com.netflix.niws.client.http.HttpClientResponse

          .setUri(new URI("/"
              + RSSConstants.MIDDLETIER_WEB_RESOURCE_ROOT_PATH
              + RSSConstants.RSS_ENTRY_POINT)
                    )
          .build();
      HttpClientResponse response = client.executeWithLoadBalancer(request);

      return IOUtils.toString(response.getRawEntity(), Charsets.UTF_8);
    } catch (Exception exc) {
      throw new RuntimeException("Exception", exc);
    }
  }
View Full Code Here

Examples of com.netflix.niws.client.http.HttpClientResponse

          .setUri(new URI("/"
              + RSSConstants.MIDDLETIER_WEB_RESOURCE_ROOT_PATH
              + RSSConstants.RSS_ENTRY_POINT
                            + "?url=" + url))
          .build();
      HttpClientResponse response = client.executeWithLoadBalancer(request);

      return IOUtils.toString(response.getRawEntity(), Charsets.UTF_8);
    } catch (Exception exc) {
      throw new RuntimeException("Exception occurred when adding a RSS feed", exc);
    }
  }
View Full Code Here

Examples of com.netflix.niws.client.http.HttpClientResponse

                            + RSSConstants.MIDDLETIER_WEB_RESOURCE_ROOT_PATH
                            + RSSConstants.RSS_ENTRY_POINT
                            + "?url=" + url)
                    )
          .build();
      HttpClientResponse response = client.executeWithLoadBalancer(request);

      return IOUtils.toString(response.getRawEntity(), Charsets.UTF_8);
    } catch (Exception exc) {
      throw new RuntimeException("Exception", exc);
    }
  }
View Full Code Here

Examples of com.sonian.elasticsearch.http.jetty.HttpClientResponse

    }

    @SuppressWarnings({"unchecked"})
    @Test
    public void testErrorHandler() throws Exception {
        HttpClientResponse resp = httpClient("server1").request("PUT", "foo/bar/bizzle");
        assertThat(resp.errorCode(), equalTo(HttpURLConnection.HTTP_UNAUTHORIZED));
        assertThat("response body should be error message",
                   resp.get("body").equals("401 Unauthorized /foo/bar/bizzle"));
    }
View Full Code Here

Examples of com.sonian.elasticsearch.http.jetty.HttpClientResponse

    @Test
    public void testClusterHealth() throws Exception {
        startNode("server1");
        createTestIndex();
        // Shouldn't log cluster health call
        HttpClientResponse response = httpClient("server1").request("_cluster/health");
        assertThat((String) response.get("status"), equalTo("green"));

        Map<String, Object> data = createSearchQuery("user:kimchy");
        httpClient("server1").request("POST", "_search", data);
        // Should start with logging for the POST /_search request
        Map<String, Object> logJson = XContentFactory.xContent(XContentType.JSON)
View Full Code Here

Examples of com.sonian.elasticsearch.http.jetty.HttpClientResponse

    @Test
    public void testClusterHealth() throws Exception {
        startNode("server1");
        createTestIndex();
        // Shouldn't log cluster health call
        HttpClientResponse response = httpClient("server1").request("_cluster/health");
        assertThat((String) response.get("status"), equalTo("green"));

        Map<String, Object> data = createSearchQuery("user:kimchy");
        httpClient("server1").request("POST", "_search", data);
        // Should start with logging for the POST /_search request
        String logMessage = mockESLoggerFactory.getMessage();
View Full Code Here

Examples of com.sonian.elasticsearch.http.jetty.HttpClientResponse

        );
        startNode("server1");
        createTestIndex();

        // Should log cluster health call
        HttpClientResponse response = httpClient("server1").request("_cluster/health");
        assertThat((String) response.get("status"), equalTo("green"));
        assertThat(mockESLoggerFactory.getMessage(), startsWith("INFO:[server1] GET /_cluster/health - 200 OK"));

        Map<String, Object> data = createSearchQuery("user:kimchy");
        httpClient("server1").request("POST", "_search", data);
        String logMessage = mockESLoggerFactory.getMessage();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.