2016-10-03 18:29:18 -07:00
|
|
|
#ifndef PLASMA_STORE_H
|
|
|
|
#define PLASMA_STORE_H
|
|
|
|
|
|
|
|
#include "plasma.h"
|
|
|
|
|
2017-02-26 00:32:43 -08:00
|
|
|
typedef struct Client Client;
|
2016-10-21 00:47:34 -07:00
|
|
|
|
2017-02-26 00:32:43 -08:00
|
|
|
typedef struct PlasmaStoreState PlasmaStoreState;
|
2016-10-11 17:58:14 -07:00
|
|
|
|
2016-10-03 18:29:18 -07:00
|
|
|
/**
|
2016-10-21 00:47:34 -07:00
|
|
|
* Create a new object. The client must do a call to release_object to tell the
|
|
|
|
* store when it is done with the object.
|
2016-10-03 18:29:18 -07:00
|
|
|
*
|
2016-10-21 00:47:34 -07:00
|
|
|
* @param client_context The context of the client making this request.
|
2016-10-03 18:29:18 -07:00
|
|
|
* @param object_id Object ID of the object to be created.
|
|
|
|
* @param data_size Size in bytes of the object to be created.
|
|
|
|
* @param metadata_size Size in bytes of the object metadata.
|
2016-12-28 11:56:16 -08:00
|
|
|
* @return One of the following error codes:
|
|
|
|
* - PlasmaError_OK, if the object was created successfully.
|
|
|
|
* - PlasmaError_ObjectExists, if an object with this ID is already
|
|
|
|
* present in the store. In this case, the client should not call
|
|
|
|
* plasma_release.
|
|
|
|
* - PlasmaError_OutOfMemory, if the store is out of memory and cannot
|
|
|
|
* create the object. In this case, the client should not call
|
|
|
|
* plasma_release.
|
2016-10-03 18:29:18 -07:00
|
|
|
*/
|
2017-02-26 00:32:43 -08:00
|
|
|
int create_object(Client *client_context,
|
|
|
|
ObjectID object_id,
|
2016-12-28 11:56:16 -08:00
|
|
|
int64_t data_size,
|
|
|
|
int64_t metadata_size,
|
2017-02-26 00:32:43 -08:00
|
|
|
PlasmaObject *result);
|
2016-10-03 18:29:18 -07:00
|
|
|
|
|
|
|
/**
|
2016-10-21 00:47:34 -07:00
|
|
|
* Get an object. This method assumes that we currently have or will eventually
|
|
|
|
* have this object sealed. If the object has not yet been sealed, the client
|
|
|
|
* that requested the object will be notified when it is sealed.
|
|
|
|
*
|
|
|
|
* For each call to get_object, the client must do a call to release_object to
|
|
|
|
* tell the store when it is done with the object.
|
2016-10-03 18:29:18 -07:00
|
|
|
*
|
2016-10-21 00:47:34 -07:00
|
|
|
* @param client_context The context of the client making this request.
|
2016-10-11 17:58:14 -07:00
|
|
|
* @param conn The client connection that requests the object.
|
2016-10-03 18:29:18 -07:00
|
|
|
* @param object_id Object ID of the object to be gotten.
|
2016-10-11 17:58:14 -07:00
|
|
|
* @return The status of the object (object_status in plasma.h).
|
2016-10-03 18:29:18 -07:00
|
|
|
*/
|
2017-02-26 00:32:43 -08:00
|
|
|
int get_object(Client *client_context,
|
2016-10-11 17:58:14 -07:00
|
|
|
int conn,
|
2017-02-26 00:32:43 -08:00
|
|
|
ObjectID object_id,
|
|
|
|
PlasmaObject *result);
|
2016-12-01 02:15:21 -08:00
|
|
|
|
2016-10-03 18:29:18 -07:00
|
|
|
/**
|
2016-10-21 00:47:34 -07:00
|
|
|
* Record the fact that a particular client is no longer using an object.
|
|
|
|
*
|
|
|
|
* @param client_context The context of the client making this request.
|
|
|
|
* @param object_id The object ID of the object that is being released.
|
|
|
|
* @param Void.
|
|
|
|
*/
|
2017-02-26 00:32:43 -08:00
|
|
|
void release_object(Client *client_context, ObjectID object_id);
|
2016-10-21 00:47:34 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Seal an object. The object is now immutable and can be accessed with get.
|
2016-10-03 18:29:18 -07:00
|
|
|
*
|
2016-10-21 00:47:34 -07:00
|
|
|
* @param client_context The context of the client making this request.
|
2016-10-03 18:29:18 -07:00
|
|
|
* @param object_id Object ID of the object to be sealed.
|
2016-12-08 20:57:08 -08:00
|
|
|
* @param digest The digest of the object. This is used to tell if two objects
|
|
|
|
* with the same object ID are the same.
|
2016-10-11 17:58:14 -07:00
|
|
|
* @return Void.
|
2016-10-03 18:29:18 -07:00
|
|
|
*/
|
2017-02-26 00:32:43 -08:00
|
|
|
void seal_object(Client *client_context,
|
|
|
|
ObjectID object_id,
|
2016-12-08 20:57:08 -08:00
|
|
|
unsigned char digest[]);
|
2016-10-03 18:29:18 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if the plasma store contains an object:
|
|
|
|
*
|
2016-10-21 00:47:34 -07:00
|
|
|
* @param client_context The context of the client making this request.
|
2016-10-03 18:29:18 -07:00
|
|
|
* @param object_id Object ID that will be checked.
|
2016-10-11 17:58:14 -07:00
|
|
|
* @return OBJECT_FOUND if the object is in the store, OBJECT_NOT_FOUND if not
|
|
|
|
*/
|
2017-02-26 00:32:43 -08:00
|
|
|
int contains_object(Client *client_context, ObjectID object_id);
|
2016-10-11 17:58:14 -07:00
|
|
|
|
2016-10-14 19:27:17 -07:00
|
|
|
/**
|
|
|
|
* Send notifications about sealed objects to the subscribers. This is called
|
|
|
|
* in seal_object. If the socket's send buffer is full, the notification will be
|
|
|
|
* buffered, and this will be called again when the send buffer has room.
|
|
|
|
*
|
|
|
|
* @param loop The Plasma store event loop.
|
2016-10-21 00:47:34 -07:00
|
|
|
* @param client_sock The socket of the client to send the notification to.
|
|
|
|
* @param plasma_state The plasma store global state.
|
2016-10-14 19:27:17 -07:00
|
|
|
* @param events This is needed for this function to have the signature of a
|
|
|
|
callback.
|
|
|
|
* @return Void.
|
|
|
|
*/
|
|
|
|
void send_notifications(event_loop *loop,
|
|
|
|
int client_sock,
|
2016-10-21 00:47:34 -07:00
|
|
|
void *plasma_state,
|
2016-10-14 19:27:17 -07:00
|
|
|
int events);
|
|
|
|
|
2017-02-26 00:32:43 -08:00
|
|
|
void remove_objects(PlasmaStoreState *plasma_state,
|
2016-11-05 21:34:11 -07:00
|
|
|
int64_t num_objects_to_evict,
|
2017-02-26 00:32:43 -08:00
|
|
|
ObjectID *objects_to_evict);
|
2016-11-05 21:34:11 -07:00
|
|
|
|
2016-10-03 18:29:18 -07:00
|
|
|
#endif /* PLASMA_STORE_H */
|