[Java] Support exchange ObjectRef between processes (#10729)

This commit is contained in:
Xianyang Liu
2020-09-13 11:54:45 +08:00
committed by GitHub
parent 9f9b53e624
commit 8166d71bde
8 changed files with 175 additions and 1 deletions
@@ -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