mirror of
https://github.com/wassname/ray.git
synced 2026-07-30 12:30:30 +08:00
End-to-end object size information passthrough (#105)
* rebase Alexey's PR on top * rebase on master * fix test failure waiting for plasma manager to exit * clang format * addressing comments * Minor formatting and naming fixes.
This commit is contained in:
committed by
Robert Nishihara
parent
61904c4c3e
commit
0abbf5a113
@@ -202,7 +202,7 @@ TEST add_timeout_test(void) {
|
||||
retry_info retry = {
|
||||
.num_retries = 5, .timeout = 100, .fail_callback = add_fail_callback,
|
||||
};
|
||||
object_table_add(db, NIL_ID, (unsigned char *) NIL_DIGEST, &retry,
|
||||
object_table_add(db, NIL_ID, 0, (unsigned char *) NIL_DIGEST, &retry,
|
||||
add_done_callback, (void *) add_timeout_context);
|
||||
/* Disconnect the database to see if the lookup times out. */
|
||||
close(db->context->c.fd);
|
||||
@@ -360,7 +360,7 @@ TEST add_retry_test(void) {
|
||||
.timeout = 100,
|
||||
.fail_callback = add_retry_fail_callback,
|
||||
};
|
||||
object_table_add(db, NIL_ID, (unsigned char *) NIL_DIGEST, &retry,
|
||||
object_table_add(db, NIL_ID, 0, (unsigned char *) NIL_DIGEST, &retry,
|
||||
add_retry_done_callback, (void *) add_retry_context);
|
||||
/* Disconnect the database to let the add time out the first time. */
|
||||
close(db->context->c.fd);
|
||||
@@ -413,7 +413,7 @@ TEST add_lookup_test(void) {
|
||||
.timeout = 100,
|
||||
.fail_callback = lookup_retry_fail_callback,
|
||||
};
|
||||
object_table_add(db, NIL_ID, (unsigned char *) NIL_DIGEST, &retry,
|
||||
object_table_add(db, NIL_ID, 0, (unsigned char *) NIL_DIGEST, &retry,
|
||||
add_lookup_callback, (void *) db);
|
||||
/* Install handler for terminating the event loop. */
|
||||
event_loop_add_timer(g_loop, 750,
|
||||
@@ -568,7 +568,7 @@ TEST add_late_test(void) {
|
||||
retry_info retry = {
|
||||
.num_retries = 0, .timeout = 0, .fail_callback = add_late_fail_callback,
|
||||
};
|
||||
object_table_add(db, NIL_ID, (unsigned char *) NIL_DIGEST, &retry,
|
||||
object_table_add(db, NIL_ID, 0, (unsigned char *) NIL_DIGEST, &retry,
|
||||
add_late_done_callback, (void *) add_late_context);
|
||||
/* Install handler for terminating the event loop. */
|
||||
event_loop_add_timer(g_loop, 750,
|
||||
@@ -653,7 +653,7 @@ void subscribe_success_done_callback(object_id object_id,
|
||||
retry_info retry = {
|
||||
.num_retries = 0, .timeout = 750, .fail_callback = NULL,
|
||||
};
|
||||
object_table_add((db_handle *) user_context, object_id,
|
||||
object_table_add((db_handle *) user_context, object_id, 0,
|
||||
(unsigned char *) NIL_DIGEST, &retry, NULL, NULL);
|
||||
subscribe_success_done = 1;
|
||||
}
|
||||
@@ -721,7 +721,7 @@ TEST subscribe_object_present_test(void) {
|
||||
retry_info retry = {
|
||||
.num_retries = 0, .timeout = 100, .fail_callback = NULL,
|
||||
};
|
||||
object_table_add(db, id, (unsigned char *) NIL_DIGEST, &retry, NULL, NULL);
|
||||
object_table_add(db, id, 0, (unsigned char *) NIL_DIGEST, &retry, NULL, NULL);
|
||||
object_table_subscribe(
|
||||
db, id, subscribe_object_present_object_available_callback,
|
||||
(void *) subscribe_object_present_context, &retry, NULL, (void *) db);
|
||||
@@ -802,7 +802,7 @@ int64_t add_object_callback(event_loop *loop, int64_t timer_id, void *context) {
|
||||
retry_info retry = {
|
||||
.num_retries = 0, .timeout = 100, .fail_callback = NULL,
|
||||
};
|
||||
object_table_add(db, NIL_ID, (unsigned char *) NIL_DIGEST, &retry, NULL,
|
||||
object_table_add(db, NIL_ID, 0, (unsigned char *) NIL_DIGEST, &retry, NULL,
|
||||
NULL);
|
||||
/* Reset the timer to this large value, so it doesn't trigger again. */
|
||||
return 10000;
|
||||
@@ -838,6 +838,76 @@ TEST subscribe_object_available_later_test(void) {
|
||||
PASS();
|
||||
}
|
||||
|
||||
/* Test if object size is correctly reported by the object_info callback. */
|
||||
|
||||
typedef struct {
|
||||
char *subscribe_success_msg;
|
||||
int64_t data_size;
|
||||
int subscribe_succeeded;
|
||||
int subscribe_callback_done;
|
||||
} object_info_subscribe_context;
|
||||
|
||||
object_info_subscribe_context obj_info_subscribe_context = {"foo", 42, 0, 0};
|
||||
|
||||
void subscribe_object_info_done_callback(object_id object_id,
|
||||
void *user_context) {
|
||||
retry_info retry = {
|
||||
.num_retries = 0, .timeout = 100, .fail_callback = NULL,
|
||||
};
|
||||
CHECK(obj_info_subscribe_context.subscribe_succeeded == 0);
|
||||
CHECK(obj_info_subscribe_context.subscribe_callback_done == 0);
|
||||
|
||||
object_table_add((db_handle *) user_context, object_id,
|
||||
obj_info_subscribe_context.data_size, NIL_DIGEST, &retry,
|
||||
NULL, NULL);
|
||||
|
||||
obj_info_subscribe_context.subscribe_callback_done = 1;
|
||||
}
|
||||
|
||||
void subscribe_success_object_info_available_callback(object_id object_id,
|
||||
int64_t object_size,
|
||||
void *user_context) {
|
||||
CHECK(user_context == (void *) &obj_info_subscribe_context);
|
||||
/* Check to make sure subscription done callback already fired. */
|
||||
CHECK(obj_info_subscribe_context.subscribe_callback_done == 1);
|
||||
CHECK(obj_info_subscribe_context.subscribe_succeeded == 0);
|
||||
CHECK(obj_info_subscribe_context.data_size == object_size);
|
||||
|
||||
/* Mark success. */
|
||||
obj_info_subscribe_context.subscribe_succeeded = 1;
|
||||
}
|
||||
|
||||
TEST subscribe_object_info_success_test(void) {
|
||||
g_loop = event_loop_create();
|
||||
db_handle *db =
|
||||
db_connect("127.0.0.1", 6379, "plasma_manager", "127.0.0.1", 11236);
|
||||
db_attach(db, g_loop, false);
|
||||
|
||||
retry_info retry = {
|
||||
.num_retries = 0,
|
||||
.timeout = 100,
|
||||
.fail_callback = subscribe_success_fail_callback,
|
||||
};
|
||||
|
||||
object_info_subscribe(db, subscribe_success_object_info_available_callback,
|
||||
(void *) &obj_info_subscribe_context, &retry,
|
||||
subscribe_object_info_done_callback, (void *) db);
|
||||
|
||||
/* Install handler for terminating the event loop. */
|
||||
event_loop_add_timer(g_loop, 1000,
|
||||
(event_loop_timer_handler) terminate_event_loop_callback,
|
||||
NULL);
|
||||
|
||||
event_loop_run(g_loop);
|
||||
db_disconnect(db);
|
||||
destroy_outstanding_callbacks(g_loop);
|
||||
event_loop_destroy(g_loop);
|
||||
|
||||
ASSERT(obj_info_subscribe_context.subscribe_succeeded == 1);
|
||||
ASSERT(obj_info_subscribe_context.subscribe_callback_done == 1);
|
||||
PASS();
|
||||
}
|
||||
|
||||
SUITE(object_table_tests) {
|
||||
RUN_REDIS_TEST(new_object_test);
|
||||
RUN_REDIS_TEST(new_object_no_task_test);
|
||||
@@ -855,6 +925,7 @@ SUITE(object_table_tests) {
|
||||
RUN_REDIS_TEST(subscribe_object_present_test);
|
||||
RUN_REDIS_TEST(subscribe_object_not_present_test);
|
||||
RUN_REDIS_TEST(subscribe_object_available_later_test);
|
||||
RUN_REDIS_TEST(subscribe_object_info_success_test);
|
||||
}
|
||||
|
||||
GREATEST_MAIN_DEFS();
|
||||
|
||||
Reference in New Issue
Block a user