1
1

Add a new "file" component to the notifier framework.

When this component is selected, the notification messages are sent to a file. 
The file can be a plain file or stdout or stderr.

The MCA parameter "notifier_file_name" can be used to specify the suffix of the file the notification messages should be sent to.
The default suffix is "wdc" and the file full name is "output-wdc".

This commit was SVN r23155.
Этот коммит содержится в:
Abhishek Kulkarni 2010-05-17 22:39:52 +00:00
родитель b43288f01e
Коммит 197ec7586d
7 изменённых файлов: 497 добавлений и 0 удалений

44
orte/mca/notifier/file/Makefile.am Обычный файл
Просмотреть файл

@ -0,0 +1,44 @@
#
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
# University Research and Technology
# Corporation. All rights reserved.
# Copyright (c) 2004-2005 The University of Tennessee and The University
# of Tennessee Research Foundation. All rights
# reserved.
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
# University of Stuttgart. All rights reserved.
# Copyright (c) 2004-2005 The Regents of the University of California.
# All rights reserved.
# Copyright (c) 2009 Bull SAS. All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
sources = \
notifier_file.h \
notifier_file_module.c \
notifier_file_component.c
# Make the output library in this directory, and name it either
# mca_<type>_<name>.la (for DSO builds) or libmca_<type>_<name>.la
# (for static builds).
if OMPI_BUILD_notifier_file_DSO
component_noinst =
component_install = mca_notifier_file.la
else
component_noinst = libmca_notifier_file.la
component_install =
endif
mcacomponentdir = $(pkglibdir)
mcacomponent_LTLIBRARIES = $(component_install)
mca_notifier_file_la_SOURCES = $(sources)
mca_notifier_file_la_LDFLAGS = -module -avoid-version
noinst_LTLIBRARIES = $(component_noinst)
libmca_notifier_file_la_SOURCES =$(sources)
libmca_notifier_file_la_LDFLAGS = -module -avoid-version

14
orte/mca/notifier/file/configure.m4 Обычный файл
Просмотреть файл

@ -0,0 +1,14 @@
# -*- shell-script -*-
#
# Copyright (c) 2007 Sandia National Laboratories. All rights reserved.
# Copyright (c) 2009 Bull SAS. All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
# MCA_notifier_file_CONFIG([action-if-found], [action-if-not-found])
# -----------------------------------------------------------
AC_DEFUN([MCA_notifier_file_CONFIG], [$1])

25
orte/mca/notifier/file/configure.params Обычный файл
Просмотреть файл

@ -0,0 +1,25 @@
# -*- shell-script -*-
#
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
# University Research and Technology
# Corporation. All rights reserved.
# Copyright (c) 2004-2005 The University of Tennessee and The University
# of Tennessee Research Foundation. All rights
# reserved.
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
# University of Stuttgart. All rights reserved.
# Copyright (c) 2004-2005 The Regents of the University of California.
# All rights reserved.
# Copyright (c) 2007 Los Alamos National Security, LLC. All rights
# reserved.
# Copyright (c) 2009 Bull SAS. All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
# Specific to this module
PARAM_CONFIG_FILES="Makefile"

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

@ -0,0 +1,15 @@
# -*- text -*-
#
# Copyright (c) 2009 Cisco Systems, Inc. All rights reserved.
# Copyright (c) 2009 Bull SAS. All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
# This is the US/English help file for Open MPI's SMTP notifier support
#
[file name not specified]
Error: the Open MPI file notifier component had no file name specified.
#

51
orte/mca/notifier/file/notifier_file.h Обычный файл
Просмотреть файл

@ -0,0 +1,51 @@
/* -*- C -*-
*
* Copyright (c) 2004-2008 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2006 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2009 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2009 Bull SAS. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*
*/
#ifndef NOTIFIER_FILE_H
#define NOTIFIER_FILE_H
#include "orte_config.h"
#include "orte/mca/notifier/notifier.h"
BEGIN_C_DECLS
typedef struct {
orte_notifier_base_component_t super;
/* File name the traces should be sent to */
char *fname;
/* Priority */
int priority;
} orte_notifier_file_component_t;
/*
* Notifier interfaces
*/
ORTE_MODULE_DECLSPEC extern orte_notifier_file_component_t mca_notifier_file_component;
extern orte_notifier_base_module_t orte_notifier_file_module;
END_C_DECLS
#endif /* NOTIFIER_FILE_H */

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

