[Java] Fix the required-resources issue of actor member function in Java worker. (#3002)

This fixes a bug in which Java actor methods inherit the resource requirements of the actor creation task.
This commit is contained in:
Wang Qing
2018-10-02 03:56:36 +08:00
committed by Robert Nishihara
parent b45bed4bce
commit fcef4edd46
4 changed files with 28 additions and 7 deletions
@@ -45,6 +45,13 @@ public class ResourcesManagementTest {
}
}
@RayRemote(resources = {@ResourceItem(name = "RES-A", value = 4)})
public static class Echo3 {
public Integer echo(Integer number) {
return number;
}
}
@Test
public void testMethods() {
// This is a case that can satisfy required resources.
@@ -75,5 +82,14 @@ public class ResourcesManagementTest {
Assert.assertEquals(1, waitResult.getUnready().size());
}
@Test
public void testActorAndMemberMethods() {
// Note(qwang): This case depends on the following line.
// https://github.com/ray-project/ray/blob/master/java/test/src/main/java/org/ray/api/test/TestListener.java#L13
// If we change the static resources configuration item, this case may not pass.
// Then we should change this case too.
RayActor<Echo3> echo3 = Ray.createActor(Echo3::new);
Assert.assertEquals(100, (int) Ray.call(Echo3::echo, echo3, 100).get());
}
}
@@ -10,7 +10,7 @@ public class TestListener extends RunListener {
@Override
public void testRunStarted(Description description) {
System.setProperty("ray.home", "../..");
System.setProperty("ray.resources", "CPU:4");
System.setProperty("ray.resources", "CPU:4,RES-A:4");
Ray.init();
}