[cpp worker] support cluster mode and object Put/Get works (#9682)

This commit is contained in:
SongGuyang
2020-08-28 13:53:36 +08:00
committed by GitHub
parent 0d22c0b653
commit cb70864c04
28 changed files with 490 additions and 58 deletions
+1 -1
View File
@@ -33,7 +33,7 @@ int main() {
/// put and get object
auto obj = Ray::Put(123);
auto getRsult = obj.Get();
auto get_result = obj.Get();
/// general function remote callargs passed by value
auto r0 = Ray::Task(Return1).Remote();
+27
View File
@@ -0,0 +1,27 @@
/// This is a complete example of writing a distributed program using the C ++ worker API.
/// including the header
#include <ray/api.h>
#include <ray/api/ray_config.h>
#include <ray/util/logging.h>
/// using namespace
using namespace ray::api;
int main(int argc, char **argv) {
RAY_LOG(INFO) << "Start cpp worker example";
/// initialization to cluster mode
ray::api::RayConfig::GetInstance()->run_mode = RunMode::CLUSTER;
/// Set redis ip to connect an existing ray cluster.
/// ray::api::RayConfig::GetInstance()->redis_ip = "127.0.0.1";
Ray::Init();
/// put and get object
auto obj = Ray::Put(123);
auto get_result = *(obj.Get());
RAY_LOG(INFO) << "Get result: " << get_result;
Ray::Shutdown();
}