Search in sources :

Example 6 with CoordinatorDynamicConfig

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

the class CoordinatorDynamicConfigTest method testConstructorWithNullsShouldKillUnusedSegmentsInAllDataSources.

@Test
public void testConstructorWithNullsShouldKillUnusedSegmentsInAllDataSources() {
    CoordinatorDynamicConfig config = new CoordinatorDynamicConfig(1, 1, 1, 1, null, false, 1, 2, 10, true, null, null, null, ImmutableSet.of("host1"), 5, true, true, 10);
    Assert.assertTrue(config.isKillUnusedSegmentsInAllDataSources());
    Assert.assertTrue(config.getSpecificDataSourcesToKillUnusedSegmentsIn().isEmpty());
}
Also used : CoordinatorDynamicConfig(org.apache.druid.server.coordinator.CoordinatorDynamicConfig) Test(org.junit.Test)

Example 7 with CoordinatorDynamicConfig

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

the class CoordinatorResourceTestClient method getDynamicConfig.

public CoordinatorDynamicConfig getDynamicConfig() {
    String url = StringUtils.format("%sconfig", getCoordinatorURL());
    CoordinatorDynamicConfig config;
    try {
        StatusResponseHolder response = makeRequest(HttpMethod.GET, url);
        config = jsonMapper.readValue(response.getContent(), CoordinatorDynamicConfig.class);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return config;
}
Also used : CoordinatorDynamicConfig(org.apache.druid.server.coordinator.CoordinatorDynamicConfig) StatusResponseHolder(org.apache.druid.java.util.http.client.response.StatusResponseHolder)

Example 8 with CoordinatorDynamicConfig

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

the class CoordinatorDynamicConfigsResource method setDynamicConfigs.

// default value is used for backwards compatibility
@POST
@Consumes(MediaType.APPLICATION_JSON)
public Response setDynamicConfigs(final CoordinatorDynamicConfig.Builder dynamicConfigBuilder, @HeaderParam(AuditManager.X_DRUID_AUTHOR) @DefaultValue("") final String author, @HeaderParam(AuditManager.X_DRUID_COMMENT) @DefaultValue("") final String comment, @Context HttpServletRequest req) {
    try {
        CoordinatorDynamicConfig current = CoordinatorDynamicConfig.current(manager);
        final SetResult setResult = manager.set(CoordinatorDynamicConfig.CONFIG_KEY, dynamicConfigBuilder.build(current), new AuditInfo(author, comment, req.getRemoteAddr()));
        if (setResult.isOk()) {
            return Response.ok().build();
        } else {
            return Response.status(Response.Status.BAD_REQUEST).entity(ServletResourceUtils.sanitizeException(setResult.getException())).build();
        }
    } catch (IllegalArgumentException e) {
        return Response.status(Response.Status.BAD_REQUEST).entity(ServletResourceUtils.sanitizeException(e)).build();
    }
}
Also used : AuditInfo(org.apache.druid.audit.AuditInfo) CoordinatorDynamicConfig(org.apache.druid.server.coordinator.CoordinatorDynamicConfig) SetResult(org.apache.druid.common.config.ConfigManager.SetResult) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes)

Example 9 with CoordinatorDynamicConfig

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

the class CoordinatorDynamicConfigTest method testSerdeWithStringinKillDataSourceWhitelist.

@Test
public void testSerdeWithStringinKillDataSourceWhitelist() throws Exception {
    String jsonStr = "{\n" + "  \"millisToWaitBeforeDeleting\": 1,\n" + "  \"mergeBytesLimit\": 1,\n" + "  \"mergeSegmentsLimit\" : 1,\n" + "  \"maxSegmentsToMove\": 1,\n" + "  \"percentOfSegmentsToConsiderPerMove\": 1,\n" + "  \"replicantLifetime\": 1,\n" + "  \"replicationThrottleLimit\": 1,\n" + "  \"balancerComputeThreads\": 2, \n" + "  \"emitBalancingStats\": true,\n" + "  \"killDataSourceWhitelist\": \"test1, test2\", \n" + "  \"maxSegmentsInNodeLoadingQueue\": 1\n" + "}\n";
    CoordinatorDynamicConfig actual = mapper.readValue(mapper.writeValueAsString(mapper.readValue(jsonStr, CoordinatorDynamicConfig.class)), CoordinatorDynamicConfig.class);
    assertConfig(actual, 1, 1, 1, 1, 1, 1, 1, 2, true, ImmutableSet.of("test1", "test2"), false, 1, ImmutableSet.of(), 0, false, false, Integer.MAX_VALUE);
}
Also used : CoordinatorDynamicConfig(org.apache.druid.server.coordinator.CoordinatorDynamicConfig) Test(org.junit.Test)

