Package io.druid.client.selector

Examples of io.druid.client.selector.Server


    final RetryPolicy retryPolicy = retryPolicyFactory.makeRetryPolicy();

    while (true) {
      try {
        final Server server;
        final URI serviceUri;
        try {
          server = getServiceInstance();
          serviceUri = makeServiceUri(server);
        }
        catch (Exception e) {
          // Want to retry, so throw an IOException.
          throw new IOException("Failed to locate service uri", e);
        }

        final StatusResponseHolder response;

        log.info("Submitting action for task[%s] to overlord[%s]: %s", task.getId(), serviceUri, taskAction);

        try {
          response = httpClient.post(serviceUri.toURL())
                               .setContent("application/json", dataToSend)
                               .go(new StatusResponseHandler(Charsets.UTF_8))
                               .get();
        }
        catch (Exception e) {
          Throwables.propagateIfInstanceOf(e.getCause(), IOException.class);
          Throwables.propagateIfInstanceOf(e.getCause(), ChannelException.class);
          throw Throwables.propagate(e);
        }

        if (response.getStatus().getCode() / 200 == 1) {
          final Map<String, Object> responseDict = jsonMapper.readValue(
              response.getContent(),
              new TypeReference<Map<String, Object>>()
              {
              }
          );
          return jsonMapper.convertValue(responseDict.get("result"), taskAction.getReturnTypeReference());
        } else {
          // Want to retry, so throw an IOException.
          throw new IOException(
              String.format(
                  "Scary HTTP status returned: %s. Check your overlord[%s] logs for exceptions.",
                  response.getStatus(),
                  server.getHost()
              )
          );
        }
      }
      catch (IOException | ChannelException e) {
View Full Code Here


    return new URI(String.format("%s://%s%s", instance.getScheme(), instance.getHost(), "/druid/indexer/v1/action"));
  }

  private Server getServiceInstance()
  {
    final Server instance = selector.pick();
    if (instance == null) {
      throw new ISE("Cannot find instance of indexer to talk to!");
    } else {
      return instance;
    }
View Full Code Here

    if (instance == null) {
      log.error("No server instance found");
      return null;
    }

    return new Server()
    {
      @Override
      public String getHost()
      {
        return String.format("%s:%d", getAddress(), getPort());
View Full Code Here

  }

  private String baseUrl()
  {
    try {
      final Server instance = selector.pick();
      if (instance == null) {
        throw new ISE("Cannot find instance of indexingService");
      }

      return String.format("http://%s/druid/indexer/v1", instance.getHost());
    }
    catch (Exception e) {
      throw Throwables.propagate(e);
    }
  }
View Full Code Here

      {
        return "hotBroker";
      }
    };

    server = new Server()
    {
      @Override
      public String getScheme()
      {
        return null;
View Full Code Here

    QueryHostFinder queryRunner = new QueryHostFinder(
        brokerSelector
    );

    Server server = queryRunner.findServer(
        new TimeBoundaryQuery(
            new TableDataSource("test"),
            new MultipleIntervalSegmentSpec(Arrays.<Interval>asList(new Interval("2011-08-31/2011-09-01"))),
            null,
            null
        )
    );

    Assert.assertEquals("foo", server.getHost());
  }
View Full Code Here

    {
      @Override
      public Sequence<T> run(Query<T> query, Map<String, Object> context)
      {
        try {
          Server instance = brokerSelector.pick();
          if (instance == null) {
            return Sequences.empty();
          }

          final String url = String.format(
View Full Code Here

    return findServerInner(selected);
  }

  public String getHost(Query<T> query)
  {
    Server server = findServer(query);

    if (server == null) {
      log.makeAlert(
          "Catastrophic failure! No servers found at all! Failing request!"
      ).emit();

      throw new ISE("No server found for query[%s]", query);
    }

    log.debug("Selected [%s]", server.getHost());

    return server.getHost();
  }
View Full Code Here

    return server.getHost();
  }

  public String getDefaultHost()
  {
    Server server = findDefaultServer();

    if (server == null) {
      log.makeAlert(
          "Catastrophic failure! No servers found at all! Failing request!"
      ).emit();

      throw new ISE("No default server found!");
    }

    return server.getHost();
  }
View Full Code Here

    }

    final String serviceName = selected == null ? hostSelector.getDefaultServiceName() : selected.lhs;
    final ServerDiscoverySelector selector = selected == null ? null : selected.rhs;

    Server server = selector == null ? null : selector.pick();
    if (server == null) {
      log.error(
          "WTF?! No server found for serviceName[%s]. Using backup",
          serviceName
      );
View Full Code Here

TOP

Related Classes of io.druid.client.selector.Server

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.