Add delete_creating_tasks option for internal.free() (#4588)

* add delete creating task objects.

* format code style

* Fix lint

* add tests add address comments.

* Refine test

* Refine java test

* Fix CI

* Refine

* Fix lint

* Fix CI
This commit is contained in:
Wang Qing
2019-04-12 13:38:31 +08:00
committed by Yuhong Guo
parent e88e706fcc
commit fe07a5b4b1
19 changed files with 131 additions and 54 deletions
@@ -205,8 +205,8 @@ public abstract class AbstractRayRuntime implements RayRuntime {
}
@Override
public void free(List<UniqueId> objectIds, boolean localOnly) {
rayletClient.freePlasmaObjects(objectIds, localOnly);
public void free(List<UniqueId> objectIds, boolean localOnly, boolean deleteCreatingTasks) {
rayletClient.freePlasmaObjects(objectIds, localOnly, deleteCreatingTasks);
}
private List<List<UniqueId>> splitIntoBatches(List<UniqueId> objectIds) {
@@ -213,4 +213,22 @@ public final class RayNativeRuntime extends AbstractRayRuntime {
return false;
}
/**
* Query whether the raylet task exists in Gcs.
*/
public boolean rayletTaskExistsInGcs(UniqueId taskId) {
byte[] key = ArrayUtils.addAll("RAYLET_TASK".getBytes(), taskId.getBytes());
// TODO(qwang): refactor this with `GlobalState` after this issue
// getting finished. https://github.com/ray-project/ray/issues/3933
for (RedisClient client : redisClients) {
if (client.exists(key)) {
return true;
}
}
return false;
}
}
@@ -191,7 +191,8 @@ public class MockRayletClient implements RayletClient {
}
@Override
public void freePlasmaObjects(List<UniqueId> objectIds, boolean localOnly) {
public void freePlasmaObjects(List<UniqueId> objectIds, boolean localOnly,
boolean deleteCreatingTasks) {
for (UniqueId id : objectIds) {
store.free(id);
}
@@ -24,7 +24,7 @@ public interface RayletClient {
<T> WaitResult<T> wait(List<RayObject<T>> waitFor, int numReturns, int
timeoutMs, UniqueId currentTaskId);
void freePlasmaObjects(List<UniqueId> objectIds, boolean localOnly);
void freePlasmaObjects(List<UniqueId> objectIds, boolean localOnly, boolean deleteCreatingTasks);
UniqueId prepareCheckpoint(UniqueId actorId);
@@ -123,9 +123,10 @@ public class RayletClientImpl implements RayletClient {
}
@Override
public void freePlasmaObjects(List<UniqueId> objectIds, boolean localOnly) {
public void freePlasmaObjects(List<UniqueId> objectIds, boolean localOnly,
boolean deleteCreatingTasks) {
byte[][] objectIdsArray = UniqueIdUtil.getIdBytes(objectIds);
nativeFreePlasmaObjects(client, objectIdsArray, localOnly);
nativeFreePlasmaObjects(client, objectIdsArray, localOnly, deleteCreatingTasks);
}
@Override
@@ -350,7 +351,7 @@ public class RayletClientImpl implements RayletClient {
int taskIndex);
private static native void nativeFreePlasmaObjects(long conn, byte[][] objectIds,
boolean localOnly) throws RayException;
boolean localOnly, boolean deleteCreatingTasks) throws RayException;
private static native byte[] nativePrepareCheckpoint(long conn, byte[] actorId);