[Java][API CHANGE] Rename mode SINGLE_PROCESS to LOCAL (#24714)

for aligning to the key concept local mode, this PR renames SINGLE_PROCESS to LOCAL.
This commit is contained in:
Qing Wang 2022-05-19 10:17:24 +08:00 committed by GitHub
parent 502c3e132d
commit cc621ff08a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 22 additions and 27 deletions

View file

@ -25,10 +25,8 @@ public interface RuntimeContext {
/** Returns true if the current actor was restarted, otherwise false. */ /** Returns true if the current actor was restarted, otherwise false. */
boolean wasCurrentActorRestarted(); boolean wasCurrentActorRestarted();
/** /** Returns true if Ray is running in local mode, false if Ray is running in cluster mode. */
* Returns true if Ray is running in single-process mode, false if Ray is running in cluster mode. boolean isLocalMode();
*/
boolean isSingleProcess();
/** Get all node information in Ray cluster. */ /** Get all node information in Ray cluster. */
List<NodeInfo> getAllNodeInfo(); List<NodeInfo> getAllNodeInfo();

View file

@ -339,8 +339,7 @@ public abstract class AbstractRayRuntime implements RayRuntimeInternal {
LOGGER.debug("Creating Actor {}, jvmOptions = {}.", functionDescriptor, options.jvmOptions); LOGGER.debug("Creating Actor {}, jvmOptions = {}.", functionDescriptor, options.jvmOptions);
} }
} }
if (rayConfig.runMode == RunMode.SINGLE_PROCESS if (rayConfig.runMode == RunMode.LOCAL && functionDescriptor.getLanguage() != Language.JAVA) {
&& functionDescriptor.getLanguage() != Language.JAVA) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Ray doesn't support cross-language invocation in local mode."); "Ray doesn't support cross-language invocation in local mode.");
} }

View file

