[Java] Generate head redis port randomly (#6879)

* Random head port

* address comments.
This commit is contained in:
Qing Wang
2020-01-23 23:37:41 +08:00
committed by GitHub
parent aa2a0cb6da
commit cfbde39ba8
3 changed files with 33 additions and 2 deletions
@@ -11,6 +11,8 @@ import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Random;
import org.ray.api.id.JobId;
import org.ray.runtime.generated.Common.WorkerType;
import org.ray.runtime.util.NetworkUtil;
@@ -144,7 +146,12 @@ public class RayConfig {
} else {
this.redisAddress = null;
}
headRedisPort = config.getInt("ray.redis.head-port");
if (config.hasPath("ray.redis.head-port")) {
headRedisPort = config.getInt("ray.redis.head-port");
} else {
headRedisPort = NetworkUtil.getUnusedPort();
}
numberRedisShards = config.getInt("ray.redis.shard-number");
headRedisPassword = config.getString("ray.redis.head-password");
redisPassword = config.getString("ray.redis.password");
@@ -58,7 +58,8 @@ ray {
// Redis server, Raylet and object store.
address: ""
// If `redis.server` isn't provided, which port we should use to start redis server.
head-port: 6379
// If `head-port` is not provided, it will be generated randomly.
// head-port: 6379
// Below passwords should be consistent with the one defined in python/ray/ray_constants.py.
// The password used to start the redis server on the head node.
head-password: "5241590000000000"