Merge pull request #1413 from metamx/TaskUtilIdCommonizer

Move TaskUtils.makeId to AbstractTask
This commit is contained in:
Himanshu 2015-06-03 15:54:22 -05:00
commit c096c21b6a
6 changed files with 17 additions and 43 deletions

View File

@ -28,6 +28,8 @@ import io.druid.indexing.common.TaskToolbox;
import io.druid.indexing.common.actions.LockListAction;
import io.druid.query.Query;
import io.druid.query.QueryRunner;
import org.joda.time.DateTime;
import org.joda.time.Interval;
import java.io.IOException;
@ -65,6 +67,17 @@ public abstract class AbstractTask implements Task
this.dataSource = Preconditions.checkNotNull(dataSource, "dataSource");
}
public static String makeId(String id, final String typeName, String dataSource, Interval interval)
{
return id != null ? id : joinId(
typeName,
dataSource,
interval.getStart(),
interval.getEnd(),
new DateTime().toString()
);
}
@JsonProperty
@Override
public String getId()

View File

@ -20,7 +20,6 @@ package io.druid.indexing.common.task;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.metamx.common.ISE;
import com.metamx.common.logger.Logger;
import io.druid.indexing.common.TaskLock;
@ -44,7 +43,7 @@ public class ArchiveTask extends AbstractFixedIntervalTask
)
{
super(
TaskUtils.makeId(id, "archive", dataSource, interval),
makeId(id, "archive", dataSource, interval),
dataSource,
interval
);

View File

@ -47,7 +47,7 @@ public class KillTask extends AbstractFixedIntervalTask
)
{
super(
TaskUtils.makeId(id, "kill", dataSource, interval),
makeId(id, "kill", dataSource, interval),
dataSource,
interval
);

View File

@ -49,7 +49,7 @@ public class MoveTask extends AbstractFixedIntervalTask
)
{
super(
TaskUtils.makeId(id, "move", dataSource, interval),
makeId(id, "move", dataSource, interval),
dataSource,
interval
);

View File

@ -44,7 +44,7 @@ public class RestoreTask extends AbstractFixedIntervalTask
)
{
super(
TaskUtils.makeId(id, "restore", dataSource, interval),
makeId(id, "restore", dataSource, interval),
dataSource,
interval
);

View File

@ -1,38 +0,0 @@
/*
* Druid - a distributed column store.
* Copyright 2012 - 2015 Metamarkets Group Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.druid.indexing.common.task;
import org.joda.time.DateTime;
import org.joda.time.Interval;
/**
*/
public class TaskUtils
{
public static String makeId(String id, final String typeName, String dataSource, Interval interval)
{
return id != null ? id : String.format(
"%s_%s_%s_%s_%s",
typeName,
dataSource,
interval.getStart(),
interval.getEnd(),
new DateTime().toString()
);
}
}