mirror of
https://github.com/wassname/ray.git
synced 2026-07-18 12:40:56 +08:00
[Java] Support exchange ObjectRef between processes (#10729)
This commit is contained in:
@@ -174,6 +174,34 @@ Java_io_ray_runtime_object_NativeObjectStore_nativeGetAllReferenceCounts(JNIEnv
|
||||
});
|
||||
}
|
||||
|
||||
JNIEXPORT jbyteArray JNICALL
|
||||
Java_io_ray_runtime_object_NativeObjectStore_nativePromoteAndGetOwnershipInfo(
|
||||
JNIEnv *env, jclass, jbyteArray objectId) {
|
||||
auto object_id = JavaByteArrayToId<ray::ObjectID>(env, objectId);
|
||||
ray::CoreWorkerProcess::GetCoreWorker().PromoteObjectToPlasma(object_id);
|
||||
ray::rpc::Address address;
|
||||
ray::CoreWorkerProcess::GetCoreWorker().GetOwnershipInfo(object_id, &address);
|
||||
auto address_str = address.SerializeAsString();
|
||||
auto arr = NativeStringToJavaByteArray(env, address_str);
|
||||
return arr;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_io_ray_runtime_object_NativeObjectStore_nativeRegisterOwnershipInfoAndResolveFuture(
|
||||
JNIEnv *env, jclass, jbyteArray objectId, jbyteArray outerObjectId,
|
||||
jbyteArray ownerAddress) {
|
||||
auto object_id = JavaByteArrayToId<ray::ObjectID>(env, objectId);
|
||||
auto outer_objectId = ray::ObjectID::Nil();
|
||||
if (outerObjectId != NULL) {
|
||||
outer_objectId = JavaByteArrayToId<ray::ObjectID>(env, outerObjectId);
|
||||
}
|
||||
auto ownerAddressStr = JavaByteArrayToNativeString(env, ownerAddress);
|
||||
ray::rpc::Address address;
|
||||
address.ParseFromString(ownerAddressStr);
|
||||
ray::CoreWorkerProcess::GetCoreWorker().RegisterOwnershipInfoAndResolveFuture(
|
||||
object_id, outer_objectId, address);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -94,6 +94,25 @@ JNIEXPORT jobject JNICALL
|
||||
Java_io_ray_runtime_object_NativeObjectStore_nativeGetAllReferenceCounts(JNIEnv *,
|
||||
jclass);
|
||||
|
||||
/*
|
||||
* Class: io_ray_runtime_object_NativeObjectStore
|
||||
* Method: nativePromoteAndGetOwnershipInfo
|
||||
* Signature: ([B)[B
|
||||
*/
|
||||
JNIEXPORT jbyteArray JNICALL
|
||||
Java_io_ray_runtime_object_NativeObjectStore_nativePromoteAndGetOwnershipInfo(JNIEnv *,
|
||||
jclass,
|
||||
jbyteArray);
|
||||
|
||||
/*
|
||||
* Class: io_ray_runtime_object_NativeObjectStore
|
||||
* Method: nativeRegisterOwnershipInfoAndResolveFuture
|
||||
* Signature: ([B[B[B)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_io_ray_runtime_object_NativeObjectStore_nativeRegisterOwnershipInfoAndResolveFuture(
|
||||
JNIEnv *, jclass, jbyteArray, jbyteArray, jbyteArray);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user