File: notifier_ftb_component.c

package info (click to toggle)
openmpi 1.6.5-9.1%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 91,628 kB
  • ctags: 44,305
  • sloc: ansic: 408,966; cpp: 44,454; sh: 27,828; makefile: 10,486; asm: 3,882; python: 1,239; lex: 805; perl: 549; csh: 253; fortran: 232; f90: 126; tcl: 12
file content (156 lines) | stat: -rw-r--r-- 5,206 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/* -*- C -*-
*
* Copyright (c) 2004-2011 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$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/** @file:
*
* This component proxies notification events to the Fault Tolerant
* Backplane (See http://www.mcs.anl.gov/research/cifts/).
* The ORTE notifier severity is translated to the corresponding
* FTB severity before the event is published to the FTB.  
*/

/*
 * includes
 */
#include "orte_config.h"
#include "orte/constants.h"

#include <string.h>

#include "orte/util/show_help.h"
#include "orte/runtime/orte_globals.h"
#include "opal/mca/base/mca_base_param.h"
#include "notifier_ftb.h"

static int orte_notifier_ftb_close(void);
static int orte_notifier_ftb_component_query(mca_base_module_t **module, int *priority);
static int orte_notifier_ftb_register(void);

/*
 * Struct of function pointers that need to be initialized
 */
orte_notifier_ftb_component_t mca_notifier_ftb_component = {
    {
        {
            ORTE_NOTIFIER_BASE_VERSION_1_0_0,

            "ftb", /* 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_ftb_close, /* module close */
            orte_notifier_ftb_component_query, /* module query */
            orte_notifier_ftb_register, /* module register */
        },
        {
            /* The component is checkpoint ready */
            MCA_BASE_METADATA_PARAM_CHECKPOINT
        }
    },

    /* FTB client subscription style */
    "FTB_SUBSCRIPTION_NONE",

    /* Priority */
    10,
};

static int orte_notifier_ftb_close(void)
{

    if (NULL != mca_notifier_ftb_component.subscription_style) {
        free(mca_notifier_ftb_component.subscription_style);
    }

    return ORTE_SUCCESS;
}

static int orte_notifier_ftb_component_query(mca_base_module_t **module, int *priority)
{
    int ret;
    *priority = 0;
    *module = NULL;

    /* Fill the FTB client information structure */
    memset(&ftb_client_info, 0, sizeof(ftb_client_info));
    strcpy(ftb_client_info.event_space, "ftb.mpi.openmpi");

    /* We represent each client with a client name of the form
       openmpi/<hostname>/<PID> as a unique identifier in the
       FTB client namespace */
    sprintf(ftb_client_info.client_name, "ompi%u", orte_process_info.pid);

    sprintf(ftb_client_info.client_jobid, "%u", ORTE_PROC_MY_NAME->jobid);

    strncpy(ftb_client_info.client_subscription_style,
            mca_notifier_ftb_component.subscription_style,
            strlen(mca_notifier_ftb_component.subscription_style));

    /* We try to connect to the FTB backplane now, and we abort
       if we cannot connect for some reason. */
    if (FTB_SUCCESS != (ret = FTB_Connect(&ftb_client_info, &ftb_client_handle))) {
        switch (ret) {
        case FTB_ERR_SUBSCRIPTION_STYLE:
            orte_show_help("help-orte-notifier-ftb.txt",
                           "invalid subscription style",
                           true, ftb_client_info.client_subscription_style);

        case FTB_ERR_INVALID_VALUE:
            orte_show_help("help-orte-notifier-ftb.txt",
                           "invalid value",
                           true);

        default:
            orte_show_help("help-orte-notifier-ftb.txt",
                           "unable to connect",
                           true);
        }
        
        return ORTE_ERR_NOT_FOUND;
    }

    *priority = 10;
    *module = (mca_base_module_t *)&orte_notifier_ftb_module;

    return ORTE_SUCCESS;
}

static int orte_notifier_ftb_register(void)
{

    /* FTB client subscription style */
    mca_base_param_reg_string(&mca_notifier_ftb_component.super.base_version,
                              "subscription_style",
                              "FTB client subscription style. "
                              "Possible values are none, polling, notify and both (polling and notify).",
                              false, false,
                              mca_notifier_ftb_component.subscription_style,
                              &mca_notifier_ftb_component.subscription_style);

    /* Priority */
    mca_base_param_reg_int(&mca_notifier_ftb_component.super.base_version,
                           "priority",
                           "Priority of this component",
                           false, false, 
                           mca_notifier_ftb_component.priority,
                           &mca_notifier_ftb_component.priority);

    return ORTE_SUCCESS;
}