mirror of
https://github.com/wassname/ray.git
synced 2026-06-29 13:15:35 +08:00
[Java] Dynamic resource API in Java (#4824)
This commit is contained in:
@@ -210,6 +210,15 @@ public abstract class AbstractRayRuntime implements RayRuntime {
|
||||
rayletClient.freePlasmaObjects(objectIds, localOnly, deleteCreatingTasks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setResource(String resourceName, double capacity, UniqueId nodeId) {
|
||||
Preconditions.checkArgument(Double.compare(capacity, 0) >= 0);
|
||||
if (nodeId == null) {
|
||||
nodeId = UniqueId.NIL;
|
||||
}
|
||||
rayletClient.setResource(resourceName, capacity, nodeId);
|
||||
}
|
||||
|
||||
private List<List<UniqueId>> splitIntoBatches(List<UniqueId> objectIds) {
|
||||
List<List<UniqueId>> batches = new ArrayList<>();
|
||||
int objectsSize = objectIds.size();
|
||||
|
||||
@@ -209,6 +209,11 @@ public class MockRayletClient implements RayletClient {
|
||||
throw new NotImplementedException("Not implemented.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setResource(String resourceName, double capacity, UniqueId nodeId) {
|
||||
LOGGER.error("Not implemented under SINGLE_PROCESS mode.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
exec.shutdown();
|
||||
|
||||
@@ -30,5 +30,7 @@ public interface RayletClient {
|
||||
|
||||
void notifyActorResumedFromCheckpoint(UniqueId actorId, UniqueId checkpointId);
|
||||
|
||||
void setResource(String resourceName, double capacity, UniqueId nodeId);
|
||||
|
||||
void destroy();
|
||||
}
|
||||
|
||||
@@ -308,6 +308,10 @@ public class RayletClientImpl implements RayletClient {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public void setResource(String resourceName, double capacity, UniqueId nodeId) {
|
||||
nativeSetResource(client, resourceName, capacity, nodeId.getBytes());
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
nativeDestroy(client);
|
||||
}
|
||||
@@ -357,4 +361,7 @@ public class RayletClientImpl implements RayletClient {
|
||||
|
||||
private static native void nativeNotifyActorResumedFromCheckpoint(long conn, byte[] actorId,
|
||||
byte[] checkpointId);
|
||||
|
||||
private static native void nativeSetResource(long conn, String resourceName, double capacity,
|
||||
byte[] nodeId) throws RayException;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user