Search in sources :

Example 16 with Server

use of org.apache.druid.client.selector.Server in project druid by druid-io.

the class QueryHostFinder method pickDefaultServer.

public Server pickDefaultServer() {
    Server server = findDefaultServer();
    assertServerFound(server, "No default server found!");
    return server;
}
Also used : Server(org.apache.druid.client.selector.Server)

Example 17 with Server

use of org.apache.druid.client.selector.Server in project druid by druid-io.

the class QueryHostFinder method findServerAvatica.

public Server findServerAvatica(String connectionId) {
    Server chosenServer = avaticaConnectionBalancer.pickServer(getAllServers(), connectionId);
    assertServerFound(chosenServer, "No server found for Avatica request with connectionId[%s]", connectionId);
    log.debug("Balancer class [%s] sending request with connectionId[%s] to server: %s", avaticaConnectionBalancer.getClass(), connectionId, chosenServer.getHost());
    return chosenServer;
}
Also used : Server(org.apache.druid.client.selector.Server)

Example 18 with Server

use of org.apache.druid.client.selector.Server in project druid by druid-io.

the class QueryHostFinder method findServerInner.

private Server findServerInner(final Pair<String, Server> selected) {
    if (selected == null) {
        log.error("Unable to find any brokers!");
    }
    final String serviceName = selected == null ? hostSelector.getDefaultServiceName() : selected.lhs;
    Server server = selected == null ? null : selected.rhs;
    if (server == null) {
        log.error("No server found for serviceName[%s]. Using backup", serviceName);
        server = serverBackup.get(serviceName);
        if (server == null) {
            log.error("No backup found for serviceName[%s]. Using default[%s]", serviceName, hostSelector.getDefaultServiceName());
            server = serverBackup.get(hostSelector.getDefaultServiceName());
        }
    }
    if (server != null) {
        serverBackup.put(serviceName, server);
    }
    return server;
}
Also used : Server(org.apache.druid.client.selector.Server)

Example 19 with Server

use of org.apache.druid.client.selector.Server in project druid by druid-io.

the class QueryHostFinder method pickServer.

public <T> Server pickServer(Query<T> query) {
    Server server = findServer(query);
    assertServerFound(server, "No server found for query[%s]", query);
    return server;
}
Also used : Server(org.apache.druid.client.selector.Server)

Example 20 with Server

use of org.apache.druid.client.selector.Server in project druid by druid-io.

the class QueryHostFinderTest method setUp.

@Before
public void setUp() {
    brokerSelector = EasyMock.createMock(TieredBrokerHostSelector.class);
    server = new Server() {

        @Override
        public String getScheme() {
            return null;
        }

        @Override
        public String getHost() {
            return "foo";
        }

        @Override
        public String getAddress() {
            return null;
        }

        @Override
        public int getPort() {
            return 0;
        }
    };
    EasyMock.expect(brokerSelector.select(EasyMock.anyObject(Query.class))).andReturn(Pair.of("service", server));
    EasyMock.replay(brokerSelector);
}
Also used : Server(org.apache.druid.client.selector.Server) Query(org.apache.druid.query.Query) TimeBoundaryQuery(org.apache.druid.query.timeboundary.TimeBoundaryQuery) Before(org.junit.Before)

Aggregations

Server (org.apache.druid.client.selector.Server)20 Test (org.junit.Test)10 URI (java.net.URI)5 IOException (java.io.IOException)3 Query (org.apache.druid.query.Query)3 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ServletException (javax.servlet.ServletException)2 Service (org.apache.calcite.avatica.remote.Service)2 DruidServer (org.apache.druid.client.DruidServer)2 QueryInterruptedException (org.apache.druid.query.QueryInterruptedException)2 CountAggregatorFactory (org.apache.druid.query.aggregation.CountAggregatorFactory)2 SqlQuery (org.apache.druid.sql.http.SqlQuery)2 SmileMediaTypes (com.fasterxml.jackson.jaxrs.smile.SmileMediaTypes)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Inject (com.google.inject.Inject)1 Provider (com.google.inject.Provider)1