jihoonson commented on a change in pull request #6334: make 0.13 tasks API 
backwards compatible with 0.12  (#6333)
URL: https://github.com/apache/incubator-druid/pull/6334#discussion_r221115740
 
 

 ##########
 File path: api/src/main/java/org/apache/druid/indexer/TaskStatusPlus.java
 ##########
 @@ -42,28 +47,71 @@
   @Nullable
   private final String errorMsg;
 
+  public TaskStatusPlus(
+      String id,
+      String type, // nullable for backward compatibility
+      DateTime createdTime,
+      DateTime queueInsertionTime,
+      @Nullable TaskState statusCode,
+      @Nullable RunnerTaskState runnerStatusCode,
+      @Nullable Long duration,
+      TaskLocation location,
+      @Nullable String dataSource, // nullable for backward compatibility
+      @Nullable String errorMsg
+  )
+  {
+    this(
+        id,
+        type,
+        createdTime,
+        queueInsertionTime,
+        statusCode,
+        statusCode,
+        runnerStatusCode,
+        duration,
+        location,
+        dataSource,
+        errorMsg
+    );
+  }
+
+
   @JsonCreator
   public TaskStatusPlus(
       @JsonProperty("id") String id,
       @JsonProperty("type") @Nullable String type, // nullable for backward 
compatibility
       @JsonProperty("createdTime") DateTime createdTime,
       @JsonProperty("queueInsertionTime") DateTime queueInsertionTime,
-      @JsonProperty("statusCode") @Nullable TaskState state,
+      @JsonProperty("statusCode") @Nullable TaskState statusCode,
+      @Deprecated @JsonProperty("status") @Nullable TaskState status,  // 
present for backwards compatibility
       @JsonProperty("runnerStatusCode") @Nullable RunnerTaskState 
runnerTaskState,
       @JsonProperty("duration") @Nullable Long duration,
       @JsonProperty("location") TaskLocation location,
       @JsonProperty("dataSource") @Nullable String dataSource, // nullable for 
backward compatibility
       @JsonProperty("errorMsg") @Nullable String errorMsg
   )
   {
-    if (state != null && state.isComplete()) {
+    if (statusCode != null && statusCode.isComplete()) {
       Preconditions.checkNotNull(duration, "duration");
     }
     this.id = Preconditions.checkNotNull(id, "id");
     this.type = type;
     this.createdTime = Preconditions.checkNotNull(createdTime, "createdTime");
     this.queueInsertionTime = Preconditions.checkNotNull(queueInsertionTime, 
"queueInsertionTime");
-    this.state = state;
+    //checks for deserialization safety
+    if (statusCode != null && status == null) {
+      this.statusCode = statusCode;
+      this.status = statusCode;
+    } else if (statusCode == null && status != null) {
+      this.statusCode = status;
+      this.status = status;
+    } else {
+      if (statusCode != null && status != null && statusCode != status) {
+        log.error("statusCode[%s] and status[%s] must be same", statusCode, 
status);
 
 Review comment:
   Is there any case that we can allow this mismatch? If so, it would be better 
`log.warn()`. Otherwise, it would be better to throw an exception.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to