int orte_sstore_base_tool_get_attr(orte_sstore_base_handle_t handle, orte_sstore_base_key_t key, char **value) { int ret, exit_status = ORTE_SUCCESS; if( SSTORE_METADATA_GLOBAL_SNAP_LOC_ABS == key ) { asprintf(value, "%s/%s", tool_global_snapshot->basedir, tool_global_snapshot->reference); } else if( SSTORE_METADATA_LOCAL_SNAP_REF_FMT == key ) { *value = strdup(orte_sstore_base_local_snapshot_fmt); } else if( SSTORE_METADATA_LOCAL_SNAP_LOC == key ) { asprintf(value, "%s/%s/%d", tool_global_snapshot->basedir, tool_global_snapshot->reference, tool_global_snapshot->seq_num); } else if( SSTORE_METADATA_LOCAL_SNAP_REF_LOC_FMT == key ) { asprintf(value, "%s/%s/%d/%s", tool_global_snapshot->basedir, tool_global_snapshot->reference, tool_global_snapshot->seq_num, orte_sstore_base_local_snapshot_fmt); } else if( SSTORE_METADATA_GLOBAL_SNAP_NUM_SEQ == key ) { if( NULL == tool_global_snapshot->all_seqs ) { if( ORTE_SUCCESS != (ret = orte_sstore_base_find_all_seq_nums(tool_global_snapshot, &(tool_global_snapshot->num_seqs), &(tool_global_snapshot->all_seqs)))) { ORTE_ERROR_LOG(ORTE_ERROR); exit_status = ORTE_ERROR; goto cleanup; } } asprintf(value, "%d", tool_global_snapshot->num_seqs); } else if( SSTORE_METADATA_GLOBAL_SNAP_ALL_SEQ == key ) { if( NULL == tool_global_snapshot->all_seqs ) { if( ORTE_SUCCESS != (ret = orte_sstore_base_find_all_seq_nums(tool_global_snapshot, &(tool_global_snapshot->num_seqs), &(tool_global_snapshot->all_seqs)))) { ORTE_ERROR_LOG(ORTE_ERROR); exit_status = ORTE_ERROR; goto cleanup; } } *value = opal_argv_join(tool_global_snapshot->all_seqs, ','); } else if( SSTORE_METADATA_GLOBAL_AMCA_PARAM == key ) { *value = strdup(tool_global_snapshot->amca_param); } else { return ORTE_ERR_NOT_SUPPORTED; } cleanup: return exit_status; }
static int list_all_snapshots(void) { int ret, exit_status = ORTE_SUCCESS; opal_list_t *all_snapshots = NULL; opal_list_item_t* item = NULL; orte_sstore_base_global_snapshot_info_t *global_snapshot = NULL; int s; all_snapshots = OBJ_NEW(opal_list_t); if( ORTE_SUCCESS != (ret = orte_sstore_base_get_all_snapshots(all_snapshots, NULL)) ) { opal_output(0, "Error: Unable to list the checkpoints in the directory <%s>\n", orte_sstore_base_global_snapshot_dir); ORTE_ERROR_LOG(ret); exit_status = ret; goto cleanup; } /* * For each reference */ for(item = opal_list_get_first(all_snapshots); item != opal_list_get_end(all_snapshots); item = opal_list_get_next(item) ) { global_snapshot = (orte_sstore_base_global_snapshot_info_t*)item; /* * Get a list of valid sequence numbers */ if( ORTE_SUCCESS != (ret = orte_sstore_base_find_all_seq_nums(global_snapshot, &(global_snapshot->num_seqs), &(global_snapshot->all_seqs)))) { ORTE_ERROR_LOG(ret); exit_status = ret; goto cleanup; } s = 0; /* Silence a compiler warning */ #if OPAL_ENABLE_CRDEBUG == 1 /* Pretty print the result - C/R Debug version */ if( orte_checkpoint_globals.enable_crdebug ) { for(s = 0; s < global_snapshot->num_seqs; ++s) { printf("-s %s %s\n", global_snapshot->all_seqs[s], global_snapshot->reference); } } else #endif { /* Pretty print the result */ printf("Snapshot Ref.: %s\t[", global_snapshot->reference); if( 0 >= global_snapshot->num_seqs ) { printf("No Valid Checkpoints"); } else { printf("%s", opal_argv_join(global_snapshot->all_seqs, ',')); } printf("]\n"); } } cleanup: while (NULL != (item = opal_list_remove_first(all_snapshots))) { OBJ_RELEASE(item); } OBJ_RELEASE(all_snapshots); return exit_status; }