Barrelfish
Functions
query.h File Reference

octopus Query Interface Header file More...

Functions

errval_t set_binding (octopus_binding_type_t type, uint64_t id, void *binding)
 Stores a binding for the given id. More...
 
errval_t get_record_names (struct ast_object *ast, struct oct_query_state *dqs)
 
errval_t get_record (struct ast_object *ast, struct oct_query_state *dqs)
 Returns a record matching the given query. More...
 
errval_t set_record (struct ast_object *ast, uint64_t mode, struct oct_query_state *dqs)
 Stores a record in the database. More...
 
errval_t del_record (struct ast_object *, struct oct_query_state *)
 Deletes a record in the database. More...
 
errval_t set_watch (struct octopus_binding *b, struct ast_object *ast, uint64_t mode, struct oct_reply_state *drs, uint64_t *wid)
 
errval_t del_watch (struct octopus_binding *b, octopus_trigger_id_t id, struct oct_query_state *dqs)
 Removes a watch. More...
 
errval_t add_subscription (struct octopus_binding *b, struct ast_object *ast, uint64_t trigger_fn, uint64_t state, struct oct_reply_state *drs)
 Adds a subscription. More...
 
errval_t del_subscription (struct octopus_binding *b, uint64_t id, struct oct_query_state *dqs)
 Deletes a subscription for a given (Binding, Id) pair. More...
 
errval_t find_subscribers (struct ast_object *ast, struct oct_query_state *dqs)
 
struct octopus_binding * get_event_binding (struct octopus_binding *binding)
 Find the event binding of the client based on his RPC binding. More...
 

Detailed Description

octopus Query Interface Header file

The server must implement this interface in order for dist2 to work accordingly.

Function Documentation

errval_t add_subscription ( struct octopus_binding *  b,
struct ast_object *  ast,
uint64_t  trigger_fn,
uint64_t  state,
struct oct_reply_state *  drs 
)

Adds a subscription.

Parameters
bRPC binding of subscriber.
astSubscription template (to match with published records).
trigger_fnClient handler function.
stateAdditional state argument supplied by client.
drsReturned result of query invocation.
Return values
SYS_ERR_OK
OCT_ERR_MAX_SUBSCRIPTIONS
OCT_ERR_ENGINE_FAIL
LIB_ERR_MALLOC_FAIL
errval_t del_record ( struct ast_object *  ,
struct oct_query_state *   
)

Deletes a record in the database.

Parameters
astRecord to delete.
dqsReturned result of query invocation.
Return values
SYS_ERR_OK
OCT_ERR_NO_RECORD
OCT_ERR_ENGINE_FAIL
errval_t del_subscription ( struct octopus_binding *  b,
uint64_t  id,
struct oct_query_state *  dqs 
)

Deletes a subscription for a given (Binding, Id) pair.

Parameters
bRPC binding of subscriber.
idID of the subscription.
dqsReturned result of query invocation.
Return values
SYS_ERR_OK
OCT_ERR_NO_SUBSCRIPTION
OCT_ERR_ENGINE_FAIL
errval_t del_watch ( struct octopus_binding *  b,
octopus_trigger_id_t  id,
struct oct_query_state *  dqs 
)

Removes a watch.

Parameters
bBinding of caller
idTrigger Id supplied by caller
dqsQuery state
Return values
SYS_ERR_OK
OCT_ERR_INVALID_ID
OCT_ERR_ENGINE_FAIL
errval_t find_subscribers ( struct ast_object *  ast,
struct oct_query_state *  dqs 
)

Find all subscribers with a matching subscription for the given AST.

Parameters
astRecord to match with stored subscription.
dqsReturned result of query invocation.
Return values
SYS_ERR_OK
OCT_ERR_NO_SUBSCRIBERS
OCT_ERR_ENGINE_FAIL
struct octopus_binding* get_event_binding ( struct octopus_binding *  binding)

Find the event binding of the client based on his RPC binding.

Parameters
bindingRPC binding
Returns
Pointer of event binding or NULL on error.
errval_t get_record ( struct ast_object *  ast,
struct oct_query_state *  dqs 
)

Returns a record matching the given query.

Parameters
astQuery supplied by client converted to AST.
dqsContains the result of the query invocation.
Return values
SYS_ERR_OK
OCT_ERR_NO_RECORD
OCT_ERR_ENGINE_FAIL
errval_t get_record_names ( struct ast_object *  ast,
struct oct_query_state *  dqs 
)

Given a query returns a number of record names matching the query. The record names are stored as a comma separated string in oct_query_state.

Parameters
astAbstract Syntax Tree of query.
dqsContains the result of the query invocation.
Return values
SYS_ERR_OK
OCT_ERR_NO_RECORD
OCT_ERR_ENGINE_FAIL
errval_t set_binding ( octopus_binding_type_t  type,
uint64_t  id,
void *  binding 
)

Stores a binding for the given id.

Used to find the event binding for a given RPC connection since in a regular flounder interface RPC calls are on on a different waitset we currently need two binding.

Parameters
typeBinding type (RPC or Event)
idIdentifier unique per client
bindingPointer value of binding
Return values
SYS_ERR_OK
OCT_ERR_UNSUPPORTED_BINDING
OCT_ERR_ENGINE_FAIL
LIB_ERR_MALLOC_FAIL
errval_t set_record ( struct ast_object *  ast,
uint64_t  mode,
struct oct_query_state *  dqs 
)

Stores a record in the database.

Parameters
astRecord to set.
modeA combination of modes as defined in getset.h.
dqsReturned result of query invocation.
Return values
SYS_ERR_OK
OCT_ERR_ENGINE_FAIL
errval_t set_watch ( struct octopus_binding *  b,
struct ast_object *  ast,
uint64_t  mode,
struct oct_reply_state *  drs,
uint64_t *  wid 
)

Sets a watch for a record(s) matching the given query. The Query Engine is supposed to use the drs struct to reply to the client once the watch is triggered.

Parameters
bRPC Binding
astAST to watch for
modeWhen to trigger the watch (del or set).
drsReply state used to reply to the client.
widID of the installed watch (used for remove).
Return values
SYS_ERR_OK
OCT_ERR_ENGINE_FAIL