Consolidate the two TaskStatus classes. (#12765)

* Consolidate the two TaskStatus classes.

There are two, but we don't need more than one.

* Fix import order.
This commit is contained in:
Gian Merlino 2022-07-11 07:25:22 -07:00 committed by GitHub
parent 32946216d0
commit d2576584a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 10 additions and 110 deletions

View File

@ -96,11 +96,11 @@ public class TaskStatus
private final TaskLocation location; private final TaskLocation location;
@JsonCreator @JsonCreator
protected TaskStatus( public TaskStatus(
@JsonProperty("id") String id, @JsonProperty("id") String id,
@JsonProperty("status") TaskState status, @JsonProperty("status") TaskState status,
@JsonProperty("duration") long duration, @JsonProperty("duration") long duration,
@JsonProperty("errorMsg") @Nullable String errorMsg, @Nullable @JsonProperty("errorMsg") String errorMsg,
@Nullable @JsonProperty("location") TaskLocation location @Nullable @JsonProperty("location") TaskLocation location
) )
{ {

View File

@ -25,10 +25,10 @@ import com.google.common.io.ByteSource;
import com.google.common.io.Files; import com.google.common.io.Files;
import com.google.inject.Inject; import com.google.inject.Inject;
import org.apache.commons.lang3.mutable.MutableInt; import org.apache.commons.lang3.mutable.MutableInt;
import org.apache.druid.client.indexing.TaskStatus;
import org.apache.druid.common.guava.FutureUtils; import org.apache.druid.common.guava.FutureUtils;
import org.apache.druid.common.utils.IdUtils; import org.apache.druid.common.utils.IdUtils;
import org.apache.druid.guice.ManageLifecycle; import org.apache.druid.guice.ManageLifecycle;
import org.apache.druid.indexer.TaskStatus;
import org.apache.druid.indexing.common.TaskToolbox; import org.apache.druid.indexing.common.TaskToolbox;
import org.apache.druid.indexing.common.config.TaskConfig; import org.apache.druid.indexing.common.config.TaskConfig;
import org.apache.druid.indexing.common.task.batch.parallel.GenericPartitionStat; import org.apache.druid.indexing.common.task.batch.parallel.GenericPartitionStat;

View File

@ -25,8 +25,8 @@ import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFuture;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.apache.druid.client.indexing.NoopOverlordClient; import org.apache.druid.client.indexing.NoopOverlordClient;
import org.apache.druid.client.indexing.TaskStatus;
import org.apache.druid.indexer.TaskState; import org.apache.druid.indexer.TaskState;
import org.apache.druid.indexer.TaskStatus;
import org.apache.druid.indexing.common.config.TaskConfig; import org.apache.druid.indexing.common.config.TaskConfig;
import org.apache.druid.indexing.worker.config.WorkerConfig; import org.apache.druid.indexing.worker.config.WorkerConfig;
import org.apache.druid.java.util.common.Intervals; import org.apache.druid.java.util.common.Intervals;
@ -87,7 +87,7 @@ public class LocalIntermediaryDataManagerAutoCleanupTest
final Map<String, TaskStatus> result = new HashMap<>(); final Map<String, TaskStatus> result = new HashMap<>();
for (String taskId : taskIds) { for (String taskId : taskIds) {
TaskState state = taskId.startsWith("running_") ? TaskState.RUNNING : TaskState.SUCCESS; TaskState state = taskId.startsWith("running_") ? TaskState.RUNNING : TaskState.SUCCESS;
result.put(taskId, new TaskStatus(taskId, state, 10)); result.put(taskId, new TaskStatus(taskId, state, 10, null, null));
} }
return Futures.immediateFuture(result); return Futures.immediateFuture(result);
} }

View File

@ -25,8 +25,8 @@ import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFuture;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.apache.druid.client.indexing.NoopOverlordClient; import org.apache.druid.client.indexing.NoopOverlordClient;
import org.apache.druid.client.indexing.TaskStatus;
import org.apache.druid.indexer.TaskState; import org.apache.druid.indexer.TaskState;
import org.apache.druid.indexer.TaskStatus;
import org.apache.druid.indexing.common.config.TaskConfig; import org.apache.druid.indexing.common.config.TaskConfig;
import org.apache.druid.indexing.worker.config.WorkerConfig; import org.apache.druid.indexing.worker.config.WorkerConfig;
import org.apache.druid.indexing.worker.shuffle.ShuffleMetrics.PerDatasourceShuffleMetrics; import org.apache.druid.indexing.worker.shuffle.ShuffleMetrics.PerDatasourceShuffleMetrics;
@ -112,7 +112,7 @@ public class ShuffleResourceTest
{ {
final Map<String, TaskStatus> result = new HashMap<>(); final Map<String, TaskStatus> result = new HashMap<>();
for (String taskId : taskIds) { for (String taskId : taskIds) {
result.put(taskId, new TaskStatus(taskId, TaskState.SUCCESS, 10)); result.put(taskId, new TaskStatus(taskId, TaskState.SUCCESS, 10, null, null));
} }
return Futures.immediateFuture(result); return Futures.immediateFuture(result);
} }

View File

@ -1,101 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 org.apache.druid.client.indexing;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.Objects;
import com.google.common.base.Preconditions;
import org.apache.druid.indexer.TaskState;
/**
* Should be synced with org.apache.druid.indexing.common.TaskStatus
*/
public class TaskStatus
{
private final String id;
private final TaskState status;
private final long duration;
@JsonCreator
public TaskStatus(
@JsonProperty("id") String id,
@JsonProperty("status") TaskState status,
@JsonProperty("duration") long duration
)
{
this.id = id;
this.status = status;
this.duration = duration;
// Check class invariants.
Preconditions.checkNotNull(id, "id");
Preconditions.checkNotNull(status, "status");
}
@JsonProperty("id")
public String getId()
{
return id;
}
@JsonProperty("status")
public TaskState getStatusCode()
{
return status;
}
@JsonProperty("duration")
public long getDuration()
{
return duration;
}
@Override
public boolean equals(Object o)
{
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
TaskStatus that = (TaskStatus) o;
return duration == that.duration &&
java.util.Objects.equals(id, that.id) &&
status == that.status;
}
@Override
public int hashCode()
{
return java.util.Objects.hash(id, status, duration);
}
@Override
public String toString()
{
return Objects.toStringHelper(this)
.add("id", id)
.add("status", status)
.add("duration", duration)
.toString();
}
}

View File

@ -20,8 +20,8 @@
package org.apache.druid.rpc.indexing; package org.apache.druid.rpc.indexing;
import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFuture;
import org.apache.druid.client.indexing.TaskStatus;
import org.apache.druid.client.indexing.TaskStatusResponse; import org.apache.druid.client.indexing.TaskStatusResponse;
import org.apache.druid.indexer.TaskStatus;
import org.apache.druid.rpc.ServiceRetryPolicy; import org.apache.druid.rpc.ServiceRetryPolicy;
import java.util.Map; import java.util.Map;

View File

@ -23,9 +23,9 @@ import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFuture;
import org.apache.druid.client.indexing.TaskStatus;
import org.apache.druid.client.indexing.TaskStatusResponse; import org.apache.druid.client.indexing.TaskStatusResponse;
import org.apache.druid.common.guava.FutureUtils; import org.apache.druid.common.guava.FutureUtils;
import org.apache.druid.indexer.TaskStatus;
import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.java.util.common.StringUtils;
import org.apache.druid.java.util.common.jackson.JacksonUtils; import org.apache.druid.java.util.common.jackson.JacksonUtils;
import org.apache.druid.java.util.http.client.response.BytesFullResponseHandler; import org.apache.druid.java.util.http.client.response.BytesFullResponseHandler;

View File

@ -20,6 +20,7 @@
package org.apache.druid.client.indexing; package org.apache.druid.client.indexing;
import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFuture;
import org.apache.druid.indexer.TaskStatus;
import org.apache.druid.rpc.ServiceRetryPolicy; import org.apache.druid.rpc.ServiceRetryPolicy;
import org.apache.druid.rpc.indexing.OverlordClient; import org.apache.druid.rpc.indexing.OverlordClient;