Usage of the SAForum AIS (Application Interface Specification). More...
#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: 145121 $") | |
| 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 |
Usage of the SAForum AIS (Application Interface Specification).
This file contains the code specific to the use of the CLM (Cluster Membership) Service.
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 72 of file clm.c.
References ast_cli_args::argc, ast_cli_entry::args, ARRAY_LEN, ast_cli(), buf, 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.
00073 { 00074 int i; 00075 SaClmClusterNotificationBufferT buf; 00076 SaClmClusterNotificationT notif[64]; 00077 SaAisErrorT ais_res; 00078 00079 switch (cmd) { 00080 case CLI_INIT: 00081 e->command = "ais show clm members"; 00082 e->usage = 00083 "Usage: ais show clm members\n" 00084 " List members of the cluster using the CLM (Cluster Membership) service.\n"; 00085 return NULL; 00086 00087 case CLI_GENERATE: 00088 return NULL; /* no completion */ 00089 } 00090 00091 if (a->argc != e->args) 00092 return CLI_SHOWUSAGE; 00093 00094 buf.notification = notif; 00095 buf.numberOfItems = ARRAY_LEN(notif); 00096 00097 ais_res = saClmClusterTrack(clm_handle, SA_TRACK_CURRENT, &buf); 00098 if (ais_res != SA_AIS_OK) { 00099 ast_cli(a->fd, "Error retrieving current cluster members.\n"); 00100 return CLI_FAILURE; 00101 } 00102 00103 ast_cli(a->fd, "\n" 00104 "=============================================================\n" 00105 "=== Cluster Members =========================================\n" 00106 "=============================================================\n" 00107 "===\n"); 00108 00109 for (i = 0; i < buf.numberOfItems; i++) { 00110 SaClmClusterNodeT *node = &buf.notification[i].clusterNode; 00111 00112 ast_cli(a->fd, "=== ---------------------------------------------------------\n" 00113 "=== Node Name: %s\n" 00114 "=== ==> ID: 0x%x\n" 00115 "=== ==> Address: %s\n" 00116 "=== ==> Member: %s\n", 00117 (char *) node->nodeName.value, (int) node->nodeId, 00118 (char *) node->nodeAddress.value, 00119 node->member ? "Yes" : "No"); 00120 00121 ast_cli(a->fd, "=== ---------------------------------------------------------\n" 00122 "===\n"); 00123 } 00124 00125 ast_cli(a->fd, "=============================================================\n" 00126 "\n"); 00127 00128 return CLI_SUCCESS; 00129 }
| int ast_ais_clm_load_module | ( | void | ) |
Definition at line 135 of file clm.c.
References ais_err2str(), ais_version, ARRAY_LEN, ast_cli_register_multiple(), ast_log(), clm_callbacks, clm_handle, and LOG_ERROR.
Referenced by load_module().
00136 { 00137 SaAisErrorT ais_res; 00138 00139 ais_res = saClmInitialize(&clm_handle, &clm_callbacks, &ais_version); 00140 if (ais_res != SA_AIS_OK) { 00141 ast_log(LOG_ERROR, "Could not initialize cluster membership service: %s\n", 00142 ais_err2str(ais_res)); 00143 return -1; 00144 } 00145 00146 ast_cli_register_multiple(ais_cli, ARRAY_LEN(ais_cli)); 00147 00148 return 0; 00149 }
| int ast_ais_clm_unload_module | ( | void | ) |
Definition at line 151 of file clm.c.
References ais_err2str(), ARRAY_LEN, ast_cli_unregister_multiple(), ast_log(), clm_handle, and LOG_ERROR.
Referenced by load_module(), and unload_module().
00152 { 00153 SaAisErrorT ais_res; 00154 00155 ast_cli_unregister_multiple(ais_cli, ARRAY_LEN(ais_cli)); 00156 00157 ais_res = saClmFinalize(clm_handle); 00158 if (ais_res != SA_AIS_OK) { 00159 ast_log(LOG_ERROR, "Problem stopping cluster membership service: %s\n", 00160 ais_err2str(ais_res)); 00161 return -1; 00162 } 00163 00164 return 0; 00165 }
| ASTERISK_FILE_VERSION | ( | __FILE__ | , | |
| "$Revision: 145121 $" | ||||
| ) |
| 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] |
{
AST_CLI_DEFINE(ais_clm_show_members, "List current members of the cluster"),
}
const SaClmCallbacksT clm_callbacks [static] |
{
.saClmClusterNodeGetCallback = clm_node_get_cb,
.saClmClusterTrackCallback = clm_track_cb,
}
Definition at line 55 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().
1.6.2