1
1

Continue massaging of the notifier framework. Convert it to an event-driven interface. Add the ability to report job state if requested. Cleanup object declarations.

Этот коммит содержится в:
Ralph Castain 2015-02-17 12:44:58 -08:00
родитель 298f238096
Коммит 78245e8a33
8 изменённых файлов: 218 добавлений и 247 удалений

Просмотреть файл

@ -46,7 +46,7 @@ ORTE_DECLSPEC extern mca_base_framework_t orte_notifier_base_framework;
typedef struct { typedef struct {
opal_event_base_t *ev_base; opal_event_base_t *ev_base;
bool ev_base_active; bool ev_base_active;
opal_pointer_array_t modules; opal_list_t modules;
orte_notifier_severity_t severity_level; orte_notifier_severity_t severity_level;
char *default_actions; char *default_actions;
char *emerg_actions; char *emerg_actions;
@ -68,29 +68,18 @@ typedef struct {
orte_notifier_base_component_t *component; orte_notifier_base_component_t *component;
/* Module */ /* Module */
orte_notifier_base_module_t *module; orte_notifier_base_module_t *module;
/* Priority */
int priority;
} orte_notifier_active_module_t; } orte_notifier_active_module_t;
OBJ_CLASS_DECLARATION(orte_notifier_active_module_t); OBJ_CLASS_DECLARATION(orte_notifier_active_module_t);
typedef struct {
opal_object_t super;
opal_event_t ev;
char **modules;
orte_notifier_severity_t severity;
int errcode;
const char *msg;
va_list *ap;
} orte_notifier_request_t;
OBJ_CLASS_DECLARATION(orte_notifier_request_t);
ORTE_DECLSPEC extern orte_notifier_base_t orte_notifier_base; ORTE_DECLSPEC extern orte_notifier_base_t orte_notifier_base;
ORTE_DECLSPEC extern orte_notifier_severity_t orte_notifier_severity;
/* select a component */ /* select a component */
ORTE_DECLSPEC int orte_notifier_base_select(void); ORTE_DECLSPEC int orte_notifier_base_select(void);
/* log function */
ORTE_DECLSPEC void orte_notifier_base_log(orte_notifier_severity_t severity, /* base functions */
int errcode, const char *msg, ...); ORTE_DECLSPEC void orte_notifier_base_log(int sd, short args, void *cbdata);
ORTE_DECLSPEC void orte_notifier_base_report(int sd, short args, void *cbdata);
/* severity to string */ /* severity to string */
ORTE_DECLSPEC const char* orte_notifier_base_sev2str(orte_notifier_severity_t severity); ORTE_DECLSPEC const char* orte_notifier_base_sev2str(orte_notifier_severity_t severity);
END_C_DECLS END_C_DECLS

Просмотреть файл

@ -20,81 +20,54 @@
#include "orte_config.h" #include "orte_config.h"
#include "opal/mca/event/event.h"
#include "opal/runtime/opal_progress_threads.h"
#include "orte/constants.h" #include "orte/constants.h"
#include "orte/mca/ess/ess.h"
#include "orte/util/error_strings.h" #include "opal/util/argv.h"
#include "orte/util/name_fns.h"
#include "orte/runtime/orte_globals.h"
#include "orte/mca/notifier/base/base.h" #include "orte/mca/notifier/base/base.h"
static void process_log(int fd, short args, void *cbdata) void orte_notifier_base_log(int sd, short args, void *cbdata)
{ {
int i = 0, j = 0; orte_notifier_request_t *req = (orte_notifier_request_t*)cbdata;
orte_notifier_active_module_t *i_module; char **modules = NULL;
orte_notifier_request_t *req = (orte_notifier_request_t *)cbdata; orte_notifier_active_module_t *imod;
char **modules = req->modules; int i;
/* call the log function of all modules in priority order */
for (i = 0; i < orte_notifier_base.modules.size; i++) {
if (NULL == (i_module = (orte_notifier_active_module_t*)opal_pointer_array_get_item (&orte_notifier_base.modules, i))) {
continue;
}
for (j = 0; NULL != modules[j]; j++) {
if (0 == strncasecmp(i_module->component->base_version.mca_component_name, modules[j], strlen(modules[j]))) {
if (NULL != i_module->module->log) {
i_module->module->log(req->severity, req->errcode, req->msg, req->ap);
va_end(*req->ap);
}
}
}
}
}
void orte_notifier_base_log(orte_notifier_severity_t severity,
int errcode, const char *msg, ...)
{
va_list ap;
char **modules;
orte_notifier_request_t *req;
/* if no modules are active, then there is nothing to do */ /* if no modules are active, then there is nothing to do */
if (0 == orte_notifier_base.modules.size) { if (0 == opal_list_get_size(&orte_notifier_base.modules)) {
return; return;
} }
/* check if the severity is >= severity level set for reporting */ /* check if the severity is >= severity level set for
if (orte_notifier_base.severity_level < severity ) { * reporting - note that the severity enum value goes up
* as severity goes down */
if (orte_notifier_base.severity_level < req->severity ) {
return; return;
} }
if (ORTE_NOTIFIER_EMERG == severity && if (ORTE_NOTIFIER_EMERG == req->severity &&
(NULL != orte_notifier_base.emerg_actions)) { (NULL != orte_notifier_base.emerg_actions)) {
modules = opal_argv_split(orte_notifier_base.emerg_actions, ','); modules = opal_argv_split(orte_notifier_base.emerg_actions, ',');
} else if (ORTE_NOTIFIER_ALERT == severity && } else if (ORTE_NOTIFIER_ALERT == req->severity &&
(NULL != orte_notifier_base.alert_actions)) { (NULL != orte_notifier_base.alert_actions)) {
modules = opal_argv_split(orte_notifier_base.alert_actions, ','); modules = opal_argv_split(orte_notifier_base.alert_actions, ',');
} else if (ORTE_NOTIFIER_CRIT == severity && } else if (ORTE_NOTIFIER_CRIT == req->severity &&
(NULL != orte_notifier_base.crit_actions)) { (NULL != orte_notifier_base.crit_actions)) {
modules = opal_argv_split(orte_notifier_base.crit_actions, ','); modules = opal_argv_split(orte_notifier_base.crit_actions, ',');
} else if (ORTE_NOTIFIER_WARN == severity && } else if (ORTE_NOTIFIER_WARN == req->severity &&
(NULL != orte_notifier_base.warn_actions)) { (NULL != orte_notifier_base.warn_actions)) {
modules = opal_argv_split(orte_notifier_base.warn_actions, ','); modules = opal_argv_split(orte_notifier_base.warn_actions, ',');
} else if (ORTE_NOTIFIER_NOTICE == severity && } else if (ORTE_NOTIFIER_NOTICE == req->severity &&
(NULL != orte_notifier_base.notice_actions)) { (NULL != orte_notifier_base.notice_actions)) {
modules = opal_argv_split(orte_notifier_base.notice_actions, ','); modules = opal_argv_split(orte_notifier_base.notice_actions, ',');
} else if (ORTE_NOTIFIER_INFO == severity && } else if (ORTE_NOTIFIER_INFO == req->severity &&
(NULL != orte_notifier_base.info_actions)) { (NULL != orte_notifier_base.info_actions)) {
modules = opal_argv_split(orte_notifier_base.info_actions, ','); modules = opal_argv_split(orte_notifier_base.info_actions, ',');
} else if (ORTE_NOTIFIER_DEBUG == severity && } else if (ORTE_NOTIFIER_DEBUG == req->severity &&
(NULL != orte_notifier_base.debug_actions)) { (NULL != orte_notifier_base.debug_actions)) {
modules = opal_argv_split(orte_notifier_base.debug_actions, ','); modules = opal_argv_split(orte_notifier_base.debug_actions, ',');
} else if (ORTE_NOTIFIER_ERROR == severity && } else if (ORTE_NOTIFIER_ERROR == req->severity &&
(NULL != orte_notifier_base.error_actions)) { (NULL != orte_notifier_base.error_actions)) {
modules = opal_argv_split(orte_notifier_base.error_actions, ','); modules = opal_argv_split(orte_notifier_base.error_actions, ',');
} else if (NULL != orte_notifier_base.default_actions) { } else if (NULL != orte_notifier_base.default_actions) {
@ -104,27 +77,44 @@ void orte_notifier_base_log(orte_notifier_severity_t severity,
return; return;
} }
/* set the event base and push this request into event base for (i=0; NULL != modules[i]; i++) {
*/ OPAL_LIST_FOREACH(imod, &orte_notifier_base.modules, orte_notifier_active_module_t) {
req = OBJ_NEW(orte_notifier_request_t); if (NULL != imod->module->log &&
0 == strcmp(imod->component->base_version.mca_component_name, modules[i]))
req->modules = modules; imod->module->log(req);
req->severity = severity; }
req->errcode = errcode; }
req->msg = msg; opal_argv_free(modules);
va_start(ap, msg);
req->ap = &ap;
/*
* set the event and activate
*/
opal_event_set(orte_notifier_base.ev_base, &req->ev, -1,
OPAL_EV_WRITE,
process_log, req);
opal_event_set_priority(&req->ev, OPAL_EV_SYS_HI_PRI);
opal_event_active (&req->ev, OPAL_EV_WRITE, 1);
} }
void orte_notifier_base_report(int sd, short args, void *cbdata)
{
orte_notifier_request_t *req = (orte_notifier_request_t*)cbdata;
char **modules = NULL;
char *notifies = NULL;
orte_notifier_active_module_t *imod;
int i;
/* if no modules are active, then there is nothing to do */
if (0 == opal_list_get_size(&orte_notifier_base.modules)) {
return;
}
/* see if the job requested any notifications */
if (!orte_get_attribute(&req->jdata->attributes, ORTE_JOB_NOTIFICATIONS, (void**)notifies, OPAL_STRING)) {
return;
}
/* need to process the notification string to get the names of the modules */
return;
OPAL_LIST_FOREACH(imod, &orte_notifier_base.modules, orte_notifier_active_module_t) {
if (NULL != imod->module->report &&
0 == strcmp(imod->component->base_version.mca_component_name, modules[i]))
imod->module->report(req);
}
}
const char* orte_notifier_base_sev2str(orte_notifier_severity_t severity) const char* orte_notifier_base_sev2str(orte_notifier_severity_t severity)
{ {

Просмотреть файл

@ -51,13 +51,10 @@
*/ */
opal_list_t orte_notifier_base_components_available; opal_list_t orte_notifier_base_components_available;
orte_notifier_base_API_module_t orte_notifier = {
orte_notifier_base_log
};
orte_notifier_base_t orte_notifier_base; orte_notifier_base_t orte_notifier_base;
static char *notifier_severity = NULL; static char *notifier_severity = NULL;
static bool use_progress_thread = false;
/** /**
* Function for selecting a set of components from all those that are * Function for selecting a set of components from all those that are
@ -70,6 +67,13 @@ static char *notifier_severity = NULL;
*/ */
static int orte_notifier_base_register(mca_base_register_flag_t flags) static int orte_notifier_base_register(mca_base_register_flag_t flags)
{ {
(void) mca_base_var_register("orte", "notifier", "base", "use_progress_thread",
"Use a dedicated progress thread for notifications [default: false]",
MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0,
OPAL_INFO_LVL_9,
MCA_BASE_VAR_SCOPE_READONLY,
&use_progress_thread);
/* let the user define a base level of severity to report */ /* let the user define a base level of severity to report */
(void) mca_base_var_register("orte", "notifier", "base", "severity_level", (void) mca_base_var_register("orte", "notifier", "base", "severity_level",
"Report all events at or above this severity [default: error]", "Report all events at or above this severity [default: error]",
@ -187,25 +191,19 @@ static int orte_notifier_base_register(mca_base_register_flag_t flags)
static int orte_notifier_base_close(void) static int orte_notifier_base_close(void)
{ {
orte_notifier_active_module_t *i_module; orte_notifier_active_module_t *i_module;
int i;
for (i = 0; i < orte_notifier_base.modules.size; i++) {
if (NULL == (i_module = (orte_notifier_active_module_t*)
opal_pointer_array_get_item(&orte_notifier_base.modules,
i))) {
continue;
}
if (NULL != i_module->module->finalize) {
i_module->module->finalize();
}
}
OBJ_DESTRUCT(&orte_notifier_base.modules);
if (orte_notifier_base.ev_base_active) { if (orte_notifier_base.ev_base_active) {
orte_notifier_base.ev_base_active = false; orte_notifier_base.ev_base_active = false;
opal_stop_progress_thread("notifier", true); opal_stop_progress_thread("notifier", true);
} }
OPAL_LIST_FOREACH(i_module, &orte_notifier_base.modules, orte_notifier_active_module_t) {
if (NULL != i_module->module->finalize) {
i_module->module->finalize();
}
}
OPAL_LIST_DESTRUCT(&orte_notifier_base.modules);
/* close all remaining available components */ /* close all remaining available components */
return mca_base_framework_components_close(&orte_notifier_base_framework, NULL); return mca_base_framework_components_close(&orte_notifier_base_framework, NULL);
} }
@ -217,15 +215,18 @@ static int orte_notifier_base_close(void)
static int orte_notifier_base_open(mca_base_open_flag_t flags) static int orte_notifier_base_open(mca_base_open_flag_t flags)
{ {
/* construct the array of modules */ /* construct the array of modules */
OBJ_CONSTRUCT(&orte_notifier_base.modules, opal_pointer_array_t); OBJ_CONSTRUCT(&orte_notifier_base.modules, opal_list_t);
opal_pointer_array_init (&orte_notifier_base.modules, 3, INT_MAX, 1);
/* create our own event base */ /* if requested, create our own event base */
orte_notifier_base.ev_base_active = true; if (use_progress_thread) {
if (NULL == (orte_notifier_base.ev_base = orte_notifier_base.ev_base_active = true;
opal_start_progress_thread("notifier", true))) { if (NULL == (orte_notifier_base.ev_base =
orte_notifier_base.ev_base_active = false; opal_start_progress_thread("notifier", true))) {
return ORTE_ERROR; orte_notifier_base.ev_base_active = false;
return ORTE_ERROR;
}
} else {
orte_notifier_base.ev_base = orte_event_base;
} }
/* Open up all available components */ /* Open up all available components */
@ -239,16 +240,22 @@ MCA_BASE_FRAMEWORK_DECLARE(orte, notifier, "ORTE Notifier Framework",
mca_notifier_base_static_components, 0); mca_notifier_base_static_components, 0);
static void cons (orte_notifier_active_module_t *t)
{
}
OBJ_CLASS_INSTANCE (orte_notifier_active_module_t, OBJ_CLASS_INSTANCE (orte_notifier_active_module_t,
opal_object_t, opal_list_item_t,
cons, NULL); NULL, NULL);
static void req_cons (orte_notifier_request_t *t) static void req_cons (orte_notifier_request_t *r)
{ {
r->jdata = NULL;
r->msg = NULL;
r->t = 0;
}
static void req_des(orte_notifier_request_t *r)
{
if (NULL != r->jdata) {
OBJ_RELEASE(r->jdata);
}
} }
OBJ_CLASS_INSTANCE (orte_notifier_request_t, OBJ_CLASS_INSTANCE (orte_notifier_request_t,
opal_object_t, opal_object_t,
req_cons, NULL); req_cons, req_des);

Просмотреть файл

@ -54,28 +54,22 @@ int orte_notifier_base_select(void)
mca_base_component_list_item_t *cli = NULL; mca_base_component_list_item_t *cli = NULL;
orte_notifier_base_component_t *component = NULL; orte_notifier_base_component_t *component = NULL;
mca_base_module_t *module = NULL; mca_base_module_t *module = NULL;
orte_notifier_active_module_t *i_module; int priority;
int priority = 0, i, j, low_i; orte_notifier_active_module_t *tmp_module;
opal_pointer_array_t tmp_array; orte_notifier_base_module_t *bmod;
bool none_found;
orte_notifier_active_module_t *tmp_module = NULL, *tmp_module_sw = NULL;
if (orte_notifier_base_selected) { if (orte_notifier_base_selected) {
return ORTE_SUCCESS; return ORTE_SUCCESS;
} }
orte_notifier_base_selected = true; orte_notifier_base_selected = true;
OBJ_CONSTRUCT(&tmp_array, opal_pointer_array_t);
opal_output_verbose(10, orte_notifier_base_framework.framework_output, opal_output_verbose(10, orte_notifier_base_framework.framework_output,
"notifier:base:select: Auto-selecting components"); "notifier:base:select: Auto-selecting components");
/* /*
* Traverse the list of available components. * Traverse the list of available components.
* For each call their 'query' functions to determine relative priority. * For each call their 'query' functions to see if they are available.
*/ */
none_found = true;
OPAL_LIST_FOREACH(cli, &orte_notifier_base_framework.framework_components, mca_base_component_list_item_t) { OPAL_LIST_FOREACH(cli, &orte_notifier_base_framework.framework_components, mca_base_component_list_item_t) {
component = (orte_notifier_base_component_t *) cli->cli_component; component = (orte_notifier_base_component_t *) cli->cli_component;
@ -107,89 +101,28 @@ int orte_notifier_base_select(void)
component->base_version.mca_component_name ); component->base_version.mca_component_name );
continue; continue;
} }
bmod = (orte_notifier_base_module_t*)module;
/* see if it can be init'd */
if (NULL != bmod->init) {
opal_output_verbose(5, orte_notifier_base_framework.framework_output,
"notifier:base:init module called with priority [%s] %d",
component->base_version.mca_component_name, priority);
if (ORTE_SUCCESS != bmod->init()) {
continue;
}
}
/* /*
* Append them to the temporary list, we will sort later * Append them to the list
*/ */
opal_output_verbose(5, orte_notifier_base_framework.framework_output, opal_output_verbose(5, orte_notifier_base_framework.framework_output,
"notifier:base:select Query of component [%s] set priority to %d", "notifier:base:select adding component [%s]",
component->base_version.mca_component_name, priority); component->base_version.mca_component_name);
tmp_module = OBJ_NEW(orte_notifier_active_module_t); tmp_module = OBJ_NEW(orte_notifier_active_module_t);
tmp_module->component = component; tmp_module->component = component;
tmp_module->module = (orte_notifier_base_module_t*)module; tmp_module->module = (orte_notifier_base_module_t*)module;
tmp_module->priority = priority;
opal_pointer_array_add(&tmp_array, (void*)tmp_module); opal_list_append(&orte_notifier_base.modules, (void*)tmp_module);
none_found = false;
}
if (none_found) {
/* okay for no modules to be found */
return ORTE_SUCCESS;
}
/*
* Sort the list by decending priority
*/
priority = 0;
for(j = 0; j < tmp_array.size; ++j) {
tmp_module_sw = (orte_notifier_active_module_t*)opal_pointer_array_get_item(&tmp_array, j);
if( NULL == tmp_module_sw ) {
continue;
}
low_i = -1;
priority = tmp_module_sw->priority;
for(i = 0; i < tmp_array.size; ++i) {
tmp_module = (orte_notifier_active_module_t*)opal_pointer_array_get_item(&tmp_array, i);
if( NULL == tmp_module ) {
continue;
}
if( tmp_module->priority > priority ) {
low_i = i;
priority = tmp_module->priority;
}
}
if( low_i >= 0 ) {
tmp_module = (orte_notifier_active_module_t*)opal_pointer_array_get_item(&tmp_array, low_i);
if ( NULL == tmp_module ) {
continue;
}
opal_pointer_array_set_item(&tmp_array, low_i, NULL);
j--; /* Try this entry again, if it is not the lowest */
} else {
tmp_module = tmp_module_sw;
opal_pointer_array_set_item(&tmp_array, j, NULL);
}
if ( tmp_module ) {
opal_output_verbose(5, orte_notifier_base_framework.framework_output,
"notifier:base:select Add module with priority [%s] %d",
tmp_module->component->base_version.mca_component_name, tmp_module->priority);
opal_pointer_array_add(&orte_notifier_base.modules, tmp_module);
}
}
OBJ_DESTRUCT(&tmp_array);
/*
* Initialize each of the modules in priority order from
* highest to lowest
*/
for(i = 0; i < orte_notifier_base.modules.size; ++i) {
i_module = (orte_notifier_active_module_t*)opal_pointer_array_get_item(&orte_notifier_base.modules, i);
if( NULL == i_module ) {
continue;
}
if( NULL != i_module->module->init ) {
opal_output_verbose(5, orte_notifier_base_framework.framework_output,
"notifier:base:init module called with priority [%s] %d",
i_module->component->base_version.mca_component_name, i_module->priority);
if (ORTE_SUCCESS != i_module->module->init()) {
opal_pointer_array_set_item(&orte_notifier_base.modules, i, NULL);
OBJ_RELEASE(i_module);
}
}
} }
return ORTE_SUCCESS; return ORTE_SUCCESS;

Просмотреть файл

@ -12,7 +12,7 @@
* Copyright (c) 2009 Cisco Systems, Inc. All Rights Reserved. * Copyright (c) 2009 Cisco Systems, Inc. All Rights Reserved.
* Copyright (c) 2012 Los Alamos National Security, LLC. * Copyright (c) 2012 Los Alamos National Security, LLC.
* All rights reserved. * All rights reserved.
* Copyright (c) 2014 Intel, Inc. All rights reserved. * Copyright (c) 2014-2015 Intel, Inc. All rights reserved.
* $COPYRIGHT$ * $COPYRIGHT$
* *
* Additional copyrights may follow * Additional copyrights may follow
@ -53,6 +53,7 @@
#include "orte/constants.h" #include "orte/constants.h"
#include "orte/types.h" #include "orte/types.h"
#include "orte/runtime/orte_globals.h"
BEGIN_C_DECLS BEGIN_C_DECLS
@ -75,6 +76,18 @@ typedef enum {
ORTE_NOTIFIER_DEBUG = LOG_DEBUG ORTE_NOTIFIER_DEBUG = LOG_DEBUG
} orte_notifier_severity_t; } orte_notifier_severity_t;
typedef struct {
opal_object_t super;
opal_event_t ev;
orte_job_t *jdata;
orte_job_state_t state;
orte_notifier_severity_t severity;
int errcode;
const char *msg;
time_t t;
} orte_notifier_request_t;
OBJ_CLASS_DECLARATION(orte_notifier_request_t);
/* /*
* Component functions - all MUST be provided! * Component functions - all MUST be provided!
*/ */
@ -85,49 +98,73 @@ typedef int (*orte_notifier_base_module_init_fn_t)(void);
/* finalize the selected module */ /* finalize the selected module */
typedef void (*orte_notifier_base_module_finalize_fn_t)(void); typedef void (*orte_notifier_base_module_finalize_fn_t)(void);
/* Log a failure message */ /* Log an error */
typedef void (*orte_notifier_base_module_log_fn_t)(orte_notifier_severity_t severity, int errcode, const char *msg, va_list *ap) typedef void (*orte_notifier_base_module_log_fn_t)(orte_notifier_request_t *req);
__opal_attribute_format_funcptr__(__printf__, 3, 0);
/* Report a state */
typedef void (*orte_notifier_base_module_report_fn_t)(orte_notifier_request_t *req);
#define ORTE_NOTIFIER_LOG_ERROR(j, st, s, e, m) \
do { \
orte_notifier_request_t *_n; \
opal_output_verbose(2, orte_notifier_base_framework.framework_output, \
"%s notifier:log:error[%s:%d] for job %s error %s severity %s", \
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), __FILE__, __LINE__, \
ORTE_JOBID_PRINT((j)->jobid), ORTE_ERROR_NAME((e)), \
orte_notifier_base_sev2str(s)); \
_n = OBJ_NEW(orte_notifier_request_t); \
_n->jdata = (j); \
_n->state = (st); \
_n->severity = (s); \
_n->errcode = (e); \
_n->msg = (m); \
_n->t = time(NULL); \
/* add the event */ \
opal_event_set(orte_notifier_base.ev_base, &(_n)->ev, -1, \
OPAL_EV_WRITE, orte_notifier_base_log, (_n)); \
opal_event_set_priority(&(_n)->ev, ORTE_ERROR_PRI); \
opal_event_active(&(_n)->ev, OPAL_EV_WRITE, 1); \
} while(0);
#define ORTE_NOTIFIER_REPORT_STATE(j, st, m) \
do { \
orte_notifier_request_t *_n; \
opal_output_verbose(2, orte_notifier_base_framework.framework_output, \
"%s notifier:report:event[%s:%d] for job %s state %s", \
ORTE_NAME_PRINT(ORTE_PROC_MY_NAME), __FILE__, __LINE__, \
ORTE_JOBID_PRINT((j)->jobid), \
orte_job_state_to_str(st)); \
_n = OBJ_NEW(orte_notifier_request_t); \
_n->jdata = (j); \
_n->msg = (m); \
_n->t = time(NULL); \
/* add the event */ \
opal_event_set(orte_notifier_base.ev_base, &(_n)->ev, -1, \
OPAL_EV_WRITE, orte_notifier_base_report, (_n)); \
opal_event_set_priority(&(_n)->ev, ORTE_ERROR_PRI); \
opal_event_active(&(_n)->ev, OPAL_EV_WRITE, 1); \
} while(0);
/* /*
* Ver 1.0 * Ver 1.0
*/ */
struct orte_notifier_base_module_1_0_0_t { typedef struct {
orte_notifier_base_module_init_fn_t init; orte_notifier_base_module_init_fn_t init;
orte_notifier_base_module_finalize_fn_t finalize; orte_notifier_base_module_finalize_fn_t finalize;
orte_notifier_base_module_log_fn_t log; orte_notifier_base_module_log_fn_t log;
}; orte_notifier_base_module_report_fn_t report;
} orte_notifier_base_module_t;
typedef struct orte_notifier_base_module_1_0_0_t orte_notifier_base_module_1_0_0_t;
typedef orte_notifier_base_module_1_0_0_t orte_notifier_base_module_t;
/*
* API functions
*/
/* Log a failure message */
typedef void (*orte_notifier_base_API_log_fn_t)(orte_notifier_severity_t severity, int errcode, const char *msg, ...);
/*
* Define a struct to hold the API functions that users will call
*/
struct orte_notifier_base_API_module_1_0_0_t {
orte_notifier_base_API_log_fn_t log;
};
typedef struct orte_notifier_base_API_module_1_0_0_t orte_notifier_base_API_module_1_0_0_t;
typedef orte_notifier_base_API_module_1_0_0_t orte_notifier_base_API_module_t;
ORTE_DECLSPEC extern orte_notifier_base_API_module_t orte_notifier;
/* /*
* the standard component data structure * the standard component data structure
*/ */
struct orte_notifier_base_component_1_0_0_t { typedef struct {
mca_base_component_t base_version; mca_base_component_t base_version;
mca_base_component_data_t base_data; mca_base_component_data_t base_data;
}; } orte_notifier_base_component_t;
typedef struct orte_notifier_base_component_1_0_0_t orte_notifier_base_component_1_0_0_t;
typedef orte_notifier_base_component_1_0_0_t orte_notifier_base_component_t;
/* /*

Просмотреть файл

@ -10,7 +10,7 @@
* Copyright (c) 2004-2005 The Regents of the University of California. * Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved. * All rights reserved.
* Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved. * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
* Copyright (c) 2014 Intel, Inc. All rights reserved. * Copyright (c) 2014-2015 Intel, Inc. All rights reserved.
* $COPYRIGHT$ * $COPYRIGHT$
* *
* Additional copyrights may follow * Additional copyrights may follow
@ -44,14 +44,15 @@
/* Static API's */ /* Static API's */
static int init(void); static int init(void);
static void finalize(void); static void finalize(void);
static void mylog(orte_notifier_severity_t severity, int errcode, static void mylog(orte_notifier_request_t *req);
const char *msg, va_list *ap); static void myreport(orte_notifier_request_t *req);
/* Module def */ /* Module def */
orte_notifier_base_module_t orte_notifier_syslog_module = { orte_notifier_base_module_t orte_notifier_syslog_module = {
init, init,
finalize, finalize,
mylog, mylog,
myreport
}; };
@ -60,7 +61,7 @@ static int init(void)
int opts; int opts;
opts = LOG_CONS | LOG_PID; opts = LOG_CONS | LOG_PID;
openlog("Open MPI Error Report:", opts, LOG_USER); openlog("OpenRTE Error Report:", opts, LOG_USER);
return ORTE_SUCCESS; return ORTE_SUCCESS;
} }
@ -70,19 +71,26 @@ static void finalize(void)
closelog(); closelog();
} }
static void mylog(orte_notifier_severity_t severity, int errcode, static void mylog(orte_notifier_request_t *req)
const char *msg, va_list *ap)
{ {
char tod[48];
opal_output_verbose(5, orte_notifier_base_framework.framework_output, opal_output_verbose(5, orte_notifier_base_framework.framework_output,
"notifier:syslog:mylog function called with severity %d errcode %d and messg %s", "notifier:syslog:mylog function called with severity %d errcode %d and messg %s",
(int) severity, errcode, msg); (int)req->severity, req->errcode, req->msg);
/* If there was a message, output it */ /* If there was a message, output it */
#if defined(HAVE_VSYSLOG) (void)ctime_r(&req->t, tod);
vsyslog(severity, msg, *ap); /* trim the newline */
#else tod[strlen(tod)] = '\0';
char *output;
vasprintf(&output, msg, *ap); syslog(req->severity, "[%s]%s JOBID %s REPORTS ERROR %s: %s", tod,
syslog(severity, output, NULL); ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
free(output); ORTE_JOBID_PRINT(req->jdata->jobid),
#endif orte_job_state_to_str(req->state),
(NULL == req->msg) ? "<N/A>" : req->msg);
} }
static void myreport(orte_notifier_request_t *req)
{
}

