#include "asterisk.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include "ais.h"
#include "asterisk/module.h"
#include "asterisk/utils.h"
#include "asterisk/cli.h"
#include "asterisk/logger.h"
Go to the source code of this file.
Functions | |
static char * | ais_clm_show_members (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
int | ast_ais_clm_load_module (void) |
int | ast_ais_clm_unload_module (void) |
ASTERISK_FILE_VERSION (__FILE__,"$Revision: 294535 $") | |
static void | clm_node_get_cb (SaInvocationT invocation, const SaClmClusterNodeT *cluster_node, SaAisErrorT error) |
static void | clm_track_cb (const SaClmClusterNotificationBufferT *notif_buffer, SaUint32T num_members, SaAisErrorT error) |
Variables | |
static struct ast_cli_entry | ais_cli [] |
static const SaClmCallbacksT | clm_callbacks |
SaClmHandleT | clm_handle |
static SaAisErrorT | clm_init_res |
Definition in file clm.c.
static char* ais_clm_show_members | ( | struct ast_cli_entry * | e, | |
int | cmd, | |||
struct ast_cli_args * | a | |||
) | [static] |
Definition at line 73 of file clm.c.
References ast_cli_args::argc, ast_cli_entry::args, ARRAY_LEN, ast_cli(), CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, clm_handle, ast_cli_entry::command, ast_cli_args::fd, and ast_cli_entry::usage.
00074 { 00075 int i; 00076 SaClmClusterNotificationBufferT buf; 00077 SaClmClusterNotificationT notif[64]; 00078 SaAisErrorT ais_res; 00079 00080 switch (cmd) { 00081 case CLI_INIT: 00082 e->command = "ais clm show members"; 00083 e->usage = 00084 "Usage: ais clm show members\n" 00085 " List members of the cluster using the CLM (Cluster Membership) service.\n"; 00086 return NULL; 00087 00088 case CLI_GENERATE: 00089 return NULL; /* no completion */ 00090 } 00091 00092 if (a->argc != e->args) 00093 return CLI_SHOWUSAGE; 00094 00095 buf.notification = notif; 00096 buf.numberOfItems = ARRAY_LEN(notif); 00097 00098 ais_res = saClmClusterTrack(clm_handle, SA_TRACK_CURRENT, &buf); 00099 if (ais_res != SA_AIS_OK) { 00100 ast_cli(a->fd, "Error retrieving current cluster members.\n"); 00101 return CLI_FAILURE; 00102 } 00103 00104 ast_cli(a->fd, "\n" 00105 "=============================================================\n" 00106 "=== Cluster Members =========================================\n" 00107 "=============================================================\n" 00108 "===\n"); 00109 00110 for (i = 0; i < buf.numberOfItems; i++) { 00111 SaClmClusterNodeT *node = &buf.notification[i].clusterNode; 00112 00113 ast_cli(a->fd, "=== ---------------------------------------------------------\n" 00114 "=== Node Name: %s\n" 00115 "=== ==> ID: 0x%x\n" 00116 "=== ==> Address: %s\n" 00117 "=== ==> Member: %s\n", 00118 (char *) node->nodeName.value, (int) node->nodeId, 00119 (char *) node->nodeAddress.value, 00120 node->member ? "Yes" : "No"); 00121 00122 ast_cli(a->fd, "=== ---------------------------------------------------------\n" 00123 "===\n"); 00124 } 00125 00126 ast_cli(a->fd, "=============================================================\n" 00127 "\n"); 00128 00129 return CLI_SUCCESS; 00130 }
int ast_ais_clm_load_module | ( | void | ) |
Definition at line 136 of file clm.c.
References ais_cli, ais_err2str(), ais_version, ARRAY_LEN, ast_cli_register_multiple(), ast_log(), clm_callbacks, clm_handle, clm_init_res, and LOG_ERROR.
Referenced by load_module().
00137 { 00138 clm_init_res = saClmInitialize(&clm_handle, &clm_callbacks, &ais_version); 00139 if (clm_init_res != SA_AIS_OK) { 00140 ast_log(LOG_ERROR, "Could not initialize cluster membership service: %s\n", 00141 ais_err2str(clm_init_res)); 00142 return -1; 00143 } 00144 00145 ast_cli_register_multiple(ais_cli, ARRAY_LEN(ais_cli)); 00146 00147 return 0; 00148 }
int ast_ais_clm_unload_module | ( | void | ) |
Definition at line 150 of file clm.c.
References ais_cli, ais_err2str(), ARRAY_LEN, ast_cli_unregister_multiple(), ast_log(), clm_handle, clm_init_res, and LOG_ERROR.
Referenced by load_module(), and unload_module().
00151 { 00152 SaAisErrorT ais_res; 00153 00154 if (clm_init_res != SA_AIS_OK) { 00155 return 0; 00156 } 00157 00158 ast_cli_unregister_multiple(ais_cli, ARRAY_LEN(ais_cli)); 00159 00160 ais_res = saClmFinalize(clm_handle); 00161 if (ais_res != SA_AIS_OK) { 00162 ast_log(LOG_ERROR, "Problem stopping cluster membership service: %s\n", 00163 ais_err2str(ais_res)); 00164 return -1; 00165 } 00166 00167 return 0; 00168 }
ASTERISK_FILE_VERSION | ( | __FILE__ | , | |
"$Revision: 294535 $" | ||||
) |
static void clm_node_get_cb | ( | SaInvocationT | invocation, | |
const SaClmClusterNodeT * | cluster_node, | |||
SaAisErrorT | error | |||
) | [static] |
static void clm_track_cb | ( | const SaClmClusterNotificationBufferT * | notif_buffer, | |
SaUint32T | num_members, | |||
SaAisErrorT | error | |||
) | [static] |
struct ast_cli_entry ais_cli[] [static] |
Initial value:
{ { .handler = ais_clm_show_members , .summary = "List current members of the cluster" ,__VA_ARGS__ }, }
Definition at line 132 of file clm.c.
Referenced by ast_ais_clm_load_module(), ast_ais_clm_unload_module(), and ast_ais_evt_load_module().
const SaClmCallbacksT clm_callbacks [static] |
Initial value:
{ .saClmClusterNodeGetCallback = clm_node_get_cb, .saClmClusterTrackCallback = clm_track_cb, }
Definition at line 56 of file clm.c.
Referenced by ast_ais_clm_load_module().
SaClmHandleT clm_handle |
Definition at line 48 of file clm.c.
Referenced by ais_clm_show_members(), ast_ais_clm_load_module(), ast_ais_clm_unload_module(), ast_event_cb(), and dispatch_thread_handler().
SaAisErrorT clm_init_res [static] |
Definition at line 49 of file clm.c.
Referenced by ast_ais_clm_load_module(), and ast_ais_clm_unload_module().