@ -29,7 +29,7 @@ public class DefaultRayRuntimeFactory implements RayRuntimeFactory {
try { try {
logger.debug("Initializing runtime with config: {}", rayConfig); logger.debug("Initializing runtime with config: {}", rayConfig);
AbstractRayRuntime innerRuntime = AbstractRayRuntime innerRuntime =
rayConfig.runMode == RunMode.SINGLE_PROCESS rayConfig.runMode == RunMode.LOCAL
? new RayDevRuntime(rayConfig) ? new RayDevRuntime(rayConfig)
: new RayNativeRuntime(rayConfig); : new RayNativeRuntime(rayConfig);
RayRuntimeInternal runtime = innerRuntime; RayRuntimeInternal runtime = innerRuntime;

View file

@ -107,7 +107,7 @@ public class RayConfig {
boolean isDriver = workerMode == WorkerType.DRIVER; boolean isDriver = workerMode == WorkerType.DRIVER;
// Run mode. // Run mode.
if (config.hasPath("ray.local-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 { } else {
runMode = config.getEnum(RunMode.class, "ray.run-mode"); runMode = config.getEnum(RunMode.class, "ray.run-mode");
} }

View file

@ -6,7 +6,7 @@ public enum RunMode {
* Ray is running in one single Java process, without Raylet backend, object store, and GCS. It's * Ray is running in one single Java process, without Raylet backend, object store, and GCS. It's
* useful for debug. * useful for debug.
*/ */
SINGLE_PROCESS, LOCAL,
/** Ray is running on one or more nodes, with multiple processes. */ /** Ray is running on one or more nodes, with multiple processes. */
CLUSTER, CLUSTER,

View file

@ -47,15 +47,15 @@ public class RuntimeContextImpl implements RuntimeContext {
@Override @Override
public boolean wasCurrentActorRestarted() { public boolean wasCurrentActorRestarted() {
if (isSingleProcess()) { if (isLocalMode()) {
return false; return false;
} }
return runtime.getGcsClient().wasCurrentActorRestarted(getCurrentActorId()); return runtime.getGcsClient().wasCurrentActorRestarted(getCurrentActorId());
} }
@Override @Override
public boolean isSingleProcess() { public boolean isLocalMode() {
return RunMode.SINGLE_PROCESS == runtime.getRayConfig().runMode; return RunMode.LOCAL == runtime.getRayConfig().runMode;
} }
@Override @Override

View file

@ -13,8 +13,8 @@ ray {
// Run mode, available options are: // Run mode, available options are:
// //
// `SINGLE_PROCESS`: Ray is running in one single Java process, without Raylet backend, // `LOCAL`: Ray is running in one single Java process, without Raylet backend,
// object store, and GCS. It's useful for debug. // object store, and GCS. It's useful for debug.
// `CLUSTER`: Ray is running on one or more nodes, with multiple processes. // `CLUSTER`: Ray is running on one or more nodes, with multiple processes.
run-mode: CLUSTER run-mode: CLUSTER

View file

@ -44,7 +44,7 @@ public enum RayServeMetrics {
public static final String TAG_REPLICA = "replica"; public static final String TAG_REPLICA = "replica";
private static final boolean canBeUsed = private static final boolean canBeUsed =
Ray.isInitialized() && !Ray.getRuntimeContext().isSingleProcess(); Ray.isInitialized() && !Ray.getRuntimeContext().isLocalMode();
private static volatile boolean enabled = true; private static volatile boolean enabled = true;

View file

@ -29,7 +29,7 @@ run_testng() {
# exit_code == 2 means there are skipped tests. # exit_code == 2 means there are skipped tests.
if [ $exit_code -ne 2 ] && [ $exit_code -ne 0 ] ; then if [ $exit_code -ne 2 ] && [ $exit_code -ne 0 ] ; then
# Only print log files if it ran in cluster mode # Only print log files if it ran in cluster mode
if [[ ! "$*" =~ SINGLE_PROCESS ]]; then if [[ ! "$*" =~ LOCAL ]]; then
if [ $exit_code -gt 128 ] ; then if [ $exit_code -gt 128 ] ; then
# Test crashed. Print the driver log for diagnosis. # Test crashed. Print the driver log for diagnosis.
cat /tmp/ray/session_latest/logs/java-core-driver-*$pid* cat /tmp/ray/session_latest/logs/java-core-driver-*$pid*
@ -101,9 +101,8 @@ while true; do
fi fi
done done
echo "Running tests under single-process mode." echo "Running tests under local mode."
# bazel test //java:all_tests --jvmopt="-Dray.run-mode=SINGLE_PROCESS" --config=ci || single_exit_code=$? 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
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 connecting existing cluster tests." echo "Running connecting existing cluster tests."
case "${OSTYPE}" in case "${OSTYPE}" in

View file

@ -11,7 +11,7 @@ import java.util.Map;
import org.testng.Assert; import org.testng.Assert;
import org.testng.annotations.Test; import org.testng.annotations.Test;
public class SingleProcessModeTest extends BaseTest { public class LocalModeTest extends BaseTest {
private static final int NUM_ACTOR_INSTANCE = 10; 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() { public void testActorTasksInOneThread() {
List<ActorHandle<MyActor>> actors = new ArrayList<>(); List<ActorHandle<MyActor>> actors = new ArrayList<>();
Map<ActorId, Long> actorThreadIds = new HashMap<>(); Map<ActorId, Long> actorThreadIds = new HashMap<>();

View file

@ -132,7 +132,7 @@ public class MultiThreadingTest extends BaseTest {
testMultiThreading(); testMultiThreading();
} }
// Single-process mode doesn't have real workers. // Local mode doesn't have real workers.
@Test(groups = {"cluster"}) @Test(groups = {"cluster"})
public void testInWorker() { public void testInWorker() {
ObjectRef<String> obj = Ray.task(MultiThreadingTest::testMultiThreading).remote(); ObjectRef<String> obj = Ray.task(MultiThreadingTest::testMultiThreading).remote();

View file

@ -28,7 +28,7 @@ public class PlasmaFreeTest extends BaseTest {
.wait(ImmutableList.of(((ObjectRefImpl<String>) helloId).getId()), 1, 0, true) .wait(ImmutableList.of(((ObjectRefImpl<String>) helloId).getId()), 1, 0, true)
.get(0), .get(0),
50); 50);
if (TestUtils.isSingleProcessMode()) { if (TestUtils.isLocalMode()) {
Assert.assertTrue(result); Assert.assertTrue(result);
} else { } else {
// The object will not be deleted under cluster mode. // The object will not be deleted under cluster mode.

View file

@ -13,8 +13,7 @@ public class RayAlterSuiteListener implements IAlterSuiteListener {
@Override @Override
public void alter(List<XmlSuite> suites) { public void alter(List<XmlSuite> suites) {
XmlSuite suite = suites.get(0); XmlSuite suite = suites.get(0);
String excludedGroup = String excludedGroup = RayConfig.create().runMode == RunMode.LOCAL ? "cluster" : "local";
RayConfig.create().runMode == RunMode.SINGLE_PROCESS ? "cluster" : "singleProcess";
XmlGroups groups = new XmlGroups(); XmlGroups groups = new XmlGroups();
XmlRun run = new XmlRun(); XmlRun run = new XmlRun();
run.onExclude(excludedGroup); run.onExclude(excludedGroup);

View file

@ -34,8 +34,8 @@ public class TestUtils {
private static final int WAIT_INTERVAL_MS = 5; private static final int WAIT_INTERVAL_MS = 5;
public static boolean isSingleProcessMode() { public static boolean isLocalMode() {
return getRuntime().getRayConfig().runMode == RunMode.SINGLE_PROCESS; return getRuntime().getRayConfig().runMode == RunMode.LOCAL;
} }
/** /**