root/opal/mca/pmix/pmix4x/pmix/src/mca/gds/ds21/gds_ds21_base.c

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

DEFINITIONS

This source file includes following definitions.
  1. ds21_init
  2. ds21_finalize
  3. ds21_assign_module
  4. ds21_cache_job_info
  5. ds21_register_job_info
  6. ds21_store_job_info
  7. ds21_store
  8. ds21_store_modex
  9. ds21_fetch
  10. ds21_setup_fork
  11. ds21_add_nspace
  12. ds21_del_nspace

   1 /*
   2  * Copyright (c) 2015-2018 Intel, Inc. All rights reserved.
   3  * Copyright (c) 2016-2018 IBM Corporation.  All rights reserved.
   4  * Copyright (c) 2016-2019 Mellanox Technologies, Inc.
   5  *                         All rights reserved.
   6  * Copyright (c) 2018      Research Organization for Information Science
   7  *                         and Technology (RIST).  All rights reserved.
   8  *
   9  * $COPYRIGHT$
  10  *
  11  * Additional copyrights may follow
  12  *
  13  * $HEADER$
  14  */
  15 
  16 #include <src/include/pmix_config.h>
  17 #include <pmix_common.h>
  18 #include "src/include/pmix_globals.h"
  19 #include "src/util/error.h"
  20 #include "src/mca/gds/base/base.h"
  21 #include "src/util/argv.h"
  22 
  23 #include "src/mca/common/dstore/dstore_common.h"
  24 #include "gds_ds21_base.h"
  25 #include "gds_ds21_lock.h"
  26 #include "gds_ds21_file.h"
  27 #include "src/mca/common/dstore/dstore_base.h"
  28 
  29 static pmix_common_dstore_ctx_t *ds21_ctx;
  30 
  31 static pmix_status_t ds21_init(pmix_info_t info[], size_t ninfo)
  32 {
  33     pmix_status_t rc = PMIX_SUCCESS;
  34 
  35     ds21_ctx = pmix_common_dstor_init("ds21", info, ninfo,
  36                                       &pmix_ds21_lock_module,
  37                                       &pmix_ds21_file_module);
  38     if (NULL == ds21_ctx) {
  39         rc = PMIX_ERR_INIT;
  40     }
  41 
  42     return rc;
  43 }
  44 
  45 static void ds21_finalize(void)
  46 {
  47     pmix_common_dstor_finalize(ds21_ctx);
  48 }
  49 
  50 static pmix_status_t ds21_assign_module(pmix_info_t *info, size_t ninfo,
  51                                         int *priority)
  52 {
  53     size_t n, m;
  54     char **options;
  55 
  56     *priority = 20;
  57     if (NULL != info) {
  58         for (n=0; n < ninfo; n++) {
  59             if (0 == strncmp(info[n].key, PMIX_GDS_MODULE, PMIX_MAX_KEYLEN)) {
  60                 options = pmix_argv_split(info[n].value.data.string, ',');
  61                 for (m=0; NULL != options[m]; m++) {
  62                     if (0 == strcmp(options[m], "ds21")) {
  63                         /* they specifically asked for us */
  64                         *priority = 120;
  65                         break;
  66                     }
  67                     if (0 == strcmp(options[m], "dstore")) {
  68                         *priority = 60;
  69                         break;
  70                     }
  71                 }
  72                 pmix_argv_free(options);
  73                 break;
  74             }
  75         }
  76     }
  77 
  78     return PMIX_SUCCESS;
  79 }
  80 
  81 static pmix_status_t ds21_cache_job_info(struct pmix_namespace_t *ns,
  82                                 pmix_info_t info[], size_t ninfo)
  83 {
  84     return PMIX_SUCCESS;
  85 }
  86 
  87 static pmix_status_t ds21_register_job_info(struct pmix_peer_t *pr,
  88                                             pmix_buffer_t *reply)
  89 {
  90     return pmix_common_dstor_register_job_info(ds21_ctx, pr, reply);
  91 }
  92 
  93 static pmix_status_t ds21_store_job_info(const char *nspace,  pmix_buffer_t *buf)
  94 {
  95     return pmix_common_dstor_store_job_info(ds21_ctx, nspace, buf);
  96 }
  97 
  98 static pmix_status_t ds21_store(const pmix_proc_t *proc,
  99                                     pmix_scope_t scope,
 100                                     pmix_kval_t *kv)
 101 {
 102     return pmix_common_dstor_store(ds21_ctx, proc, scope, kv);
 103 }
 104 
 105 /* this function is only called by the PMIx server when its
 106  * host has received data from some other peer. It therefore
 107  * always contains data solely from remote procs, and we
 108  * shall store it accordingly */
 109 static pmix_status_t ds21_store_modex(struct pmix_namespace_t *nspace,
 110                                       pmix_buffer_t *buf,
 111                                       void *cbdata)
 112 {
 113     return pmix_common_dstor_store_modex(ds21_ctx, nspace, buf, cbdata);
 114 }
 115 
 116 static pmix_status_t ds21_fetch(const pmix_proc_t *proc,
 117                                     pmix_scope_t scope, bool copy,
 118                                     const char *key,
 119                                     pmix_info_t info[], size_t ninfo,
 120                                     pmix_list_t *kvs)
 121 {
 122     return pmix_common_dstor_fetch(ds21_ctx, proc, scope, copy, key, info, ninfo, kvs);
 123 }
 124 
 125 static pmix_status_t ds21_setup_fork(const pmix_proc_t *peer, char ***env)
 126 {
 127     pmix_status_t rc;
 128     char *env_name = NULL;
 129     int ds_ver = 0;
 130 
 131     sscanf(ds21_ctx->ds_name, "ds%d", &ds_ver);
 132     if (0 == ds_ver) {
 133         rc = PMIX_ERR_INIT;
 134         PMIX_ERROR_LOG(rc);
 135         return rc;
 136     }
 137     if (0 > asprintf(&env_name, PMIX_DSTORE_VER_BASE_PATH_FMT, ds_ver)) {
 138          rc = PMIX_ERR_NOMEM;
 139          PMIX_ERROR_LOG(rc);
 140          return rc;
 141     }
 142     rc = pmix_common_dstor_setup_fork(ds21_ctx, env_name, peer, env);
 143     free(env_name);
 144 
 145     return rc;
 146 }
 147 
 148 static pmix_status_t ds21_add_nspace(const char *nspace,
 149                                 pmix_info_t info[],
 150                                 size_t ninfo)
 151 {
 152     return pmix_common_dstor_add_nspace(ds21_ctx, nspace, info, ninfo);
 153 }
 154 
 155 static pmix_status_t ds21_del_nspace(const char* nspace)
 156 {
 157     return pmix_common_dstor_del_nspace(ds21_ctx, nspace);
 158 }
 159 
 160 pmix_gds_base_module_t pmix_ds21_module = {
 161     .name = "ds21",
 162     .is_tsafe = true,
 163     .init = ds21_init,
 164     .finalize = ds21_finalize,
 165     .assign_module = ds21_assign_module,
 166     .cache_job_info = ds21_cache_job_info,
 167     .register_job_info = ds21_register_job_info,
 168     .store_job_info = ds21_store_job_info,
 169     .store = ds21_store,
 170     .store_modex = ds21_store_modex,
 171     .fetch = ds21_fetch,
 172     .setup_fork = ds21_setup_fork,
 173     .add_nspace = ds21_add_nspace,
 174     .del_nspace = ds21_del_nspace,
 175 };
 176 

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