root/orte/mca/sstore/central/sstore_central_module.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. orte_sstore_central_component_query
  2. orte_sstore_central_module_init
  3. orte_sstore_central_module_finalize
  4. orte_sstore_central_request_checkpoint_handle
  5. orte_sstore_central_request_restart_handle
  6. orte_sstore_central_request_global_snapshot_data
  7. orte_sstore_central_register
  8. orte_sstore_central_get_attr
  9. orte_sstore_central_set_attr
  10. orte_sstore_central_sync
  11. orte_sstore_central_remove
  12. orte_sstore_central_pack
  13. orte_sstore_central_unpack
  14. orte_sstore_central_fetch_app_deps
  15. orte_sstore_central_wait_all_deps

   1 /*
   2  * Copyright (c)      2010 The Trustees of Indiana University.
   3  *                         All rights reserved.
   4  * $COPYRIGHT$
   5  *
   6  * Additional copyrights may follow
   7  *
   8  * $HEADER$
   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  /* HAVE_UNISTD_H */
  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/rml/rml_types.h"
  47 #include "orte/mca/snapc/snapc.h"
  48 
  49 #include "orte/mca/sstore/sstore.h"
  50 #include "orte/mca/sstore/base/base.h"
  51 
  52 #include "sstore_central.h"
  53 
  54 /**********
  55  * Local Function and Variable Declarations
  56  **********/
  57 
  58 /*
  59  * central module
  60  */
  61 static orte_sstore_base_module_t loc_module = {
  62     /** Initialization Function */
  63     orte_sstore_central_module_init,
  64     /** Finalization Function */
  65     orte_sstore_central_module_finalize,
  66 
  67     orte_sstore_central_request_checkpoint_handle,
  68     orte_sstore_central_request_restart_handle,
  69     orte_sstore_central_request_global_snapshot_data,
  70     orte_sstore_central_register,
  71     orte_sstore_central_get_attr,
  72     orte_sstore_central_set_attr,
  73     orte_sstore_central_sync,
  74     orte_sstore_central_remove,
  75 
  76     orte_sstore_central_pack,
  77     orte_sstore_central_unpack,
  78     orte_sstore_central_fetch_app_deps,
  79     orte_sstore_central_wait_all_deps
  80 };
  81 
  82 /*
  83  * MCA Functions
  84  */
  85 int orte_sstore_central_component_query(mca_base_module_t **module, int *priority)
  86 {
  87     OPAL_OUTPUT_VERBOSE((10, mca_sstore_central_component.super.output_handle,
  88                          "sstore:central: component_query()"));
  89 
  90     *priority = mca_sstore_central_component.super.priority;
  91     *module = (mca_base_module_t *)&loc_module;
  92 
  93     return ORTE_SUCCESS;
  94 }
  95 
  96 int orte_sstore_central_module_init(void)
  97 {
  98     OPAL_OUTPUT_VERBOSE((10, mca_sstore_central_component.super.output_handle,
  99                          "sstore:central: module_init()"));
 100 
 101     if( orte_sstore_context & ORTE_SSTORE_GLOBAL_TYPE ) {
 102         /* Global is also a Local, so it will init the local module internally */
 103         return orte_sstore_central_global_module_init();
 104     }
 105     else if( orte_sstore_context & ORTE_SSTORE_LOCAL_TYPE ) {
 106         return orte_sstore_central_local_module_init();
 107     }
 108     else if( orte_sstore_context & ORTE_SSTORE_APP_TYPE ) {
 109         return orte_sstore_central_app_module_init();
 110     }
 111 
 112     return ORTE_SUCCESS;
 113 }
 114 
 115 int orte_sstore_central_module_finalize(void)
 116 {
 117     OPAL_OUTPUT_VERBOSE((10, mca_sstore_central_component.super.output_handle,
 118                          "sstore:central: module_finalize()"));
 119 
 120     if( orte_sstore_context & ORTE_SSTORE_GLOBAL_TYPE ) {
 121         /* Global is also a Local, so it will fin. the local module internally */
 122         return orte_sstore_central_global_module_finalize();
 123     }
 124     else if( orte_sstore_context & ORTE_SSTORE_LOCAL_TYPE ) {
 125         return orte_sstore_central_local_module_finalize();
 126     }
 127     else if( orte_sstore_context & ORTE_SSTORE_APP_TYPE ) {
 128         return orte_sstore_central_app_module_finalize();
 129     }
 130 
 131     return ORTE_SUCCESS;
 132 }
 133 
 134 /******************
 135  * Local functions
 136  ******************/
 137 int orte_sstore_central_request_checkpoint_handle(orte_sstore_base_handle_t *handle, int seq, orte_jobid_t jobid)
 138 {
 139     if( orte_sstore_context & ORTE_SSTORE_TOOL_TYPE ) {
 140         opal_output(0, "sstore:central:(tool): request_checkpoint_handle() Not supported!");
 141     }
 142     else if( orte_sstore_context & ORTE_SSTORE_GLOBAL_TYPE ) {
 143         return orte_sstore_central_global_request_checkpoint_handle(handle, seq, jobid);
 144     }
 145     else if( orte_sstore_context & ORTE_SSTORE_LOCAL_TYPE ) {
 146         return orte_sstore_central_local_request_checkpoint_handle(handle, seq, jobid);
 147     }
 148     else if( orte_sstore_context & ORTE_SSTORE_APP_TYPE ) {
 149         return orte_sstore_central_app_request_checkpoint_handle(handle, seq, jobid);
 150     }
 151 
 152     return ORTE_ERR_NOT_SUPPORTED;
 153 }
 154 
 155 int orte_sstore_central_request_restart_handle(orte_sstore_base_handle_t *handle, char *basedir, char *ref, int seq,
 156                                                orte_sstore_base_global_snapshot_info_t *snapshot)
 157 {
 158     if( orte_sstore_context & ORTE_SSTORE_TOOL_TYPE ) {
 159         return orte_sstore_base_tool_request_restart_handle(handle, basedir, ref, seq, snapshot);
 160     }
 161     else if( orte_sstore_context & ORTE_SSTORE_GLOBAL_TYPE ) {
 162         return orte_sstore_central_global_request_restart_handle(handle, basedir, ref, seq, snapshot);
 163     }
 164     else if( orte_sstore_context & ORTE_SSTORE_LOCAL_TYPE ) {
 165         opal_output(0, "sstore:central:(local): request_restart_handle() Not supported!");
 166     }
 167     else if( orte_sstore_context & ORTE_SSTORE_APP_TYPE ) {
 168         opal_output(0, "sstore:central:(app): request_restart_handle() Not supported!");
 169     }
 170 
 171     return ORTE_ERR_NOT_SUPPORTED;
 172 }
 173 
 174 int orte_sstore_central_request_global_snapshot_data(orte_sstore_base_handle_t *handle,
 175                                                      orte_sstore_base_global_snapshot_info_t *snapshot)
 176 {
 177     if( orte_sstore_context & ORTE_SSTORE_TOOL_TYPE ) {
 178         opal_output(0, "sstore:central:(tool): request_global_snapshot_data() Not supported!");
 179     }
 180     else if( orte_sstore_context & ORTE_SSTORE_GLOBAL_TYPE ) {
 181         return orte_sstore_central_global_request_global_snapshot_data(handle, snapshot);
 182     }
 183     else if( orte_sstore_context & ORTE_SSTORE_LOCAL_TYPE ) {
 184         opal_output(0, "sstore:central:(local): request_global_snapshot_data() Not supported!");
 185     }
 186     else if( orte_sstore_context & ORTE_SSTORE_APP_TYPE ) {
 187         opal_output(0, "sstore:central:(app): request_global_snapshot_data() Not supported!");
 188     }
 189 
 190     return ORTE_ERR_NOT_SUPPORTED;
 191 }
 192 
 193 int orte_sstore_central_register(orte_sstore_base_handle_t handle)
 194 {
 195     if( ORTE_SSTORE_HANDLE_INVALID == handle ) {
 196         ORTE_ERROR_LOG(ORTE_ERROR);
 197         return ORTE_ERROR;
 198     }
 199 
 200     if( orte_sstore_context & ORTE_SSTORE_GLOBAL_TYPE ) {
 201         return orte_sstore_central_global_register(handle);
 202     }
 203     else if( orte_sstore_context & ORTE_SSTORE_LOCAL_TYPE ) {
 204         return orte_sstore_central_local_register(handle);
 205     }
 206     else if( orte_sstore_context & ORTE_SSTORE_APP_TYPE ) {
 207         return orte_sstore_central_app_register(handle);
 208     }
 209 
 210     return ORTE_ERR_NOT_SUPPORTED;
 211 }
 212 
 213 int orte_sstore_central_get_attr(orte_sstore_base_handle_t handle, orte_sstore_base_key_t key, char **value)
 214 {
 215     if( ORTE_SSTORE_HANDLE_INVALID == handle ) {
 216         ORTE_ERROR_LOG(ORTE_ERROR);
 217         return ORTE_ERROR;
 218     }
 219 
 220     if( orte_sstore_context & ORTE_SSTORE_TOOL_TYPE ) {
 221         return orte_sstore_base_tool_get_attr(handle, key, value);
 222     }
 223     if( orte_sstore_context & ORTE_SSTORE_GLOBAL_TYPE ) {
 224         return orte_sstore_central_global_get_attr(handle, key, value);
 225     }
 226     else if( orte_sstore_context & ORTE_SSTORE_LOCAL_TYPE ) {
 227         return orte_sstore_central_local_get_attr(handle, key, value);
 228     }
 229     else if( orte_sstore_context & ORTE_SSTORE_APP_TYPE ) {
 230         return orte_sstore_central_app_get_attr(handle, key, value);
 231     }
 232 
 233     return ORTE_ERR_NOT_SUPPORTED;
 234 }
 235 
 236 int orte_sstore_central_set_attr(orte_sstore_base_handle_t handle, orte_sstore_base_key_t key, char *value)
 237 {
 238     if( ORTE_SSTORE_HANDLE_INVALID == handle ) {
 239         opal_output(0, "Error: (%6s) Passed an invalid handle (%d) [%d = \"%s\"]",
 240                     (orte_sstore_context & ORTE_SSTORE_GLOBAL_TYPE ? "global" :
 241                      (orte_sstore_context & ORTE_SSTORE_LOCAL_TYPE ? "local"  :
 242                       (orte_sstore_context & ORTE_SSTORE_APP_TYPE  ? "app"    : "other"))),
 243                     (int)handle, key, value);
 244         {
 245             int sleeper = 2;
 246             while(sleeper == 1 ) {
 247                 sleep(1);
 248             }
 249         }
 250         ORTE_ERROR_LOG(ORTE_ERROR);
 251         return ORTE_ERROR;
 252     }
 253 
 254     if( orte_sstore_context & ORTE_SSTORE_GLOBAL_TYPE ) {
 255         return orte_sstore_central_global_set_attr(handle, key, value);
 256     }
 257     else if( orte_sstore_context & ORTE_SSTORE_LOCAL_TYPE ) {
 258         return orte_sstore_central_local_set_attr(handle, key, value);
 259     }
 260     else if( orte_sstore_context & ORTE_SSTORE_APP_TYPE ) {
 261         return orte_sstore_central_app_set_attr(handle, key, value);
 262     }
 263 
 264     return ORTE_ERR_NOT_SUPPORTED;
 265 }
 266 
 267 int orte_sstore_central_sync(orte_sstore_base_handle_t handle)
 268 {
 269     if( ORTE_SSTORE_HANDLE_INVALID == handle ) {
 270         ORTE_ERROR_LOG(ORTE_ERROR);
 271         return ORTE_ERROR;
 272     }
 273 
 274     if( orte_sstore_context & ORTE_SSTORE_GLOBAL_TYPE ) {
 275         return orte_sstore_central_global_sync(handle);
 276     }
 277     else if( orte_sstore_context & ORTE_SSTORE_LOCAL_TYPE ) {
 278         return orte_sstore_central_local_sync(handle);
 279     }
 280     else if( orte_sstore_context & ORTE_SSTORE_APP_TYPE ) {
 281         return orte_sstore_central_app_sync(handle);
 282     }
 283 
 284     return ORTE_ERR_NOT_SUPPORTED;
 285 }
 286 
 287 int orte_sstore_central_remove(orte_sstore_base_handle_t handle)
 288 {
 289     if( ORTE_SSTORE_HANDLE_INVALID == handle ) {
 290         ORTE_ERROR_LOG(ORTE_ERROR);
 291         return ORTE_ERROR;
 292     }
 293 
 294     if( orte_sstore_context & ORTE_SSTORE_GLOBAL_TYPE ) {
 295         return orte_sstore_central_global_remove(handle);
 296     }
 297     else if( orte_sstore_context & ORTE_SSTORE_LOCAL_TYPE ) {
 298         return orte_sstore_central_local_remove(handle);
 299     }
 300     else if( orte_sstore_context & ORTE_SSTORE_APP_TYPE ) {
 301         return orte_sstore_central_app_remove(handle);
 302     }
 303 
 304     return ORTE_ERR_NOT_SUPPORTED;
 305 }
 306 
 307 int orte_sstore_central_pack(orte_process_name_t* peer, opal_buffer_t* buffer, orte_sstore_base_handle_t handle)
 308 {
 309     if( ORTE_SSTORE_HANDLE_INVALID == handle ) {
 310         ORTE_ERROR_LOG(ORTE_ERROR);
 311         return ORTE_ERROR;
 312     }
 313 
 314     if( orte_sstore_context & ORTE_SSTORE_GLOBAL_TYPE ) {
 315         return orte_sstore_central_global_pack(peer, buffer, handle);
 316     }
 317     else if( orte_sstore_context & ORTE_SSTORE_LOCAL_TYPE ) {
 318         return orte_sstore_central_local_pack(peer, buffer, handle);
 319     }
 320     else if( orte_sstore_context & ORTE_SSTORE_APP_TYPE ) {
 321         return orte_sstore_central_app_pack(peer, buffer, handle);
 322     }
 323 
 324     return ORTE_ERR_NOT_SUPPORTED;
 325 }
 326 
 327 int orte_sstore_central_unpack(orte_process_name_t* peer, opal_buffer_t* buffer, orte_sstore_base_handle_t *handle)
 328 {
 329     if( orte_sstore_context & ORTE_SSTORE_GLOBAL_TYPE ) {
 330         return orte_sstore_central_global_unpack(peer, buffer, handle);
 331     }
 332     else if( orte_sstore_context & ORTE_SSTORE_LOCAL_TYPE ) {
 333         return orte_sstore_central_local_unpack(peer, buffer, handle);
 334     }
 335     else if( orte_sstore_context & ORTE_SSTORE_APP_TYPE ) {
 336         return orte_sstore_central_app_unpack(peer, buffer, handle);
 337     }
 338 
 339     return ORTE_ERR_NOT_SUPPORTED;
 340 }
 341 
 342 int orte_sstore_central_fetch_app_deps(orte_app_context_t *app)
 343 {
 344     /* Nothing to do */
 345     return ORTE_SUCCESS;
 346 }
 347 
 348 int orte_sstore_central_wait_all_deps(void)
 349 {
 350     /* Nothing to do */
 351     return ORTE_SUCCESS;
 352 }
 353 
 354 /**************************
 355  * Local functions
 356  **************************/

/* [<][>][^][v][top][bottom][index][help] */