2016-08-13 17:11:11 -07:00
|
|
|
#ifndef PLASMA_H
|
|
|
|
#define PLASMA_H
|
|
|
|
|
|
|
|
#include <inttypes.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <errno.h>
|
2016-09-10 16:39:24 -07:00
|
|
|
#include <stddef.h>
|
2016-08-13 17:11:11 -07:00
|
|
|
#include <string.h>
|
|
|
|
|
2016-10-03 18:29:18 -07:00
|
|
|
#include "common.h"
|
2016-09-13 16:45:44 -07:00
|
|
|
|
2016-11-05 21:34:11 -07:00
|
|
|
#include "utarray.h"
|
|
|
|
#include "uthash.h"
|
|
|
|
|
2016-08-13 17:11:11 -07:00
|
|
|
typedef struct {
|
2016-09-14 14:20:34 -07:00
|
|
|
int64_t data_size;
|
|
|
|
int64_t metadata_size;
|
2016-08-13 17:11:11 -07:00
|
|
|
int64_t create_time;
|
|
|
|
int64_t construct_duration;
|
|
|
|
} plasma_object_info;
|
|
|
|
|
2016-10-03 18:29:18 -07:00
|
|
|
/* Handle to access memory mapped file and map it into client address space */
|
|
|
|
typedef struct {
|
|
|
|
/** The file descriptor of the memory mapped file in the store. It is used
|
|
|
|
* as a unique identifier of the file in the client to look up the
|
|
|
|
* corresponding file descriptor on the client's side. */
|
|
|
|
int store_fd;
|
|
|
|
/** The size in bytes of the memory mapped file. */
|
|
|
|
int64_t mmap_size;
|
|
|
|
} object_handle;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
/** Handle for memory mapped file the object is stored in. */
|
|
|
|
object_handle handle;
|
|
|
|
/** The offset in bytes in the memory mapped file of the data. */
|
|
|
|
ptrdiff_t data_offset;
|
|
|
|
/** The offset in bytes in the memory mapped file of the metadata. */
|
|
|
|
ptrdiff_t metadata_offset;
|
|
|
|
/** The size in bytes of the data. */
|
|
|
|
int64_t data_size;
|
|
|
|
/** The size in bytes of the metadata. */
|
|
|
|
int64_t metadata_size;
|
|
|
|
} plasma_object;
|
|
|
|
|
|
|
|
enum object_status { OBJECT_NOT_FOUND = 0, OBJECT_FOUND = 1 };
|
2016-08-13 17:11:11 -07:00
|
|
|
|
2016-11-03 17:33:54 -07:00
|
|
|
typedef enum { OPEN, SEALED } object_state;
|
|
|
|
|
2016-10-03 18:29:18 -07:00
|
|
|
enum plasma_message_type {
|
2016-09-28 18:59:00 -07:00
|
|
|
/** Create a new object. */
|
2016-10-03 18:29:18 -07:00
|
|
|
PLASMA_CREATE = 128,
|
2016-09-28 18:59:00 -07:00
|
|
|
/** Get an object. */
|
2016-09-07 20:19:37 -07:00
|
|
|
PLASMA_GET,
|
2016-10-21 00:47:34 -07:00
|
|
|
/** Tell the store that the client no longer needs an object. */
|
|
|
|
PLASMA_RELEASE,
|
2016-09-28 18:59:00 -07:00
|
|
|
/** Check if an object is present. */
|
2016-09-23 15:07:50 -07:00
|
|
|
PLASMA_CONTAINS,
|
2016-09-28 18:59:00 -07:00
|
|
|
/** Seal an object. */
|
2016-09-07 20:19:37 -07:00
|
|
|
PLASMA_SEAL,
|
2016-09-28 18:59:00 -07:00
|
|
|
/** Delete an object. */
|
2016-09-23 15:07:50 -07:00
|
|
|
PLASMA_DELETE,
|
2016-11-05 21:34:11 -07:00
|
|
|
/** Evict objects from the store. */
|
|
|
|
PLASMA_EVICT,
|
2016-10-14 19:27:17 -07:00
|
|
|
/** Subscribe to notifications about sealed objects. */
|
|
|
|
PLASMA_SUBSCRIBE,
|
2016-09-28 18:59:00 -07:00
|
|
|
/** Request transfer to another store. */
|
2016-09-07 20:19:37 -07:00
|
|
|
PLASMA_TRANSFER,
|
2016-09-28 18:59:00 -07:00
|
|
|
/** Header for sending data. */
|
2016-09-07 20:19:37 -07:00
|
|
|
PLASMA_DATA,
|
2016-10-18 18:20:59 -07:00
|
|
|
/** Request a fetch of an object in another store. */
|
|
|
|
PLASMA_FETCH,
|
2016-10-29 17:30:34 -07:00
|
|
|
/** Wait until an object becomes available. */
|
|
|
|
PLASMA_WAIT
|
2016-08-13 17:11:11 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct {
|
2016-09-28 18:59:00 -07:00
|
|
|
/** The size of the object's data. */
|
2016-09-14 14:20:34 -07:00
|
|
|
int64_t data_size;
|
2016-09-28 18:59:00 -07:00
|
|
|
/** The size of the object's metadata. */
|
2016-09-14 14:20:34 -07:00
|
|
|
int64_t metadata_size;
|
2016-10-29 17:30:34 -07:00
|
|
|
/** The timeout of the request. */
|
|
|
|
uint64_t timeout;
|
|
|
|
/** The number of objects we wait for for wait. */
|
|
|
|
int num_returns;
|
2016-09-28 18:59:00 -07:00
|
|
|
/** In a transfer request, this is the IP address of the Plasma Manager to
|
|
|
|
* transfer the object to. */
|
2016-08-15 16:41:22 -07:00
|
|
|
uint8_t addr[4];
|
2016-09-28 18:59:00 -07:00
|
|
|
/** In a transfer request, this is the port of the Plasma Manager to transfer
|
|
|
|
* the object to. */
|
2016-08-15 16:41:22 -07:00
|
|
|
int port;
|
2016-11-05 21:34:11 -07:00
|
|
|
/** A number of bytes. This is used for eviction requests. */
|
|
|
|
int64_t num_bytes;
|
2016-10-18 18:20:59 -07:00
|
|
|
/** The number of object IDs that will be included in this request. */
|
|
|
|
int num_object_ids;
|
|
|
|
/** The IDs of the objects that the request is about. */
|
|
|
|
object_id object_ids[1];
|
2016-08-13 17:11:11 -07:00
|
|
|
} plasma_request;
|
|
|
|
|
|
|
|
typedef struct {
|
2016-10-03 18:29:18 -07:00
|
|
|
/** The object that is returned with this reply. */
|
|
|
|
plasma_object object;
|
2016-10-18 18:20:59 -07:00
|
|
|
/** This is used only to respond to requests of type
|
|
|
|
* PLASMA_CONTAINS or PLASMA_FETCH. It is 1 if the object is
|
|
|
|
* present and 0 otherwise. Used for plasma_contains and
|
|
|
|
* plasma_fetch. */
|
2016-09-23 15:07:50 -07:00
|
|
|
int has_object;
|
2016-11-05 21:34:11 -07:00
|
|
|
/** A number of bytes. This is used for replies to eviction requests. */
|
|
|
|
int64_t num_bytes;
|
2016-10-29 17:30:34 -07:00
|
|
|
/** Number of object IDs a wait is returning. */
|
|
|
|
int num_objects_returned;
|
|
|
|
/** The number of object IDs that will be included in this reply. */
|
|
|
|
int num_object_ids;
|
|
|
|
/** The IDs of the objects that this reply refers to. */
|
|
|
|
object_id object_ids[1];
|
2016-08-13 17:11:11 -07:00
|
|
|
} plasma_reply;
|
|
|
|
|
2016-11-05 21:34:11 -07:00
|
|
|
/** This type is used by the Plasma store. It is here because it is exposed to
|
|
|
|
* the eviction policy. */
|
|
|
|
typedef struct {
|
|
|
|
/** Object id of this object. */
|
|
|
|
object_id object_id;
|
|
|
|
/** Object info like size, creation time and owner. */
|
|
|
|
plasma_object_info info;
|
|
|
|
/** Memory mapped file containing the object. */
|
|
|
|
int fd;
|
|
|
|
/** Size of the underlying map. */
|
|
|
|
int64_t map_size;
|
|
|
|
/** Offset from the base of the mmap. */
|
|
|
|
ptrdiff_t offset;
|
|
|
|
/** Handle for the uthash table. */
|
|
|
|
UT_hash_handle handle;
|
|
|
|
/** Pointer to the object data. Needed to free the object. */
|
|
|
|
uint8_t *pointer;
|
|
|
|
/** An array of the clients that are currently using this object. */
|
|
|
|
UT_array *clients;
|
|
|
|
/** The state of the object, e.g., whether it is open or sealed. */
|
|
|
|
object_state state;
|
|
|
|
} object_table_entry;
|
|
|
|
|
|
|
|
/** The plasma store information that is exposed to the eviction policy. */
|
|
|
|
typedef struct {
|
|
|
|
/** Objects that are in the Plasma store. */
|
|
|
|
object_table_entry *objects;
|
|
|
|
} plasma_store_info;
|
|
|
|
|
2016-08-13 17:11:11 -07:00
|
|
|
#endif
|