2016-10-29 15:22:33 -07:00
|
|
|
#ifndef OBJECT_TABLE_H
|
|
|
|
#define OBJECT_TABLE_H
|
|
|
|
|
2016-09-13 18:54:26 -07:00
|
|
|
#include "common.h"
|
2016-10-29 15:22:33 -07:00
|
|
|
#include "table.h"
|
2016-09-13 18:54:26 -07:00
|
|
|
#include "db.h"
|
2016-11-10 18:13:26 -08:00
|
|
|
#include "task.h"
|
2016-09-13 18:54:26 -07:00
|
|
|
|
2016-10-29 15:22:33 -07:00
|
|
|
/*
|
|
|
|
* ==== Lookup call and callback ====
|
|
|
|
*/
|
2016-09-13 18:54:26 -07:00
|
|
|
|
2016-10-29 15:22:33 -07:00
|
|
|
/* Callback called when the lookup completes. The callback should free
|
2017-02-01 19:18:46 -08:00
|
|
|
* the manager_vector array, but NOT the strings they are pointing to. If there
|
|
|
|
* was no entry at all for the object (the object had never been created
|
|
|
|
* before), then manager_count will be -1.
|
2016-10-29 15:22:33 -07:00
|
|
|
*/
|
|
|
|
typedef void (*object_table_lookup_done_callback)(
|
2017-02-26 00:32:43 -08:00
|
|
|
ObjectID object_id,
|
2016-10-29 15:22:33 -07:00
|
|
|
int manager_count,
|
|
|
|
OWNER const char *manager_vector[],
|
|
|
|
void *user_context);
|
2016-09-13 18:54:26 -07:00
|
|
|
|
2017-02-26 00:32:43 -08:00
|
|
|
/* Callback called when object ObjectID is available. */
|
2016-12-19 21:07:25 -08:00
|
|
|
typedef void (*object_table_object_available_callback)(
|
2017-02-26 00:32:43 -08:00
|
|
|
ObjectID object_id,
|
2016-12-19 21:07:25 -08:00
|
|
|
int64_t data_size,
|
|
|
|
int manager_count,
|
|
|
|
OWNER const char *manager_vector[],
|
|
|
|
void *user_context);
|
|
|
|
|
2016-10-29 15:22:33 -07:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2017-02-26 00:32:43 -08:00
|
|
|
void object_table_lookup(DBHandle *db_handle,
|
|
|
|
ObjectID object_id,
|
|
|
|
RetryInfo *retry,
|
2016-10-29 15:22:33 -07:00
|
|
|
object_table_lookup_done_callback done_callback,
|
|
|
|
void *user_context);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ==== Add object call and callback ====
|
|
|
|
*/
|
|
|
|
|
2017-03-07 00:32:15 -08:00
|
|
|
/**
|
|
|
|
* Callback called when the object add/remove operation completes.
|
|
|
|
*
|
|
|
|
* @param object_id The ID of the object that was added or removed.
|
|
|
|
* @param success Whether the operation was successful or not. If this is false
|
|
|
|
* and the operation was an addition, the object was added, but there
|
|
|
|
* was a hash mismatch.
|
|
|
|
* @param user_context The user context that was passed into the add/remove
|
|
|
|
* call.
|
|
|
|
*/
|
2017-02-26 00:32:43 -08:00
|
|
|
typedef void (*object_table_done_callback)(ObjectID object_id,
|
2017-03-07 00:32:15 -08:00
|
|
|
bool success,
|
2016-10-29 15:22:33 -07:00
|
|
|
void *user_context);
|
2016-09-13 18:54:26 -07:00
|
|
|
|
2016-10-29 15:22:33 -07:00
|
|
|
/**
|
|
|
|
* 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.
|
2016-12-09 00:51:44 -08:00
|
|
|
* @param data_size Object data size.
|
2016-10-29 15:22:33 -07:00
|
|
|
* @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.
|
|
|
|
*/
|
2017-02-26 00:32:43 -08:00
|
|
|
void object_table_add(DBHandle *db_handle,
|
|
|
|
ObjectID object_id,
|
2016-12-18 18:19:02 -08:00
|
|
|
int64_t object_size,
|
2016-12-08 20:57:08 -08:00
|
|
|
unsigned char digest[],
|
2017-02-26 00:32:43 -08:00
|
|
|
RetryInfo *retry,
|
2016-10-29 15:22:33 -07:00
|
|
|
object_table_done_callback done_callback,
|
|
|
|
void *user_context);
|
|
|
|
|
2016-12-18 18:19:02 -08:00
|
|
|
/** Data that is needed to add new objects to the object table. */
|
|
|
|
typedef struct {
|
|
|
|
int64_t object_size;
|
|
|
|
unsigned char digest[DIGEST_SIZE];
|
2017-02-26 00:32:43 -08:00
|
|
|
} ObjectTableAddData;
|
2016-12-18 18:19:02 -08:00
|
|
|
|
2016-10-29 15:22:33 -07:00
|
|
|
/*
|
|
|
|
* ==== Remove object call and callback ====
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Object remove function.
|
|
|
|
*
|
|
|
|
* @param db_handle Handle to db.
|
|
|
|
* @param object_id Object unique identifier.
|
2016-12-19 23:18:57 -08:00
|
|
|
* @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.
|
2016-10-29 15:22:33 -07:00
|
|
|
* @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.
|
|
|
|
*/
|
2017-02-26 00:32:43 -08:00
|
|
|
void object_table_remove(DBHandle *db_handle,
|
|
|
|
ObjectID object_id,
|
|
|
|
DBClientID *client_id,
|
|
|
|
RetryInfo *retry,
|
2016-10-29 15:22:33 -07:00
|
|
|
object_table_done_callback done_callback,
|
|
|
|
void *user_context);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ==== Subscribe to be announced when new object available ====
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2016-12-18 18:19:02 -08:00
|
|
|
* Set up a client-specific channel for receiving notifications about available
|
|
|
|
* objects from the object table. The callback will be called once per
|
|
|
|
* notification received on this channel.
|
2016-10-29 15:22:33 -07:00
|
|
|
*
|
|
|
|
* @param db_handle Handle to db.
|
2016-12-18 18:19:02 -08:00
|
|
|
* @param object_available_callback Callback to be called when new object
|
2016-12-05 00:26:53 -08:00
|
|
|
* becomes available.
|
2016-12-18 18:19:02 -08:00
|
|
|
* @param subscribe_context Caller context which will be passed to the
|
2016-10-29 15:22:33 -07:00
|
|
|
* object_available_callback.
|
|
|
|
* @param retry Information about retrying the request to the database.
|
|
|
|
* @param done_callback Callback to be called when subscription is installed.
|
2016-12-18 18:19:02 -08:00
|
|
|
* This is only used for the tests.
|
|
|
|
* @param user_context User context to be passed into the done callback. This is
|
|
|
|
* only used for the tests.
|
2016-10-29 15:22:33 -07:00
|
|
|
* @return Void.
|
|
|
|
*/
|
2016-12-18 18:19:02 -08:00
|
|
|
void object_table_subscribe_to_notifications(
|
2017-02-26 00:32:43 -08:00
|
|
|
DBHandle *db_handle,
|
2016-12-19 21:07:25 -08:00
|
|
|
bool subscribe_all,
|
2016-10-29 15:22:33 -07:00
|
|
|
object_table_object_available_callback object_available_callback,
|
|
|
|
void *subscribe_context,
|
2017-02-26 00:32:43 -08:00
|
|
|
RetryInfo *retry,
|
2016-12-05 00:26:53 -08:00
|
|
|
object_table_lookup_done_callback done_callback,
|
2016-10-29 15:22:33 -07:00
|
|
|
void *user_context);
|
|
|
|
|
2016-12-18 18:19:02 -08:00
|
|
|
/**
|
|
|
|
* Request notifications about the availability of some objects from the object
|
|
|
|
* table. The notifications will be published to this client's object
|
|
|
|
* notification channel, which was set up by the method
|
|
|
|
* object_table_subscribe_to_notifications.
|
|
|
|
*
|
|
|
|
* @param db_handle Handle to db.
|
|
|
|
* @param object_ids The object IDs to receive notifications about.
|
|
|
|
* @param retry Information about retrying the request to the database.
|
|
|
|
* @return Void.
|
|
|
|
*/
|
2017-02-26 00:32:43 -08:00
|
|
|
void object_table_request_notifications(DBHandle *db,
|
2016-12-18 18:19:02 -08:00
|
|
|
int num_object_ids,
|
2017-02-26 00:32:43 -08:00
|
|
|
ObjectID object_ids[],
|
|
|
|
RetryInfo *retry);
|
2016-12-18 18:19:02 -08:00
|
|
|
|
|
|
|
/** Data that is needed to run object_request_notifications requests. */
|
|
|
|
typedef struct {
|
|
|
|
/** The number of object IDs. */
|
|
|
|
int num_object_ids;
|
|
|
|
/** This field is used to store a variable number of object IDs. */
|
2017-02-26 00:32:43 -08:00
|
|
|
ObjectID object_ids[0];
|
|
|
|
} ObjectTableRequestNotificationsData;
|
2016-12-18 18:19:02 -08:00
|
|
|
|
|
|
|
/** Data that is needed to register new object available callbacks with the
|
|
|
|
* state database. */
|
2016-10-29 15:22:33 -07:00
|
|
|
typedef struct {
|
2016-12-19 21:07:25 -08:00
|
|
|
bool subscribe_all;
|
2016-10-29 15:22:33 -07:00
|
|
|
object_table_object_available_callback object_available_callback;
|
|
|
|
void *subscribe_context;
|
2017-02-26 00:32:43 -08:00
|
|
|
} ObjectTableSubscribeData;
|
2016-10-29 15:22:33 -07:00
|
|
|
|
2016-12-09 00:51:44 -08:00
|
|
|
/*
|
|
|
|
* ==== Object info table, contains size of the object ====
|
|
|
|
*/
|
|
|
|
|
2017-02-26 00:32:43 -08:00
|
|
|
typedef void (*object_info_done_callback)(ObjectID object_id,
|
2016-12-09 00:51:44 -08:00
|
|
|
void *user_context);
|
|
|
|
|
2017-02-26 00:32:43 -08:00
|
|
|
typedef void (*object_info_subscribe_callback)(ObjectID object_id,
|
2016-12-09 00:51:44 -08:00
|
|
|
int64_t object_size,
|
|
|
|
void *user_context);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Subcribing to the object info pub/sub channel
|
|
|
|
*
|
|
|
|
* @param db_handle Handle to db.
|
|
|
|
* @param object_info_subscribe_callback callback triggered when pub/sub channel
|
|
|
|
* is notified of a new object size.
|
|
|
|
* @param subscribe_context caller context which will be passed back in the
|
|
|
|
* object_info_subscribe_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 into the done and fail
|
|
|
|
* callbacks.
|
|
|
|
* @return Void.
|
|
|
|
*/
|
2017-02-26 00:32:43 -08:00
|
|
|
void object_info_subscribe(DBHandle *db_handle,
|
2016-12-09 00:51:44 -08:00
|
|
|
object_info_subscribe_callback subscribe_callback,
|
|
|
|
void *subscribe_context,
|
2017-02-26 00:32:43 -08:00
|
|
|
RetryInfo *retry,
|
2016-12-09 00:51:44 -08:00
|
|
|
object_info_done_callback done_callback,
|
|
|
|
void *user_context);
|
|
|
|
|
|
|
|
/* Data that is needed to register new object info callbacks with the state
|
|
|
|
* database. */
|
|
|
|
typedef struct {
|
|
|
|
object_info_subscribe_callback subscribe_callback;
|
|
|
|
void *subscribe_context;
|
2017-02-26 00:32:43 -08:00
|
|
|
} ObjectInfoSubscribeData;
|
2016-12-09 00:51:44 -08:00
|
|
|
|
2016-11-10 18:13:26 -08:00
|
|
|
/*
|
|
|
|
* ==== Result table ====
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Callback called when the add/remove operation for a result table entry
|
|
|
|
* completes. */
|
2017-02-26 00:32:43 -08:00
|
|
|
typedef void (*result_table_done_callback)(ObjectID object_id,
|
2016-11-10 18:13:26 -08:00
|
|
|
void *user_context);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add information about a new object to the object table. This
|
|
|
|
* is immutable information like the ID of the task that
|
|
|
|
* created the object.
|
|
|
|
*
|
|
|
|
* @param db_handle Handle to object_table database.
|
|
|
|
* @param object_id ID of the object to add.
|
|
|
|
* @param task_id ID of the task that creates this object.
|
|
|
|
* @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.
|
|
|
|
*/
|
2017-02-26 00:32:43 -08:00
|
|
|
void result_table_add(DBHandle *db_handle,
|
|
|
|
ObjectID object_id,
|
|
|
|
TaskID task_id,
|
|
|
|
RetryInfo *retry,
|
2016-11-10 18:13:26 -08:00
|
|
|
result_table_done_callback done_callback,
|
|
|
|
void *user_context);
|
|
|
|
|
|
|
|
/** Callback called when the result table lookup completes. */
|
2017-02-26 00:32:43 -08:00
|
|
|
typedef void (*result_table_lookup_callback)(ObjectID object_id,
|
|
|
|
TaskID task_id,
|
2016-11-10 18:13:26 -08:00
|
|
|
void *user_context);
|
|
|
|
|
|
|
|
/**
|
2017-02-01 19:18:46 -08:00
|
|
|
* Lookup the task that created an object in the result table. The return value
|
|
|
|
* is the task ID.
|
2016-11-10 18:13:26 -08:00
|
|
|
*
|
|
|
|
* @param db_handle Handle to object_table database.
|
|
|
|
* @param object_id ID of the object to lookup.
|
|
|
|
* @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.
|
|
|
|
*/
|
2017-02-26 00:32:43 -08:00
|
|
|
void result_table_lookup(DBHandle *db_handle,
|
|
|
|
ObjectID object_id,
|
|
|
|
RetryInfo *retry,
|
2016-11-10 18:13:26 -08:00
|
|
|
result_table_lookup_callback done_callback,
|
|
|
|
void *user_context);
|
|
|
|
|
2016-10-29 15:22:33 -07:00
|
|
|
#endif /* OBJECT_TABLE_H */
|