[Java] Support wasCurrentActorRestarted in actor task. (#13120)

* Remove check.

* Add test

* fix lint

* lint

* Fix spotless lint

* Address comments.

* Fix lint

Co-authored-by: Qing Wang <jovany.wq@antgroup.com>
This commit is contained in:
Qing Wang
2021-01-02 11:31:08 +08:00
committed by GitHub
parent 710615c228
commit d3dd5b87ce
3 changed files with 29 additions and 27 deletions
@@ -7,7 +7,6 @@ import io.ray.api.runtimecontext.NodeInfo;
import io.ray.api.runtimecontext.RuntimeContext;
import io.ray.runtime.RayRuntimeInternal;
import io.ray.runtime.config.RunMode;
import io.ray.runtime.generated.Common.TaskType;
import java.util.List;
public class RuntimeContextImpl implements RuntimeContext {
@@ -33,14 +32,9 @@ public class RuntimeContextImpl implements RuntimeContext {
@Override
public boolean wasCurrentActorRestarted() {
TaskType currentTaskType = runtime.getWorkerContext().getCurrentTaskType();
Preconditions.checkState(
currentTaskType == TaskType.ACTOR_CREATION_TASK,
"This method can only be called from an actor creation task.");
if (isSingleProcess()) {
return false;
}
return runtime.getGcsClient().wasCurrentActorRestarted(getCurrentActorId());
}