Object table remove (#139)

* Object table remove redis module

* Test case for object table remove redis module

* Client code for object_table_remove

* Delete object notifications in plasma

* Test for object deletion notifications

* Fix subscribe deletion test

* Address Robert's comments

* free hash table entry
This commit is contained in:
Stephanie Wang
2016-12-19 23:18:57 -08:00
committed by Philipp Moritz
parent cb3e6cde9e
commit d729f9b7ea
15 changed files with 394 additions and 46 deletions
+17
View File
@@ -28,6 +28,23 @@ void object_table_add(db_handle *db_handle,
done_callback, redis_object_table_add, user_context);
}
void object_table_remove(db_handle *db_handle,
object_id object_id,
db_client_id *client_id,
retry_info *retry,
object_table_done_callback done_callback,
void *user_context) {
CHECK(db_handle != NULL);
/* Copy the client ID, if one was provided. */
db_client_id *client_id_copy = NULL;
if (client_id != NULL) {
client_id_copy = malloc(sizeof(db_client_id));
*client_id_copy = *client_id;
}
init_table_callback(db_handle, object_id, __func__, client_id_copy, retry,
done_callback, redis_object_table_remove, user_context);
}
void object_table_subscribe_to_notifications(
db_handle *db_handle,
bool subscribe_all,
+5 -5
View File
@@ -86,20 +86,20 @@ typedef struct {
*
* @param db_handle Handle to db.
* @param object_id Object unique identifier.
* @param client_id A pointer to the database client ID to remove. If this is
* set to NULL, then the client ID associated with db_handle will be
* removed.
* @param retry Information about retrying the request to the database.
* @param done_callback Callback to be called when lookup completes.
* @param user_context User context to be passed in the callbacks.
* @return Void.
*/
/*
void object_table_remove(db_handle *db,
void object_table_remove(db_handle *db_handle,
object_id object_id,
lookup_callback callback,
void *context);
db_client_id *client_id,
retry_info *retry,
object_table_done_callback done_callback,
void *user_context);
*/
/*
* ==== Subscribe to be announced when new object available ====
+44 -1
View File
@@ -314,7 +314,7 @@ void redis_object_table_add_callback(redisAsyncContext *c,
CHECK(strcmp(reply->str, "OK") == 0);
/* Call the done callback if there is one. */
if (callback_data->done_callback != NULL) {
task_table_done_callback done_callback = callback_data->done_callback;
object_table_done_callback done_callback = callback_data->done_callback;
done_callback(callback_data->id, callback_data->user_context);
}
/* Clean up the timer and callback. */
@@ -340,6 +340,49 @@ void redis_object_table_add(table_callback_data *callback_data) {
}
}
void redis_object_table_remove_callback(redisAsyncContext *c,
void *r,
void *privdata) {
REDIS_CALLBACK_HEADER(db, callback_data, r);
/* Do some minimal checking. */
redisReply *reply = r;
if (strcmp(reply->str, "object not found") == 0) {
/* If our object entry was not in the table, it's probably a race
* condition with an object_table_add. */
return;
}
CHECK(reply->type != REDIS_REPLY_ERROR);
CHECK(strcmp(reply->str, "OK") == 0);
/* Call the done callback if there is one. */
if (callback_data->done_callback != NULL) {
object_table_done_callback done_callback = callback_data->done_callback;
done_callback(callback_data->id, callback_data->user_context);
}
/* Clean up the timer and callback. */
destroy_timer_callback(db->loop, callback_data);
}
void redis_object_table_remove(table_callback_data *callback_data) {
db_handle *db = callback_data->db_handle;
object_id obj_id = callback_data->id;
/* If the caller provided a manager ID to delete, use it. Otherwise, use our
* own client ID as the ID to delete. */
db_client_id *client_id = callback_data->data;
if (client_id == NULL) {
client_id = &db->client;
}
int status = redisAsyncCommand(
db->context, redis_object_table_remove_callback,
(void *) callback_data->timer_id, "RAY.OBJECT_TABLE_REMOVE %b %b",
obj_id.id, sizeof(obj_id.id), client_id->id, sizeof(client_id->id));
if ((status == REDIS_ERR) || db->context->err) {
LOG_REDIS_DEBUG(db->context, "error in redis_object_table_remove");
}
}
void redis_object_table_lookup(table_callback_data *callback_data) {
CHECK(callback_data);
db_handle *db = callback_data->db_handle;
+9
View File
@@ -81,6 +81,15 @@ void redis_object_table_lookup(table_callback_data *callback_data);
*/
void redis_object_table_add(table_callback_data *callback_data);
/**
* Remove a location entry from the object table in redis.
*
* @param callback_data Data structure containing redis connection and timeout
* information.
* @return Void.
*/
void redis_object_table_remove(table_callback_data *callback_data);
/**
* Create a client-specific channel for receiving notifications from the object
* table.