opal/mca/dstore/zht/dstore_zht.c
/* lookup a (key, value) record from ZHT server */
lookup a (key, value) record from ZHT server
lookup a ( key value ) record from ZHT server
static int fetch(struct opal_dstore_base_module_t *imod,
                 const opal_process_name_t *proc,
                 const char *key,
                 opal_list_t *kvs)
{
    int rc;
    opal_output_verbose(1, opal_dstore_base_framework.framework_output,
                "%s dstore:zht:kvs looking up data for proc %s",
                OPAL_NAME_PRINT(OPAL_PROC_MY_NAME), OPAL_NAME_PRINT(*proc));
    if (NULL == key) {
        opal_output_verbose(1, opal_dstore_base_framework.framework_output,
                "%s dstore:zht:kvs looking up empty key for proc %s",
                OPAL_NAME_PRINT(OPAL_PROC_MY_NAME), OPAL_NAME_PRINT(*proc));
        return OPAL_ERROR;
    }
    char *str_val;
    while (NULL == (str_val = (char*)calloc(MSG_SIZE, sizeof(char)))) {
        opal_output_verbose(1, opal_dstore_base_framework.framework_output,
                "%s dstore:zht:kvs unable to allocate %d memory for proc %s",
                OPAL_NAME_PRINT(OPAL_PROC_MY_NAME),
                MSG_SIZE, OPAL_NAME_PRINT(*proc));
        sleep(1);
    }
    if (0 != (rc = c_zht_lookup(key, str_val))) {
        opal_output_verbose(1, opal_dstore_base_framework.framework_output,
                "%s dstore:zht:kvs lookup failed with key: %s for proc %s",
                OPAL_NAME_PRINT(OPAL_PROC_MY_NAME),
				key, OPAL_NAME_PRINT(*proc));
        free(str_val);
        str_val = NULL;
        return OPAL_ERROR;
    }
    opal_buffer_t *buffer = OBJ_NEW(opal_buffer_t);
    opal_value_t *val, *knew;
    val = unpack_kvs(buffer, str_val);
    OBJ_RELEASE(buffer);
    if (NULL == val) {
        return OPAL_ERROR;
    }
    if (OPAL_SUCCESS != (rc = opal_dss.copy((void**)&knew, val, OPAL_VALUE))) {
        OPAL_ERROR_LOG(rc);
        OBJ_RELEASE(val);
        return rc;
    }
    OBJ_RELEASE(val);
    opal_list_append(kvs, &knew->super);
    return OPAL_SUCCESS;
}
static int fetch ( struct opal_dstore_base_module_t * imod , const opal_process_name_t * proc , const char * key , opal_list_t * kvs ) { int rc ; opal_output_verbose ( 1 , opal_dstore_base_framework . framework_output , " " , OPAL_NAME_PRINT ( OPAL_PROC_MY_NAME ) , OPAL_NAME_PRINT ( * proc ) ) ; if ( NULL == key ) { opal_output_verbose ( 1 , opal_dstore_base_framework . framework_output , " " , OPAL_NAME_PRINT ( OPAL_PROC_MY_NAME ) , OPAL_NAME_PRINT ( * proc ) ) ; return OPAL_ERROR ; } char * str_val ; while ( NULL == ( str_val = ( char * ) calloc ( MSG_SIZE , sizeof ( char ) ) ) ) { opal_output_verbose ( 1 , opal_dstore_base_framework . framework_output , " " , OPAL_NAME_PRINT ( OPAL_PROC_MY_NAME ) , MSG_SIZE , OPAL_NAME_PRINT ( * proc ) ) ; sleep ( 1 ) ; } if ( 0 != ( rc = c_zht_lookup ( key , str_val ) ) ) { opal_output_verbose ( 1 , opal_dstore_base_framework . framework_output , " " , OPAL_NAME_PRINT ( OPAL_PROC_MY_NAME ) , key , OPAL_NAME_PRINT ( * proc ) ) ; free ( str_val ) ; str_val = NULL ; return OPAL_ERROR ; } opal_buffer_t * buffer = OBJ_NEW ( opal_buffer_t ) ; opal_value_t * val , * knew ; val = unpack_kvs ( buffer , str_val ) ; OBJ_RELEASE ( buffer ) ; if ( NULL == val ) { return OPAL_ERROR ; } if ( OPAL_SUCCESS != ( rc = opal_dss . copy ( ( void * * ) & knew , val , OPAL_VALUE ) ) ) { OPAL_ERROR_LOG ( rc ) ; OBJ_RELEASE ( val ) ; return rc ; } OBJ_RELEASE ( val ) ; opal_list_append ( kvs , & knew -> super ) ; return OPAL_SUCCESS ; }
lookup a (key, value) record from ZHT server
lookup a ( key value ) record from ZHT server
/* ZHT doesn't like empty key */ /* add the value to the output list */