mirror of
https://github.com/wassname/ray.git
synced 2026-07-01 22:58:00 +08:00
[PlacementGroup]Add PlacementGroup wait java api (#12499)
* add part code * add part code * add part code * add part code * fix review comments * fix compile bug * fix compile bug * fix review comments * fix review comments * fix code style * add part code * fix review comments * fix review comments * fix code style * rebase master * fix bug * fix lint error * fix compile bug * fix newline issue Co-authored-by: 灵洵 <fengbin.ffb@antgroup.com>
This commit is contained in:
@@ -200,6 +200,11 @@ public abstract class AbstractRayRuntime implements RayRuntimeInternal {
|
||||
return gcsClient.getAllPlacementGroupInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean waitPlacementGroupReady(PlacementGroupId id, int timeoutMs) {
|
||||
return taskSubmitter.waitPlacementGroupReady(id, timeoutMs);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T extends BaseActorHandle> T getActorHandle(ActorId actorId) {
|
||||
|
||||
@@ -82,8 +82,7 @@ public class GlobalStateAccessor {
|
||||
|
||||
public byte[] getPlacementGroupInfo(PlacementGroupId placementGroupId) {
|
||||
synchronized (GlobalStateAccessor.class) {
|
||||
Preconditions.checkNotNull(placementGroupId,
|
||||
"PlacementGroupId can't be null when get placement group info.");
|
||||
validateGlobalStateAccessorPointer();
|
||||
return nativeGetPlacementGroupInfo(globalStateAccessorNativePointer,
|
||||
placementGroupId.getBytes());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package io.ray.runtime.placementgroup;
|
||||
|
||||
import io.ray.api.Ray;
|
||||
import io.ray.api.id.PlacementGroupId;
|
||||
import io.ray.api.placementgroup.PlacementGroup;
|
||||
import io.ray.api.placementgroup.PlacementGroupState;
|
||||
@@ -49,6 +50,15 @@ public class PlacementGroupImpl implements PlacementGroup {
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for the placement group to be ready within the specified time.
|
||||
* @param timeoutMs Timeout in milliseconds.
|
||||
* @return True if the placement group is created. False otherwise.
|
||||
*/
|
||||
public boolean wait(int timeoutMs) {
|
||||
return Ray.internal().waitPlacementGroupReady(id, timeoutMs);
|
||||
}
|
||||
|
||||
/**
|
||||
* A help class for create the placement group.
|
||||
*/
|
||||
|
||||
@@ -240,6 +240,11 @@ public class LocalModeTaskSubmitter implements TaskSubmitter {
|
||||
placementGroups.remove(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean waitPlacementGroupReady(PlacementGroupId id, int timeoutMs) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseActorHandle getActor(ActorId actorId) {
|
||||
return actorHandles.get(actorId).copy();
|
||||
|
||||
@@ -91,6 +91,11 @@ public class NativeTaskSubmitter implements TaskSubmitter {
|
||||
nativeRemovePlacementGroup(id.getBytes());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean waitPlacementGroupReady(PlacementGroupId id, int timeoutMs) {
|
||||
return nativeWaitPlacementGroupReady(id.getBytes(), timeoutMs);
|
||||
}
|
||||
|
||||
private static native List<byte[]> nativeSubmitTask(FunctionDescriptor functionDescriptor,
|
||||
int functionDescriptorHash, List<FunctionArg> args, int numReturns, CallOptions callOptions);
|
||||
|
||||
@@ -107,4 +112,6 @@ public class NativeTaskSubmitter implements TaskSubmitter {
|
||||
|
||||
private static native void nativeRemovePlacementGroup(byte[] placementGroupId);
|
||||
|
||||
private static native boolean nativeWaitPlacementGroupReady(byte[] placementGroupId,
|
||||
int timeoutMs);
|
||||
}
|
||||
|
||||
@@ -68,6 +68,14 @@ public interface TaskSubmitter {
|
||||
*/
|
||||
void removePlacementGroup(PlacementGroupId id);
|
||||
|
||||
/**
|
||||
* Wait for the placement group to be ready within the specified time.
|
||||
* @param id Id of placement group.
|
||||
* @param timeoutMs Timeout in milliseconds.
|
||||
* @return True if the placement group is created. False otherwise.
|
||||
*/
|
||||
boolean waitPlacementGroupReady(PlacementGroupId id, int timeoutMs);
|
||||
|
||||
BaseActorHandle getActor(ActorId actorId);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user