|
DTNMA Reference Tools v2.1.0 - 13.gc5c0bac
Delay-Tolerant Networking Management Architecture (DTNMA) Tool Suite
|
#include "exec.h"#include "exec_proc.h"#include "eval.h"#include "ctrl_exec_ctx.h"#include "valprod.h"#include "reporting.h"#include "amm/ctrl.h"#include <cace/ari/text.h>#include <cace/ari/text_util.h>#include <cace/amm/lookup.h>#include <cace/util/logging.h>#include <cace/util/defs.h>#include <timespec.h>
Include dependency graph for exec.c:Functions | |
| int | refda_exec_add_target (refda_runctx_ptr_t *runctxp, const cace_ari_t *target, refda_exec_status_t *status) |
| From outside the exec worker thread, inject a single execution target and allow its sequence to be tracked to its finish. | |
| static int | refda_exec_add_execset (refda_agent_t *agent, const refda_msgdata_t *msg) |
| int | refda_exec_waiting (refda_agent_t *agent) |
| Execute any waiting sequences as part of normal worker iteration. | |
| void * | refda_exec_worker (void *arg) |
| Work thread function for the Agent execution manager. | |
| bool | refda_exec_worker_iteration (refda_agent_t *agent) |
| Helper function to run a single iteration of the exec worker thread. | |
| static int | refda_exec_rule_action (refda_agent_t *agent, const cace_ari_t *action) |
| Expand a rule's action that has already been verified. | |
| static int | refda_exec_schedule_tbr (refda_agent_t *agent, refda_amm_tbr_desc_t *tbr, bool starting) |
| Schedule execution of a time based rule. | |
| static void | refda_exec_run_tbr (refda_agent_t *agent, refda_amm_tbr_desc_t *tbr) |
| Begin a single execution of a time based rule. | |
| static int | refda_exec_tbr_next_scheduled_time (struct timespec *schedtime, const refda_amm_tbr_desc_t *tbr, bool starting) |
| Compute the next scheduled time at which to run the TBR. | |
| int | refda_exec_tbr_enable (refda_agent_t *agent, refda_amm_tbr_desc_t *tbr) |
| Begin periodic execution of a time based rule. | |
| int | refda_exec_tbr_disable (refda_agent_t *agent, refda_amm_tbr_desc_t *tbr) |
| Cease periodic execution of a time based rule. | |
| static int | refda_exec_schedule_sbr (refda_agent_t *agent, refda_amm_sbr_desc_t *sbr) |
| Schedule execution of a state based rule. | |
| static int | refda_exec_check_sbr_condition (refda_agent_t *agent, const refda_amm_sbr_desc_t *sbr, cace_ari_t *result) |
| static void | refda_exec_run_sbr (refda_agent_t *agent, refda_amm_sbr_desc_t *sbr) |
| Begin a single run of a state based rule, evaluating its condition and executing its action if necessary. | |
| static int | refda_exec_sbr_next_scheduled_time (struct timespec *schedtime, const refda_amm_sbr_desc_t *sbr) |
| Compute the next scheduled time at which to run the SBR. | |
| int | refda_exec_sbr_enable (refda_agent_t *agent, refda_amm_sbr_desc_t *sbr) |
| Begin periodic execution of a state based rule. | |
| int | refda_exec_sbr_disable (refda_agent_t *agent, refda_amm_sbr_desc_t *sbr) |
| Cease periodic execution of a state based rule. | |
| int | refda_exec_next (refda_exec_seq_t *seq, const cace_ari_t *target) |
| Setup an ARI to execute next in the sequence. | |
|
static |
References agent, cace_ari_prim_val_u::as_execset, cace_ari_t::as_lit, CHKERR1, refda_exec_add_target(), refda_runctx_from(), cace_ari_lit_t::value, and refda_msgdata_t::value.
Referenced by refda_exec_worker_iteration().
| int refda_exec_add_target | ( | refda_runctx_ptr_t * | runctxp, |
| const cace_ari_t * | target, | ||
| refda_exec_status_t * | finish | ||
| ) |
From outside the exec worker thread, inject a single execution target and allow its sequence to be tracked to its finish.
This function is thread safe on the agent.
| [in] | runctxp | The run context, which includes the agent pointer. |
| [in] | target | The execution target (CTRL ref or macro). |
| [in] | finish | An optional execution-finished state for the whole target, or a null pointer to not track this state. |
References agent, refda_runctx_t::agent, CACE_LOG_CRIT, CACE_LOG_ERR, CHKERR1, refda_agent_t::exec_next_pid, refda_agent_t::exec_state, refda_agent_t::exec_state_mutex, refda_agent_t::execs_sem, refda_exec_status_t::failed, refda_exec_status_t::finished, refda_exec_seq_t::pid, refda_exec_proc_expand(), refda_exec_seq_t::runctx, and refda_exec_seq_t::status.
Referenced by refda_agent_startup_exec(), and refda_exec_add_execset().
|
static |
References agent, refda_amm_sbr_desc_t::condition, refda_eval_condition(), refda_runctx_deinit(), refda_runctx_from(), refda_runctx_init(), and result.
Referenced by refda_exec_run_sbr().
| int refda_exec_next | ( | refda_exec_seq_t * | seq, |
| const cace_ari_t * | target | ||
| ) |
Setup an ARI to execute next in the sequence.
The front of the execution sequence, the current item, is not modified.
| [in] | agent | The agent context pointer |
| [in] | seq | The sequence within which to inject the ARI target(s) |
| [in] | target | The ARI to execute |
References CHKERR1, and refda_exec_proc_expand().
Referenced by refda_adm_ietf_dtnma_agent_ctrl_catch(), and refda_adm_ietf_dtnma_agent_ctrl_if_then_else().
|
static |
Expand a rule's action that has already been verified.
Based on code from refda_exec_exp_execset
References agent, refda_agent_t::exec_next_pid, refda_agent_t::exec_state, refda_exec_seq_t::pid, refda_exec_proc_expand(), refda_runctx_from(), and refda_exec_seq_t::runctx.
Referenced by refda_exec_run_sbr(), and refda_exec_run_tbr().
|
static |
Begin a single run of a state based rule, evaluating its condition and executing its action if necessary.
References refda_amm_sbr_desc_t::action, agent, cace_amm_ari_is_truthy(), CACE_ARI_INIT_UNDEFINED, CACE_LOG_INFO, CHKVOID, refda_amm_sbr_desc_t::enabled, refda_amm_sbr_desc_t::exec_count, refda_agent_t::instr, refda_instr_t::num_sbrs_trig, refda_amm_sbr_desc_reached_max_exec_count(), refda_exec_check_sbr_condition(), refda_exec_rule_action(), refda_exec_sbr_disable(), refda_exec_schedule_sbr(), and result.
Referenced by refda_exec_schedule_sbr().
|
static |
Begin a single execution of a time based rule.
References refda_amm_tbr_desc_t::action, agent, CACE_LOG_INFO, CHKVOID, refda_amm_tbr_desc_t::enabled, refda_amm_tbr_desc_t::exec_count, refda_agent_t::instr, refda_instr_t::num_tbrs_trig, refda_amm_tbr_desc_reached_max_exec_count(), refda_exec_rule_action(), refda_exec_schedule_tbr(), and refda_exec_tbr_disable().
Referenced by refda_exec_schedule_tbr().
| int refda_exec_sbr_disable | ( | refda_agent_t * | agent, |
| refda_amm_sbr_desc_t * | sbr | ||
| ) |
Cease periodic execution of a state based rule.
| [in] | agent | The agent context pointer |
| [in] | sbr | The rule to disable |
References agent, CHKERR1, refda_amm_sbr_desc_t::enabled, refda_agent_t::instr, and refda_instr_t::num_sbrs.
Referenced by refda_adm_ietf_dtnma_agent_ctrl_ensure_rule_enabled(), refda_adm_ietf_dtnma_agent_ctrl_obsolete_rule(), refda_adm_ietf_dtnma_agent_ctrl_reset_rule_enabled(), and refda_exec_run_sbr().
| int refda_exec_sbr_enable | ( | refda_agent_t * | agent, |
| refda_amm_sbr_desc_t * | sbr | ||
| ) |
Begin periodic execution of a state based rule.
| [in] | agent | The agent context pointer |
| [in] | sbr | The rule to execute |
References refda_amm_sbr_desc_t::action, agent, cace_ari_cget_ac(), CACE_LOG_ERR, refda_amm_sbr_desc_t::condition, refda_amm_sbr_desc_t::enabled, refda_amm_sbr_desc_t::exec_count, refda_agent_t::instr, refda_instr_t::num_sbrs, refda_exec_schedule_sbr(), and result.
Referenced by refda_adm_ietf_dtnma_agent_ctrl_ensure_rule_enabled(), refda_adm_ietf_dtnma_agent_ctrl_ensure_sbr(), refda_adm_ietf_dtnma_agent_ctrl_reset_rule_enabled(), refda_agent_init_sbr(), test_refda_exec_state_based_rule(), and test_refda_exec_state_based_rule_cond_false_then_true().
|
static |
Compute the next scheduled time at which to run the SBR.
References cace_ari_get_td(), cace_ari_is_lit_typed(), CACE_ARI_TYPE_TD, CACE_LOG_ERR, and refda_amm_sbr_desc_t::min_interval.
Referenced by refda_exec_schedule_sbr().
|
static |
Schedule execution of a state based rule.
References agent, CACE_LOG_INFO, refda_agent_t::exec_end, refda_agent_t::exec_timeline, refda_timeline_event_t::purpose, refda_amm_sbr_desc_reached_max_exec_count(), refda_exec_run_sbr(), refda_exec_sbr_next_scheduled_time(), result, and refda_timeline_event_t::ts.
Referenced by refda_exec_run_sbr(), and refda_exec_sbr_enable().
|
static |
Schedule execution of a time based rule.
References agent, CACE_LOG_INFO, refda_agent_t::exec_end, refda_agent_t::exec_timeline, refda_timeline_event_t::purpose, refda_amm_tbr_desc_reached_max_exec_count(), refda_exec_run_tbr(), refda_exec_tbr_disable(), refda_exec_tbr_next_scheduled_time(), result, and refda_timeline_event_t::ts.
Referenced by refda_exec_run_tbr(), and refda_exec_tbr_enable().
| int refda_exec_tbr_disable | ( | refda_agent_t * | agent, |
| refda_amm_tbr_desc_t * | tbr | ||
| ) |
Cease periodic execution of a time based rule.
| [in] | agent | The agent context pointer |
| [in] | tbr | The rule to disable |
References agent, CHKERR1, refda_amm_tbr_desc_t::enabled, refda_agent_t::instr, and refda_instr_t::num_tbrs.
Referenced by refda_adm_ietf_dtnma_agent_ctrl_ensure_rule_enabled(), refda_adm_ietf_dtnma_agent_ctrl_obsolete_rule(), refda_adm_ietf_dtnma_agent_ctrl_reset_rule_enabled(), refda_exec_run_tbr(), and refda_exec_schedule_tbr().
| int refda_exec_tbr_enable | ( | refda_agent_t * | agent, |
| refda_amm_tbr_desc_t * | tbr | ||
| ) |
Begin periodic execution of a time based rule.
| [in] | agent | The agent context pointer |
| [in] | tbr | The rule to execute |
References refda_amm_tbr_desc_t::action, agent, cace_ari_cget_ac(), CACE_LOG_ERR, CHKERR1, refda_amm_tbr_desc_t::enabled, refda_amm_tbr_desc_t::exec_count, refda_agent_t::instr, refda_instr_t::num_tbrs, refda_exec_schedule_tbr(), and result.
Referenced by refda_adm_ietf_dtnma_agent_ctrl_ensure_rule_enabled(), refda_adm_ietf_dtnma_agent_ctrl_ensure_tbr(), refda_adm_ietf_dtnma_agent_ctrl_reset_rule_enabled(), refda_agent_init_tbr(), and test_refda_exec_time_based_rule().
|
static |
Compute the next scheduled time at which to run the TBR.
References refda_amm_tbr_desc_t::absolute_start_time, cace_ari_t::as_lit, cace_ari_prim_val_u::as_timespec, cace_ari_get_td(), cace_ari_get_tp(), cace_ari_is_lit_typed(), CACE_ARI_TYPE_TD, CACE_ARI_TYPE_TP, CACE_LOG_ERR, refda_amm_tbr_desc_t::period, refda_amm_tbr_desc_t::start_time, and cace_ari_lit_t::value.
Referenced by refda_exec_schedule_tbr().
| int refda_exec_waiting | ( | refda_agent_t * | agent | ) |
Execute any waiting sequences as part of normal worker iteration.
| [in] | agent | The agent state. |
References agent, CACE_LOG_CRIT, CACE_LOG_DEBUG, CACE_LOG_ERR, CACE_LOG_WARNING, refda_agent_t::exec_state, refda_agent_t::exec_state_mutex, refda_exec_item_t::execution_stage, refda_exec_seq_t::items, refda_exec_seq_t::pid, refda_exec_proc_run(), and REFDA_EXEC_WAITING.
Referenced by refda_exec_worker_iteration(), test_refda_exec_state_based_rule(), test_refda_exec_state_based_rule_cond_false_then_true(), and test_refda_exec_time_based_rule().
| void * refda_exec_worker | ( | void * | arg | ) |
Work thread function for the Agent execution manager.
| [in] | arg | The context refda_agent_t pointer. |
References agent, CACE_LOG_INFO, and refda_exec_worker_iteration().
Referenced by refda_agent_start().
| bool refda_exec_worker_iteration | ( | refda_agent_t * | agent | ) |
Helper function to run a single iteration of the exec worker thread.
| [in] | agent | The agent state. |
References agent, refda_runctx_t::agent, refda_timeline_sbr_event_t::agent, refda_timeline_tbr_event_t::agent, cace_ari_is_undefined(), CACE_LOG_DEBUG, CACE_LOG_ERR, CACE_LOG_INFO, cace_log_is_enabled_for(), cace_timeperiod_encode(), refda_timeline_sbr_event_t::callback, refda_timeline_tbr_event_t::callback, refda_timeline_exec_event_t::callback, refda_timeline_event_t::exec, refda_agent_t::exec_end, refda_agent_t::exec_timeline, refda_agent_t::execs, refda_agent_t::execs_enable, refda_agent_t::execs_sem, refda_exec_item_t::execution_stage, refda_agent_t::instr, refda_timeline_exec_event_t::item, refda_instr_t::num_ctrls_run, refda_timeline_event_t::purpose, refda_ctrl_exec_ctx_deinit(), refda_ctrl_exec_ctx_init(), refda_exec_add_execset(), refda_exec_proc_ctrl_finish(), refda_exec_waiting(), REFDA_EXEC_WAITING, refda_msgdata_deinit(), refda_msgdata_init(), refda_agent_t::rptgs, refda_agent_t::rptgs_sem, refda_ctrl_exec_ctx_t::runctx, refda_timeline_sbr_event_t::sbr, refda_timeline_event_t::sbr, refda_timeline_tbr_event_t::tbr, refda_timeline_event_t::tbr, refda_timeline_event_t::ts, and refda_msgdata_t::value.
Referenced by refda_exec_worker(), test_refda_exec_state_based_rule(), test_refda_exec_state_based_rule_cond_false_then_true(), and test_refda_exec_time_based_rule().