Example 10 with CoordinatorDynamicConfig

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

the class CoordinatorDynamicConfigTest method testSerde.

@Test
public void testSerde() throws Exception {
    String jsonStr = "{\n" + "  \"millisToWaitBeforeDeleting\": 1,\n" + "  \"mergeBytesLimit\": 1,\n" + "  \"mergeSegmentsLimit\" : 1,\n" + "  \"maxSegmentsToMove\": 1,\n" + "  \"percentOfSegmentsToConsiderPerMove\": 1,\n" + "  \"replicantLifetime\": 1,\n" + "  \"replicationThrottleLimit\": 1,\n" + "  \"balancerComputeThreads\": 2, \n" + "  \"emitBalancingStats\": true,\n" + "  \"killDataSourceWhitelist\": [\"test1\",\"test2\"],\n" + "  \"maxSegmentsInNodeLoadingQueue\": 1,\n" + "  \"decommissioningNodes\": [\"host1\", \"host2\"],\n" + "  \"decommissioningMaxPercentOfMaxSegmentsToMove\": 9,\n" + "  \"pauseCoordination\": false,\n" + "  \"replicateAfterLoadTimeout\": false,\n" + "  \"maxNonPrimaryReplicantsToLoad\": 2147483647\n" + "}\n";
    CoordinatorDynamicConfig actual = mapper.readValue(mapper.writeValueAsString(mapper.readValue(jsonStr, CoordinatorDynamicConfig.class)), CoordinatorDynamicConfig.class);
    ImmutableSet<String> decommissioning = ImmutableSet.of("host1", "host2");
    ImmutableSet<String> whitelist = ImmutableSet.of("test1", "test2");
    assertConfig(actual, 1, 1, 1, 1, 1, 1, 1, 2, true, whitelist, false, 1, decommissioning, 9, false, false, Integer.MAX_VALUE);
    actual = CoordinatorDynamicConfig.builder().withDecommissioningNodes(ImmutableSet.of("host1")).build(actual);
    assertConfig(actual, 1, 1, 1, 1, 1, 1, 1, 2, true, whitelist, false, 1, ImmutableSet.of("host1"), 9, false, false, Integer.MAX_VALUE);
    actual = CoordinatorDynamicConfig.builder().withDecommissioningMaxPercentOfMaxSegmentsToMove(5).build(actual);
    assertConfig(actual, 1, 1, 1, 1, 1, 1, 1, 2, true, whitelist, false, 1, ImmutableSet.of("host1"), 5, false, false, Integer.MAX_VALUE);
    actual = CoordinatorDynamicConfig.builder().withPauseCoordination(true).build(actual);
    assertConfig(actual, 1, 1, 1, 1, 1, 1, 1, 2, true, whitelist, false, 1, ImmutableSet.of("host1"), 5, true, false, Integer.MAX_VALUE);
    actual = CoordinatorDynamicConfig.builder().withPercentOfSegmentsToConsiderPerMove(10).build(actual);
    assertConfig(actual, 1, 1, 1, 1, 10, 1, 1, 2, true, whitelist, false, 1, ImmutableSet.of("host1"), 5, true, false, Integer.MAX_VALUE);
    actual = CoordinatorDynamicConfig.builder().withReplicateAfterLoadTimeout(true).build(actual);
    assertConfig(actual, 1, 1, 1, 1, 10, 1, 1, 2, true, whitelist, false, 1, ImmutableSet.of("host1"), 5, true, true, Integer.MAX_VALUE);
    actual = CoordinatorDynamicConfig.builder().withMaxNonPrimaryReplicantsToLoad(10).build(actual);
    assertConfig(actual, 1, 1, 1, 1, 10, 1, 1, 2, true, whitelist, false, 1, ImmutableSet.of("host1"), 5, true, true, 10);
}
Also used : CoordinatorDynamicConfig(org.apache.druid.server.coordinator.CoordinatorDynamicConfig) Test(org.junit.Test)

Aggregations

CoordinatorDynamicConfig (org.apache.druid.server.coordinator.CoordinatorDynamicConfig)14 Test (org.junit.Test)12 Consumes (javax.ws.rs.Consumes)1 POST (javax.ws.rs.POST)1 AuditInfo (org.apache.druid.audit.AuditInfo)1 SetResult (org.apache.druid.common.config.ConfigManager.SetResult)1 StatusResponseHolder (org.apache.druid.java.util.http.client.response.StatusResponseHolder)1