mirror of
https://github.com/wassname/ray.git
synced 2026-06-27 21:23:10 +08:00
[Java] Rename java ObjectRef/ActorHandle (#8799)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package io.ray.exercise;
|
||||
|
||||
import io.ray.api.ObjectRef;
|
||||
import io.ray.api.Ray;
|
||||
import io.ray.api.RayObject;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
@@ -29,8 +29,8 @@ public class Exercise01 implements Serializable {
|
||||
// Use `Ray.init` to initialize the Ray runtime.
|
||||
Ray.init();
|
||||
// Use `Ray.call` to call a remote function.
|
||||
RayObject<String> hello = Ray.call(Exercise01::sayHello);
|
||||
RayObject<String> world = Ray.call(Exercise01::sayWorld);
|
||||
ObjectRef<String> hello = Ray.call(Exercise01::sayHello);
|
||||
ObjectRef<String> world = Ray.call(Exercise01::sayWorld);
|
||||
System.out.println("First remote call result:" + hello.get());
|
||||
System.out.println("Second remote call result:" + world.get());
|
||||
} catch (Throwable t) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package io.ray.exercise;
|
||||
|
||||
import io.ray.api.ObjectRef;
|
||||
import io.ray.api.Ray;
|
||||
import io.ray.api.RayObject;
|
||||
|
||||
/**
|
||||
* Execute remote functions in parallel with some dependencies.
|
||||
@@ -28,8 +28,8 @@ public class Exercise02 {
|
||||
}
|
||||
|
||||
public static String sayHelloWorld() {
|
||||
RayObject<String> hello = Ray.call(Exercise02::sayHello);
|
||||
RayObject<String> world = Ray.call(Exercise02::sayWorld);
|
||||
ObjectRef<String> hello = Ray.call(Exercise02::sayHello);
|
||||
ObjectRef<String> world = Ray.call(Exercise02::sayWorld);
|
||||
// Pass unfinished results as the parameters to another remote function.
|
||||
return Ray.call(Exercise02::merge, hello, world).get();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package io.ray.exercise;
|
||||
|
||||
import io.ray.api.ObjectRef;
|
||||
import io.ray.api.Ray;
|
||||
import io.ray.api.RayObject;
|
||||
|
||||
/**
|
||||
* Call a remote function from within another remote function.
|
||||
@@ -14,7 +14,7 @@ public class Exercise03 {
|
||||
public static String sayHelloWithWorld() {
|
||||
String ret = "hello";
|
||||
System.out.println(ret);
|
||||
RayObject<String> world = Ray.call(Exercise03::sayWorld);
|
||||
ObjectRef<String> world = Ray.call(Exercise03::sayWorld);
|
||||
return ret + "," + world.get();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package io.ray.exercise;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import io.ray.api.ObjectRef;
|
||||
import io.ray.api.Ray;
|
||||
import io.ray.api.RayObject;
|
||||
import io.ray.api.WaitResult;
|
||||
import java.util.List;
|
||||
|
||||
@@ -38,7 +38,7 @@ public class Exercise04 {
|
||||
public static void main(String[] args) throws Exception {
|
||||
try {
|
||||
Ray.init();
|
||||
List<RayObject<String>> waitList = ImmutableList.of(
|
||||
List<ObjectRef<String>> waitList = ImmutableList.of(
|
||||
Ray.call(Exercise04::f1),
|
||||
Ray.call(Exercise04::f2),
|
||||
Ray.call(Exercise04::f3)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package io.ray.exercise;
|
||||
|
||||
import io.ray.api.ActorHandle;
|
||||
import io.ray.api.ObjectRef;
|
||||
import io.ray.api.Ray;
|
||||
import io.ray.api.RayActor;
|
||||
import io.ray.api.RayObject;
|
||||
|
||||
/**
|
||||
* Show usage of actors.
|
||||
@@ -13,11 +13,11 @@ public class Exercise05 {
|
||||
try {
|
||||
Ray.init();
|
||||
// `Ray.createActor` creates an actor instance.
|
||||
RayActor<Adder> adder = Ray.createActor(Adder::new, 0);
|
||||
ActorHandle<Adder> adder = Ray.createActor(Adder::new, 0);
|
||||
// Use `Ray.call(actor, parameters)` to call an actor method.
|
||||
RayObject<Integer> result1 = adder.call(Adder::add, 1);
|
||||
ObjectRef<Integer> result1 = adder.call(Adder::add, 1);
|
||||
System.out.println(result1.get());
|
||||
RayObject<Integer> result2 = adder.call(Adder::add, 10);
|
||||
ObjectRef<Integer> result2 = adder.call(Adder::add, 10);
|
||||
System.out.println(result2.get());
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
|
||||
Reference in New Issue
Block a user