From 736a2ab7c132b85f9ee541b2eb531c5eeababf46 Mon Sep 17 00:00:00 2001 From: Alberic Liu Date: Mon, 29 Apr 2024 14:42:55 -0700 Subject: [PATCH] update code style for task type (#16343) * update code style for task type * address the comments --- .../AppenderatorDriverRealtimeIndexTask.java | 3 ++- .../indexing/common/task/ArchiveTask.java | 3 ++- .../indexing/common/task/CompactionTask.java | 3 +-- .../indexing/common/task/HadoopIndexTask.java | 4 ++-- .../druid/indexing/common/task/IndexTask.java | 1 - .../druid/indexing/common/task/MoveTask.java | 3 ++- .../druid/indexing/common/task/NoopTask.java | 3 ++- .../common/task/RealtimeIndexTask.java | 3 ++- .../indexing/common/task/RestoreTask.java | 3 ++- .../druid/indexing/common/task/Task.java | 18 +++++++++--------- 10 files changed, 24 insertions(+), 20 deletions(-) diff --git a/indexing-service/src/main/java/org/apache/druid/indexing/common/task/AppenderatorDriverRealtimeIndexTask.java b/indexing-service/src/main/java/org/apache/druid/indexing/common/task/AppenderatorDriverRealtimeIndexTask.java index 1230711e57b2..d97caaec874f 100644 --- a/indexing-service/src/main/java/org/apache/druid/indexing/common/task/AppenderatorDriverRealtimeIndexTask.java +++ b/indexing-service/src/main/java/org/apache/druid/indexing/common/task/AppenderatorDriverRealtimeIndexTask.java @@ -122,6 +122,7 @@ public class AppenderatorDriverRealtimeIndexTask extends AbstractTask implements ChatHandler, PendingSegmentAllocatingTask { + public static final String TYPE = "index_realtime_appenderator"; private static final String CTX_KEY_LOOKUP_TIER = "lookupTier"; private static final EmittingLogger log = new EmittingLogger(RealtimeIndexTask.class); @@ -217,7 +218,7 @@ public int getPriority() @Override public String getType() { - return "index_realtime_appenderator"; + return TYPE; } @Override diff --git a/indexing-service/src/main/java/org/apache/druid/indexing/common/task/ArchiveTask.java b/indexing-service/src/main/java/org/apache/druid/indexing/common/task/ArchiveTask.java index 9104e2cfb05b..46303806dabe 100644 --- a/indexing-service/src/main/java/org/apache/druid/indexing/common/task/ArchiveTask.java +++ b/indexing-service/src/main/java/org/apache/druid/indexing/common/task/ArchiveTask.java @@ -40,6 +40,7 @@ public class ArchiveTask extends AbstractFixedIntervalTask { + public static final String TYPE = "archive"; private static final Logger log = new Logger(ArchiveTask.class); public ArchiveTask( @@ -60,7 +61,7 @@ public ArchiveTask( @Override public String getType() { - return "archive"; + return TYPE; } @Nonnull diff --git a/indexing-service/src/main/java/org/apache/druid/indexing/common/task/CompactionTask.java b/indexing-service/src/main/java/org/apache/druid/indexing/common/task/CompactionTask.java index f5aec08c3062..833bcdd2fed9 100644 --- a/indexing-service/src/main/java/org/apache/druid/indexing/common/task/CompactionTask.java +++ b/indexing-service/src/main/java/org/apache/druid/indexing/common/task/CompactionTask.java @@ -129,6 +129,7 @@ */ public class CompactionTask extends AbstractBatchIndexTask implements PendingSegmentAllocatingTask { + public static final String TYPE = "compact"; private static final Logger log = new Logger(CompactionTask.class); private static final Clock UTC_CLOCK = Clock.systemUTC(); @@ -145,8 +146,6 @@ public class CompactionTask extends AbstractBatchIndexTask implements PendingSeg */ public static final String CTX_KEY_APPENDERATOR_TRACKING_TASK_ID = "appenderatorTrackingTaskId"; - private static final String TYPE = "compact"; - private static final boolean STORE_COMPACTION_STATE = true; static { diff --git a/indexing-service/src/main/java/org/apache/druid/indexing/common/task/HadoopIndexTask.java b/indexing-service/src/main/java/org/apache/druid/indexing/common/task/HadoopIndexTask.java index 4a31be24dd2e..bc9d5aca2b65 100644 --- a/indexing-service/src/main/java/org/apache/druid/indexing/common/task/HadoopIndexTask.java +++ b/indexing-service/src/main/java/org/apache/druid/indexing/common/task/HadoopIndexTask.java @@ -94,10 +94,10 @@ public class HadoopIndexTask extends HadoopTask implements ChatHandler { + public static final String TYPE = "index_hadoop"; public static final String INPUT_SOURCE_TYPE = "hadoop"; private static final Logger log = new Logger(HadoopIndexTask.class); private static final String HADOOP_JOB_ID_FILENAME = "mapReduceJobId.json"; - private static final String TYPE = "index_hadoop"; private TaskConfig taskConfig = null; private static String getTheDataSource(HadoopIngestionSpec spec) @@ -192,7 +192,7 @@ public HadoopIndexTask( @Override public String getType() { - return "index_hadoop"; + return TYPE; } @Nonnull diff --git a/indexing-service/src/main/java/org/apache/druid/indexing/common/task/IndexTask.java b/indexing-service/src/main/java/org/apache/druid/indexing/common/task/IndexTask.java index 7603fe9542ba..14e37cc81c5d 100644 --- a/indexing-service/src/main/java/org/apache/druid/indexing/common/task/IndexTask.java +++ b/indexing-service/src/main/java/org/apache/druid/indexing/common/task/IndexTask.java @@ -141,7 +141,6 @@ public class IndexTask extends AbstractBatchIndexTask implements ChatHandler, PendingSegmentAllocatingTask { - public static final HashFunction HASH_FUNCTION = Hashing.murmur3_128(); public static final String TYPE = "index"; diff --git a/indexing-service/src/main/java/org/apache/druid/indexing/common/task/MoveTask.java b/indexing-service/src/main/java/org/apache/druid/indexing/common/task/MoveTask.java index e02af66e0465..8762aa91b4cc 100644 --- a/indexing-service/src/main/java/org/apache/druid/indexing/common/task/MoveTask.java +++ b/indexing-service/src/main/java/org/apache/druid/indexing/common/task/MoveTask.java @@ -41,6 +41,7 @@ public class MoveTask extends AbstractFixedIntervalTask { + public static final String TYPE = "move"; private static final Logger log = new Logger(MoveTask.class); private final Map targetLoadSpec; @@ -68,7 +69,7 @@ public MoveTask( @Override public String getType() { - return "move"; + return TYPE; } @Nonnull diff --git a/indexing-service/src/main/java/org/apache/druid/indexing/common/task/NoopTask.java b/indexing-service/src/main/java/org/apache/druid/indexing/common/task/NoopTask.java index 9d91542ebf0b..7887ab081119 100644 --- a/indexing-service/src/main/java/org/apache/druid/indexing/common/task/NoopTask.java +++ b/indexing-service/src/main/java/org/apache/druid/indexing/common/task/NoopTask.java @@ -41,6 +41,7 @@ */ public class NoopTask extends AbstractTask implements PendingSegmentAllocatingTask { + public static final String TYPE = "noop"; private static final int DEFAULT_RUN_TIME = 2500; @JsonIgnore @@ -70,7 +71,7 @@ public NoopTask( @Override public String getType() { - return "noop"; + return TYPE; } @Nonnull diff --git a/indexing-service/src/main/java/org/apache/druid/indexing/common/task/RealtimeIndexTask.java b/indexing-service/src/main/java/org/apache/druid/indexing/common/task/RealtimeIndexTask.java index a32ef91192bb..443b72ec21ab 100644 --- a/indexing-service/src/main/java/org/apache/druid/indexing/common/task/RealtimeIndexTask.java +++ b/indexing-service/src/main/java/org/apache/druid/indexing/common/task/RealtimeIndexTask.java @@ -85,6 +85,7 @@ @Deprecated public class RealtimeIndexTask extends AbstractTask { + public static final String TYPE = "index_realtime"; public static final String CTX_KEY_LOOKUP_TIER = "lookupTier"; private static final EmittingLogger log = new EmittingLogger(RealtimeIndexTask.class); @@ -180,7 +181,7 @@ public int getPriority() @Override public String getType() { - return "index_realtime"; + return TYPE; } @Override diff --git a/indexing-service/src/main/java/org/apache/druid/indexing/common/task/RestoreTask.java b/indexing-service/src/main/java/org/apache/druid/indexing/common/task/RestoreTask.java index e3a0ecf633ee..3b0f5d6c622c 100644 --- a/indexing-service/src/main/java/org/apache/druid/indexing/common/task/RestoreTask.java +++ b/indexing-service/src/main/java/org/apache/druid/indexing/common/task/RestoreTask.java @@ -41,6 +41,7 @@ public class RestoreTask extends AbstractFixedIntervalTask { + public static final String TYPE = "restore"; private static final Logger log = new Logger(RestoreTask.class); public RestoreTask( @@ -61,7 +62,7 @@ public RestoreTask( @Override public String getType() { - return "restore"; + return TYPE; } @Nonnull diff --git a/indexing-service/src/main/java/org/apache/druid/indexing/common/task/Task.java b/indexing-service/src/main/java/org/apache/druid/indexing/common/task/Task.java index 7556908023a4..cdf7cea7e3f2 100644 --- a/indexing-service/src/main/java/org/apache/druid/indexing/common/task/Task.java +++ b/indexing-service/src/main/java/org/apache/druid/indexing/common/task/Task.java @@ -67,10 +67,10 @@ @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") @JsonSubTypes(value = { @Type(name = KillUnusedSegmentsTask.TYPE, value = KillUnusedSegmentsTask.class), - @Type(name = "move", value = MoveTask.class), - @Type(name = "archive", value = ArchiveTask.class), - @Type(name = "restore", value = RestoreTask.class), - @Type(name = "index", value = IndexTask.class), + @Type(name = MoveTask.TYPE, value = MoveTask.class), + @Type(name = ArchiveTask.TYPE, value = ArchiveTask.class), + @Type(name = RestoreTask.TYPE, value = RestoreTask.class), + @Type(name = IndexTask.TYPE, value = IndexTask.class), @Type(name = ParallelIndexSupervisorTask.TYPE, value = ParallelIndexSupervisorTask.class), @Type(name = SinglePhaseSubTask.TYPE, value = SinglePhaseSubTask.class), // for backward compatibility @@ -80,11 +80,11 @@ @Type(name = PartialRangeSegmentGenerateTask.TYPE, value = PartialRangeSegmentGenerateTask.class), @Type(name = PartialDimensionDistributionTask.TYPE, value = PartialDimensionDistributionTask.class), @Type(name = PartialGenericSegmentMergeTask.TYPE, value = PartialGenericSegmentMergeTask.class), - @Type(name = "index_hadoop", value = HadoopIndexTask.class), - @Type(name = "index_realtime", value = RealtimeIndexTask.class), - @Type(name = "index_realtime_appenderator", value = AppenderatorDriverRealtimeIndexTask.class), - @Type(name = "noop", value = NoopTask.class), - @Type(name = "compact", value = CompactionTask.class) + @Type(name = HadoopIndexTask.TYPE, value = HadoopIndexTask.class), + @Type(name = RealtimeIndexTask.TYPE, value = RealtimeIndexTask.class), + @Type(name = AppenderatorDriverRealtimeIndexTask.TYPE, value = AppenderatorDriverRealtimeIndexTask.class), + @Type(name = NoopTask.TYPE, value = NoopTask.class), + @Type(name = CompactionTask.TYPE, value = CompactionTask.class) }) public interface Task {