diff --git a/java/api/src/main/java/io/ray/api/runtimecontext/RuntimeContext.java b/java/api/src/main/java/io/ray/api/runtimecontext/RuntimeContext.java index 57c8d6f7a..7a66cd34e 100644 --- a/java/api/src/main/java/io/ray/api/runtimecontext/RuntimeContext.java +++ b/java/api/src/main/java/io/ray/api/runtimecontext/RuntimeContext.java @@ -25,10 +25,8 @@ public interface RuntimeContext { /** Returns true if the current actor was restarted, otherwise false. */ boolean wasCurrentActorRestarted(); - /** - * Returns true if Ray is running in single-process mode, false if Ray is running in cluster mode. - */ - boolean isSingleProcess(); + /** Returns true if Ray is running in local mode, false if Ray is running in cluster mode. */ + boolean isLocalMode(); /** Get all node information in Ray cluster. */ List getAllNodeInfo(); diff --git a/java/runtime/src/main/java/io/ray/runtime/AbstractRayRuntime.java b/java/runtime/src/main/java/io/ray/runtime/AbstractRayRuntime.java index 7659a6b35..d19b25ed4 100644 --- a/java/runtime/src/main/java/io/ray/runtime/AbstractRayRuntime.java +++ b/java/runtime/src/main/java/io/ray/runtime/AbstractRayRuntime.java @@ -339,8 +339,7 @@ public abstract class AbstractRayRuntime implements RayRuntimeInternal { LOGGER.debug("Creating Actor {}, jvmOptions = {}.", functionDescriptor, options.jvmOptions); } } - if (rayConfig.runMode == RunMode.SINGLE_PROCESS - && functionDescriptor.getLanguage() != Language.JAVA) { + if (rayConfig.runMode == RunMode.LOCAL && functionDescriptor.getLanguage() != Language.JAVA) { throw new IllegalArgumentException( "Ray doesn't support cross-language invocation in local mode."); } diff --git a/java/runtime/src/main/java/io/ray/runtime/DefaultRayRuntimeFactory.java b/java/runtime/src/main/java/io/ray/runtime/DefaultRayRuntimeFactory.java index a9461b820..806ec0209 100644 --- a/java/runtime/src/main/java/io/ray/runtime/DefaultRayRuntimeFactory.java +++ b/java/runtime/src/main/java/io/ray/runtime/DefaultRayRuntimeFactory.java @@ -29,7 +29,7 @@ public class DefaultRayRuntimeFactory implements RayRuntimeFactory { try { logger.debug("Initializing runtime with config: {}", rayConfig); AbstractRayRuntime innerRuntime = - rayConfig.runMode == RunMode.SINGLE_PROCESS + rayConfig.runMode == RunMode.LOCAL ? new RayDevRuntime(rayConfig) : new RayNativeRuntime(rayConfig); RayRuntimeInternal runtime = innerRuntime; diff --git a/java/runtime/src/main/java/io/ray/runtime/config/RayConfig.java b/java/runtime/src/main/java/io/ray/runtime/config/RayConfig.java index 89dada1eb..20c7a8706 100644 --- a/java/runtime/src/main/java/io/ray/runtime/config/RayConfig.java +++ b/java/runtime/src/main/java/io/ray/runtime/config/RayConfig.java @@ -107,7 +107,7 @@ public class RayConfig { boolean isDriver = workerMode == WorkerType.DRIVER; // Run mode. if (config.hasPath("ray.local-mode")) { - runMode = config.getBoolean("ray.local-mode") ? RunMode.SINGLE_PROCESS : RunMode.CLUSTER; + runMode = config.getBoolean("ray.local-mode") ? RunMode.LOCAL : RunMode.CLUSTER; } else { runMode = config.getEnum(RunMode.class, "ray.run-mode"); } diff --git a/java/runtime/src/main/java/io/ray/runtime/config/RunMode.java b/java/runtime/src/main/java/io/ray/runtime/config/RunMode.java index c86b0b3d5..d42b28ebe 100644 --- a/java/runtime/src/main/java/io/ray/runtime/config/RunMode.java +++ b/java/runtime/src/main/java/io/ray/runtime/config/RunMode.java @@ -6,7 +6,7 @@ public enum RunMode { * Ray is running in one single Java process, without Raylet backend, object store, and GCS. It's * useful for debug. */ - SINGLE_PROCESS, + LOCAL, /** Ray is running on one or more nodes, with multiple processes. */ CLUSTER, diff --git a/java/runtime/src/main/java/io/ray/runtime/context/RuntimeContextImpl.java b/java/runtime/src/main/java/io/ray/runtime/context/RuntimeContextImpl.java index c6d8765ef..ba10acc0a 100644 --- a/java/runtime/src/main/java/io/ray/runtime/context/RuntimeContextImpl.java +++ b/java/runtime/src/main/java/io/ray/runtime/context/RuntimeContextImpl.java @@ -47,15 +47,15 @@ public class RuntimeContextImpl implements RuntimeContext { @Override public boolean wasCurrentActorRestarted() { - if (isSingleProcess()) { + if (isLocalMode()) { return false; } return runtime.getGcsClient().wasCurrentActorRestarted(getCurrentActorId()); } @Override - public boolean isSingleProcess() { - return RunMode.SINGLE_PROCESS == runtime.getRayConfig().runMode; + public boolean isLocalMode() { + return RunMode.LOCAL == runtime.getRayConfig().runMode; } @Override diff --git a/java/runtime/src/main/resources/ray.default.conf b/java/runtime/src/main/resources/ray.default.conf index cf73f321d..02d850fd5 100644 --- a/java/runtime/src/main/resources/ray.default.conf +++ b/java/runtime/src/main/resources/ray.default.conf @@ -13,8 +13,8 @@ ray { // Run mode, available options are: // - // `SINGLE_PROCESS`: Ray is running in one single Java process, without Raylet backend, - // object store, and GCS. It's useful for debug. + // `LOCAL`: Ray is running in one single Java process, without Raylet backend, + // object store, and GCS. It's useful for debug. // `CLUSTER`: Ray is running on one or more nodes, with multiple processes. run-mode: CLUSTER diff --git a/java/serve/src/main/java/io/ray/serve/RayServeMetrics.java b/java/serve/src/main/java/io/ray/serve/RayServeMetrics.java index b3d3e95c9..bfd95cf44 100644 --- a/java/serve/src/main/java/io/ray/serve/RayServeMetrics.java +++ b/java/serve/src/main/java/io/ray/serve/RayServeMetrics.java @@ -44,7 +44,7 @@ public enum RayServeMetrics { public static final String TAG_REPLICA = "replica"; private static final boolean canBeUsed = - Ray.isInitialized() && !Ray.getRuntimeContext().isSingleProcess(); + Ray.isInitialized() && !Ray.getRuntimeContext().isLocalMode(); private static volatile boolean enabled = true; diff --git a/java/test.sh b/java/test.sh index 7a8bdc637..e40d123f5 100755 --- a/java/test.sh +++ b/java/test.sh @@ -29,7 +29,7 @@ run_testng() { # exit_code == 2 means there are skipped tests. if [ $exit_code -ne 2 ] && [ $exit_code -ne 0 ] ; then # Only print log files if it ran in cluster mode - if [[ ! "$*" =~ SINGLE_PROCESS ]]; then + if [[ ! "$*" =~ LOCAL ]]; then if [ $exit_code -gt 128 ] ; then # Test crashed. Print the driver log for diagnosis. cat /tmp/ray/session_latest/logs/java-core-driver-*$pid* @@ -101,9 +101,8 @@ while true; do fi done -echo "Running tests under single-process mode." -# bazel test //java:all_tests --jvmopt="-Dray.run-mode=SINGLE_PROCESS" --config=ci || single_exit_code=$? -run_testng java -Dray.run-mode="SINGLE_PROCESS" -cp "$ROOT_DIR"/../bazel-bin/java/all_tests_shaded.jar org.testng.TestNG -d /tmp/ray_java_test_output "$ROOT_DIR"/testng.xml +echo "Running tests under local mode." +run_testng java -Dray.run-mode="LOCAL" -cp "$ROOT_DIR"/../bazel-bin/java/all_tests_shaded.jar org.testng.TestNG -d /tmp/ray_java_test_output "$ROOT_DIR"/testng.xml echo "Running connecting existing cluster tests." case "${OSTYPE}" in diff --git a/java/test/src/main/java/io/ray/test/SingleProcessModeTest.java b/java/test/src/main/java/io/ray/test/LocalModeTest.java similarity index 95% rename from java/test/src/main/java/io/ray/test/SingleProcessModeTest.java rename to java/test/src/main/java/io/ray/test/LocalModeTest.java index 38af97c07..ae8b8152f 100644 --- a/java/test/src/main/java/io/ray/test/SingleProcessModeTest.java +++ b/java/test/src/main/java/io/ray/test/LocalModeTest.java @@ -11,7 +11,7 @@ import java.util.Map; import org.testng.Assert; import org.testng.annotations.Test; -public class SingleProcessModeTest extends BaseTest { +public class LocalModeTest extends BaseTest { private static final int NUM_ACTOR_INSTANCE = 10; @@ -25,7 +25,7 @@ public class SingleProcessModeTest extends BaseTest { } } - @Test(groups = {"singleProcess"}) + @Test(groups = {"local"}) public void testActorTasksInOneThread() { List> actors = new ArrayList<>(); Map actorThreadIds = new HashMap<>(); diff --git a/java/test/src/main/java/io/ray/test/MultiThreadingTest.java b/java/test/src/main/java/io/ray/test/MultiThreadingTest.java index 81629245c..c06dd982a 100644 --- a/java/test/src/main/java/io/ray/test/MultiThreadingTest.java +++ b/java/test/src/main/java/io/ray/test/MultiThreadingTest.java @@ -132,7 +132,7 @@ public class MultiThreadingTest extends BaseTest { testMultiThreading(); } - // Single-process mode doesn't have real workers. + // Local mode doesn't have real workers. @Test(groups = {"cluster"}) public void testInWorker() { ObjectRef obj = Ray.task(MultiThreadingTest::testMultiThreading).remote(); diff --git a/java/test/src/main/java/io/ray/test/PlasmaFreeTest.java b/java/test/src/main/java/io/ray/test/PlasmaFreeTest.java index b8235b8d8..1f2cdebce 100644 --- a/java/test/src/main/java/io/ray/test/PlasmaFreeTest.java +++ b/java/test/src/main/java/io/ray/test/PlasmaFreeTest.java @@ -28,7 +28,7 @@ public class PlasmaFreeTest extends BaseTest { .wait(ImmutableList.of(((ObjectRefImpl) helloId).getId()), 1, 0, true) .get(0), 50); - if (TestUtils.isSingleProcessMode()) { + if (TestUtils.isLocalMode()) { Assert.assertTrue(result); } else { // The object will not be deleted under cluster mode. diff --git a/java/test/src/main/java/io/ray/test/RayAlterSuiteListener.java b/java/test/src/main/java/io/ray/test/RayAlterSuiteListener.java index 185372bdf..5cde630c4 100644 --- a/java/test/src/main/java/io/ray/test/RayAlterSuiteListener.java +++ b/java/test/src/main/java/io/ray/test/RayAlterSuiteListener.java @@ -13,8 +13,7 @@ public class RayAlterSuiteListener implements IAlterSuiteListener { @Override public void alter(List suites) { XmlSuite suite = suites.get(0); - String excludedGroup = - RayConfig.create().runMode == RunMode.SINGLE_PROCESS ? "cluster" : "singleProcess"; + String excludedGroup = RayConfig.create().runMode == RunMode.LOCAL ? "cluster" : "local"; XmlGroups groups = new XmlGroups(); XmlRun run = new XmlRun(); run.onExclude(excludedGroup); diff --git a/java/test/src/main/java/io/ray/test/TestUtils.java b/java/test/src/main/java/io/ray/test/TestUtils.java index 5db5e0e8e..d302a0bae 100644 --- a/java/test/src/main/java/io/ray/test/TestUtils.java +++ b/java/test/src/main/java/io/ray/test/TestUtils.java @@ -34,8 +34,8 @@ public class TestUtils { private static final int WAIT_INTERVAL_MS = 5; - public static boolean isSingleProcessMode() { - return getRuntime().getRayConfig().runMode == RunMode.SINGLE_PROCESS; + public static boolean isLocalMode() { + return getRuntime().getRayConfig().runMode == RunMode.LOCAL; } /**