[Java] Simplify Java worker configuration (#2938)

## What do these changes do?
Previously, Java worker configuration is complicated, because it requires setting environment variables as well as command-line arguments.

This PR aims to simplify Java worker's configuration. 
1) Configuration management is now migrated to [lightbend config](https://github.com/lightbend/config), thus doesn't require setting environment variables.
2) Many unused config items are removed.
3) Provide a simple `example.conf` file, so users can get started quickly.
4) All possible options and their default values are declared and documented in `ray.default.conf` file.

This PR also simplifies and refines the following code:
1) The process of `Ray.init()`.
2) `RunManager`.
3) `WorkerContext`. 

### How to use this configuration?
1. Copy `example.conf` into your classpath and rename it to `ray.conf`.
2. Modify/add your configuration items. The all items are declared in `ray.default.conf`.
3. You can also set the items in java system prosperities.

Note: configuration is read in this priority:
System properties > `ray.conf` > `ray.default.conf`

## Related issue number
N/A
This commit is contained in:
Wang Qing
2018-09-26 20:14:22 +08:00
committed by Hao Chen
parent 0e552fbb22
commit 8e8e123777
45 changed files with 865 additions and 1892 deletions
@@ -1,20 +1,17 @@
# define default properties here
logging.level=WARN
logging.path=./run/logs
logging.file.name=core
logging.max.log.file.num=10
logging.max.log.file.size=500MB
ray.logging.level=INFO
log4j.rootLogger=${logging.level}, stdout, core
ray.logging.stdout=org.apache.log4j.ConsoleAppender
ray.logging.file=org.apache.log4j.varia.NullAppender
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.rootLogger=${ray.logging.level}, stdout, file
log4j.appender.stdout=${ray.logging.stdout}
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %p %c{1} [%t]: %m%n
log4j.appender.core=org.apache.log4j.RollingFileAppender
log4j.appender.core.File=${logging.path}/${logging.file.name}.log
log4j.appender.core.Append=true
log4j.appender.core.MaxFileSize=${logging.max.log.file.size}
log4j.appender.core.MaxBackupIndex=${logging.max.log.file.num}
log4j.appender.core.layout=org.apache.log4j.PatternLayout
log4j.appender.core.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %p %c{1} [%t]: %m%n
# Set the file appender to null by default. If `ray.redirect-output` config is set to true,
# this appender will be set to a real file appender.
log4j.appender.file=${ray.logging.file}
log4j.appender.file.File=${ray.logging.file.path}
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %p %c{1} [%t]: %m%n
@@ -0,0 +1,79 @@
// This file contains default values of all Ray configurations.
// Users should define their own 'ray.conf' file in the classpath,
// or use Java properties, to overwrite these values.
ray {
// ----------------------
// Basic configurations
// ----------------------
// This is the path to the directory where Ray is installed, e.g.,
// something like /home/ubmutu/ray. This can be an absolute path or
// a relative path from the current working directory.
home: ""
// IP of this node. if not provided, IP will be automatically detected.
node-ip: ""
// 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.
// `CLUSTER`: Ray is running on one or more nodes, with multiple processes.
run-mode: CLUSTER
// Available resources on this node, for example "CPU:4,GPU:0".
resources: ""
// If worker.mode is DRIVER, specify the driver id.
// If not provided, a random id will be used.
driver.id: ""
// Root dir of log files.
log-dir: /tmp/ray/logs
// If true, output of worker processes will be redirected to log files.
// Otherwise, output will be printed to console.
redirect-output: true
// Custom `java.library.path`
// Note, do not use `dir1:dir2` format, put each dir as a list item.
library.path: []
// Custom classpath.
// Note, do not use `dir1:dir2` format, put each dir as a list item.
classpath = []
// ----------------------
// Redis configurations
// ----------------------
redis {
// The address of the redis server to connect, in format `ip:port`.
// If not provided, Ray processes will be started locally, including
// 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 `redis.server` isn't provided, how many Redis shards we should start in addition to the
// primary Redis shard. The ports of these shards will be `head-port + 1`, `head-port + 2`, etc.
shard-number: 1
}
// ----------------------------
// Object store configurations
// ----------------------------
object-store {
// RPC socket name of object store
socket-name: /tmp/ray/sockets/object_store
// Initial size of the object store.
size: 10 MB
}
// ----------------------------
// Raylet configurations
// ----------------------------
raylet {
// RPC socket name of Raylet
socket-name: /tmp/ray/sockets/raylet
}
}