Merge pull request #2572 from gianm/fix-rit-taskresource

Fix default TaskResource for RealtimeIndexTasks.
This commit is contained in:
Fangjin Yang 2016-03-02 10:20:27 -08:00
commit 80d954578d
3 changed files with 19 additions and 6 deletions

View File

@ -56,19 +56,25 @@ public abstract class AbstractTask implements Task
protected AbstractTask(String id, String dataSource, Map<String, Object> context)
{
this(id, id, new TaskResource(id, 1), dataSource, context);
this(id, null, null, dataSource, context);
}
protected AbstractTask(String id, String groupId, String dataSource, Map<String, Object> context)
{
this(id, groupId, new TaskResource(id, 1), dataSource, context);
this(id, groupId, null, dataSource, context);
}
protected AbstractTask(String id, String groupId, TaskResource taskResource, String dataSource, Map<String, Object> context)
protected AbstractTask(
String id,
String groupId,
TaskResource taskResource,
String dataSource,
Map<String, Object> context
)
{
this.id = Preconditions.checkNotNull(id, "id");
this.groupId = Preconditions.checkNotNull(groupId, "groupId");
this.taskResource = Preconditions.checkNotNull(taskResource, "resource");
this.groupId = groupId == null ? id : groupId;
this.taskResource = taskResource == null ? new TaskResource(id, 1) : taskResource;
this.dataSource = Preconditions.checkNotNull(dataSource, "dataSource");
this.context = context;
}

View File

@ -142,7 +142,7 @@ public class RealtimeIndexTask extends AbstractTask
super(
id == null ? makeTaskId(fireDepartment) : id,
String.format("index_realtime_%s", makeDatasource(fireDepartment)),
taskResource == null ? new TaskResource(makeTaskId(fireDepartment), 1) : taskResource,
taskResource,
makeDatasource(fireDepartment),
context
);

View File

@ -274,6 +274,13 @@ public class RealtimeIndexTaskTest
);
}
@Test(timeout = 60_000L)
public void testDefaultResource() throws Exception
{
final RealtimeIndexTask task = makeRealtimeTask(null);
Assert.assertEquals(task.getId(), task.getTaskResource().getAvailabilityGroup());
}
@Test(timeout = 60_000L)
public void testBasics() throws Exception
{