MCPcopy Create free account
hub / github.com/corosync/corosync / mon_instance_init

Function mon_instance_init

exec/mon.c:445–493  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

443}
444
445static void mon_instance_init (struct resource_instance* inst)
446{
447 uint64_t tmp_value;
448 char key_name[ICMAP_KEYNAME_MAXLEN];
449 icmap_track_t icmap_track = NULL;
450 char *tmp_str;
451
452 snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s%s", inst->icmap_path, "current");
453 if (inst->max_type == ICMAP_VALUETYPE_INT32) {
454 icmap_set_int32(key_name, 0);
455 } else {
456 icmap_set_double(key_name, 0);
457 }
458
459 snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s%s", inst->icmap_path, "last_updated");
460 icmap_set_uint64(key_name, 0);
461
462 snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s%s", inst->icmap_path, "state");
463 icmap_set_string(key_name, mon_stopped_str);
464
465 inst->fsm.name = inst->name;
466 inst->fsm.curr_entry = 0;
467 inst->fsm.curr_state = MON_S_STOPPED;
468 inst->fsm.table = mon_fsm_table;
469 inst->fsm.entries = sizeof(mon_fsm_table) / sizeof(struct cs_fsm_entry);
470 inst->fsm.state_to_str = mon_res_state_to_str;
471 inst->fsm.event_to_str = mon_res_event_to_str;
472
473 snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s%s", inst->icmap_path, "poll_period");
474 if (icmap_get_string(key_name, &tmp_str) != CS_OK ||
475 sscanf(tmp_str, "%"PRIu64, &tmp_value) != 1) {
476 icmap_set_uint64(key_name, inst->period);
477 }
478 else {
479 if (tmp_value >= MON_MIN_PERIOD && tmp_value <= MON_MAX_PERIOD) {
480 inst->period = tmp_value;
481 } else {
482 log_printf (LOGSYS_LEVEL_WARNING,
483 "Could NOT use poll_period:%"PRIu64" ms for resource %s",
484 tmp_value, inst->name);
485 }
486 free(tmp_str);
487 }
488 cs_fsm_process (&inst->fsm, MON_E_CONFIG_CHANGED, inst, mon_fsm_cb);
489
490 icmap_track_add(inst->icmap_path,
491 ICMAP_TRACK_ADD | ICMAP_TRACK_MODIFY | ICMAP_TRACK_DELETE | ICMAP_TRACK_PREFIX,
492 mon_key_changed_cb, inst, &icmap_track);
493}
494
495static char *mon_exec_init_fn (struct corosync_api_v1 *corosync_api)
496{

Callers 1

mon_exec_init_fnFunction · 0.85

Calls 7

icmap_set_int32Function · 0.85
icmap_set_doubleFunction · 0.85
icmap_set_uint64Function · 0.85
icmap_set_stringFunction · 0.85
icmap_get_stringFunction · 0.85
cs_fsm_processFunction · 0.85
icmap_track_addFunction · 0.85

Tested by

no test coverage detected