32 #define CHECK_STATE_REPLACEMENT 1
59 state->
data = malloc(size);
63 log(LOG_STATE_MANAGEMENT,
"Allocating new state of size %d for msu %d, key %d",
64 (
int)size, msu->
id, (
int)key->
id);
66 #if CHECK_STATE_REPLACEMENT
69 if (old_state != NULL) {
70 log_warn(
"Replacing old state! Not freeing! Bad!");
85 log(LOG_STATE_MANAGEMENT,
"Accessing state for MSU %d, key %d",
86 msu->
id, (
int)key->
id);
88 log(LOG_STATE_MANAGEMENT,
"State does not exist");
100 log(LOG_STATE_MANAGEMENT,
"Freeing state for MSU %d, key %d",
101 msu->
id, (
int)key->
id);
103 log_warn(
"State for MSU %d, key %d does not exist",
104 msu->
id, (
int)key->
id);
110 (
double)(-1 * (
int)(
sizeof(*state) + state->
size)));
#define HASH_FIND(hh, head, keyptr, keylen, out)
Collecting statistics within the runtime.
int32_t id
A unique identifier for the state (not used at the moment, will be utilized in state transfer) ...
#define HASH_REPLACE(hh, head, fieldname, keylen_in, add, replaced)
void msu_free_all_state(struct local_msu *msu)
Frees all state structures associated with the given MSU.
struct composite_key key
The full, arbitrary-length, unique key (used in state)
void * msu_get_state(struct local_msu *msu, struct msu_msg_key *key, size_t *size)
Gets the state allocated with the given key.
int32_t id
A shorter, often hashed id for the key of fixed length (used in routing)
Logging of status messages to the terminal.
unsigned int id
Unique ID for a local MSU.
void * msu_init_state(struct local_msu *msu, struct msu_msg_key *key, size_t size)
Initializes a new MSU state of the given size with the provided key.
struct msu_state * item_state
Keyed state structure, accessible through queue item IDs.
Declares the structures and functions applicable to MSUs on the local machine.
struct composite_key key
The key with which the state is stored.
The structure that represents an MSU located on the local machine.
void * data
The payload of the state.
#define HASH_ADD(hh, head, fieldname, keylen_in, add)
The composite key is used to store a key of arbitrary length (up to 192 bytes).
The structure contining msu state.
size_t size
The size of the data being stored.
UT_hash_handle hh
For use with the UT hash structure.
int group_id
Used to mark a route ID when storing state.
int increment_stat(enum stat_id stat_id, unsigned int item_id, double value)
Increments the given statistic by the provided value.
#define log(level, fmt,...)
Log at a custom level.
int group_id
An ID to facilitate the transferring of state between msus (not implemented yet)
#define HASH_ITER(hh, head, el, tmp)
int msu_free_state(struct local_msu *msu, struct msu_msg_key *key)
Frees the state assocated with the given MSU and key.
#define HASH_DEL(head, delptr)
int msu_num_states(struct local_msu *msu)
Used to uniquely identify the source of a message, used in state storage as well as routing...
size_t key_len
The length of the composite key.
#define log_warn(fmt,...)