mirror of
https://github.com/wassname/ray.git
synced 2026-09-10 12:38:43 +08:00
Object reconstruction in Photon (#65)
* Object reconstruction in Photon and C test cases for Photon * Fix hanging test case on mac * Remove unnecessary event from photon tests * make photon_disconnect not leak file descriptors * fix some of the memory errors * Fix valgrind * lint * Address Robert's comments and add test case for object reconstruction suppression * Remove OWNER
This commit is contained in:
committed by
Robert Nishihara
parent
817f1e730c
commit
4bdb9f7224
@@ -141,7 +141,7 @@ TEST task_table_test(void) {
|
||||
db_handle *db = db_connect("127.0.0.1", 6379, "local_scheduler", "", -1);
|
||||
db_attach(db, loop, false);
|
||||
node_id node = globally_unique_id();
|
||||
task_spec *spec = example_task_spec();
|
||||
task_spec *spec = example_task_spec(1, 1);
|
||||
task_table_test_task = alloc_task(spec, TASK_STATUS_SCHEDULED, node);
|
||||
free_task_spec(spec);
|
||||
retry_info retry = {
|
||||
@@ -172,7 +172,7 @@ TEST task_table_all_test(void) {
|
||||
event_loop *loop = event_loop_create();
|
||||
db_handle *db = db_connect("127.0.0.1", 6379, "local_scheduler", "", -1);
|
||||
db_attach(db, loop, false);
|
||||
task_spec *spec = example_task_spec();
|
||||
task_spec *spec = example_task_spec(1, 1);
|
||||
/* Schedule two tasks on different nodes. */
|
||||
task *task1 = alloc_task(spec, TASK_STATUS_SCHEDULED, globally_unique_id());
|
||||
task *task2 = alloc_task(spec, TASK_STATUS_SCHEDULED, globally_unique_id());
|
||||
|
||||
@@ -67,7 +67,7 @@ TEST new_object_test(void) {
|
||||
new_object_failed = 0;
|
||||
new_object_succeeded = 0;
|
||||
new_object_id = globally_unique_id();
|
||||
new_object_task = example_task();
|
||||
new_object_task = example_task(1, 1, TASK_STATUS_WAITING);
|
||||
new_object_task_spec = task_task_spec(new_object_task);
|
||||
new_object_task_id = task_spec_id(new_object_task_spec);
|
||||
g_loop = event_loop_create();
|
||||
|
||||
@@ -92,7 +92,7 @@ void add_success_callback(task_id task_id, void *context) {
|
||||
}
|
||||
|
||||
TEST add_lookup_test(void) {
|
||||
add_lookup_task = example_task();
|
||||
add_lookup_task = example_task(1, 1, TASK_STATUS_WAITING);
|
||||
g_loop = event_loop_create();
|
||||
db_handle *db =
|
||||
db_connect("127.0.0.1", 6379, "plasma_manager", "127.0.0.1", 1234);
|
||||
@@ -180,7 +180,7 @@ TEST publish_timeout_test(void) {
|
||||
db_handle *db =
|
||||
db_connect("127.0.0.1", 6379, "plasma_manager", "127.0.0.1", 1234);
|
||||
db_attach(db, g_loop, false);
|
||||
task *task = example_task();
|
||||
task *task = example_task(1, 1, TASK_STATUS_WAITING);
|
||||
retry_info retry = {
|
||||
.num_retries = 5, .timeout = 100, .fail_callback = publish_fail_callback,
|
||||
};
|
||||
@@ -289,7 +289,7 @@ TEST publish_retry_test(void) {
|
||||
db_handle *db =
|
||||
db_connect("127.0.0.1", 6379, "plasma_manager", "127.0.0.1", 11235);
|
||||
db_attach(db, g_loop, false);
|
||||
task *task = example_task();
|
||||
task *task = example_task(1, 1, TASK_STATUS_WAITING);
|
||||
retry_info retry = {
|
||||
.num_retries = 5,
|
||||
.timeout = 100,
|
||||
@@ -383,7 +383,7 @@ TEST publish_late_test(void) {
|
||||
db_handle *db =
|
||||
db_connect("127.0.0.1", 6379, "plasma_manager", "127.0.0.1", 11236);
|
||||
db_attach(db, g_loop, false);
|
||||
task *task = example_task();
|
||||
task *task = example_task(1, 1, TASK_STATUS_WAITING);
|
||||
retry_info retry = {
|
||||
.num_retries = 0,
|
||||
.timeout = 0,
|
||||
|
||||
@@ -1,30 +1,99 @@
|
||||
#ifndef TEST_COMMON_H
|
||||
#define TEST_COMMON_H
|
||||
|
||||
#include "io.h"
|
||||
#include "hiredis/hiredis.h"
|
||||
#include "utstring.h"
|
||||
|
||||
#include "task.h"
|
||||
|
||||
static task_spec *example_task_spec(void) {
|
||||
#ifndef _WIN32
|
||||
/* This function is actually not declared in standard POSIX, so declare it. */
|
||||
extern int usleep(useconds_t usec);
|
||||
#endif
|
||||
|
||||
const int64_t arg_value_size = 1000;
|
||||
|
||||
static inline task_spec *example_task_spec_with_args(int64_t num_args,
|
||||
int64_t num_returns,
|
||||
object_id arg_ids[]) {
|
||||
task_id parent_task_id = globally_unique_id();
|
||||
function_id func_id = globally_unique_id();
|
||||
task_spec *task =
|
||||
start_construct_task_spec(parent_task_id, 0, func_id, 2, 1, 0);
|
||||
task_args_add_ref(task, globally_unique_id());
|
||||
task_args_add_ref(task, globally_unique_id());
|
||||
task_spec *task = start_construct_task_spec(
|
||||
parent_task_id, 0, func_id, num_args, num_returns, arg_value_size);
|
||||
for (int64_t i = 0; i < num_args; ++i) {
|
||||
object_id arg_id;
|
||||
if (arg_ids == NULL) {
|
||||
arg_id = globally_unique_id();
|
||||
} else {
|
||||
arg_id = arg_ids[i];
|
||||
}
|
||||
task_args_add_ref(task, arg_id);
|
||||
}
|
||||
finish_construct_task_spec(task);
|
||||
return task;
|
||||
}
|
||||
|
||||
static task *example_task(void) {
|
||||
task_spec *spec = example_task_spec();
|
||||
task *instance = alloc_task(spec, TASK_STATUS_WAITING, NIL_ID);
|
||||
static inline task_spec *example_task_spec(int64_t num_args,
|
||||
int64_t num_returns) {
|
||||
return example_task_spec_with_args(num_args, num_returns, NULL);
|
||||
}
|
||||
|
||||
static inline task *example_task_with_args(int64_t num_args,
|
||||
int64_t num_returns,
|
||||
scheduling_state task_state,
|
||||
object_id arg_ids[]) {
|
||||
task_spec *spec = example_task_spec_with_args(num_args, num_returns, arg_ids);
|
||||
task *instance = alloc_task(spec, task_state, NIL_ID);
|
||||
free_task_spec(spec);
|
||||
return instance;
|
||||
}
|
||||
|
||||
static inline task *example_task(int64_t num_args,
|
||||
int64_t num_returns,
|
||||
scheduling_state task_state) {
|
||||
task_spec *spec = example_task_spec(num_args, num_returns);
|
||||
task *instance = alloc_task(spec, task_state, NIL_ID);
|
||||
free_task_spec(spec);
|
||||
return instance;
|
||||
}
|
||||
|
||||
/* I/O helper methods to retry binding to sockets. */
|
||||
static inline UT_string *bind_ipc_sock_retry(const char *socket_name_format,
|
||||
int *fd) {
|
||||
UT_string *socket_name = NULL;
|
||||
for (int num_retries = 0; num_retries < 5; ++num_retries) {
|
||||
LOG_INFO("trying to find plasma socket (attempt %d)", num_retries);
|
||||
utstring_renew(socket_name);
|
||||
utstring_printf(socket_name, socket_name_format, rand());
|
||||
*fd = bind_ipc_sock(utstring_body(socket_name), true);
|
||||
if (*fd < 0) {
|
||||
/* Sleep for 100ms. */
|
||||
usleep(100000);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return socket_name;
|
||||
}
|
||||
|
||||
static inline int bind_inet_sock_retry(int *fd) {
|
||||
int port = -1;
|
||||
for (int num_retries = 0; num_retries < 5; ++num_retries) {
|
||||
port = 10000 + rand() % 40000;
|
||||
*fd = bind_inet_sock(port, true);
|
||||
if (*fd < 0) {
|
||||
/* Sleep for 100ms. */
|
||||
usleep(100000);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return port;
|
||||
}
|
||||
|
||||
/* Flush redis. */
|
||||
static void flushall_redis() {
|
||||
static inline void flushall_redis() {
|
||||
redisContext *context = redisConnect("127.0.0.1", 6379);
|
||||
freeReplyObject(redisCommand(context, "FLUSHALL"));
|
||||
redisFree(context);
|
||||
|
||||
Reference in New Issue
Block a user