Search in sources :

Example 6 with TaskInfo

use of org.apache.druid.indexer.TaskInfo in project druid by druid-io.

the class OverlordResourceTest method testShutdownAllTasks.

@Test
public void testShutdownAllTasks() {
    // This is disabled since OverlordResource.shutdownTasksForDataSource is annotated with DatasourceResourceFilter
    // This should be fixed in https://github.com/apache/druid/issues/6685.
    // expectAuthorizationTokenCheck();
    TaskQueue mockQueue = EasyMock.createMock(TaskQueue.class);
    EasyMock.expect(taskMaster.isLeader()).andReturn(true).anyTimes();
    EasyMock.expect(taskMaster.getTaskRunner()).andReturn(Optional.of(taskRunner)).anyTimes();
    EasyMock.expect(taskMaster.getTaskQueue()).andReturn(Optional.of(mockQueue)).anyTimes();
    EasyMock.expect(taskStorageQueryAdapter.getActiveTaskInfo("datasource")).andStubReturn(ImmutableList.of(new TaskInfo("id_1", DateTime.now(ISOChronology.getInstanceUTC()), TaskStatus.success("id_1"), "datasource", getTaskWithIdAndDatasource("id_1", "datasource")), new TaskInfo("id_2", DateTime.now(ISOChronology.getInstanceUTC()), TaskStatus.success("id_2"), "datasource", getTaskWithIdAndDatasource("id_2", "datasource"))));
    mockQueue.shutdown("id_1", "Shutdown request from user");
    EasyMock.expectLastCall();
    mockQueue.shutdown("id_2", "Shutdown request from user");
    EasyMock.expectLastCall();
    EasyMock.replay(taskRunner, taskMaster, taskStorageQueryAdapter, indexerMetadataStorageAdapter, req, mockQueue, workerTaskRunnerQueryAdapter);
    final Map<String, Integer> response = (Map<String, Integer>) overlordResource.shutdownTasksForDataSource("datasource").getEntity();
    Assert.assertEquals("datasource", response.get("dataSource"));
}
Also used : TaskInfo(org.apache.druid.indexer.TaskInfo) TaskQueue(org.apache.druid.indexing.overlord.TaskQueue) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) Test(org.junit.Test)

Example 7 with TaskInfo

use of org.apache.druid.indexer.TaskInfo in project druid by druid-io.

the class OverlordResourceTest method testGetNullCompleteTask.

@Test
public void testGetNullCompleteTask() {
    expectAuthorizationTokenCheck();
    EasyMock.expect(taskStorageQueryAdapter.getCompletedTaskInfoByCreatedTimeDuration(null, null, null)).andStubReturn(ImmutableList.of(new TaskInfo("id_1", DateTime.now(ISOChronology.getInstanceUTC()), TaskStatus.success("id_1"), "allow", null), new TaskInfo("id_2", DateTime.now(ISOChronology.getInstanceUTC()), TaskStatus.success("id_2"), "deny", getTaskWithIdAndDatasource("id_2", "deny")), new TaskInfo("id_3", DateTime.now(ISOChronology.getInstanceUTC()), TaskStatus.success("id_3"), "allow", getTaskWithIdAndDatasource("id_3", "allow"))));
    EasyMock.replay(taskRunner, taskMaster, taskStorageQueryAdapter, indexerMetadataStorageAdapter, req, workerTaskRunnerQueryAdapter);
    List<TaskStatusPlus> responseObjects = (List<TaskStatusPlus>) overlordResource.getTasks("complete", null, null, null, null, req).getEntity();
    Assert.assertEquals(2, responseObjects.size());
    Assert.assertEquals("id_1", responseObjects.get(0).getId());
    TaskStatusPlus tsp = responseObjects.get(0);
    Assert.assertEquals(null, tsp.getType());
    Assert.assertTrue("DataSource Check", "allow".equals(responseObjects.get(0).getDataSource()));
}
Also used : TaskInfo(org.apache.druid.indexer.TaskInfo) TaskStatusPlus(org.apache.druid.indexer.TaskStatusPlus) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) Test(org.junit.Test)

Example 8 with TaskInfo

use of org.apache.druid.indexer.TaskInfo in project druid by druid-io.

the class OverlordResourceTest method testGetTasksFilterCompleteStateWithInterval.

@Test
public void testGetTasksFilterCompleteStateWithInterval() {
    expectAuthorizationTokenCheck();
    List<String> tasksIds = ImmutableList.of("id_1", "id_2", "id_3");
    Duration duration = new Period("PT86400S").toStandardDuration();
    EasyMock.expect(taskStorageQueryAdapter.getCompletedTaskInfoByCreatedTimeDuration(null, duration, null)).andStubReturn(ImmutableList.of(new TaskInfo("id_1", DateTime.now(ISOChronology.getInstanceUTC()), TaskStatus.success("id_1"), "deny", getTaskWithIdAndDatasource("id_1", "deny")), new TaskInfo("id_2", DateTime.now(ISOChronology.getInstanceUTC()), TaskStatus.success("id_2"), "allow", getTaskWithIdAndDatasource("id_2", "allow")), new TaskInfo("id_3", DateTime.now(ISOChronology.getInstanceUTC()), TaskStatus.success("id_3"), "allow", getTaskWithIdAndDatasource("id_3", "allow"))));
    EasyMock.replay(taskRunner, taskMaster, taskStorageQueryAdapter, indexerMetadataStorageAdapter, req, workerTaskRunnerQueryAdapter);
    String interval = "2010-01-01_P1D";
    List<TaskStatusPlus> responseObjects = (List<TaskStatusPlus>) overlordResource.getTasks("complete", null, interval, null, null, req).getEntity();
    Assert.assertEquals(2, responseObjects.size());
    Assert.assertEquals("id_2", responseObjects.get(0).getId());
    Assert.assertTrue("DataSource Check", "allow".equals(responseObjects.get(0).getDataSource()));
}
Also used : TaskInfo(org.apache.druid.indexer.TaskInfo) Period(org.joda.time.Period) TaskStatusPlus(org.apache.druid.indexer.TaskStatusPlus) Duration(org.joda.time.Duration) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) Test(org.junit.Test)

Aggregations

TaskInfo (org.apache.druid.indexer.TaskInfo)8 Test (org.junit.Test)6 ImmutableList (com.google.common.collect.ImmutableList)4 TaskStatusPlus (org.apache.druid.indexer.TaskStatusPlus)4 List (java.util.List)3 Interval (org.joda.time.Interval)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 Map (java.util.Map)2 Response (javax.ws.rs.core.Response)2 TaskStatus (org.apache.druid.indexer.TaskStatus)2 Task (org.apache.druid.indexing.common.task.Task)2 TaskQueue (org.apache.druid.indexing.overlord.TaskQueue)2 Duration (org.joda.time.Duration)2 Function (com.google.common.base.Function)1 Optional (com.google.common.base.Optional)1 Lists (com.google.common.collect.Lists)1 Maps (com.google.common.collect.Maps)1 ByteSource (com.google.common.io.ByteSource)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 SettableFuture (com.google.common.util.concurrent.SettableFuture)1