diff --git a/java/runtime/src/main/java/org/ray/runtime/config/RayConfig.java b/java/runtime/src/main/java/org/ray/runtime/config/RayConfig.java index c77d62628..d374d25a5 100644 --- a/java/runtime/src/main/java/org/ray/runtime/config/RayConfig.java +++ b/java/runtime/src/main/java/org/ray/runtime/config/RayConfig.java @@ -158,17 +158,12 @@ public class RayConfig { rayletExecutablePath = rayHome + "/build/src/ray/raylet/raylet"; // driver resource path - String localDriverResourcePath; if (config.hasPath("ray.driver.resource-path")) { - localDriverResourcePath = config.getString("ray.driver.resource-path"); + driverResourcePath = config.getString("ray.driver.resource-path"); } else { - localDriverResourcePath = rayHome + "/driver/resource"; - LOGGER.warn("Didn't configure ray.driver.resource-path, set it to default value: {}", - localDriverResourcePath); + driverResourcePath = null; } - driverResourcePath = localDriverResourcePath; - // validate config validate(); LOGGER.debug("Created config: {}", this); diff --git a/java/runtime/src/main/java/org/ray/runtime/functionmanager/FunctionManager.java b/java/runtime/src/main/java/org/ray/runtime/functionmanager/FunctionManager.java index cf92b0c21..d7698c22a 100644 --- a/java/runtime/src/main/java/org/ray/runtime/functionmanager/FunctionManager.java +++ b/java/runtime/src/main/java/org/ray/runtime/functionmanager/FunctionManager.java @@ -89,13 +89,11 @@ public class FunctionManager { String resourcePath = driverResourcePath + "/" + driverId.toString() + "/"; ClassLoader classLoader; - try { + if (driverResourcePath != null && !driverResourcePath.isEmpty()) { classLoader = JarLoader.loadJars(resourcePath, false); LOGGER.info("Succeeded to load driver({}) resource. Resource path is {}", driverId, resourcePath); - } catch (Exception e) { - LOGGER.error("Failed to load driver({}) resource. Resource path is {}", - driverId, resourcePath); + } else { classLoader = getClass().getClassLoader(); } diff --git a/java/runtime/src/main/resources/ray.default.conf b/java/runtime/src/main/resources/ray.default.conf index 58a3be2de..892d90c6c 100644 --- a/java/runtime/src/main/resources/ray.default.conf +++ b/java/runtime/src/main/resources/ray.default.conf @@ -25,15 +25,16 @@ ray { // Available resources on this node, for example "CPU:4,GPU:0". resources: "" - // Configuration items about driver. - driver { - // If worker.mode is DRIVER, specify the driver id. - // If not provided, a random id will be used. - id: "" - // If worker.mode is WORKER, it means that worker will load - // the resources from this path to execute tasks. - resource-path: /tmp/ray/driver/resource - } + // Configuration items about driver. + driver { + // If worker.mode is DRIVER, specify the driver id. + // If not provided, a random id will be used. + id: "" + // If this config is set, worker will use different paths to loadresources when + // executing tasks from different drivers. E.g. if it's set to '/tm/driver_resources', + // the path for driver 123 will be '/tmp/driver_resources/123'. + resource-path: "" + } // Root dir of log files. log-dir: /tmp/ray/logs diff --git a/java/runtime/src/test/java/org/ray/runtime/functionmanager/FunctionManagerTest.java b/java/runtime/src/test/java/org/ray/runtime/functionmanager/FunctionManagerTest.java index c82ae27af..f5ff1e481 100644 --- a/java/runtime/src/test/java/org/ray/runtime/functionmanager/FunctionManagerTest.java +++ b/java/runtime/src/test/java/org/ray/runtime/functionmanager/FunctionManagerTest.java @@ -45,10 +45,6 @@ public class FunctionManagerTest { private static FunctionDescriptor barDescriptor; private static FunctionDescriptor barConstructorDescriptor; - private final static String resourcePath = "/tmp/ray/test/resource"; - - private FunctionManager functionManager; - @BeforeClass public static void beforeClass() { fooFunc = FunctionManagerTest::foo; @@ -63,13 +59,9 @@ public class FunctionManagerTest { "()V"); } - @Before - public void before() { - functionManager = new FunctionManager(FunctionManagerTest.resourcePath); - } - @Test public void testGetFunctionFromRayFunc() { + final FunctionManager functionManager = new FunctionManager(null); // Test normal function. RayFunction func = functionManager.getFunction(UniqueId.NIL, fooFunc); Assert.assertFalse(func.isConstructor()); @@ -91,6 +83,7 @@ public class FunctionManagerTest { @Test public void testGetFunctionFromFunctionDescriptor() { + final FunctionManager functionManager = new FunctionManager(null); // Test normal function. RayFunction func = functionManager.getFunction(UniqueId.NIL, fooDescriptor); Assert.assertFalse(func.isConstructor()); @@ -129,6 +122,7 @@ public class FunctionManagerTest { UniqueId driverId = UniqueId.fromHexString("0123456789012345678901234567890123456789"); //TODO(qwang): We should use a independent app demo instead of `tutorial`. + final String resourcePath = "/tmp/ray/test/resource"; final String srcJarPath = System.getProperty("user.dir") + "/../tutorial/target/ray-tutorial-0.1-SNAPSHOT.jar"; final String destJarPath = resourcePath + "/" + driverId.toString() + @@ -136,9 +130,9 @@ public class FunctionManagerTest { File file = new File(resourcePath + "/" + driverId.toString()); file.mkdirs(); - Files.copy(Paths.get(srcJarPath), Paths.get(destJarPath), StandardCopyOption.REPLACE_EXISTING); + final FunctionManager functionManager = new FunctionManager(resourcePath); FunctionDescriptor sayHelloDescriptor = new FunctionDescriptor("org.ray.exercise.Exercise02", "sayHello", "()Ljava/lang/String;"); RayFunction func = functionManager.getFunction(driverId, sayHelloDescriptor);