[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
@@ -58,12 +58,17 @@ public class RayFunction {
}
public RayRemote getRayRemoteAnnotation() {
RayRemote rayRemote = executable.getAnnotation(RayRemote.class);
if (rayRemote == null) {
// If the method doesn't have a annotation, get the annotation from
// its wrapping class.
RayRemote rayRemote;
// If this method is a constructor, the task of it should be a actorCreationTask.
// And the annotation of actorCreationTask should inherit from class.
// Otherwise, it's a normal method, and it shouldn't inherit annotation from class.
if (isConstructor()) {
rayRemote = executable.getDeclaringClass().getAnnotation(RayRemote.class);
} else {
rayRemote = executable.getAnnotation(RayRemote.class);
}
return rayRemote;
}
@@ -74,7 +74,7 @@ public class FunctionManagerTest {
func = functionManager.getFunction(UniqueId.NIL, barFunc);
Assert.assertFalse(func.isConstructor());
Assert.assertEquals(func.getFunctionDescriptor(), barDescriptor);
Assert.assertNotNull(func.getRayRemoteAnnotation());
Assert.assertNull(func.getRayRemoteAnnotation());
// Test actor constructor
func = functionManager.getFunction(UniqueId.NIL, barConstructor);
@@ -95,7 +95,7 @@ public class FunctionManagerTest {
func = functionManager.getFunction(UniqueId.NIL, barDescriptor);
Assert.assertFalse(func.isConstructor());
Assert.assertEquals(func.getFunctionDescriptor(), barDescriptor);
Assert.assertNotNull(func.getRayRemoteAnnotation());
Assert.assertNull(func.getRayRemoteAnnotation());
// Test actor constructor
func = functionManager.getFunction(UniqueId.NIL, barConstructorDescriptor);