XROAD
xroad_node.h File Reference
#include "xroad_system.h"
#include "xroad_node_types.h"
#include <cache/xroad_cache.h>
#include <cache/xroad_objects.h>
#include <cache/xroad_storage_fwd.h>
#include <common/xroad_xml.h>
#include <common/xroad_string.h>
#include <common/xroad_aux.h>
#include <stdint.h>
#include <stdbool.h>
#include <sys/epoll.h>
Include dependency graph for xroad_node.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  xroad_node_callback_t
 
struct  xroad_node_epoll_callback_t
 
struct  xroad_epoll_timestamps
 

Macros

#define xroad_node_is_offline()
 
#define xroad_node_find_object(type, fun, ...)
 

Functions

xroad_errno_t xroad_node_create (xroad_str_t node_name, uint32_t major_version, uint32_t minor_version, xroad_str_t git_hash, xroad_node_callback_t callback)
 
void xroad_node_destroy (void)
 
xroad_errno_t xroad_node_reconfig (void)
 
xroad_xml_doc_t * xroad_node_get_config (void)
 
const xroad_epoll_timestampsxroad_node_get_epoll_timestamps (void)
 
int32_t xroad_node_receive (void)
 
int32_t xroad_node_receive_ex (int32_t timeout)
 
xroad_errno_t xroad_node_add_epoll (uint32_t events, xroad_node_epoll_callback_t *cback)
 
xroad_errno_t xroad_node_mod_epoll (uint32_t events, xroad_node_epoll_callback_t *cback)
 
xroad_errno_t xroad_node_del_epoll (xroad_node_epoll_callback_t *cback)
 
int32_t xroad_node_get_epoll_fd (void)
 
void * xroad_node_create_object (xroad_object_type_t type)
 
void * xroad_node_clone_object (const void *obj)
 
xroad_errno_t xroad_node_send_object (void *obj, xroad_node_id_t id)
 
xroad_errno_t xroad_node_route_object (void *obj,...)
 
xroad_errno_t xroad_node_route_object_va (void *obj, va_list ap)
 
void * xroad_node_get_fun (xroad_str_t fname)
 
void * xroad_node_get_object (xroad_object_type_t type, xroad_object_id_t id)
 
xroad_lock_by_pid_t * xroad_node_get_used_lock (void)
 
xroad_node_data_txroad_node_get_data (void)
 
void xroad_node_reset_statistic (void)
 
xroad_str_t xroad_node_get_working_dir (void)
 
void xroad_node_set_flags (uint32_t flags)
 
int32_t xroad_node_get_link_descriptor (void)
 
xroad_cursor_t * xroad_node_create_cursor (xroad_object_type_t type)
 
void xroad_node_destroy_cursor (xroad_cursor_t *cursor)
 
void * xroad_node_cursor_get_next (xroad_cursor_t *cursor)
 
void * xroad_node_cursor_get_prev (xroad_cursor_t *cursor)
 
void * xroad_node_cursor_get_first (xroad_cursor_t *cursor)
 
void * xroad_node_cursor_get_last (xroad_cursor_t *cursor)
 
void * xroad_node_cursor_offset (xroad_cursor_t *cursor, int64_t offset)
 
xroad_errno_t xroad_node_clear_cache (xroad_object_type_t type, bool force)
 
xroad_cache_t * xroad_node_get_cache ()
 
size_t xroad_node_get_object_count (xroad_object_type_t type)
 
const xroad_version_txroad_node_get_version (void)
 
bool xroad_node_is_initialized (void)
 
xroad_errno_t xroad_node_subscribe (xroad_domain_t group, xroad_node_callback_t cback)
 
xroad_errno_t xroad_node_unsubscribe (xroad_domain_t group, xroad_node_callback_t cback)
 
xroad_str_t xroad_node_get_env_param (xroad_str_t param)
 
void xroad_node_renamed ()
 

Detailed Description

Macro Definition Documentation

◆ xroad_node_find_object

#define xroad_node_find_object (   type,
  fun,
  ... 
)
Value:
({ \
xroad_cursor_t* cur __xroad_cursor_dtor__ = xroad_node_create_cursor(type); \
void* obj = xroad_node_cursor_get_first(cur); \
while(obj) \
{ \
if (fun(obj, __VA_ARGS__)) \
{ \
break; \
} \
} \
obj; \
})
#define __xroad_cursor_dtor__
Definition: xroad_cache.h:98
void * xroad_node_cursor_get_next(xroad_cursor_t *cursor)
void * xroad_node_cursor_get_first(xroad_cursor_t *cursor)
xroad_cursor_t * xroad_node_create_cursor(xroad_object_type_t type)

