Package com.netflix.niws.client.http

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


  @Override
  protected String run() {
    try {
      // The named client param must match the prefix for the ribbon
      // configuration specified in the edge.properties file
      RestClient client = (RestClient) ClientFactory
          .getNamedClient("middletier-client");

      MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
      queryParams.putSingle("log", URLEncoder.encode(log, Charsets.UTF_8.name()));

      // Note: If running locally on MacOS, you'll need to make sure your
      // /etc/hosts file contains the following entry:
      // 127.0.0.1 <hostname>.local
      // or else this will likely fail.
      HttpClientRequest request = HttpClientRequest
          .newBuilder()
          .setVerb(Verb.POST)
          .setUri(new URI("/service/"
              + FluxConstants.MIDDLETIER_WEB_RESOURCE_ROOT_PATH
              + "/"
              + FluxConstants.MIDDLETIER_WEB_RESOURCE_VERSION
              + "/"
              + FluxConstants.MIDDLETIER_WEB_RESOURCE_ADD_PATH
              + "/"
              + 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());
View Full Code Here


  @Override
  protected String run() {
    try {
      // The named client param must match the prefix for the ribbon
      // configuration specified in the edge.properties file
      RestClient client = (RestClient) ClientFactory
          .getNamedClient("middletier-client");

      //MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
      //headers.putSingle("Content-Type", "text/plain");

      // Note: If running locally on MacOS, you'll need to make sure your
      // /etc/hosts file contains the following entry:
      // 127.0.0.1 <hostname>.local
      // or else this will likely fail.
      HttpClientRequest request = HttpClientRequest
          .newBuilder()
          .setVerb(Verb.GET)
          .setUri(new URI("/service/"
              + FluxConstants.MIDDLETIER_WEB_RESOURCE_ROOT_PATH
              + "/"
              + FluxConstants.MIDDLETIER_WEB_RESOURCE_VERSION
              + "/"
              + FluxConstants.MIDDLETIER_WEB_RESOURCE_GET_PATH
              + "/"
              + 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());
View Full Code Here

    /**
     * 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());
            }
View Full Code Here

  @Override
  protected String run() {
    try {
      // The named client param must match the prefix for the ribbon
      // configuration specified in the edge.properties file
      RestClient client = (RestClient) ClientFactory.getNamedClient(RSSConstants.MIDDLETIER_REST_CLIENT);

      HttpClientRequest request = HttpClientRequest
          .newBuilder()
          .setVerb(Verb.GET)
          .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

    try {
      /*
       * The named client param must match the prefix for the ribbon
       * configuration specified in the edge.properties file
       */
      RestClient client = (RestClient) ClientFactory.getNamedClient(RSSConstants.MIDDLETIER_REST_CLIENT);

      HttpClientRequest request = HttpClientRequest
          .newBuilder()
          .setVerb(Verb.POST)
          .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

  @Override
  protected String run() {
    try {
      // The named client param must match the prefix for the ribbon
      // configuration specified in the edge.properties file
      RestClient client = (RestClient) ClientFactory.getNamedClient(RSSConstants.MIDDLETIER_REST_CLIENT);

      HttpClientRequest request = HttpClientRequest
          .newBuilder()
          .setVerb(Verb.DELETE)
          .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", exc);
    }
View Full Code Here

TOP

Related Classes of com.netflix.niws.client.http.RestClient

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.