@ -0,0 +1,115 @@
/* -*- C -*-
*
* Copyright (c) 2004-2008 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2009 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2009 Bull SAS. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/** @file:
*
*/
/*
* includes
*/
#include "orte_config.h"
#include "orte/constants.h"
#ifdef HAVE_STRING_H
#include <string.h>
#endif /* HAVE_STRING_H */
#include "opal/mca/base/mca_base_param.h"
#include "orte/util/show_help.h"
#include "notifier_file.h"
static int orte_notifier_file_register(void);
static int orte_notifier_file_component_query(mca_base_module_t **, int *);
static int orte_notifier_file_close(void);
/*
* Struct of function pointers that need to be initialized
*/
orte_notifier_file_component_t mca_notifier_file_component = {
{
{
ORTE_NOTIFIER_BASE_VERSION_1_0_0,
"file", /* MCA module name */
ORTE_MAJOR_VERSION, /* MCA module major version */
ORTE_MINOR_VERSION, /* MCA module minor version */
ORTE_RELEASE_VERSION, /* MCA module release version */
NULL,
orte_notifier_file_close,
orte_notifier_file_component_query,
orte_notifier_file_register,
},
{
/* The component is checkpoint ready */
MCA_BASE_METADATA_PARAM_CHECKPOINT
}
},
/* Log file name */
"wdc",
/* Priority */
10
};
static int orte_notifier_file_register(void)
{
mca_base_component_t *mcb = &mca_notifier_file_component.super.base_version;
orte_notifier_file_component_t *nfc = &mca_notifier_file_component;
mca_base_param_reg_string(mcb, "name",
"File name the traces should be redirected to",
false, false, nfc->fname, &nfc->fname);
mca_base_param_reg_int(mcb, "priority",
"Priority of the file notifier component",
false, false, nfc->priority, &nfc->priority);
return ORTE_SUCCESS;
}
static int orte_notifier_file_close(void)
{
if (NULL != mca_notifier_file_component.fname) {
free(mca_notifier_file_component.fname);
}
return ORTE_SUCCESS;
}
static int orte_notifier_file_component_query(mca_base_module_t **module,
int *priority)
{
*priority = mca_notifier_file_component.priority;
*module = (mca_base_module_t *)&orte_notifier_file_module;
if (NULL == mca_notifier_file_component.fname ||
!strlen(mca_notifier_file_component.fname)) {
orte_show_help("help-orte-notifier-file.txt",
"file name not specified", true);
return ORTE_ERR_BAD_PARAM;
}
return ORTE_SUCCESS;
}

233
orte/mca/notifier/file/notifier_file_module.c Обычный файл
Просмотреть файл

