overlord check task whether is present before get lock (#6308)

This commit is contained in:
dyf6372 2018-09-29 07:57:40 +08:00 committed by Jihoon Son
parent 122caec7b1
commit 63ba7f7bec
1 changed files with 5 additions and 0 deletions

View File

@ -38,6 +38,7 @@ import org.apache.druid.indexing.common.actions.TaskActionClientFactory;
import org.apache.druid.indexing.common.task.IndexTaskUtils;
import org.apache.druid.indexing.common.task.Task;
import org.apache.druid.indexing.overlord.config.TaskQueueConfig;
import org.apache.druid.java.util.common.StringUtils;
import org.apache.druid.java.util.common.concurrent.ScheduledExecutors;
import org.apache.druid.java.util.common.lifecycle.LifecycleStart;
import org.apache.druid.java.util.common.lifecycle.LifecycleStop;
@ -312,6 +313,10 @@ public class TaskQueue
*/
public boolean add(final Task task) throws EntryExistsException
{
if (taskStorage.getTask(task.getId()).isPresent()) {
throw new EntryExistsException(StringUtils.format("Task %s is already exists", task.getId()));
}
giant.lock();
try {