[java] fix check exception type (#3093)

<!--
Thank you for your contribution!

Please review https://github.com/ray-project/ray/blob/master/CONTRIBUTING.rst before opening a pull request.
-->

## What do these changes do?
remove TaskExecutionException, use RayException instead
<!-- Please give a short brief about these changes. -->

## Related issue number

<!-- Are there any issues opened that will be resolved by merging this change? -->
This commit is contained in:
bibabolynn
2018-10-19 21:43:42 +08:00
committed by Hao Chen
parent b410ee0d29
commit 9a5c273db7
3 changed files with 12 additions and 27 deletions
@@ -10,6 +10,7 @@ import org.apache.commons.lang3.tuple.Pair;
import org.ray.api.RayActor;
import org.ray.api.RayObject;
import org.ray.api.WaitResult;
import org.ray.api.exception.RayException;
import org.ray.api.function.RayFunc;
import org.ray.api.id.UniqueId;
import org.ray.api.options.ActorCreationOptions;
@@ -26,7 +27,6 @@ import org.ray.runtime.task.ArgumentsBuilder;
import org.ray.runtime.task.TaskSpec;
import org.ray.runtime.util.ResourceUtil;
import org.ray.runtime.util.UniqueIdUtil;
import org.ray.runtime.util.exception.TaskExecutionException;
import org.ray.runtime.util.logger.RayLog;
/**
@@ -80,7 +80,7 @@ public abstract class AbstractRayRuntime implements RayRuntime {
}
@Override
public <T> T get(UniqueId objectId) throws TaskExecutionException {
public <T> T get(UniqueId objectId) throws RayException {
List<T> ret = get(ImmutableList.of(objectId));
return ret.get(0);
}
@@ -149,7 +149,7 @@ public abstract class AbstractRayRuntime implements RayRuntime {
}
return finalRet;
} catch (TaskExecutionException e) {
} catch (RayException e) {
RayLog.core.error("Task " + taskId + " Objects " + Arrays.toString(objectIds.toArray())
+ " get with Exception", e);
throw e;
@@ -4,11 +4,11 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.arrow.plasma.ObjectStoreLink;
import org.apache.commons.lang3.tuple.Pair;
import org.ray.api.exception.RayException;
import org.ray.api.id.UniqueId;
import org.ray.runtime.AbstractRayRuntime;
import org.ray.runtime.util.Serializer;
import org.ray.runtime.util.UniqueIdUtil;
import org.ray.runtime.util.exception.TaskExecutionException;
/**
* Object store proxy, which handles serialization and deserialization, and utilize a {@code
@@ -27,18 +27,18 @@ public class ObjectStoreProxy {
}
public <T> Pair<T, GetStatus> get(UniqueId objectId, boolean isMetadata)
throws TaskExecutionException {
throws RayException {
return get(objectId, GET_TIMEOUT_MS, isMetadata);
}
public <T> Pair<T, GetStatus> get(UniqueId id, int timeoutMs, boolean isMetadata)
throws TaskExecutionException {
throws RayException {
byte[] obj = store.get(id.getBytes(), timeoutMs, isMetadata);
if (obj != null) {
T t = Serializer.decode(obj, runtime.getWorkerContext().getCurrentClassLoader());
store.release(id.getBytes());
if (t instanceof TaskExecutionException) {
throw (TaskExecutionException) t;
if (t instanceof RayException) {
throw (RayException) t;
}
return Pair.of(t, GetStatus.SUCCESS);
} else {
@@ -47,12 +47,12 @@ public class ObjectStoreProxy {
}
public <T> List<Pair<T, GetStatus>> get(List<UniqueId> objectIds, boolean isMetadata)
throws TaskExecutionException {
throws RayException {
return get(objectIds, GET_TIMEOUT_MS, isMetadata);
}
public <T> List<Pair<T, GetStatus>> get(List<UniqueId> ids, int timeoutMs, boolean isMetadata)
throws TaskExecutionException {
throws RayException {
List<byte[]> objs = store.get(UniqueIdUtil.getIdBytes(ids), timeoutMs, isMetadata);
List<Pair<T, GetStatus>> ret = new ArrayList<>();
for (int i = 0; i < objs.size(); i++) {
@@ -60,8 +60,8 @@ public class ObjectStoreProxy {
if (obj != null) {
T t = Serializer.decode(obj, runtime.getWorkerContext().getCurrentClassLoader());
store.release(ids.get(i).getBytes());
if (t instanceof TaskExecutionException) {
throw (TaskExecutionException) t;
if (t instanceof RayException) {
throw (RayException) t;
}
ret.add(Pair.of(t, GetStatus.SUCCESS));
} else {
@@ -1,15 +0,0 @@
package org.ray.runtime.util.exception;
/**
* An exception which is thrown when a ray task encounters an error when executing.
*/
public class TaskExecutionException extends RuntimeException {
public TaskExecutionException(Throwable cause) {
super(cause);
}
public TaskExecutionException(String message, Throwable cause) {
super(message, cause);
}
}