mirror of
https://github.com/wassname/ray.git
synced 2026-07-28 11:25:04 +08:00
Update logging and check macros. (#1627)
* Update logging and check macros. * Fix linting. * Fix RAY_DCHECK and unused variable. * Fix linting
This commit is contained in:
committed by
Philipp Moritz
parent
e7df293946
commit
0fcceef772
@@ -42,13 +42,13 @@ void lookup_done_callback(ObjectID object_id,
|
||||
const std::vector<DBClientID> &manager_ids,
|
||||
void *user_context) {
|
||||
DBHandle *db = (DBHandle *) user_context;
|
||||
CHECK(manager_ids.size() == 2);
|
||||
RAY_CHECK(manager_ids.size() == 2);
|
||||
const std::vector<std::string> managers =
|
||||
db_client_table_get_ip_addresses(db, manager_ids);
|
||||
CHECK(parse_ip_addr_port(managers.at(0).c_str(), received_addr1,
|
||||
&received_port1) == 0);
|
||||
CHECK(parse_ip_addr_port(managers.at(1).c_str(), received_addr2,
|
||||
&received_port2) == 0);
|
||||
RAY_CHECK(parse_ip_addr_port(managers.at(0).c_str(), received_addr1,
|
||||
&received_port1) == 0);
|
||||
RAY_CHECK(parse_ip_addr_port(managers.at(1).c_str(), received_addr2,
|
||||
&received_port2) == 0);
|
||||
}
|
||||
|
||||
/* Entry added to database successfully. */
|
||||
@@ -57,7 +57,7 @@ void add_done_callback(ObjectID object_id, bool success, void *user_context) {}
|
||||
/* Test if we got a timeout callback if we couldn't connect database. */
|
||||
void timeout_callback(ObjectID object_id, void *context, void *user_data) {
|
||||
user_context *uc = (user_context *) context;
|
||||
CHECK(uc->test_number == TEST_NUMBER)
|
||||
RAY_CHECK(uc->test_number == TEST_NUMBER);
|
||||
}
|
||||
|
||||
int64_t timeout_handler(event_loop *loop, int64_t id, void *context) {
|
||||
@@ -136,9 +136,9 @@ 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;
|
||||
CHECK(Task_state(callback_task) == TASK_STATUS_SCHEDULED);
|
||||
CHECK(Task_size(callback_task) == Task_size(task_table_test_task));
|
||||
CHECK(Task_equals(callback_task, task_table_test_task));
|
||||
RAY_CHECK(Task_state(callback_task) == TASK_STATUS_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;
|
||||
event_loop_stop(loop);
|
||||
}
|
||||
|
||||
@@ -38,13 +38,13 @@ void new_object_done_callback(ObjectID object_id,
|
||||
bool is_put,
|
||||
void *user_context) {
|
||||
new_object_succeeded = 1;
|
||||
CHECK(object_id == new_object_id);
|
||||
CHECK(task_id == new_object_task_id);
|
||||
RAY_CHECK(object_id == new_object_id);
|
||||
RAY_CHECK(task_id == new_object_task_id);
|
||||
event_loop_stop(g_loop);
|
||||
}
|
||||
|
||||
void new_object_lookup_callback(ObjectID object_id, void *user_context) {
|
||||
CHECK(object_id == new_object_id);
|
||||
RAY_CHECK(object_id == new_object_id);
|
||||
RetryInfo retry = {
|
||||
.num_retries = 5,
|
||||
.timeout = 100,
|
||||
@@ -109,7 +109,7 @@ void new_object_no_task_callback(ObjectID object_id,
|
||||
bool is_put,
|
||||
void *user_context) {
|
||||
new_object_succeeded = 1;
|
||||
CHECK(task_id.is_nil());
|
||||
RAY_CHECK(task_id.is_nil());
|
||||
event_loop_stop(g_loop);
|
||||
}
|
||||
|
||||
@@ -150,12 +150,12 @@ void lookup_done_callback(ObjectID object_id,
|
||||
const std::vector<DBClientID> &manager_vector,
|
||||
void *context) {
|
||||
/* The done callback should not be called. */
|
||||
CHECK(0);
|
||||
RAY_CHECK(0);
|
||||
}
|
||||
|
||||
void lookup_fail_callback(UniqueID id, void *user_context, void *user_data) {
|
||||
lookup_failed = 1;
|
||||
CHECK(user_context == (void *) lookup_timeout_context);
|
||||
RAY_CHECK(user_context == (void *) lookup_timeout_context);
|
||||
event_loop_stop(g_loop);
|
||||
}
|
||||
|
||||
@@ -189,12 +189,12 @@ int add_failed = 0;
|
||||
|
||||
void add_done_callback(ObjectID object_id, bool success, void *user_context) {
|
||||
/* The done callback should not be called. */
|
||||
CHECK(0);
|
||||
RAY_CHECK(0);
|
||||
}
|
||||
|
||||
void add_fail_callback(UniqueID id, void *user_context, void *user_data) {
|
||||
add_failed = 1;
|
||||
CHECK(user_context == (void *) add_timeout_context);
|
||||
RAY_CHECK(user_context == (void *) add_timeout_context);
|
||||
event_loop_stop(g_loop);
|
||||
}
|
||||
|
||||
@@ -230,7 +230,7 @@ void subscribe_done_callback(ObjectID object_id,
|
||||
const std::vector<DBClientID> &manager_vector,
|
||||
void *user_context) {
|
||||
/* The done callback should not be called. */
|
||||
CHECK(0);
|
||||
RAY_CHECK(0);
|
||||
}
|
||||
|
||||
void subscribe_fail_callback(UniqueID id, void *user_context, void *user_data) {
|
||||
@@ -277,7 +277,7 @@ int64_t reconnect_context_callback(event_loop *loop,
|
||||
db->sync_context = redisConnect("127.0.0.1", 6379);
|
||||
/* Re-attach the database to the event loop (the file descriptor changed). */
|
||||
db_attach(db, loop, true);
|
||||
LOG_DEBUG("Reconnected to Redis");
|
||||
RAY_LOG(DEBUG) << "Reconnected to Redis";
|
||||
return EVENT_LOOP_TIMER_DONE;
|
||||
}
|
||||
|
||||
@@ -297,7 +297,7 @@ void lookup_retry_fail_callback(UniqueID id,
|
||||
void *user_context,
|
||||
void *user_data) {
|
||||
/* The fail callback should not be called. */
|
||||
CHECK(0);
|
||||
RAY_CHECK(0);
|
||||
}
|
||||
|
||||
/* === Test add retry === */
|
||||
@@ -312,15 +312,15 @@ void add_lookup_done_callback(ObjectID object_id,
|
||||
const std::vector<DBClientID> &manager_ids,
|
||||
void *context) {
|
||||
DBHandle *db = (DBHandle *) context;
|
||||
CHECK(manager_ids.size() == 1);
|
||||
RAY_CHECK(manager_ids.size() == 1);
|
||||
const std::vector<std::string> managers =
|
||||
db_client_table_get_ip_addresses(db, manager_ids);
|
||||
CHECK(managers.at(0) == "127.0.0.1:11235");
|
||||
RAY_CHECK(managers.at(0) == "127.0.0.1:11235");
|
||||
lookup_retry_succeeded = 1;
|
||||
}
|
||||
|
||||
void add_lookup_callback(ObjectID object_id, bool success, void *user_context) {
|
||||
CHECK(success);
|
||||
RAY_CHECK(success);
|
||||
DBHandle *db = (DBHandle *) user_context;
|
||||
RetryInfo retry = {
|
||||
.num_retries = 5,
|
||||
@@ -366,15 +366,15 @@ void add_remove_lookup_done_callback(
|
||||
bool never_created,
|
||||
const std::vector<DBClientID> &manager_vector,
|
||||
void *context) {
|
||||
CHECK(context == (void *) lookup_retry_context);
|
||||
CHECK(manager_vector.size() == 0);
|
||||
RAY_CHECK(context == (void *) lookup_retry_context);
|
||||
RAY_CHECK(manager_vector.size() == 0);
|
||||
lookup_retry_succeeded = 1;
|
||||
}
|
||||
|
||||
void add_remove_lookup_callback(ObjectID object_id,
|
||||
bool success,
|
||||
void *user_context) {
|
||||
CHECK(success);
|
||||
RAY_CHECK(success);
|
||||
DBHandle *db = (DBHandle *) user_context;
|
||||
RetryInfo retry = {
|
||||
.num_retries = 5,
|
||||
@@ -387,7 +387,7 @@ void add_remove_lookup_callback(ObjectID object_id,
|
||||
}
|
||||
|
||||
void add_remove_callback(ObjectID object_id, bool success, void *user_context) {
|
||||
CHECK(success);
|
||||
RAY_CHECK(success);
|
||||
DBHandle *db = (DBHandle *) user_context;
|
||||
RetryInfo retry = {
|
||||
.num_retries = 5,
|
||||
@@ -433,7 +433,7 @@ int lookup_late_failed = 0;
|
||||
void lookup_late_fail_callback(UniqueID id,
|
||||
void *user_context,
|
||||
void *user_data) {
|
||||
CHECK(user_context == (void *) lookup_late_context);
|
||||
RAY_CHECK(user_context == (void *) lookup_late_context);
|
||||
lookup_late_failed = 1;
|
||||
}
|
||||
|
||||
@@ -442,7 +442,7 @@ void lookup_late_done_callback(ObjectID object_id,
|
||||
const std::vector<DBClientID> &manager_vector,
|
||||
void *context) {
|
||||
/* This function should never be called. */
|
||||
CHECK(0);
|
||||
RAY_CHECK(0);
|
||||
}
|
||||
|
||||
TEST lookup_late_test(void) {
|
||||
@@ -478,7 +478,7 @@ const char *add_late_context = "add_late";
|
||||
int add_late_failed = 0;
|
||||
|
||||
void add_late_fail_callback(UniqueID id, void *user_context, void *user_data) {
|
||||
CHECK(user_context == (void *) add_late_context);
|
||||
RAY_CHECK(user_context == (void *) add_late_context);
|
||||
add_late_failed = 1;
|
||||
}
|
||||
|
||||
@@ -486,7 +486,7 @@ void add_late_done_callback(ObjectID object_id,
|
||||
bool success,
|
||||
void *user_context) {
|
||||
/* This function should never be called. */
|
||||
CHECK(0);
|
||||
RAY_CHECK(0);
|
||||
}
|
||||
|
||||
TEST add_late_test(void) {
|
||||
@@ -522,7 +522,7 @@ int subscribe_late_failed = 0;
|
||||
void subscribe_late_fail_callback(UniqueID id,
|
||||
void *user_context,
|
||||
void *user_data) {
|
||||
CHECK(user_context == (void *) subscribe_late_context);
|
||||
RAY_CHECK(user_context == (void *) subscribe_late_context);
|
||||
subscribe_late_failed = 1;
|
||||
}
|
||||
|
||||
@@ -531,7 +531,7 @@ void subscribe_late_done_callback(ObjectID object_id,
|
||||
const std::vector<DBClientID> &manager_vector,
|
||||
void *user_context) {
|
||||
/* This function should never be called. */
|
||||
CHECK(0);
|
||||
RAY_CHECK(0);
|
||||
}
|
||||
|
||||
TEST subscribe_late_test(void) {
|
||||
@@ -573,7 +573,7 @@ void subscribe_success_fail_callback(UniqueID id,
|
||||
void *user_context,
|
||||
void *user_data) {
|
||||
/* This function should never be called. */
|
||||
CHECK(0);
|
||||
RAY_CHECK(0);
|
||||
}
|
||||
|
||||
void subscribe_success_done_callback(
|
||||
@@ -594,9 +594,9 @@ void subscribe_success_object_available_callback(
|
||||
int64_t data_size,
|
||||
const std::vector<DBClientID> &manager_vector,
|
||||
void *user_context) {
|
||||
CHECK(user_context == (void *) subscribe_success_context);
|
||||
CHECK(object_id == subscribe_id);
|
||||
CHECK(manager_vector.size() == 1);
|
||||
RAY_CHECK(user_context == (void *) subscribe_success_context);
|
||||
RAY_CHECK(object_id == subscribe_id);
|
||||
RAY_CHECK(manager_vector.size() == 1);
|
||||
subscribe_success_succeeded = 1;
|
||||
}
|
||||
|
||||
@@ -656,15 +656,15 @@ void subscribe_object_present_object_available_callback(
|
||||
void *user_context) {
|
||||
subscribe_object_present_context_t *ctx =
|
||||
(subscribe_object_present_context_t *) user_context;
|
||||
CHECK(ctx->data_size == data_size);
|
||||
CHECK(strcmp(subscribe_object_present_str, ctx->teststr) == 0);
|
||||
RAY_CHECK(ctx->data_size == data_size);
|
||||
RAY_CHECK(strcmp(subscribe_object_present_str, ctx->teststr) == 0);
|
||||
subscribe_object_present_succeeded = 1;
|
||||
CHECK(manager_vector.size() == 1);
|
||||
RAY_CHECK(manager_vector.size() == 1);
|
||||
}
|
||||
|
||||
void fatal_fail_callback(UniqueID id, void *user_context, void *user_data) {
|
||||
/* This function should never be called. */
|
||||
CHECK(0);
|
||||
RAY_CHECK(0);
|
||||
}
|
||||
|
||||
TEST subscribe_object_present_test(void) {
|
||||
@@ -723,7 +723,7 @@ void subscribe_object_not_present_object_available_callback(
|
||||
const std::vector<DBClientID> &manager_vector,
|
||||
void *user_context) {
|
||||
/* This should not be called. */
|
||||
CHECK(0);
|
||||
RAY_CHECK(0);
|
||||
}
|
||||
|
||||
TEST subscribe_object_not_present_test(void) {
|
||||
@@ -773,11 +773,12 @@ void subscribe_object_available_later_object_available_callback(
|
||||
void *user_context) {
|
||||
subscribe_object_present_context_t *myctx =
|
||||
(subscribe_object_present_context_t *) user_context;
|
||||
CHECK(myctx->data_size == data_size);
|
||||
CHECK(strcmp(myctx->teststr, subscribe_object_available_later_context) == 0);
|
||||
RAY_CHECK(myctx->data_size == data_size);
|
||||
RAY_CHECK(strcmp(myctx->teststr, subscribe_object_available_later_context) ==
|
||||
0);
|
||||
/* Make sure the callback is only called once. */
|
||||
subscribe_object_available_later_succeeded += 1;
|
||||
CHECK(manager_vector.size() == 1);
|
||||
RAY_CHECK(manager_vector.size() == 1);
|
||||
}
|
||||
|
||||
TEST subscribe_object_available_later_test(void) {
|
||||
|
||||
@@ -47,10 +47,10 @@ void async_redis_socket_test_callback(redisAsyncContext *ac,
|
||||
redisReply *reply =
|
||||
(redisReply *) redisCommand(context, test_get_format, test_key);
|
||||
redisFree(context);
|
||||
CHECK(reply != NULL);
|
||||
RAY_CHECK(reply != NULL);
|
||||
if (strcmp(reply->str, test_value)) {
|
||||
freeReplyObject(reply);
|
||||
CHECK(0);
|
||||
RAY_CHECK(0);
|
||||
}
|
||||
freeReplyObject(reply);
|
||||
}
|
||||
@@ -97,7 +97,7 @@ void redis_accept_callback(event_loop *loop,
|
||||
void *context,
|
||||
int events) {
|
||||
int accept_fd = accept_client(socket_fd);
|
||||
CHECK(accept_fd >= 0);
|
||||
RAY_CHECK(accept_fd >= 0);
|
||||
connections.push_back(accept_fd);
|
||||
event_loop_add_file(loop, accept_fd, EVENT_LOOP_READ, redis_read_callback,
|
||||
context);
|
||||
@@ -155,8 +155,8 @@ void logging_test_callback(redisAsyncContext *ac, void *r, void *privdata) {
|
||||
redisContext *context = redisConnect("127.0.0.1", 6379);
|
||||
redisReply *reply = (redisReply *) redisCommand(context, "KEYS %s", "log:*");
|
||||
redisFree(context);
|
||||
CHECK(reply != NULL);
|
||||
CHECK(reply->elements > 0);
|
||||
RAY_CHECK(reply != NULL);
|
||||
RAY_CHECK(reply->elements > 0);
|
||||
freeReplyObject(reply);
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ void logging_accept_callback(event_loop *loop,
|
||||
void *context,
|
||||
int events) {
|
||||
int accept_fd = accept_client(socket_fd);
|
||||
CHECK(accept_fd >= 0);
|
||||
RAY_CHECK(accept_fd >= 0);
|
||||
connections.push_back(accept_fd);
|
||||
event_loop_add_file(loop, accept_fd, EVENT_LOOP_READ, logging_read_callback,
|
||||
context);
|
||||
|
||||
@@ -27,13 +27,13 @@ void lookup_nil_fail_callback(UniqueID id,
|
||||
void *user_context,
|
||||
void *user_data) {
|
||||
/* The fail callback should not be called. */
|
||||
CHECK(0);
|
||||
RAY_CHECK(0);
|
||||
}
|
||||
|
||||
void lookup_nil_success_callback(Task *task, void *context) {
|
||||
lookup_nil_success = 1;
|
||||
CHECK(task == NULL);
|
||||
CHECK(context == (void *) lookup_nil_context);
|
||||
RAY_CHECK(task == NULL);
|
||||
RAY_CHECK(context == (void *) lookup_nil_context);
|
||||
event_loop_stop(g_loop);
|
||||
}
|
||||
|
||||
@@ -70,18 +70,18 @@ void add_lookup_fail_callback(UniqueID id,
|
||||
void *user_context,
|
||||
void *user_data) {
|
||||
/* The fail callback should not be called. */
|
||||
CHECK(0);
|
||||
RAY_CHECK(0);
|
||||
}
|
||||
|
||||
void lookup_success_callback(Task *task, void *context) {
|
||||
lookup_success = 1;
|
||||
CHECK(Task_equals(task, add_lookup_task));
|
||||
RAY_CHECK(Task_equals(task, add_lookup_task));
|
||||
event_loop_stop(g_loop);
|
||||
}
|
||||
|
||||
void add_success_callback(TaskID task_id, void *context) {
|
||||
add_success = 1;
|
||||
CHECK(TaskID_equal(task_id, Task_task_id(add_lookup_task)));
|
||||
RAY_CHECK(TaskID_equal(task_id, Task_task_id(add_lookup_task)));
|
||||
|
||||
DBHandle *db = (DBHandle *) context;
|
||||
RetryInfo retry = {
|
||||
@@ -137,12 +137,12 @@ int subscribe_failed = 0;
|
||||
|
||||
void subscribe_done_callback(TaskID task_id, void *user_context) {
|
||||
/* The done callback should not be called. */
|
||||
CHECK(0);
|
||||
RAY_CHECK(0);
|
||||
}
|
||||
|
||||
void subscribe_fail_callback(UniqueID id, void *user_context, void *user_data) {
|
||||
subscribe_failed = 1;
|
||||
CHECK(user_context == (void *) subscribe_timeout_context);
|
||||
RAY_CHECK(user_context == (void *) subscribe_timeout_context);
|
||||
event_loop_stop(g_loop);
|
||||
}
|
||||
|
||||
@@ -180,12 +180,12 @@ int publish_failed = 0;
|
||||
|
||||
void publish_done_callback(TaskID task_id, void *user_context) {
|
||||
/* The done callback should not be called. */
|
||||
CHECK(0);
|
||||
RAY_CHECK(0);
|
||||
}
|
||||
|
||||
void publish_fail_callback(UniqueID id, void *user_context, void *user_data) {
|
||||
publish_failed = 1;
|
||||
CHECK(user_context == (void *) publish_timeout_context);
|
||||
RAY_CHECK(user_context == (void *) publish_timeout_context);
|
||||
event_loop_stop(g_loop);
|
||||
}
|
||||
|
||||
@@ -249,7 +249,7 @@ const char *subscribe_retry_context = "subscribe_retry";
|
||||
int subscribe_retry_succeeded = 0;
|
||||
|
||||
void subscribe_retry_done_callback(ObjectID object_id, void *user_context) {
|
||||
CHECK(user_context == (void *) subscribe_retry_context);
|
||||
RAY_CHECK(user_context == (void *) subscribe_retry_context);
|
||||
subscribe_retry_succeeded = 1;
|
||||
}
|
||||
|
||||
@@ -257,7 +257,7 @@ void subscribe_retry_fail_callback(UniqueID id,
|
||||
void *user_context,
|
||||
void *user_data) {
|
||||
/* The fail callback should not be called. */
|
||||
CHECK(0);
|
||||
RAY_CHECK(0);
|
||||
}
|
||||
|
||||
TEST subscribe_retry_test(void) {
|
||||
@@ -299,7 +299,7 @@ const char *publish_retry_context = "publish_retry";
|
||||
int publish_retry_succeeded = 0;
|
||||
|
||||
void publish_retry_done_callback(ObjectID object_id, void *user_context) {
|
||||
CHECK(user_context == (void *) publish_retry_context);
|
||||
RAY_CHECK(user_context == (void *) publish_retry_context);
|
||||
publish_retry_succeeded = 1;
|
||||
}
|
||||
|
||||
@@ -307,7 +307,7 @@ void publish_retry_fail_callback(UniqueID id,
|
||||
void *user_context,
|
||||
void *user_data) {
|
||||
/* The fail callback should not be called. */
|
||||
CHECK(0);
|
||||
RAY_CHECK(0);
|
||||
}
|
||||
|
||||
TEST publish_retry_test(void) {
|
||||
@@ -355,13 +355,13 @@ int subscribe_late_failed = 0;
|
||||
void subscribe_late_fail_callback(UniqueID id,
|
||||
void *user_context,
|
||||
void *user_data) {
|
||||
CHECK(user_context == (void *) subscribe_late_context);
|
||||
RAY_CHECK(user_context == (void *) subscribe_late_context);
|
||||
subscribe_late_failed = 1;
|
||||
}
|
||||
|
||||
void subscribe_late_done_callback(TaskID task_id, void *user_context) {
|
||||
/* This function should never be called. */
|
||||
CHECK(0);
|
||||
RAY_CHECK(0);
|
||||
}
|
||||
|
||||
TEST subscribe_late_test(void) {
|
||||
@@ -400,13 +400,13 @@ int publish_late_failed = 0;
|
||||
void publish_late_fail_callback(UniqueID id,
|
||||
void *user_context,
|
||||
void *user_data) {
|
||||
CHECK(user_context == (void *) publish_late_context);
|
||||
RAY_CHECK(user_context == (void *) publish_late_context);
|
||||
publish_late_failed = 1;
|
||||
}
|
||||
|
||||
void publish_late_done_callback(TaskID task_id, void *user_context) {
|
||||
/* This function should never be called. */
|
||||
CHECK(0);
|
||||
RAY_CHECK(0);
|
||||
}
|
||||
|
||||
TEST publish_late_test(void) {
|
||||
|
||||
@@ -22,7 +22,8 @@ static inline std::string bind_ipc_sock_retry(const char *socket_name_format,
|
||||
int *fd) {
|
||||
std::string socket_name;
|
||||
for (int num_retries = 0; num_retries < 5; ++num_retries) {
|
||||
LOG_INFO("trying to find plasma socket (attempt %d)", num_retries);
|
||||
RAY_LOG(INFO) << "trying to find plasma socket (attempt " << num_retries
|
||||
<< ")";
|
||||
size_t size = std::snprintf(nullptr, 0, socket_name_format, rand()) + 1;
|
||||
char socket_name_c_str[size];
|
||||
std::snprintf(socket_name_c_str, size, socket_name_format, rand());
|
||||
|
||||
Reference in New Issue
Block a user