mirror of https://github.com/apache/druid.git
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:
parent
32946216d0
commit
d2576584a0
|
@ -96,11 +96,11 @@ public class TaskStatus
|
|||
private final TaskLocation location;
|
||||
|
||||
@JsonCreator
|
||||
protected TaskStatus(
|
||||
public TaskStatus(
|
||||
@JsonProperty("id") String id,
|
||||
@JsonProperty("status") TaskState status,
|
||||
@JsonProperty("duration") long duration,
|
||||
@JsonProperty("errorMsg") @Nullable String errorMsg,
|
||||
@Nullable @JsonProperty("errorMsg") String errorMsg,
|
||||
@Nullable @JsonProperty("location") TaskLocation location
|
||||
)
|
||||
{
|
||||
|
|
|
@ -25,10 +25,10 @@ import com.google.common.io.ByteSource;
|
|||
import com.google.common.io.Files;
|
||||
import com.google.inject.Inject;
|
||||
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.utils.IdUtils;
|
||||
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.config.TaskConfig;
|
||||
import org.apache.druid.indexing.common.task.batch.parallel.GenericPartitionStat;
|
||||
|
|
|
@ -25,8 +25,8 @@ import com.google.common.util.concurrent.Futures;
|
|||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
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.TaskStatus;
|
||||
import org.apache.druid.indexing.common.config.TaskConfig;
|
||||
import org.apache.druid.indexing.worker.config.WorkerConfig;
|
||||
import org.apache.druid.java.util.common.Intervals;
|
||||
|
@ -87,7 +87,7 @@ public class LocalIntermediaryDataManagerAutoCleanupTest
|
|||
final Map<String, TaskStatus> result = new HashMap<>();
|
||||
for (String taskId : taskIds) {
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -25,8 +25,8 @@ import com.google.common.util.concurrent.Futures;
|
|||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
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.TaskStatus;
|
||||
import org.apache.druid.indexing.common.config.TaskConfig;
|
||||
import org.apache.druid.indexing.worker.config.WorkerConfig;
|
||||
import org.apache.druid.indexing.worker.shuffle.ShuffleMetrics.PerDatasourceShuffleMetrics;
|
||||
|
@ -112,7 +112,7 @@ public class ShuffleResourceTest
|
|||
{
|
||||
final Map<String, TaskStatus> result = new HashMap<>();
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -20,8 +20,8 @@
|
|||
package org.apache.druid.rpc.indexing;
|
||||
|
||||
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.indexer.TaskStatus;
|
||||
import org.apache.druid.rpc.ServiceRetryPolicy;
|
||||
|
||||
import java.util.Map;
|
||||
|
|
|
@ -23,9 +23,9 @@ import com.fasterxml.jackson.core.type.TypeReference;
|
|||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.google.common.base.Preconditions;
|
||||
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.common.guava.FutureUtils;
|
||||
import org.apache.druid.indexer.TaskStatus;
|
||||
import org.apache.druid.java.util.common.StringUtils;
|
||||
import org.apache.druid.java.util.common.jackson.JacksonUtils;
|
||||
import org.apache.druid.java.util.http.client.response.BytesFullResponseHandler;
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package org.apache.druid.client.indexing;
|
||||
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
import org.apache.druid.indexer.TaskStatus;
|
||||
import org.apache.druid.rpc.ServiceRetryPolicy;
|
||||
import org.apache.druid.rpc.indexing.OverlordClient;
|
||||
|
||||
|
|
Loading…
Reference in New Issue