Просмотреть файл

@ -249,6 +249,12 @@ const char *orte_attr_key_to_str(orte_attribute_key_t key)
return "JOB-PHYSICAL-CPUIDS"; return "JOB-PHYSICAL-CPUIDS";
case ORTE_JOB_LAUNCHED_DAEMONS: case ORTE_JOB_LAUNCHED_DAEMONS:
return "JOB-LAUNCHED-DAEMONS"; return "JOB-LAUNCHED-DAEMONS";
case ORTE_JOB_REPORT_BINDINGS:
return "JOB-REPORT-BINDINGS";
case ORTE_JOB_SLOT_LIST:
return "JOB-SLOT-LIST";
case ORTE_JOB_NOTIFICATIONS:
return "JOB-NOTIFICATIONS";
case ORTE_PROC_NOBARRIER: case ORTE_PROC_NOBARRIER:
return "PROC-NOBARRIER"; return "PROC-NOBARRIER";

Просмотреть файл

@ -126,6 +126,7 @@ typedef uint16_t orte_job_flags_t;
#define ORTE_JOB_LAUNCHED_DAEMONS (ORTE_JOB_START_KEY + 35) // bool - Job caused new daemons to be spawned #define ORTE_JOB_LAUNCHED_DAEMONS (ORTE_JOB_START_KEY + 35) // bool - Job caused new daemons to be spawned
#define ORTE_JOB_REPORT_BINDINGS (ORTE_JOB_START_KEY + 36) // bool - Report process bindings #define ORTE_JOB_REPORT_BINDINGS (ORTE_JOB_START_KEY + 36) // bool - Report process bindings
#define ORTE_JOB_SLOT_LIST (ORTE_JOB_START_KEY + 37) // string - constraints on cores to use #define ORTE_JOB_SLOT_LIST (ORTE_JOB_START_KEY + 37) // string - constraints on cores to use
#define ORTE_JOB_NOTIFICATIONS (ORTE_JOB_START_KEY + 38) // string - comma-separated list of desired notifications+methods
#define ORTE_JOB_MAX_KEY 300 #define ORTE_JOB_MAX_KEY 300