This source file includes following definitions.
- pmix_plog_base_select
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 #include <src/include/pmix_config.h>
21 #include <pmix_common.h>
22
23 #include <string.h>
24
25 #include "src/mca/mca.h"
26 #include "src/mca/base/base.h"
27 #include "src/util/show_help.h"
28
29 #include "src/mca/plog/base/base.h"
30
31 static bool selected = false;
32
33
34
35 int pmix_plog_base_select(void)
36 {
37 pmix_mca_base_component_list_item_t *cli = NULL;
38 pmix_mca_base_component_t *component = NULL;
39 pmix_mca_base_module_t *module = NULL;
40 pmix_plog_module_t *nmodule;
41 pmix_plog_base_active_module_t *newmodule, *mod, *default_mod = NULL;
42 int rc, priority, n;
43 bool inserted, default_added, reqd;
44 pmix_list_t actives;
45 char *ptr;
46 size_t len;
47
48 if (selected) {
49
50 return PMIX_SUCCESS;
51 }
52 selected = true;
53
54 PMIX_CONSTRUCT(&actives, pmix_list_t);
55
56
57 PMIX_LIST_FOREACH(cli, &pmix_plog_base_framework.framework_components, pmix_mca_base_component_list_item_t) {
58 component = (pmix_mca_base_component_t *) cli->cli_component;
59
60 pmix_output_verbose(5, pmix_plog_base_framework.framework_output,
61 "mca:plog:select: checking available component %s", component->pmix_mca_component_name);
62
63
64 if (NULL == component->pmix_mca_query_component) {
65 pmix_output_verbose(5, pmix_plog_base_framework.framework_output,
66 "mca:plog:select: Skipping component [%s]. It does not implement a query function",
67 component->pmix_mca_component_name );
68 continue;
69 }
70
71
72 pmix_output_verbose(5, pmix_plog_base_framework.framework_output,
73 "mca:plog:select: Querying component [%s]",
74 component->pmix_mca_component_name);
75 rc = component->pmix_mca_query_component(&module, &priority);
76
77
78 if (PMIX_SUCCESS != rc || NULL == module) {
79 pmix_output_verbose(5, pmix_plog_base_framework.framework_output,
80 "mca:plog:select: Skipping component [%s]. Query failed to return a module",
81 component->pmix_mca_component_name );
82 continue;
83 }
84
85
86 nmodule = (pmix_plog_module_t*) module;
87
88 if (NULL != nmodule->init && PMIX_SUCCESS != nmodule->init()) {
89 continue;
90 }
91
92 newmodule = PMIX_NEW(pmix_plog_base_active_module_t);
93 newmodule->pri = priority;
94 newmodule->module = nmodule;
95 newmodule->component = (pmix_plog_base_component_t*)cli->cli_component;
96
97
98 inserted = false;
99 PMIX_LIST_FOREACH(mod, &actives, pmix_plog_base_active_module_t) {
100 if (priority > mod->pri) {
101 pmix_list_insert_pos(&actives, (pmix_list_item_t*)mod, &newmodule->super);
102 inserted = true;
103 break;
104 }
105 }
106 if (!inserted) {
107
108 pmix_list_append(&actives, &newmodule->super);
109 }
110
111
112 if (0 == strcmp(newmodule->module->name, "default")) {
113 default_mod = newmodule;
114 }
115 }
116
117
118 if (NULL != pmix_plog_globals.channels) {
119 default_added = false;
120 for (n=0; NULL != pmix_plog_globals.channels[n]; n++) {
121 len = strlen(pmix_plog_globals.channels[n]);
122
123 reqd = false;
124 ptr = strrchr(pmix_plog_globals.channels[n], ':');
125 if (NULL != ptr) {
126
127
128
129 len = len - strlen(ptr);
130
131 ++ptr;
132
133 if (0 == strncasecmp(ptr, "req", 3)) {
134 reqd = true;
135 }
136 }
137
138 inserted = false;
139 PMIX_LIST_FOREACH(mod, &actives, pmix_plog_base_active_module_t) {
140 if (0 == strncasecmp(pmix_plog_globals.channels[n], mod->module->name, len)) {
141 pmix_list_remove_item(&actives, &mod->super);
142 pmix_pointer_array_add(&pmix_plog_globals.actives, mod);
143 mod->reqd = reqd;
144 inserted = true;
145 break;
146 }
147 }
148 if (!inserted) {
149
150
151
152
153 if (!default_added) {
154
155
156
157 if (NULL == default_mod && reqd) {
158 pmix_show_help("help-pmix-plog.txt", "reqd-not-found",
159 true, pmix_plog_globals.channels[n]);
160 PMIX_LIST_DESTRUCT(&actives);
161 return PMIX_ERR_NOT_FOUND;
162 } else if (NULL != default_mod) {
163 pmix_pointer_array_add(&pmix_plog_globals.actives, default_mod);
164 default_added = true;
165 default_mod->reqd = reqd;
166 }
167 } else if (reqd) {
168
169
170
171
172
173 default_mod->reqd = reqd;
174 }
175 }
176 }
177
178 PMIX_LIST_DESTRUCT(&actives);
179 } else {
180
181 while (NULL != (mod = (pmix_plog_base_active_module_t*)pmix_list_remove_first(&actives))) {
182 pmix_pointer_array_add(&pmix_plog_globals.actives, mod);
183 }
184 PMIX_DESTRUCT(&actives);
185 }
186
187 if (4 < pmix_output_get_verbosity(pmix_plog_base_framework.framework_output)) {
188 pmix_output(0, "Final plog order");
189
190 for (n=0; n < pmix_plog_globals.actives.size; n++) {
191 if (NULL != (mod = (pmix_plog_base_active_module_t*)pmix_pointer_array_get_item(&pmix_plog_globals.actives, n))) {
192 pmix_output(0, "\tplog[%d]: %s", n, mod->component->base.pmix_mca_component_name);
193 }
194 }
195 }
196
197
198 return PMIX_SUCCESS;;
199 }