Search in sources :

Example 1 with ForeverDropRule

use of org.apache.druid.server.coordinator.rules.ForeverDropRule in project druid by druid-io.

the class CoordinatorRuleManagerTest method testAddingToRulesListThrowingError.

@Test
public void testAddingToRulesListThrowingError() {
    final CoordinatorRuleManager manager = new CoordinatorRuleManager(objectMapper, () -> tieredBrokerConfig, mockClient());
    manager.poll();
    final Map<String, List<Rule>> rules = manager.getRules();
    expectedException.expect(UnsupportedOperationException.class);
    rules.get(DATASOURCE1).add(new ForeverDropRule());
}
Also used : ForeverDropRule(org.apache.druid.server.coordinator.rules.ForeverDropRule) ArrayList(java.util.ArrayList) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) Test(org.junit.Test)

Example 2 with ForeverDropRule

use of org.apache.druid.server.coordinator.rules.ForeverDropRule in project druid by druid-io.

the class CoordinatorRuleManagerTest method mockClient.

private DruidLeaderClient mockClient() {
    final Map<String, List<Rule>> rules = ImmutableMap.of(DATASOURCE1, ImmutableList.of(new ForeverLoadRule(null)), DATASOURCE2, ImmutableList.of(new ForeverLoadRule(null), new IntervalDropRule(Intervals.of("2020-01-01/2020-01-02"))), "datasource3", ImmutableList.of(new PeriodLoadRule(new Period("P1M"), true, null), new ForeverDropRule()), TieredBrokerConfig.DEFAULT_RULE_NAME, ImmutableList.of(new ForeverLoadRule(ImmutableMap.of("__default", 2))));
    final StringFullResponseHolder holder = EasyMock.niceMock(StringFullResponseHolder.class);
    EasyMock.expect(holder.getStatus()).andReturn(HttpResponseStatus.OK);
    try {
        EasyMock.expect(holder.getContent()).andReturn(objectMapper.writeValueAsString(rules));
        final DruidLeaderClient client = EasyMock.niceMock(DruidLeaderClient.class);
        EasyMock.expect(client.go(EasyMock.anyObject())).andReturn(holder);
        EasyMock.replay(holder, client);
        return client;
    } catch (IOException | InterruptedException e) {
        throw new RuntimeException(e);
    }
}
Also used : Period(org.joda.time.Period) IntervalDropRule(org.apache.druid.server.coordinator.rules.IntervalDropRule) DruidLeaderClient(org.apache.druid.discovery.DruidLeaderClient) IOException(java.io.IOException) StringFullResponseHolder(org.apache.druid.java.util.http.client.response.StringFullResponseHolder) ForeverDropRule(org.apache.druid.server.coordinator.rules.ForeverDropRule) ForeverLoadRule(org.apache.druid.server.coordinator.rules.ForeverLoadRule) ArrayList(java.util.ArrayList) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) PeriodLoadRule(org.apache.druid.server.coordinator.rules.PeriodLoadRule)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 ForeverDropRule (org.apache.druid.server.coordinator.rules.ForeverDropRule)2 IOException (java.io.IOException)1 DruidLeaderClient (org.apache.druid.discovery.DruidLeaderClient)1 StringFullResponseHolder (org.apache.druid.java.util.http.client.response.StringFullResponseHolder)1 ForeverLoadRule (org.apache.druid.server.coordinator.rules.ForeverLoadRule)1 IntervalDropRule (org.apache.druid.server.coordinator.rules.IntervalDropRule)1 PeriodLoadRule (org.apache.druid.server.coordinator.rules.PeriodLoadRule)1 Period (org.joda.time.Period)1 Test (org.junit.Test)1