Search in sources :

Example 1 with IndexingServiceClient

use of io.druid.client.indexing.IndexingServiceClient in project druid by druid-io.

the class DatasourcesResourceTest method testDeleteDataSourceSpecificInterval.

@Test
public void testDeleteDataSourceSpecificInterval() throws Exception {
    String interval = "2010-01-01_P1D";
    Interval theInterval = new Interval(interval.replace("_", "/"));
    IndexingServiceClient indexingServiceClient = EasyMock.createStrictMock(IndexingServiceClient.class);
    indexingServiceClient.killSegments("datasource1", theInterval);
    EasyMock.expectLastCall().once();
    EasyMock.replay(indexingServiceClient, server);
    DatasourcesResource datasourcesResource = new DatasourcesResource(inventoryView, null, indexingServiceClient, new AuthConfig());
    Response response = datasourcesResource.deleteDataSourceSpecificInterval("datasource1", interval);
    Assert.assertEquals(200, response.getStatus());
    Assert.assertEquals(null, response.getEntity());
    EasyMock.verify(indexingServiceClient, server);
}
Also used : Response(javax.ws.rs.core.Response) IndexingServiceClient(io.druid.client.indexing.IndexingServiceClient) AuthConfig(io.druid.server.security.AuthConfig) Interval(org.joda.time.Interval) Test(org.junit.Test)

Example 2 with IndexingServiceClient

use of io.druid.client.indexing.IndexingServiceClient in project druid by druid-io.

the class DruidCoordinatorSegmentKillerTest method testFindIntervalForKillTask.

private void testFindIntervalForKillTask(List<Interval> segmentManagerResult, Interval expected) {
    MetadataSegmentManager segmentManager = EasyMock.createMock(MetadataSegmentManager.class);
    EasyMock.expect(segmentManager.getUnusedSegmentIntervals(EasyMock.anyString(), EasyMock.anyObject(Interval.class), EasyMock.anyInt())).andReturn(segmentManagerResult);
    EasyMock.replay(segmentManager);
    IndexingServiceClient indexingServiceClient = EasyMock.createMock(IndexingServiceClient.class);
    DruidCoordinatorSegmentKiller coordinatorSegmentKiller = new DruidCoordinatorSegmentKiller(segmentManager, indexingServiceClient, new TestDruidCoordinatorConfig(null, null, Duration.parse("PT76400S"), new Duration(1), Duration.parse("PT86400S"), Duration.parse("PT86400S"), 1000, null, false, false, Duration.ZERO));
    Assert.assertEquals(expected, coordinatorSegmentKiller.findIntervalForKillTask("test", 10000));
}
Also used : IndexingServiceClient(io.druid.client.indexing.IndexingServiceClient) MetadataSegmentManager(io.druid.metadata.MetadataSegmentManager) TestDruidCoordinatorConfig(io.druid.server.coordinator.TestDruidCoordinatorConfig) Duration(org.joda.time.Duration) Interval(org.joda.time.Interval)

Example 3 with IndexingServiceClient

use of io.druid.client.indexing.IndexingServiceClient in project druid by druid-io.

the class DatasourcesResourceTest method testDeleteDataSource.

@Test
public void testDeleteDataSource() {
    IndexingServiceClient indexingServiceClient = EasyMock.createStrictMock(IndexingServiceClient.class);
    EasyMock.replay(indexingServiceClient, server);
    DatasourcesResource datasourcesResource = new DatasourcesResource(inventoryView, null, indexingServiceClient, new AuthConfig());
    Response response = datasourcesResource.deleteDataSource("datasource", "true", "???");
    Assert.assertEquals(400, response.getStatus());
    Assert.assertNotNull(response.getEntity());
    Assert.assertTrue(response.getEntity().toString().contains("java.lang.IllegalArgumentException"));
    EasyMock.verify(indexingServiceClient, server);
}
Also used : Response(javax.ws.rs.core.Response) IndexingServiceClient(io.druid.client.indexing.IndexingServiceClient) AuthConfig(io.druid.server.security.AuthConfig) Test(org.junit.Test)

Example 4 with IndexingServiceClient

use of io.druid.client.indexing.IndexingServiceClient in project druid by druid-io.

the class DruidCoordinatorSegmentMergerTest method merge.

/**
   * Runs DruidCoordinatorSegmentMerger on a particular set of segments and returns the list of requested merges.
   */
private static List<List<DataSegment>> merge(final Collection<DataSegment> segments) {
    final JacksonConfigManager configManager = EasyMock.createMock(JacksonConfigManager.class);
    EasyMock.expect(configManager.watch(DatasourceWhitelist.CONFIG_KEY, DatasourceWhitelist.class)).andReturn(new AtomicReference<DatasourceWhitelist>(null)).anyTimes();
    EasyMock.replay(configManager);
    final List<List<DataSegment>> retVal = Lists.newArrayList();
    final IndexingServiceClient indexingServiceClient = new IndexingServiceClient(null, null, null) {

        @Override
        public void mergeSegments(List<DataSegment> segmentsToMerge) {
            retVal.add(segmentsToMerge);
        }
    };
    final DruidCoordinatorSegmentMerger merger = new DruidCoordinatorSegmentMerger(indexingServiceClient, configManager);
    final DruidCoordinatorRuntimeParams params = DruidCoordinatorRuntimeParams.newBuilder().withAvailableSegments(ImmutableSet.copyOf(segments)).withDynamicConfigs(new CoordinatorDynamicConfig.Builder().withMergeBytesLimit(mergeBytesLimit).withMergeSegmentsLimit(mergeSegmentsLimit).build()).withEmitter(EasyMock.createMock(ServiceEmitter.class)).build();
    merger.run(params);
    return retVal;
}
Also used : IndexingServiceClient(io.druid.client.indexing.IndexingServiceClient) DruidCoordinatorSegmentMerger(io.druid.server.coordinator.helper.DruidCoordinatorSegmentMerger) JacksonConfigManager(io.druid.common.config.JacksonConfigManager) AtomicReference(java.util.concurrent.atomic.AtomicReference) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList)

Aggregations

IndexingServiceClient (io.druid.client.indexing.IndexingServiceClient)4 AuthConfig (io.druid.server.security.AuthConfig)2 Response (javax.ws.rs.core.Response)2 Interval (org.joda.time.Interval)2 Test (org.junit.Test)2 ImmutableList (com.google.common.collect.ImmutableList)1 JacksonConfigManager (io.druid.common.config.JacksonConfigManager)1 MetadataSegmentManager (io.druid.metadata.MetadataSegmentManager)1 TestDruidCoordinatorConfig (io.druid.server.coordinator.TestDruidCoordinatorConfig)1 DruidCoordinatorSegmentMerger (io.druid.server.coordinator.helper.DruidCoordinatorSegmentMerger)1 List (java.util.List)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Duration (org.joda.time.Duration)1