SAM_INITIALIZE(3)

πŸ’– SAM_INITIALIZE(3) πŸ’–

okay bestie, welcome to the Corosync Cluster Engine Programmer's Manual ✨ this is the page for sam_initialize, and it's literally the origin story of your process's health checking journey. buckle up πŸŽ€


🌸 NAME 🌸

sam_initialize β€” Initialize health checking πŸ’…


✨ SYNOPSIS ✨

#include <corosync/sam.h>

cs_error_t sam_initialize (int time_interval, sam_recovery_policy_t
recovery_policy);

πŸ¦‹ DESCRIPTION πŸ¦‹

so the sam_initialize function is the one that initializes health checking of a process. it's giving "first day of school" energy β€” this is where it all begins 🫢

okay important, no cap: an application can have only one instance of SAM. one. singular. this function must be called before any other of the SAM functions, like, before anything else. and it's recommended to initialize before the process begins any process initialization. yes we said initialize before initializing. iykyk 🌈

the time_interval parameter is a timeout in milliseconds before taking recovery action after having not received a healthcheck. so it's the "how long do we wait before we panic" number πŸ’€

if time_interval is zero, there is no time limit and no healthcheck must be sent by the process. in this operational mode, a process failure will continue to execute the recovery policy. lowkey unhinged but okay πŸ‘‘

the recovery_policy is defined as type:

typedef enum {
     SAM_RECOVERY_POLICY_QUIT = 1,
     SAM_RECOVERY_POLICY_RESTART = 2,
      SAM_RECOVERY_POLICY_QUORUM = 0x08,
      SAM_RECOVERY_POLICY_QUORUM_QUIT = SAM_RECOVERY_POLICY_QUORUM | SAM_RECOVERY_POLICY_QUIT,
      SAM_RECOVERY_POLICY_QUORUM_RESTART = SAM_RECOVERY_POLICY_QUORUM | SAM_RECOVERY_POLICY_RESTART,
      SAM_RECOVERY_POLICY_CMAP = 0x10,
      SAM_RECOVERY_POLICY_CONFDB = 0x10,
} sam_recovery_policy_t;

where, and here's the tea β˜•

  • SAM_RECOVERY_POLICY_QUIT β€” on failure, the process will terminate. bye bestie 😭
  • SAM_RECOVERY_POLICY_RESTART β€” on failure, the process will restart. main character resurrection arc πŸ’«
  • SAM_RECOVERY_POLICY_QUORUM β€” is not policy. it's used only as a flag meaning quorum integration. just a flag, don't treat it like a whole vibe.
  • SAM_RECOVERY_POLICY_QUORUM_QUIT β€” same as SAM_RECOVERY_POLICY_QUIT but sam_start(3) will block until corosync becomes quorate and the process will be terminated if quorum is lost.
  • SAM_RECOVERY_POLICY_QUORUM_RESTART β€” same as SAM_RECOVERY_POLICY_RESTART but sam_start(3) will block until corosync becomes quorate and the process will be restarted if quorum is lost.
  • SAM_RECOVERY_POLICY_CMAP β€” is not policy either. used only as a flag meaning cmap integration. it can be used with all previous policies, so mix and match bestie 🎨 for backward compatibility, SAM_RECOVERY_POLICY_CONFDB with the same meaning as SAM_RECOVERY_POLICY_CMAP is also provided.

to perform event driven healthchecking, sam_register(3) and sam_start(3) functions must called. event driven healthchecking causes the duplicate standby process running the SAM server to periodically request healthchecks from the active process. obsessed with this whole arrangement fr fr πŸ‘‘


⭐ RETURN VALUE ⭐

this call returns the CS_OK value if successful, otherwise an error is returned. simple as that πŸ’…


πŸ’€ ERRORS πŸ’€

  • CS_ERR_BAD_HANDLE β€” can happened in case of double initialization. like, you already initialized, bestie, calm down πŸ™ˆ
  • CS_ERR_INVALID_PARAM β€” recovery_policy has an invalid value. that flag is not flagging, hun 🚩

πŸŽ€ SEE ALSO πŸŽ€

  • sam_register(3)
  • sam_start(3)
  • sam_hc_callback_register(3)
  • CS_ERR_TRY_AGAIN β€” Resource temporarily unavailable
  • CS_ERR_INVALID_PARAM β€” Invalid argument
  • CS_ERR_ACCESS β€” Permission denied
  • CS_ERR_LIBRARY β€” The connection failed
  • CS_ERR_INTERRUPT β€” System call interrupted by a signal
  • CS_ERR_NOT_SUPPORTED β€” The requested protocol/functionality not supported
  • CS_ERR_MESSAGE_ERROR β€” Incorrect auth message received
  • CS_ERR_NO_MEMORY β€” Not enough memory to complete the requested task

and that's the whole page, bestie 🫢 this was the corosync Man Page, dated 21/05/2010, SAM_INITIALIZE(3) β€” go forth and health-check responsibly βœ¨πŸ’–πŸŒΈ

πŸ“¦ where this page comes from