[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. */
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<NodeInfo> getAllNodeInfo();

View file

@ -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.");
}

View file

@ -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;

View file

@ -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");
}

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
* useful for debug.
*/
SINGLE_PROCESS,
LOCAL,
/** Ray is running on one or more nodes, with multiple processes. */
CLUSTER,

View file

@ -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

View file

@ -13,7 +13,7 @@ ray {
// 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.
// `CLUSTER`: Ray is running on one or more nodes, with multiple processes.
run-mode: CLUSTER

View file

@ -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;

View file

@ -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

View file

@ -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<ActorHandle<MyActor>> actors = new ArrayList<>();
Map<ActorId, Long> actorThreadIds = new HashMap<>();

View file

@ -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<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)
.get(0),
50);
if (TestUtils.isSingleProcessMode()) {
if (TestUtils.isLocalMode()) {
Assert.assertTrue(result);
} else {
// The object will not be deleted under cluster mode.

View file

@ -13,8 +13,7 @@ public class RayAlterSuiteListener implements IAlterSuiteListener {
@Override
public void alter(List<XmlSuite> 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);

View file

@ -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;
}
/**