ray/java
Hao Chen f31a79f3f7
Implement actor checkpointing (#3839)
* Implement Actor checkpointing

* docs

* fix

* fix

* fix

* move restore-from-checkpoint to HandleActorStateTransition

* Revert "move restore-from-checkpoint to HandleActorStateTransition"

This reverts commit 9aa4447c1e3e321f42a1d895d72f17098b72de12.

* resubmit waiting tasks when actor frontier restored

* add doc about num_actor_checkpoints_to_keep=1

* add num_actor_checkpoints_to_keep to Cython

* add checkpoint_expired api

* check if actor class is abstract

* change checkpoint_ids to long string

* implement java

* Refactor to delay actor creation publish until checkpoint is resumed

* debug, lint

* Erase from checkpoints to restore if task fails

* fix lint

* update comments

* avoid duplicated actor notification log

* fix unintended change

* add actor_id to checkpoint_expired

* small java updates

* make checkpoint info per actor

* lint

* Remove logging

* Remove old actor checkpointing Python code, move new checkpointing code to FunctionActionManager

* Replace old actor checkpointing tests

* Fix test and lint

* address comments

* consolidate kill_actor

* Remove __ray_checkpoint__

* fix non-ascii char

* Loosen test checks

* fix java

* fix sphinx-build
2019-02-13 19:39:02 +08:00
..
api Implement actor checkpointing (#3839) 2019-02-13 19:39:02 +08:00
cli [Java] Simplify Java worker configuration (#2938) 2018-09-26 20:14:22 +08:00
doc Update arrow to reduce plasma IPCs. (#3497) 2018-12-14 23:49:37 -05:00
runtime Implement actor checkpointing (#3839) 2019-02-13 19:39:02 +08:00
test Implement actor checkpointing (#3839) 2019-02-13 19:39:02 +08:00
tutorial Remove legacy Ray code. (#3121) 2018-10-26 13:36:58 -07:00
build.sh update ray cmake build process (#2853) 2018-09-12 11:19:33 -07:00
checkstyle-suppressions.xml Implement actor checkpointing (#3839) 2019-02-13 19:39:02 +08:00
checkstyle.xml [JavaWorker] Java code lint check and binding to CI (#2225) 2018-06-09 16:26:54 -07:00
cleanup.sh [Java] fix java/cleanup.sh (#2989) 2018-09-28 21:31:47 -05:00
example.conf [Java] Simplify Java worker configuration (#2938) 2018-09-26 20:14:22 +08:00
logfilter.sh [JavaWorker] Enable java worker support (#2094) 2018-05-26 14:38:50 -07:00
modify_generated_java_flatbuffers_files.py Support to auto-generate Java files from flatbuffer (#3749) 2019-01-13 11:39:23 -08:00
pom.xml Use one memory mapped file for plasma (#3871) 2019-02-06 23:53:05 -08:00
prepare.sh Convert the raylet client (the code in local_scheduler_client.cc) to proper C++. (#3511) 2018-12-13 13:39:10 -08:00
README.rst [java] customize path of ray.conf (#3100) 2018-10-26 13:36:34 +08:00
run.sh [Java] Java worker cluster support (#2359) 2018-07-09 10:20:41 -07:00
test.sh update ray cmake build process (#2853) 2018-09-12 11:19:33 -07:00
test_cluster.sh add java tutorial (#2491) 2018-07-28 17:09:30 -07:00

Quick start
===========

Configuration
-------------
Ray will read your configurations in the following order:

* Java system properties: e.g., ``-Dray.home=/path/to/ray``.
* A ``ray.conf`` file in the classpath: `example <https://github.com/ray-project/ray/blob/master/java/example.conf>`_.
* Customise your own ``ray.conf`` path using system property ``-Dray.config=/path/to/ray.conf``

For all available config items and default values, see `this file <https://github.com/ray-project/ray/blob/master/java/runtime/src/main/resources/ray.default.conf>`_.

Starting Ray
------------

.. code:: java

    Ray.init();

Read and write remote objects
-----------------------------

Each remote object is considered a ``RayObject<T>`` where ``T`` is the
type for this object. You can use ``Ray.put`` and ``RayObject<T>.get``
to write and read the objects.

.. code:: java

    Integer x = 1;
    RayObject<Integer> obj = Ray.put(x);
    Integer x1 = obj.get();
    assert (x.equals(x1));

Remote functions
----------------

Here is an ordinary java code piece for composing
``hello world example``.

.. code:: java

    public class ExampleClass {
        public static void main(String[] args) {
            String str1 = add("hello", "world");
            String str = add(str1, "example");
            System.out.println(str);
        }
        public static String add(String a, String b) {
            return a + " " + b;
        }
    }

We use ``@RayRemote`` to indicate that a function is remote, and use
``Ray.call`` to invoke it. The result from the latter is a
``RayObject<R>`` where ``R`` is the return type of the target function.
The following shows the changed example with ``add`` annotated, and
correspondent calls executed on remote machines.

.. code:: java

    public class ExampleClass {
        public static void main(String[] args) {
            Ray.init();
            RayObject<String> objStr1 = Ray.call(ExampleClass::add, "hello", "world");
            RayObject<String> objStr2 = Ray.call(ExampleClass::add, objStr1, "example");
            String str = objStr2.get();
            System.out.println(str);
        }

        @RayRemote
        public static String add(String a, String b) {
            return a + " " + b;
        }
    }

More information
================

- `Installation <https://github.com/ray-project/ray/tree/master/java/doc/installation.rst>`_
- `API document <https://github.com/ray-project/ray/tree/master/java/doc/api.rst>`_
- `Tutorial <https://github.com/ray-project/ray/tree/master/java/tutorial>`_