mirror of
https://github.com/wassname/ray.git
synced 2026-08-19 12:30:27 +08:00
Use scoped enums in C++ and flatbuffers. (#2194)
* Enable --scoped-enums in flatbuffer compiler. * Change enum to c++11 style (enum class). * Resolve conflicts. * Solve building failure when RAY_USE_NEW_GCS=on and remove ERROR_INDEX suffix. * Merge with master and fix CI failure.
This commit is contained in:
committed by
Philipp Moritz
parent
f0907a6ee9
commit
0a34bea0b0
@@ -136,7 +136,7 @@ int64_t task_table_delayed_add_task(event_loop *loop,
|
||||
|
||||
void task_table_test_callback(Task *callback_task, void *user_data) {
|
||||
task_table_test_callback_called = 1;
|
||||
RAY_CHECK(Task_state(callback_task) == TASK_STATUS_SCHEDULED);
|
||||
RAY_CHECK(Task_state(callback_task) == TaskStatus::SCHEDULED);
|
||||
RAY_CHECK(Task_size(callback_task) == Task_size(task_table_test_task));
|
||||
RAY_CHECK(Task_equals(callback_task, task_table_test_task));
|
||||
event_loop *loop = (event_loop *) user_data;
|
||||
@@ -152,13 +152,13 @@ TEST task_table_test(void) {
|
||||
DBClientID local_scheduler_id = DBClientID::from_random();
|
||||
TaskExecutionSpec spec = example_task_execution_spec(1, 1);
|
||||
task_table_test_task =
|
||||
Task_alloc(spec, TASK_STATUS_SCHEDULED, local_scheduler_id);
|
||||
Task_alloc(spec, TaskStatus::SCHEDULED, local_scheduler_id);
|
||||
RetryInfo retry = {
|
||||
.num_retries = NUM_RETRIES,
|
||||
.timeout = TIMEOUT,
|
||||
.fail_callback = task_table_test_fail_callback,
|
||||
};
|
||||
task_table_subscribe(db, local_scheduler_id, TASK_STATUS_SCHEDULED,
|
||||
task_table_subscribe(db, local_scheduler_id, TaskStatus::SCHEDULED,
|
||||
task_table_test_callback, (void *) loop, &retry, NULL,
|
||||
(void *) loop);
|
||||
event_loop_add_timer(
|
||||
@@ -186,13 +186,13 @@ TEST task_table_all_test(void) {
|
||||
TaskExecutionSpec spec = example_task_execution_spec(1, 1);
|
||||
/* Schedule two tasks on different local local schedulers. */
|
||||
Task *task1 =
|
||||
Task_alloc(spec, TASK_STATUS_SCHEDULED, DBClientID::from_random());
|
||||
Task_alloc(spec, TaskStatus::SCHEDULED, DBClientID::from_random());
|
||||
Task *task2 =
|
||||
Task_alloc(spec, TASK_STATUS_SCHEDULED, DBClientID::from_random());
|
||||
Task_alloc(spec, TaskStatus::SCHEDULED, DBClientID::from_random());
|
||||
RetryInfo retry = {
|
||||
.num_retries = NUM_RETRIES, .timeout = TIMEOUT, .fail_callback = NULL,
|
||||
};
|
||||
task_table_subscribe(db, UniqueID::nil(), TASK_STATUS_SCHEDULED,
|
||||
task_table_subscribe(db, UniqueID::nil(), TaskStatus::SCHEDULED,
|
||||
task_table_all_test_callback, NULL, &retry, NULL, NULL);
|
||||
event_loop_add_timer(loop, 50, (event_loop_timer_handler) timeout_handler,
|
||||
NULL);
|
||||
@@ -211,7 +211,7 @@ TEST task_table_all_test(void) {
|
||||
}
|
||||
|
||||
TEST unique_client_id_test(void) {
|
||||
enum { num_conns = 100 };
|
||||
const int num_conns = 100;
|
||||
|
||||
DBClientID ids[num_conns];
|
||||
DBHandle *db;
|
||||
|
||||
@@ -42,7 +42,7 @@ static inline TaskExecutionSpec example_task_execution_spec(
|
||||
|
||||
static inline Task *example_task_with_args(int64_t num_args,
|
||||
int64_t num_returns,
|
||||
int task_state,
|
||||
TaskStatus task_state,
|
||||
ObjectID arg_ids[]) {
|
||||
TaskExecutionSpec spec =
|
||||
example_task_execution_spec_with_args(num_args, num_returns, arg_ids);
|
||||
@@ -52,7 +52,7 @@ static inline Task *example_task_with_args(int64_t num_args,
|
||||
|
||||
static inline Task *example_task(int64_t num_args,
|
||||
int64_t num_returns,
|
||||
int task_state) {
|
||||
TaskStatus task_state) {
|
||||
TaskExecutionSpec spec = example_task_execution_spec(num_args, num_returns);
|
||||
Task *instance = Task_alloc(spec, task_state, UniqueID::nil());
|
||||
return instance;
|
||||
|
||||
@@ -25,8 +25,9 @@ TEST ipc_socket_test(void) {
|
||||
socket_fd = connect_ipc_sock(socket_pathname);
|
||||
ASSERT(socket_fd >= 0);
|
||||
write_log_message(socket_fd, test_string);
|
||||
write_message(socket_fd, LOG_MESSAGE, strlen(test_bytes),
|
||||
(uint8_t *) test_bytes);
|
||||
write_message(socket_fd,
|
||||
static_cast<int64_t>(CommonMessageType::LOG_MESSAGE),
|
||||
strlen(test_bytes), (uint8_t *) test_bytes);
|
||||
close(socket_fd);
|
||||
exit(0);
|
||||
} else {
|
||||
@@ -40,7 +41,8 @@ TEST ipc_socket_test(void) {
|
||||
int64_t len;
|
||||
uint8_t *bytes;
|
||||
read_message(client_fd, &type, &len, &bytes);
|
||||
ASSERT(type == LOG_MESSAGE);
|
||||
ASSERT(static_cast<CommonMessageType>(type) ==
|
||||
CommonMessageType::LOG_MESSAGE);
|
||||
ASSERT(memcmp(test_bytes, bytes, len) == 0);
|
||||
free(bytes);
|
||||
close(client_fd);
|
||||
@@ -69,8 +71,9 @@ TEST long_ipc_socket_test(void) {
|
||||
socket_fd = connect_ipc_sock(socket_pathname);
|
||||
ASSERT(socket_fd >= 0);
|
||||
write_log_message(socket_fd, test_string.c_str());
|
||||
write_message(socket_fd, LOG_MESSAGE, strlen(test_bytes),
|
||||
(uint8_t *) test_bytes);
|
||||
write_message(socket_fd,
|
||||
static_cast<int64_t>(CommonMessageType::LOG_MESSAGE),
|
||||
strlen(test_bytes), (uint8_t *) test_bytes);
|
||||
close(socket_fd);
|
||||
exit(0);
|
||||
} else {
|
||||
@@ -84,7 +87,8 @@ TEST long_ipc_socket_test(void) {
|
||||
int64_t len;
|
||||
uint8_t *bytes;
|
||||
read_message(client_fd, &type, &len, &bytes);
|
||||
ASSERT(type == LOG_MESSAGE);
|
||||
ASSERT(static_cast<CommonMessageType>(type) ==
|
||||
CommonMessageType::LOG_MESSAGE);
|
||||
ASSERT(memcmp(test_bytes, bytes, len) == 0);
|
||||
free(bytes);
|
||||
close(client_fd);
|
||||
|
||||
@@ -79,7 +79,7 @@ TEST new_object_test(void) {
|
||||
new_object_failed = 0;
|
||||
new_object_succeeded = 0;
|
||||
new_object_id = ObjectID::from_random();
|
||||
new_object_task = example_task(1, 1, TASK_STATUS_WAITING);
|
||||
new_object_task = example_task(1, 1, TaskStatus::WAITING);
|
||||
new_object_task_spec = Task_task_execution_spec(new_object_task)->Spec();
|
||||
new_object_task_id = TaskSpec_task_id(new_object_task_spec);
|
||||
g_loop = event_loop_create();
|
||||
@@ -91,7 +91,7 @@ TEST new_object_test(void) {
|
||||
.timeout = 100,
|
||||
.fail_callback = new_object_fail_callback,
|
||||
};
|
||||
task_table_subscribe(db, UniqueID::nil(), TASK_STATUS_WAITING, NULL, NULL,
|
||||
task_table_subscribe(db, UniqueID::nil(), TaskStatus::WAITING, NULL, NULL,
|
||||
&retry, task_table_subscribe_done, db);
|
||||
event_loop_run(g_loop);
|
||||
db_disconnect(db);
|
||||
|
||||
@@ -105,7 +105,7 @@ void subscribe_success_callback(TaskID task_id, void *context) {
|
||||
}
|
||||
|
||||
TEST add_lookup_test(void) {
|
||||
add_lookup_task = example_task(1, 1, TASK_STATUS_WAITING);
|
||||
add_lookup_task = example_task(1, 1, TaskStatus::WAITING);
|
||||
g_loop = event_loop_create();
|
||||
DBHandle *db = db_connect(std::string("127.0.0.1"), 6379, "plasma_manager",
|
||||
"127.0.0.1", std::vector<std::string>());
|
||||
@@ -116,7 +116,7 @@ TEST add_lookup_test(void) {
|
||||
.fail_callback = add_lookup_fail_callback,
|
||||
};
|
||||
/* Wait for subscription to succeed before adding the task. */
|
||||
task_table_subscribe(db, UniqueID::nil(), TASK_STATUS_WAITING, NULL, NULL,
|
||||
task_table_subscribe(db, UniqueID::nil(), TaskStatus::WAITING, NULL, NULL,
|
||||
&retry, subscribe_success_callback, (void *) db);
|
||||
/* Disconnect the database to see if the lookup times out. */
|
||||
event_loop_run(g_loop);
|
||||
@@ -156,7 +156,7 @@ TEST subscribe_timeout_test(void) {
|
||||
.timeout = 100,
|
||||
.fail_callback = subscribe_fail_callback,
|
||||
};
|
||||
task_table_subscribe(db, UniqueID::nil(), TASK_STATUS_WAITING, NULL, NULL,
|
||||
task_table_subscribe(db, UniqueID::nil(), TaskStatus::WAITING, NULL, NULL,
|
||||
&retry, subscribe_done_callback,
|
||||
(void *) subscribe_timeout_context);
|
||||
/* Disconnect the database to see if the subscribe times out. */
|
||||
@@ -194,11 +194,11 @@ TEST publish_timeout_test(void) {
|
||||
DBHandle *db = db_connect(std::string("127.0.0.1"), 6379, "plasma_manager",
|
||||
"127.0.0.1", std::vector<std::string>());
|
||||
db_attach(db, g_loop, false);
|
||||
Task *task = example_task(1, 1, TASK_STATUS_WAITING);
|
||||
Task *task = example_task(1, 1, TaskStatus::WAITING);
|
||||
RetryInfo retry = {
|
||||
.num_retries = 5, .timeout = 100, .fail_callback = publish_fail_callback,
|
||||
};
|
||||
task_table_subscribe(db, UniqueID::nil(), TASK_STATUS_WAITING, NULL, NULL,
|
||||
task_table_subscribe(db, UniqueID::nil(), TaskStatus::WAITING, NULL, NULL,
|
||||
&retry, NULL, NULL);
|
||||
task_table_add_task(db, task, &retry, publish_done_callback,
|
||||
(void *) publish_timeout_context);
|
||||
@@ -270,7 +270,7 @@ TEST subscribe_retry_test(void) {
|
||||
.timeout = 100,
|
||||
.fail_callback = subscribe_retry_fail_callback,
|
||||
};
|
||||
task_table_subscribe(db, UniqueID::nil(), TASK_STATUS_WAITING, NULL, NULL,
|
||||
task_table_subscribe(db, UniqueID::nil(), TaskStatus::WAITING, NULL, NULL,
|
||||
&retry, subscribe_retry_done_callback,
|
||||
(void *) subscribe_retry_context);
|
||||
/* Disconnect the database to see if the subscribe times out. */
|
||||
@@ -315,13 +315,13 @@ TEST publish_retry_test(void) {
|
||||
DBHandle *db = db_connect(std::string("127.0.0.1"), 6379, "plasma_manager",
|
||||
"127.0.0.1", std::vector<std::string>());
|
||||
db_attach(db, g_loop, false);
|
||||
Task *task = example_task(1, 1, TASK_STATUS_WAITING);
|
||||
Task *task = example_task(1, 1, TaskStatus::WAITING);
|
||||
RetryInfo retry = {
|
||||
.num_retries = 5,
|
||||
.timeout = 100,
|
||||
.fail_callback = publish_retry_fail_callback,
|
||||
};
|
||||
task_table_subscribe(db, UniqueID::nil(), TASK_STATUS_WAITING, NULL, NULL,
|
||||
task_table_subscribe(db, UniqueID::nil(), TaskStatus::WAITING, NULL, NULL,
|
||||
&retry, NULL, NULL);
|
||||
task_table_add_task(db, task, &retry, publish_retry_done_callback,
|
||||
(void *) publish_retry_context);
|
||||
@@ -374,7 +374,7 @@ TEST subscribe_late_test(void) {
|
||||
.timeout = 0,
|
||||
.fail_callback = subscribe_late_fail_callback,
|
||||
};
|
||||
task_table_subscribe(db, UniqueID::nil(), TASK_STATUS_WAITING, NULL, NULL,
|
||||
task_table_subscribe(db, UniqueID::nil(), TaskStatus::WAITING, NULL, NULL,
|
||||
&retry, subscribe_late_done_callback,
|
||||
(void *) subscribe_late_context);
|
||||
/* Install handler for terminating the event loop. */
|
||||
@@ -414,13 +414,13 @@ TEST publish_late_test(void) {
|
||||
DBHandle *db = db_connect(std::string("127.0.0.1"), 6379, "plasma_manager",
|
||||
"127.0.0.1", std::vector<std::string>());
|
||||
db_attach(db, g_loop, false);
|
||||
Task *task = example_task(1, 1, TASK_STATUS_WAITING);
|
||||
Task *task = example_task(1, 1, TaskStatus::WAITING);
|
||||
RetryInfo retry = {
|
||||
.num_retries = 0,
|
||||
.timeout = 0,
|
||||
.fail_callback = publish_late_fail_callback,
|
||||
};
|
||||
task_table_subscribe(db, UniqueID::nil(), TASK_STATUS_WAITING, NULL, NULL,
|
||||
task_table_subscribe(db, UniqueID::nil(), TaskStatus::WAITING, NULL, NULL,
|
||||
NULL, NULL, NULL);
|
||||
task_table_add_task(db, task, &retry, publish_late_done_callback,
|
||||
(void *) publish_late_context);
|
||||
|
||||
@@ -181,13 +181,15 @@ TEST send_task(void) {
|
||||
TaskSpec *spec = TaskSpec_finish_construct(builder, &size);
|
||||
int fd[2];
|
||||
socketpair(AF_UNIX, SOCK_STREAM, 0, fd);
|
||||
write_message(fd[0], SUBMIT_TASK, size, (uint8_t *) spec);
|
||||
write_message(fd[0], static_cast<int64_t>(CommonMessageType::SUBMIT_TASK),
|
||||
size, (uint8_t *) spec);
|
||||
int64_t type;
|
||||
int64_t length;
|
||||
uint8_t *message;
|
||||
read_message(fd[1], &type, &length, &message);
|
||||
TaskSpec *result = (TaskSpec *) message;
|
||||
ASSERT(type == SUBMIT_TASK);
|
||||
ASSERT(static_cast<CommonMessageType>(type) ==
|
||||
CommonMessageType::SUBMIT_TASK);
|
||||
ASSERT(memcmp(spec, result, size) == 0);
|
||||
TaskSpec_free(spec);
|
||||
free(result);
|
||||
|
||||
Reference in New Issue
Block a user