find object using functor

Parameters
[in]type- object type
[in]fun- functor like bool fun(....) @oaram[in] ... - functor params
Returns
found object, NULL nothing found

◆ xroad_node_is_offline

#define xroad_node_is_offline ( )
Value:
xroad_node_get_data()->status == xroad_node_status_sleep)
xroad_node_status_t status
node status
Definition: xroad_system.h:138
xroad_node_data_t * xroad_node_get_data(void)
@ xroad_node_status_sleep
node is sleeping
Definition: xroad_system.h:33
@ xroad_node_status_offline
node started, but is not active
Definition: xroad_system.h:30

Function Documentation

◆ xroad_node_add_epoll()

xroad_errno_t xroad_node_add_epoll ( uint32_t  events,
xroad_node_epoll_callback_t cback 
)

add descriptor to epoll

Parameters
[in]events- fd events
[in]cback- pointer to epoll callback
Returns
XROAD_ERROR_OK - done

◆ xroad_node_clear_cache()

xroad_errno_t xroad_node_clear_cache ( xroad_object_type_t  type,
bool  force 
)

clear object cache

Parameters
[in]type- type of objects to clear
[in]force- force clear
Returns
XROAD_OK - cleared, else failed

◆ xroad_node_clone_object()

void* xroad_node_clone_object ( const void *  obj)

clone object

Parameters
[in]obj- object to clone
Returns
cloned object

◆ xroad_node_create()

xroad_errno_t xroad_node_create ( xroad_str_t  node_name,
uint32_t  major_version,
uint32_t  minor_version,
xroad_str_t  git_hash,
xroad_node_callback_t  callback 
)

create new node and registers in system

Parameters
[in]node_name- name of new node. Can be NULL.
[in]major_version- marjor version. Override value from xroad_version.c
[in]minor_version- minor version. Override value from xroad_version.c
[in]git_hash- git hash. Override value from xroad_version.c
[in]callback- callback method for objects
Returns
XROAD_OK - created, XROAD_ERROR_ALREADY_EXISTS - node already created

◆ xroad_node_create_cursor()

xroad_cursor_t* xroad_node_create_cursor ( xroad_object_type_t  type)

create new cache cursor

Parameters
[in]type- type of cursor
Returns
pointer to new cursor

◆ xroad_node_create_object()

void* xroad_node_create_object ( xroad_object_type_t  type)

create new object

Parameters
[in]type- type of object to create
Returns
created object

◆ xroad_node_cursor_get_first()

void* xroad_node_cursor_get_first ( xroad_cursor_t *  cursor)

return first object from cache

Parameters
[in]cursor- cache cursor
Returns
object from cache

◆ xroad_node_cursor_get_last()

void* xroad_node_cursor_get_last ( xroad_cursor_t *  cursor)

return last object from cache

Parameters
[in]cursor- cache cursor
Returns
object from cache

◆ xroad_node_cursor_get_next()

void* xroad_node_cursor_get_next ( xroad_cursor_t *  cursor)

return next object from cache

Parameters
[in]cursor- cache cursor
Returns
object from cache

◆ xroad_node_cursor_get_prev()

void* xroad_node_cursor_get_prev ( xroad_cursor_t *  cursor)

return previous object from cache

Parameters
[in]cursor- cache cursor
Returns
object from cache

◆ xroad_node_cursor_offset()

void* xroad_node_cursor_offset ( xroad_cursor_t *  cursor,
int64_t  offset 
)

offset cursor

Parameters
[in]cursor- cache cursor
[in]offset- offset value. Can be negative for offset back
Returns
object from cache, or NULL

◆ xroad_node_del_epoll()

xroad_errno_t xroad_node_del_epoll ( xroad_node_epoll_callback_t cback)

remove descriptor from epoll

Parameters
[in]cback- callback to remove
Returns
XROAD_ERROR_OK - done

◆ xroad_node_destroy()

void xroad_node_destroy ( void  )

destroy node and free resources

◆ xroad_node_destroy_cursor()

void xroad_node_destroy_cursor ( xroad_cursor_t *  cursor)

destroy cursor

Parameters
[in]cursor- cursor to destroy

◆ xroad_node_get_cache()

xroad_cache_t* xroad_node_get_cache ( )

returns pointer to cache

Returns
pointer to cache

◆ xroad_node_get_config()

xroad_xml_doc_t* xroad_node_get_config ( void  )

return pointer to configuration

Returns
pointer to configuration

◆ xroad_node_get_data()

xroad_node_data_t* xroad_node_get_data ( void  )
Returns
node system slot

