This source file includes following definitions.
- orte_sstore_stage_component_query
- orte_sstore_stage_module_init
- orte_sstore_stage_module_finalize
- orte_sstore_stage_request_checkpoint_handle
- orte_sstore_stage_request_restart_handle
- orte_sstore_stage_request_global_snapshot_data
- orte_sstore_stage_register
- orte_sstore_stage_get_attr
- orte_sstore_stage_set_attr
- orte_sstore_stage_sync
- orte_sstore_stage_remove
- orte_sstore_stage_pack
- orte_sstore_stage_unpack
- orte_sstore_stage_fetch_app_deps
- orte_sstore_stage_wait_all_deps
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 #include "orte_config.h"
16
17 #include <string.h>
18 #include <stdlib.h>
19 #include <sys/types.h>
20 #include <sys/stat.h>
21 #include <sys/wait.h>
22 #ifdef HAVE_UNISTD_H
23 #include <unistd.h>
24 #endif
25
26 #include "orte/mca/mca.h"
27 #include "opal/mca/base/base.h"
28
29 #include "opal/mca/event/event.h"
30
31 #include "orte/constants.h"
32 #include "orte/util/show_help.h"
33 #include "opal/util/argv.h"
34 #include "opal/util/output.h"
35 #include "opal/util/opal_environ.h"
36 #include "opal/util/basename.h"
37
38 #include "opal/threads/mutex.h"
39 #include "opal/threads/condition.h"
40
41 #include "orte/util/name_fns.h"
42 #include "orte/util/proc_info.h"
43 #include "orte/runtime/orte_globals.h"
44 #include "orte/runtime/orte_wait.h"
45 #include "orte/mca/errmgr/errmgr.h"
46 #include "orte/mca/snapc/snapc.h"
47
48 #include "orte/mca/sstore/sstore.h"
49 #include "orte/mca/sstore/base/base.h"
50
51 #include "sstore_stage.h"
52
53
54
55
56
57
58
59
60 static orte_sstore_base_module_t loc_module = {
61
62 orte_sstore_stage_module_init,
63
64 orte_sstore_stage_module_finalize,
65
66 orte_sstore_stage_request_checkpoint_handle,
67 orte_sstore_stage_request_restart_handle,
68 orte_sstore_stage_request_global_snapshot_data,
69 orte_sstore_stage_register,
70 orte_sstore_stage_get_attr,
71 orte_sstore_stage_set_attr,
72 orte_sstore_stage_sync,
73 orte_sstore_stage_remove,
74
75 orte_sstore_stage_pack,
76 orte_sstore_stage_unpack,
77 orte_sstore_stage_fetch_app_deps,
78 orte_sstore_stage_wait_all_deps
79 };
80
81
82
83
84 int orte_sstore_stage_component_query(mca_base_module_t **module, int *priority)
85 {
86 OPAL_OUTPUT_VERBOSE((10, mca_sstore_stage_component.super.output_handle,
87 "sstore:stage: component_query()"));
88
89
90
91
92 if( NULL != orte_sstore_stage_local_snapshot_dir &&
93 0 < strlen(orte_sstore_stage_local_snapshot_dir) ) {
94 *priority = mca_sstore_stage_component.super.priority;
95 *module = (mca_base_module_t *)&loc_module;
96 } else {
97 *priority = -1;
98 *module = NULL;
99 }
100
101 return ORTE_SUCCESS;
102 }
103
104 int orte_sstore_stage_module_init(void)
105 {
106 OPAL_OUTPUT_VERBOSE((10, mca_sstore_stage_component.super.output_handle,
107 "sstore:stage: module_init()"));
108
109 if( orte_sstore_context & ORTE_SSTORE_GLOBAL_TYPE ) {
110 return orte_sstore_stage_global_module_init();
111 }
112 else if( orte_sstore_context & ORTE_SSTORE_LOCAL_TYPE ) {
113 return orte_sstore_stage_local_module_init();
114 }
115 else if( orte_sstore_context & ORTE_SSTORE_APP_TYPE ) {
116 return orte_sstore_stage_app_module_init();
117 }
118
119 return ORTE_SUCCESS;
120 }
121
122 int orte_sstore_stage_module_finalize(void)
123 {
124 OPAL_OUTPUT_VERBOSE((10, mca_sstore_stage_component.super.output_handle,
125 "sstore:stage: module_finalize()"));
126
127 if( orte_sstore_context & ORTE_SSTORE_GLOBAL_TYPE ) {
128 return orte_sstore_stage_global_module_finalize();
129 }
130 else if( orte_sstore_context & ORTE_SSTORE_LOCAL_TYPE ) {
131 return orte_sstore_stage_local_module_finalize();
132 }
133 else if( orte_sstore_context & ORTE_SSTORE_APP_TYPE ) {
134 return orte_sstore_stage_app_module_finalize();
135 }
136
137 return ORTE_SUCCESS;
138 }
139
140
141
142
143 int orte_sstore_stage_request_checkpoint_handle(orte_sstore_base_handle_t *handle, int seq, orte_jobid_t jobid)
144 {
145 if( orte_sstore_context & ORTE_SSTORE_TOOL_TYPE ) {
146 opal_output(0, "sstore:stage:(tool): request_checkpoint_handle() Not supported!");
147 }
148 else if( orte_sstore_context & ORTE_SSTORE_GLOBAL_TYPE ) {
149 return orte_sstore_stage_global_request_checkpoint_handle(handle, seq, jobid);
150 }
151 else if( orte_sstore_context & ORTE_SSTORE_LOCAL_TYPE ) {
152 return orte_sstore_stage_local_request_checkpoint_handle(handle, seq, jobid);
153 }
154 else if( orte_sstore_context & ORTE_SSTORE_APP_TYPE ) {
155 return orte_sstore_stage_app_request_checkpoint_handle(handle, seq, jobid);
156 }
157
158 return ORTE_ERR_NOT_SUPPORTED;
159 }
160
161 int orte_sstore_stage_request_restart_handle(orte_sstore_base_handle_t *handle, char *basedir, char *ref, int seq,
162 orte_sstore_base_global_snapshot_info_t *snapshot)
163 {
164 if( orte_sstore_context & ORTE_SSTORE_TOOL_TYPE ) {
165 return orte_sstore_base_tool_request_restart_handle(handle, basedir, ref, seq, snapshot);
166 }
167 else if( orte_sstore_context & ORTE_SSTORE_GLOBAL_TYPE ) {
168 opal_output(0, "sstore:stage:(global): request_restart_handle() Not supported!");
169 }
170 else if( orte_sstore_context & ORTE_SSTORE_LOCAL_TYPE ) {
171 opal_output(0, "sstore:stage:(local): request_restart_handle() Not supported!");
172 }
173 else if( orte_sstore_context & ORTE_SSTORE_APP_TYPE ) {
174 opal_output(0, "sstore:stage:(app): request_restart_handle() Not supported!");
175 }
176
177 return ORTE_ERR_NOT_SUPPORTED;
178 }
179
180 int orte_sstore_stage_request_global_snapshot_data(orte_sstore_base_handle_t *handle,
181 orte_sstore_base_global_snapshot_info_t *snapshot)
182 {
183 if( orte_sstore_context & ORTE_SSTORE_TOOL_TYPE ) {
184 opal_output(0, "sstore:stage:(tool): request_global_snapshot_data() Not supported!");
185 }
186 else if( orte_sstore_context & ORTE_SSTORE_GLOBAL_TYPE ) {
187 return orte_sstore_stage_global_request_global_snapshot_data(handle, snapshot);
188 }
189 else if( orte_sstore_context & ORTE_SSTORE_LOCAL_TYPE ) {
190 opal_output(0, "sstore:stage:(local): request_global_snapshot_data() Not supported!");
191 }
192 else if( orte_sstore_context & ORTE_SSTORE_APP_TYPE ) {
193 opal_output(0, "sstore:stage:(app): request_global_snapshot_data() Not supported!");
194 }
195
196 return ORTE_ERR_NOT_SUPPORTED;
197 }
198
199 int orte_sstore_stage_register(orte_sstore_base_handle_t handle)
200 {
201 if( ORTE_SSTORE_HANDLE_INVALID == handle ) {
202 ORTE_ERROR_LOG(ORTE_ERROR);
203 return ORTE_ERROR;
204 }
205
206 if( orte_sstore_context & ORTE_SSTORE_GLOBAL_TYPE ) {
207 return orte_sstore_stage_global_register(handle);
208 }
209 else if( orte_sstore_context & ORTE_SSTORE_LOCAL_TYPE ) {
210 return orte_sstore_stage_local_register(handle);
211 }
212 else if( orte_sstore_context & ORTE_SSTORE_APP_TYPE ) {
213 return orte_sstore_stage_app_register(handle);
214 }
215
216 return ORTE_ERR_NOT_SUPPORTED;
217 }
218
219 int orte_sstore_stage_get_attr(orte_sstore_base_handle_t handle, orte_sstore_base_key_t key, char **value)
220 {
221 if( ORTE_SSTORE_HANDLE_INVALID == handle ) {
222 ORTE_ERROR_LOG(ORTE_ERROR);
223 return ORTE_ERROR;
224 }
225
226 if( orte_sstore_context & ORTE_SSTORE_TOOL_TYPE ) {
227 return orte_sstore_base_tool_get_attr(handle, key, value);
228 }
229 if( orte_sstore_context & ORTE_SSTORE_GLOBAL_TYPE ) {
230 return orte_sstore_stage_global_get_attr(handle, key, value);
231 }
232 else if( orte_sstore_context & ORTE_SSTORE_LOCAL_TYPE ) {
233 return orte_sstore_stage_local_get_attr(handle, key, value);
234 }
235 else if( orte_sstore_context & ORTE_SSTORE_APP_TYPE ) {
236 return orte_sstore_stage_app_get_attr(handle, key, value);
237 }
238
239 return ORTE_ERR_NOT_SUPPORTED;
240 }
241
242 int orte_sstore_stage_set_attr(orte_sstore_base_handle_t handle, orte_sstore_base_key_t key, char *value)
243 {
244 if( ORTE_SSTORE_HANDLE_INVALID == handle ) {
245 ORTE_ERROR_LOG(ORTE_ERROR);
246 return ORTE_ERROR;
247 }
248
249 if( orte_sstore_context & ORTE_SSTORE_GLOBAL_TYPE ) {
250 return orte_sstore_stage_global_set_attr(handle, key, value);
251 }
252 else if( orte_sstore_context & ORTE_SSTORE_LOCAL_TYPE ) {
253 return orte_sstore_stage_local_set_attr(handle, key, value);
254 }
255 else if( orte_sstore_context & ORTE_SSTORE_APP_TYPE ) {
256 return orte_sstore_stage_app_set_attr(handle, key, value);
257 }
258
259 return ORTE_ERR_NOT_SUPPORTED;
260 }
261
262 int orte_sstore_stage_sync(orte_sstore_base_handle_t handle)
263 {
264 if( ORTE_SSTORE_HANDLE_INVALID == handle ) {
265 ORTE_ERROR_LOG(ORTE_ERROR);
266 return ORTE_ERROR;
267 }
268
269 if( orte_sstore_context & ORTE_SSTORE_GLOBAL_TYPE ) {
270 return orte_sstore_stage_global_sync(handle);
271 }
272 else if( orte_sstore_context & ORTE_SSTORE_LOCAL_TYPE ) {
273 return orte_sstore_stage_local_sync(handle);
274 }
275 else if( orte_sstore_context & ORTE_SSTORE_APP_TYPE ) {
276 return orte_sstore_stage_app_sync(handle);
277 }
278
279 return ORTE_ERR_NOT_SUPPORTED;
280 }
281
282 int orte_sstore_stage_remove(orte_sstore_base_handle_t handle)
283 {
284 if( ORTE_SSTORE_HANDLE_INVALID == handle ) {
285 ORTE_ERROR_LOG(ORTE_ERROR);
286 return ORTE_ERROR;
287 }
288
289 if( orte_sstore_context & ORTE_SSTORE_GLOBAL_TYPE ) {
290 return orte_sstore_stage_global_remove(handle);
291 }
292 else if( orte_sstore_context & ORTE_SSTORE_LOCAL_TYPE ) {
293 return orte_sstore_stage_local_remove(handle);
294 }
295 else if( orte_sstore_context & ORTE_SSTORE_APP_TYPE ) {
296 return orte_sstore_stage_app_remove(handle);
297 }
298
299 return ORTE_ERR_NOT_SUPPORTED;
300 }
301
302 int orte_sstore_stage_pack(orte_process_name_t* peer, opal_buffer_t* buffer, orte_sstore_base_handle_t handle)
303 {
304 if( ORTE_SSTORE_HANDLE_INVALID == handle ) {
305 ORTE_ERROR_LOG(ORTE_ERROR);
306 return ORTE_ERROR;
307 }
308
309 if( orte_sstore_context & ORTE_SSTORE_GLOBAL_TYPE ) {
310 return orte_sstore_stage_global_pack(peer, buffer, handle);
311 }
312 else if( orte_sstore_context & ORTE_SSTORE_LOCAL_TYPE ) {
313 return orte_sstore_stage_local_pack(peer, buffer, handle);
314 }
315 else if( orte_sstore_context & ORTE_SSTORE_APP_TYPE ) {
316 return orte_sstore_stage_app_pack(peer, buffer, handle);
317 }
318
319 return ORTE_ERR_NOT_SUPPORTED;
320 }
321
322 int orte_sstore_stage_unpack(orte_process_name_t* peer, opal_buffer_t* buffer, orte_sstore_base_handle_t *handle)
323 {
324 if( orte_sstore_context & ORTE_SSTORE_GLOBAL_TYPE ) {
325 return orte_sstore_stage_global_unpack(peer, buffer, handle);
326 }
327 else if( orte_sstore_context & ORTE_SSTORE_LOCAL_TYPE ) {
328 return orte_sstore_stage_local_unpack(peer, buffer, handle);
329 }
330 else if( orte_sstore_context & ORTE_SSTORE_APP_TYPE ) {
331 return orte_sstore_stage_app_unpack(peer, buffer, handle);
332 }
333
334 return ORTE_ERR_NOT_SUPPORTED;
335 }
336
337 int orte_sstore_stage_fetch_app_deps(orte_app_context_t *app)
338 {
339 if( orte_sstore_context & ORTE_SSTORE_GLOBAL_TYPE ) {
340 opal_output(0, "sstore:stage:(Global): fetch_app_deps() Not supported!");
341 }
342 else if( orte_sstore_context & ORTE_SSTORE_LOCAL_TYPE ) {
343 return orte_sstore_stage_local_fetch_app_deps(app);
344 }
345 else if( orte_sstore_context & ORTE_SSTORE_APP_TYPE ) {
346 opal_output(0, "sstore:stage:(App): fetch_app_deps() Not supported!");
347 }
348
349 return ORTE_ERR_NOT_SUPPORTED;
350 }
351
352 int orte_sstore_stage_wait_all_deps(void)
353 {
354 if( orte_sstore_context & ORTE_SSTORE_GLOBAL_TYPE ) {
355 opal_output(0, "sstore:stage:(Global): wait_all_deps() Not supported!");
356 }
357 else if( orte_sstore_context & ORTE_SSTORE_LOCAL_TYPE ) {
358 return orte_sstore_stage_local_wait_all_deps();
359 }
360 else if( orte_sstore_context & ORTE_SSTORE_APP_TYPE ) {
361 opal_output(0, "sstore:stage:(App): wait_all_deps() Not supported!");
362 }
363
364 return ORTE_ERR_NOT_SUPPORTED;
365 }
366
367
368
369