Search in sources :

Example 1 with DirectDruidClient

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

the class TierSelectorStrategyTest method testLowestPriorityTierSelectorStrategy.

@Test
public void testLowestPriorityTierSelectorStrategy() {
    DirectDruidClient client = EasyMock.createMock(DirectDruidClient.class);
    QueryableDruidServer lowPriority = new QueryableDruidServer(new DruidServer("test1", "localhost", null, 0, ServerType.HISTORICAL, DruidServer.DEFAULT_TIER, 0), client);
    QueryableDruidServer highPriority = new QueryableDruidServer(new DruidServer("test1", "localhost", null, 0, ServerType.HISTORICAL, DruidServer.DEFAULT_TIER, 1), client);
    testTierSelectorStrategy(new LowestPriorityTierSelectorStrategy(new ConnectionCountServerSelectorStrategy()), lowPriority, highPriority);
}
Also used : DirectDruidClient(org.apache.druid.client.DirectDruidClient) DruidServer(org.apache.druid.client.DruidServer) Test(org.junit.Test)

Example 2 with DirectDruidClient

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

the class TierSelectorStrategyTest method testServerSelectorStrategyDefaults.

@Test
public void testServerSelectorStrategyDefaults() {
    DirectDruidClient client = EasyMock.createMock(DirectDruidClient.class);
    QueryableDruidServer p0 = new QueryableDruidServer(new DruidServer("test1", "localhost", null, 0, ServerType.HISTORICAL, DruidServer.DEFAULT_TIER, -1), client);
    Set<QueryableDruidServer> servers = new HashSet<>();
    servers.add(p0);
    RandomServerSelectorStrategy strategy = new RandomServerSelectorStrategy();
    Assert.assertEquals(strategy.pick(servers, EasyMock.createMock(DataSegment.class)), p0);
    Assert.assertEquals(strategy.pick(EasyMock.createMock(Query.class), servers, EasyMock.createMock(DataSegment.class)), p0);
    ServerSelectorStrategy defaultDeprecatedServerSelectorStrategy = new ServerSelectorStrategy() {

        @Override
        public <T> List<QueryableDruidServer> pick(@Nullable Query<T> query, Set<QueryableDruidServer> servers, DataSegment segment, int numServersToPick) {
            return strategy.pick(servers, segment, numServersToPick);
        }
    };
    Assert.assertEquals(defaultDeprecatedServerSelectorStrategy.pick(servers, EasyMock.createMock(DataSegment.class)), p0);
    Assert.assertEquals(defaultDeprecatedServerSelectorStrategy.pick(servers, EasyMock.createMock(DataSegment.class), 1).get(0), p0);
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) DirectDruidClient(org.apache.druid.client.DirectDruidClient) Query(org.apache.druid.query.Query) DruidServer(org.apache.druid.client.DruidServer) DataSegment(org.apache.druid.timeline.DataSegment) Nullable(javax.annotation.Nullable) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 3 with DirectDruidClient

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

the class TierSelectorStrategyTest method testEmptyCustomPriorityTierSelectorStrategy.

@Test
public void testEmptyCustomPriorityTierSelectorStrategy() {
    DirectDruidClient client = EasyMock.createMock(DirectDruidClient.class);
    QueryableDruidServer lowPriority = new QueryableDruidServer(new DruidServer("test1", "localhost", null, 0, ServerType.HISTORICAL, DruidServer.DEFAULT_TIER, -1), client);
    QueryableDruidServer mediumPriority = new QueryableDruidServer(new DruidServer("test1", "localhost", null, 0, ServerType.HISTORICAL, DruidServer.DEFAULT_TIER, 0), client);
    QueryableDruidServer highPriority = new QueryableDruidServer(new DruidServer("test1", "localhost", null, 0, ServerType.HISTORICAL, DruidServer.DEFAULT_TIER, 1), client);
    testTierSelectorStrategy(new CustomTierSelectorStrategy(new ConnectionCountServerSelectorStrategy(), new CustomTierSelectorStrategyConfig() {

        @Override
        public List<Integer> getPriorities() {
            return new ArrayList<>();
        }
    }), highPriority, mediumPriority, lowPriority);
}
Also used : DirectDruidClient(org.apache.druid.client.DirectDruidClient) ArrayList(java.util.ArrayList) DruidServer(org.apache.druid.client.DruidServer) Test(org.junit.Test)

Example 4 with DirectDruidClient

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

the class TierSelectorStrategyTest method testHighestPriorityTierSelectorStrategyRealtime.

@Test
public void testHighestPriorityTierSelectorStrategyRealtime() {
    DirectDruidClient client = EasyMock.createMock(DirectDruidClient.class);
    QueryableDruidServer lowPriority = new QueryableDruidServer(new DruidServer("test1", "localhost", null, 0, ServerType.REALTIME, DruidServer.DEFAULT_TIER, 0), client);
    QueryableDruidServer highPriority = new QueryableDruidServer(new DruidServer("test1", "localhost", null, 0, ServerType.REALTIME, DruidServer.DEFAULT_TIER, 1), client);
    testTierSelectorStrategy(new HighestPriorityTierSelectorStrategy(new ConnectionCountServerSelectorStrategy()), highPriority, lowPriority);
}
Also used : DirectDruidClient(org.apache.druid.client.DirectDruidClient) DruidServer(org.apache.druid.client.DruidServer) Test(org.junit.Test)

Example 5 with DirectDruidClient

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

the class TierSelectorStrategyTest method testIncompleteCustomPriorityTierSelectorStrategy.

@Test
public void testIncompleteCustomPriorityTierSelectorStrategy() {
    DirectDruidClient client = EasyMock.createMock(DirectDruidClient.class);
    QueryableDruidServer p0 = new QueryableDruidServer(new DruidServer("test1", "localhost", null, 0, ServerType.HISTORICAL, DruidServer.DEFAULT_TIER, -1), client);
    QueryableDruidServer p1 = new QueryableDruidServer(new DruidServer("test1", "localhost", null, 0, ServerType.HISTORICAL, DruidServer.DEFAULT_TIER, 0), client);
    QueryableDruidServer p2 = new QueryableDruidServer(new DruidServer("test1", "localhost", null, 0, ServerType.HISTORICAL, DruidServer.DEFAULT_TIER, 1), client);
    QueryableDruidServer p3 = new QueryableDruidServer(new DruidServer("test1", "localhost", null, 0, ServerType.HISTORICAL, DruidServer.DEFAULT_TIER, 2), client);
    QueryableDruidServer p4 = new QueryableDruidServer(new DruidServer("test1", "localhost", null, 0, ServerType.HISTORICAL, DruidServer.DEFAULT_TIER, 3), client);
    TierSelectorStrategy tierSelectorStrategy = new CustomTierSelectorStrategy(new ConnectionCountServerSelectorStrategy(), new CustomTierSelectorStrategyConfig() {

        @Override
        public List<Integer> getPriorities() {
            return Arrays.asList(2, 0, -1);
        }
    });
    testTierSelectorStrategy(tierSelectorStrategy, p3, p1, p0, p4, p2);
}
Also used : DirectDruidClient(org.apache.druid.client.DirectDruidClient) DruidServer(org.apache.druid.client.DruidServer) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Aggregations

DirectDruidClient (org.apache.druid.client.DirectDruidClient)7 DruidServer (org.apache.druid.client.DruidServer)7 Test (org.junit.Test)7 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1 Nullable (javax.annotation.Nullable)1 Query (org.apache.druid.query.Query)1 DataSegment (org.apache.druid.timeline.DataSegment)1