OpenMPI  0.1.1
notifier.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2004-2008 The Trustees of Indiana University and Indiana
3  * University Research and Technology
4  * Corporation. All rights reserved.
5  * Copyright (c) 2004-2005 The University of Tennessee and The University
6  * of Tennessee Research Foundation. All rights
7  * reserved.
8  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
9  * University of Stuttgart. All rights reserved.
10  * Copyright (c) 2004-2005 The Regents of the University of California.
11  * All rights reserved.
12  * Copyright (c) 2009 Cisco Systems, Inc. All Rights Reserved.
13  * $COPYRIGHT$
14  *
15  * Additional copyrights may follow
16  *
17  * $HEADER$
18  */
19 /** @file:
20  *
21  * The OpenRTE Notifier Framework
22  *
23  * The OpenRTE Notifier framework provides a mechanism for notifying
24  * system administrators or other fault monitoring systems that a
25  * problem with the underlying cluster has been detected - e.g., a
26  * failed connection in a network fabric
27  */
28 
29 #ifndef MCA_NOTIFIER_H
30 #define MCA_NOTIFIER_H
31 
32 /*
33  * includes
34  */
35 
36 #include "orte_config.h"
37 
38 #ifdef HAVE_STDARG_H
39 #include <stdarg.h>
40 #endif
41 
42 #include "opal/mca/mca.h"
43 #include "opal/util/opal_sos.h"
44 
45 #include "orte/constants.h"
46 #include "orte/types.h"
47 
48 #include "notifier_event_types.h"
49 
50 BEGIN_C_DECLS
51 
52 /* The maximum size of any on-stack buffers used in the notifier
53  * so we can try to avoid calling malloc in OUT_OF_RESOURCES conditions.
54  * The code has NOT been auditied for use of malloc, so this still
55  * may fail to get the "OUT_OF_RESOURCE" message out. Oh Well.
56  */
57 #define ORTE_NOTIFIER_MAX_BUF 512
58 
59 /* Severities, based on OPAL SOS */
60 typedef enum {
61  ORTE_NOTIFIER_EMERG = OPAL_SOS_SEVERITY_EMERG,
62  ORTE_NOTIFIER_ALERT = OPAL_SOS_SEVERITY_ALERT,
63  ORTE_NOTIFIER_CRIT = OPAL_SOS_SEVERITY_CRIT,
64  ORTE_NOTIFIER_ERROR = OPAL_SOS_SEVERITY_ERROR,
65  ORTE_NOTIFIER_WARN = OPAL_SOS_SEVERITY_WARN,
66  ORTE_NOTIFIER_NOTICE = OPAL_SOS_SEVERITY_NOTICE,
67  ORTE_NOTIFIER_INFO = OPAL_SOS_SEVERITY_INFO,
68  ORTE_NOTIFIER_DEBUG = OPAL_SOS_SEVERITY_DEBUG
69 } orte_notifier_base_severity_t;
70 
71 /*
72  * Component functions - all MUST be provided!
73  */
74 
75 /* initialize the selected module */
76 typedef int (*orte_notifier_base_module_init_fn_t)(void);
77 
78 /* finalize the selected module */
79 typedef void (*orte_notifier_base_module_finalize_fn_t)(void);
80 
81 /* Log a failure message */
82 typedef void (*orte_notifier_base_module_log_fn_t)(orte_notifier_base_severity_t severity, int errcode, const char *msg, va_list ap)
83  __opal_attribute_format_funcptr__(__printf__, 3, 0);
84 
85 /* Log a failure that is based upon a show_help message */
86 typedef void (*orte_notifier_base_module_log_show_help_fn_t)(orte_notifier_base_severity_t severity, int errcode, const char *file, const char *topic, va_list ap);
87 
88 /* Log a failure related to a peer */
89 typedef void (*orte_notifier_base_module_log_peer_fn_t)(orte_notifier_base_severity_t severity, int errcode, orte_process_name_t *peer_proc, const char *msg, va_list ap)
90  __opal_attribute_format_funcptr__(__printf__, 4, 0);
91 
92 /* Log an unusual event message */
93 typedef void (*orte_notifier_base_module_log_event_fn_t)(const char *msg);
94 
95 /*
96  * Ver 1.0
97  */
99  orte_notifier_base_module_init_fn_t init;
100  orte_notifier_base_module_finalize_fn_t finalize;
101  orte_notifier_base_module_log_fn_t log;
102  orte_notifier_base_module_log_show_help_fn_t help;
103  orte_notifier_base_module_log_peer_fn_t peer;
104  orte_notifier_base_module_log_event_fn_t log_event;
105 };
106 
109 
110 /*
111  * API functions
112  */
113 /* Log a failure message */
114 typedef void (*orte_notifier_base_API_log_fn_t)(orte_notifier_base_severity_t severity, int errcode, const char *msg, ...);
115 
116 /* Log a failure that is based upon a show_help message */
117 typedef void (*orte_notifier_base_API_log_show_help_fn_t)(orte_notifier_base_severity_t severity, int errcode, const char *file, const char *topic, ...);
118 
119 /* Log a failure related to a peer */
120 typedef void (*orte_notifier_base_API_log_peer_fn_t)(orte_notifier_base_severity_t severity, int errcode, orte_process_name_t *peer_proc, const char *msg, ...);
121 
122 /*
123  * Define a struct to hold the API functions that users will call
124  */
126  orte_notifier_base_API_log_fn_t log;
127  orte_notifier_base_API_log_show_help_fn_t show_help;
128  orte_notifier_base_API_log_peer_fn_t log_peer;
129 };
132 
133 ORTE_DECLSPEC extern orte_notifier_API_module_t orte_notifier;
134 
135 /*
136  * the standard component data structure
137  */
139  mca_base_component_t base_version;
140  mca_base_component_data_t base_data;
141 };
144 
145 
146 /*
147  * Macro for use in components that are of type notifier v1.0.0
148  */
149 #define ORTE_NOTIFIER_BASE_VERSION_1_0_0 \
150  /* notifier v1.0 is chained to MCA v2.0 */ \
151  MCA_BASE_VERSION_2_0_0, \
152  /* notifier v1.0 */ \
153  "notifier", 1, 0, 0
154 
155 /*
156  * To manage unusual events notifications
157  * Set to noop if not wanted
158  */
159 
160 #if ORTE_WANT_NOTIFIER_LOG_EVENT
161 
162 #include "notifier_event_calls.h"
163 
164 #else /* ORTE_WANT_NOTIFIER_LOG_EVENT */
165 
166 #define ORTE_NOTIFIER_DEFINE_EVENT(i, m)
167 #define ORTE_NOTIFIER_LOG_EVENT(i, c, t) do {} while (0)
168 
169 #endif /* ORTE_WANT_NOTIFIER_LOG_EVENT */
170 
171 END_C_DECLS
172 
173 #endif /* MCA_NOTIFIER_H */
Common type for all MCA components.
Definition: mca.h:250
Definition: types.h:146
Definition: notifier.h:98
Top-level interface for all MCA components.
Meta data for MCA v2.0.0 components.
Definition: mca.h:309
Definition: notifier.h:138
Definition: notifier.h:125