◆ xroad_node_get_env_param()

xroad_str_t xroad_node_get_env_param ( xroad_str_t  param)

get node environment parameter

Parameters
[in]param- paramenter name
Returns
environment paramenter value

◆ xroad_node_get_epoll_fd()

int32_t xroad_node_get_epoll_fd ( void  )

return epoll file descriptor

◆ xroad_node_get_epoll_timestamps()

const xroad_epoll_timestamps* xroad_node_get_epoll_timestamps ( void  )

Returns timestamps associated with epoll

Returns
pointer to timestamps

◆ xroad_node_get_fun()

void* xroad_node_get_fun ( xroad_str_t  fname)

get function from dll by name

Parameters
[in]fname- name of function
Returns
pointer function

◆ xroad_node_get_link_descriptor()

int32_t xroad_node_get_link_descriptor ( void  )

return link descriptor. Can be used in epoll

Returns
link descriptor

◆ xroad_node_get_object()

void* xroad_node_get_object ( xroad_object_type_t  type,
xroad_object_id_t  id 
)

return object from cache

Parameters
[in]type- type of object
[in]id- id of object
Returns
pointer of object of any

◆ xroad_node_get_object_count()

size_t xroad_node_get_object_count ( xroad_object_type_t  type)

return count of objects of desired type

Parameters
[in]type- type of objects to count
Returns
count of objects

◆ xroad_node_get_used_lock()

xroad_lock_by_pid_t* xroad_node_get_used_lock ( void  )
Returns
lock used by node

◆ xroad_node_get_version()

const xroad_version_t* xroad_node_get_version ( void  )

return node version

Returns
node version

◆ xroad_node_get_working_dir()

xroad_str_t xroad_node_get_working_dir ( void  )

get node home dir

Returns
node home dir

◆ xroad_node_is_initialized()

bool xroad_node_is_initialized ( void  )

check if node already created

Returns
1 - node is initialized, 0 - not yet

◆ xroad_node_mod_epoll()

xroad_errno_t xroad_node_mod_epoll ( uint32_t  events,
xroad_node_epoll_callback_t cback 
)

modify events of already added to epoll descriptor

Parameters
[in]events- new fd events
[in]cback- pointer to epoll callback
Returns
XROAD_ERROR_OK - done

◆ xroad_node_receive()

int32_t xroad_node_receive ( void  )

receive and dispatch events

Returns
>= 0 number of dispatched messages, < 0 - error happened

◆ xroad_node_receive_ex()

int32_t xroad_node_receive_ex ( int32_t  timeout)

receive and dispatch events

Parameters
[in]timeout- wait usecs for received message
Returns
1 - message(s) dispatched, < 0 - error happened

◆ xroad_node_reconfig()

xroad_errno_t xroad_node_reconfig ( void  )

reconfigure node

Returns
XROAD_ERROR_OK - reconfiguration complete successfully

◆ xroad_node_renamed()

void xroad_node_renamed ( )

must be called when node is renamed

◆ xroad_node_reset_statistic()

void xroad_node_reset_statistic ( void  )

reset node statistic

◆ xroad_node_route_object()

xroad_errno_t xroad_node_route_object ( void *  obj,
  ... 
)

route object

Parameters
[in]obj- object to send
Returns
XROAD_ERROR_OK - object was sent

◆ xroad_node_route_object_va()

xroad_errno_t xroad_node_route_object_va ( void *  obj,
va_list  ap 
)

route object

Parameters
[in]obj- object to send
[in]ap- argument list
Returns
XROAD_ERROR_OK - object was sent

◆ xroad_node_send_object()

xroad_errno_t xroad_node_send_object ( void *  obj,
xroad_node_id_t  id 
)

send object directly to node

Parameters
[in]obj- object to send
[in]id- id of destination node
Returns
XROAD_ERROR_OK - object was sent

◆ xroad_node_set_flags()

void xroad_node_set_flags ( uint32_t  flags)

set node flags

Parameters
[in]flags- new node flags

◆ xroad_node_subscribe()

xroad_errno_t xroad_node_subscribe ( xroad_domain_t  group,
xroad_node_callback_t  cback 
)

subscribe to objects of concrete group

Parameters
[in]domain- object domain to subscribe
[in]cback- callback
Returns
XROAD_OK, else failed

◆ xroad_node_unsubscribe()

xroad_errno_t xroad_node_unsubscribe ( xroad_domain_t  group,
xroad_node_callback_t  cback 
)

unsubscribe from group objects

Parameters
[in]domain- object domain to usubscribe
[in]cback- callback
Returns
XROAD_OK, else failed