@ -0,0 +1,233 @@
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
* Copyright (c) 2009 Bull SAS. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "orte_config.h"
#include "orte/constants.h"
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif /* HAVE_UNISTD_H */
#ifdef HAVE_STDIO_H
#include <stdio.h>
#endif /* HAVE_STDIO_H */
#ifdef HAVE_STRING_H
#include <string.h>
#endif /* HAVE_STRING_H */
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif /* HAVE_FCNTL_H */
#include "opal/util/os_path.h"
#include "opal/util/show_help.h"
#include "orte/mca/notifier/base/base.h"
#include "orte/util/proc_info.h"
#include "notifier_file.h"
/* Static API's */
static int init(void);
static void finalize(void);
static int open_file(void);
static void file_log(orte_notifier_base_severity_t severity, int errcode,
const char *msg, va_list ap);
static void file_helplog(orte_notifier_base_severity_t severity, int errcode,
const char *filename, const char *topic, va_list ap);
static void file_peerlog(orte_notifier_base_severity_t severity, int errcode,
orte_process_name_t *peer_proc, const char *msg,
va_list ap);
static void file_eventlog(const char *msg);
/* Module def */
orte_notifier_base_module_t orte_notifier_file_module = {
init,
finalize,
file_log,
file_helplog,
file_peerlog,
file_eventlog
};
static int mylogfd = -1;
static int init(void)
{
orte_notifier_file_component_t *comp = &mca_notifier_file_component;
if (!strcmp(comp->fname, "stdout")) {
mylogfd = fileno(stdout);
} else if (!strcmp(comp->fname, "stderr")) {
mylogfd = fileno(stderr);
}
/* Don't open in the case of a plain file: wait for the 1st write */
return ORTE_SUCCESS;
}
static void finalize(void)
{
if (-1 == mylogfd || fileno(stderr) == mylogfd
|| fileno(stdout) == mylogfd) {
return;
}
close(mylogfd);
}
static int open_file(void)
{
orte_notifier_file_component_t *comp = &mca_notifier_file_component;
char *full_name = NULL;
char *fname = NULL;
int rc = ORTE_SUCCESS;
if (-1 != mylogfd) {
return ORTE_SUCCESS;
}
asprintf(&fname, "output-%s", comp->fname);
if (NULL == fname) {
return ORTE_ERR_OUT_OF_RESOURCE;
}
full_name = opal_os_path(false, orte_process_info.job_session_dir,
fname, NULL);
if (NULL == full_name) {
rc = ORTE_ERR_OUT_OF_RESOURCE;
goto out_err;
}
mylogfd = open(full_name, O_CREAT | O_RDWR | O_APPEND, S_IRWXU);
if (-1 == mylogfd) {
rc = ORTE_ERR_FILE_OPEN_FAILURE;
}
free(full_name);
out_err:
free(fname);
return rc;
}
static void file_log(orte_notifier_base_severity_t severity, int errcode,
const char *msg, va_list ap)
{
char *output;
char *tmp = NULL;
/* Add a newline at the end of the format string */
asprintf(&tmp, "%s\n", msg);
if (NULL == tmp) {
return;
}
vasprintf(&output, tmp, ap);
free(tmp);
if (NULL == output) {
return;
}
/* If not done yet, open the log file */
if (-1 == mylogfd) {
if (ORTE_SUCCESS != open_file()) {
free(output);
return;
}
}
write(mylogfd, output, strlen(output));
fflush(NULL);
free(output);
}
static void file_helplog(orte_notifier_base_severity_t severity, int errcode,
const char *filename, const char *topic, va_list ap)
{
char *output = opal_show_help_vstring(filename, topic, false, ap);
if (NULL == output) {
return;
}
if (-1 == mylogfd) {
if (ORTE_SUCCESS != open_file()) {
free(output);
return;
}
}
write(mylogfd, output, strlen(output));
fflush(NULL);
free(output);
}
static void file_peerlog(orte_notifier_base_severity_t severity, int errcode,
orte_process_name_t *peer_proc, const char *msg,
va_list ap)
{
char *buf;
char *tmp = NULL;
/* Add a newline at the end of the format string */
asprintf(&tmp, "%s\n", msg);
if (NULL == tmp) {
return;
}
buf = orte_notifier_base_peer_log(errcode, peer_proc, tmp, ap);
free(tmp);
if (NULL == buf) {
return;
}
/* If not done yet, open the log file */
if (-1 == mylogfd) {
if (ORTE_SUCCESS != open_file()) {
free(buf);
return;
}
}
write(mylogfd, buf, strlen(buf));
fflush(NULL);
free(buf);
}
static void file_eventlog(const char *msg)
{
char *tmp = NULL;
/* Add a newline at the end of the string */
asprintf(&tmp, "%s\n", msg);
if (NULL == tmp) {
return;
}
/* If not done yet, open the log file */
if (-1 == mylogfd) {
if (ORTE_SUCCESS != open_file()) {
free(tmp);
return;
}
}
write(mylogfd, tmp, strlen(tmp));
fflush(NULL);
free(tmp);
}