weizhengte commented on code in PR #8860:
URL: https://github.com/apache/incubator-doris/pull/8860#discussion_r855814866


##########
fe/fe-core/src/main/java/org/apache/doris/statistics/StatisticsTask.java:
##########
@@ -33,23 +37,108 @@
  * @granularityDesc: StatsGranularity=partition
  */
 public class StatisticsTask implements Callable<StatisticsTaskResult> {
+    protected static final Logger LOG = 
LogManager.getLogger(StatisticsTask.class);
+
+    public enum TaskState {
+        PENDING,
+        RUNNING,
+        FINISHED,
+        FAILED
+    }
+
     protected long id = Catalog.getCurrentCatalog().getNextId();;
     protected long jobId;
     protected StatsGranularityDesc granularityDesc;
     protected StatsCategoryDesc categoryDesc;
     protected List<StatsType> statsTypeList;
+    protected TaskState taskState = TaskState.PENDING;
 
-    public StatisticsTask(long jobId, StatsGranularityDesc granularityDesc,
-                          StatsCategoryDesc categoryDesc, List<StatsType> 
statsTypeList) {
+    protected final long createTime = System.currentTimeMillis();
+    protected long startTime = -1L;
+    protected long finishTime = -1L;
+
+    public StatisticsTask(long jobId,
+                          StatsGranularityDesc granularityDesc,
+                          StatsCategoryDesc categoryDesc,
+                          List<StatsType> statsTypeList) {
         this.jobId = jobId;
         this.granularityDesc = granularityDesc;
         this.categoryDesc = categoryDesc;
         this.statsTypeList = statsTypeList;
     }
 
+    public long getId() {
+        return this.id;
+    }
+
+    public void setId(long id) {
+        this.id = id;
+    }
+
+    public long getJobId() {
+        return this.jobId;
+    }
+
+    public StatsGranularityDesc getGranularityDesc() {
+        return this.granularityDesc;
+    }
+
+    public StatsCategoryDesc getCategoryDesc() {
+        return this.categoryDesc;
+    }
+
+    public List<StatsType> getStatsTypeList() {
+        return this.statsTypeList;
+    }
+
+    public TaskState getTaskState() {
+        return this.taskState;
+    }
+
+    public long getCreateTime() {
+        return this.createTime;
+    }
+
+    public long getStartTime() {
+        return this.startTime;
+    }
+
+    public void setStartTime(long startTime) {
+        this.startTime = startTime;
+    }
+
+    public long getFinishTime() {
+        return this.finishTime;
+    }
+
+    public void setFinishTime(long finishTime) {
+        this.finishTime = finishTime;
+    }
+
     @Override
     public StatisticsTaskResult call() throws Exception {
-        // TODO
+        LOG.warn("execute invalid statistics task.");
         return null;
     }
+
+    public synchronized void updateTaskState(StatisticsTask.TaskState 
taskState) {
+        // PENDING -> RUNNING/FAILED
+        if (this.taskState == TaskState.PENDING) {
+            if (taskState == TaskState.RUNNING) {
+                this.taskState = TaskState.RUNNING;
+            } else if (taskState == TaskState.FAILED) {
+                this.taskState = TaskState.FAILED;
+            }
+            return;
+        }
+
+        // RUNNING -> FINISHED/FAILED
+        if (this.taskState == TaskState.RUNNING) {
+            if (taskState == TaskState.FINISHED) {
+                this.taskState = TaskState.FINISHED;
+            } else if (taskState == TaskState.FAILED) {
+                this.taskState = TaskState.FAILED;
+            }
+        }
+    }

Review Comment:
   ok



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to