-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ion and Philipp's table retries (#10)
* Ion and Philipp's table retries * Refactor the retry struct: - Rename it from retry_struct to retry_info - Retry information contains the failure callback, not the retry callback - All functions take in retry information as an arg instead of its expanded fields * Rename cb -> callback * Remove prints * Fix compiler warnings * Change some CHECKs to greatest ASSERTs * Key outstanding callbacks hash table with timer ID instead of callback data pointer * Use the new retry API for table commands * Memory cleanup in plasma unit tests * fix Robert's comments * add valgrind for common
- Loading branch information
Showing
23 changed files
with
1,914 additions
and
240 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include "object_table.h" | ||
#include "redis.h" | ||
|
||
void object_table_lookup(db_handle *db_handle, | ||
object_id object_id, | ||
retry_info *retry, | ||
object_table_lookup_done_callback done_callback, | ||
void *user_context) { | ||
init_table_callback(db_handle, object_id, NULL, retry, done_callback, | ||
redis_object_table_lookup, user_context); | ||
} | ||
|
||
void object_table_add(db_handle *db_handle, | ||
object_id object_id, | ||
retry_info *retry, | ||
object_table_done_callback done_callback, | ||
void *user_context) { | ||
init_table_callback(db_handle, object_id, NULL, retry, done_callback, | ||
redis_object_table_add, user_context); | ||
} | ||
|
||
void object_table_subscribe( | ||
db_handle *db_handle, | ||
object_id object_id, | ||
object_table_object_available_callback object_available_callback, | ||
void *subscribe_context, | ||
retry_info *retry, | ||
object_table_done_callback done_callback, | ||
void *user_context) { | ||
object_table_subscribe_data *sub_data = | ||
malloc(sizeof(object_table_subscribe_data)); | ||
utarray_push_back(db_handle->callback_freelist, &sub_data); | ||
sub_data->object_available_callback = object_available_callback; | ||
sub_data->subscribe_context = subscribe_context; | ||
|
||
init_table_callback(db_handle, object_id, sub_data, retry, done_callback, | ||
redis_object_table_subscribe, user_context); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,126 @@ | ||
#ifndef OBJECT_TABLE_H | ||
#define OBJECT_TABLE_H | ||
|
||
#include "common.h" | ||
#include "table.h" | ||
#include "db.h" | ||
|
||
/* The callback that is called when the result of a lookup | ||
* in the object table comes back. The callback should free | ||
* the manager_vector array, but NOT the strings they are pointing to. */ | ||
typedef void (*lookup_callback)(object_id object_id, | ||
int manager_count, | ||
const char *manager_vector[], | ||
void *context); | ||
/* | ||
* ==== Lookup call and callback ==== | ||
*/ | ||
|
||
/* Register a new object with the directory. */ | ||
/* TODO(pcm): Retry, print for each attempt. */ | ||
void object_table_add(db_handle *db, object_id object_id); | ||
/* Callback called when the lookup completes. The callback should free | ||
* the manager_vector array, but NOT the strings they are pointing to. | ||
*/ | ||
typedef void (*object_table_lookup_done_callback)( | ||
object_id object_id, | ||
int manager_count, | ||
OWNER const char *manager_vector[], | ||
void *user_context); | ||
|
||
/* Remove object from the directory. */ | ||
void object_table_remove(db_handle *db, | ||
/** | ||
* Return the list of nodes storing object_id in their plasma stores. | ||
* | ||
* @param db_handle Handle to object_table database. | ||
* @param object_id ID of the object being looked up. | ||
* @param retry Information about retrying the request to the database. | ||
* @param done_callback Function to be called when database returns result. | ||
* @param user_context Context passed by the caller. | ||
* @return Void. | ||
*/ | ||
void object_table_lookup(db_handle *db_handle, | ||
object_id object_id, | ||
const char *manager); | ||
retry_info *retry, | ||
object_table_lookup_done_callback done_callback, | ||
void *user_context); | ||
|
||
/* | ||
* ==== Add object call and callback ==== | ||
*/ | ||
|
||
/* Callback called when the object add/remove operation completes. */ | ||
typedef void (*object_table_done_callback)(object_id object_id, | ||
void *user_context); | ||
|
||
/* Look up entry from the directory */ | ||
void object_table_lookup(db_handle *db, | ||
/** | ||
* Add the plasma manager that created the db_handle to the | ||
* list of plasma managers that have the object_id. | ||
* | ||
* @param db_handle Handle to db. | ||
* @param object_id Object unique identifier. | ||
* @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_add(db_handle *db_handle, | ||
object_id object_id, | ||
retry_info *retry, | ||
object_table_done_callback done_callback, | ||
void *user_context); | ||
|
||
/* | ||
* ==== Remove object call and callback ==== | ||
*/ | ||
|
||
/** | ||
* Object remove function. | ||
* | ||
* @param db_handle Handle to db. | ||
* @param object_id Object unique identifier. | ||
* @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, | ||
object_id object_id, | ||
lookup_callback callback, | ||
void *context); | ||
retry_info *retry, | ||
object_table_done_callback done_callback, | ||
void *user_context); | ||
*/ | ||
|
||
/* | ||
* ==== Subscribe to be announced when new object available ==== | ||
*/ | ||
|
||
/* Callback called when object object_id is available. */ | ||
typedef void (*object_table_object_available_callback)(object_id object_id, | ||
void *user_context); | ||
|
||
/** | ||
* Subcribing to new object available function. | ||
* | ||
* @param db_handle Handle to db. | ||
* @param object_id Object unique identifier. | ||
* @param object_available_callback callback to be called when new object | ||
* becomes | ||
* available. | ||
* @param subscribe_context caller context which will be passed back in the | ||
* object_available_callback. | ||
* @param retry Information about retrying the request to the database. | ||
* @param done_callback Callback to be called when subscription is installed. | ||
* @param user_context User context to be passed in the callbacks. | ||
* @return Void. | ||
*/ | ||
|
||
void object_table_subscribe( | ||
db_handle *db, | ||
object_id object_id, | ||
object_table_object_available_callback object_available_callback, | ||
void *subscribe_context, | ||
retry_info *retry, | ||
object_table_done_callback done_callback, | ||
void *user_context); | ||
|
||
/* Data that is needed to register new object available callbacks with the state | ||
* database. */ | ||
typedef struct { | ||
object_table_object_available_callback object_available_callback; | ||
void *subscribe_context; | ||
} object_table_subscribe_data; | ||
|
||
#endif /* OBJECT_TABLE_H */ |
Oops, something went wrong.