Exemplo n.º 1
0
Arquivo: h5gImp.c Projeto: zstang/hdf5
/*
 * Class:     hdf_hdf5lib_H5
 * Method:    H5Grefresh
 * Signature: (J)V
 */
JNIEXPORT void JNICALL
Java_hdf_hdf5lib_H5_H5Grefresh
	(JNIEnv *env, jclass clss, jlong loc_id)
{
    if (H5Grefresh((hid_t)loc_id) < 0)
        h5libraryError(env);
} /* end Java_hdf_hdf5lib_H5_H5Grefresh */
Exemplo n.º 2
0
/*-------------------------------------------------------------------------
 * Function:    refresh_verification
 *
 * Purpose:     This function opens the specified object, and checks to see
 *              that is does not have any attributes on it. It then sends
 *              a signal to the main process, which will flush the object
 *              (putting an attribute on the object on disk). This function
 *              will then refresh the object, and verify that it has picked
 *              up the new metadata reflective of the added attribute.
 *
 * Return:      0 on Success, 1 on Failure
 *
 * Programmer:  Mike McGreevy
 *              July 16, 2010
 *
 * Modifications:
 *
 *-------------------------------------------------------------------------
 */
herr_t refresh_verification(const char * obj_pathname) 
{
    /* Variables */
    hid_t oid,fid,status = 0;
    H5O_info_t flushed_oinfo;
    H5O_info_t refreshed_oinfo;
    
    /* Open Object */
    if ((fid = H5Fopen(FILENAME, H5F_ACC_SWMR_READ, H5P_DEFAULT)) < 0) PROCESS_ERROR;
    if ((oid = H5Oopen(fid, obj_pathname, H5P_DEFAULT)) < 0) PROCESS_ERROR;

    /* Get Object info */
    if ((status = H5Oget_info(oid, &flushed_oinfo)) < 0) PROCESS_ERROR;
    
    /* Make sure there are no attributes on the object. This is just a sanity
        check to ensure we didn't erroneously flush the attribute before
        starting the verification. */
    if (flushed_oinfo.num_attrs != 0) PROCESS_ERROR;

    /* Send Signal to MAIN PROCESS indicating that it can go ahead and modify the 
        object. */
    send_signal(SIGNAL_BETWEEN_PROCESSES_1, NULL, NULL);

    /* Wait for Signal from MAIN PROCESS indicating that it's modified the 
        object and we can run verification now. */
    if (wait_for_signal(SIGNAL_BETWEEN_PROCESSES_2) < 0) PROCESS_ERROR;

    /* Get object info again. This will NOT reflect what's on disk, only what's 
       in the cache. Thus, all values will be unchanged from above, despite 
       newer information being on disk. */
    if ((status = H5Oget_info(oid, &refreshed_oinfo)) < 0) PROCESS_ERROR;

    /* Verify that before doing a refresh, getting the object info returns stale
       information. (i.e., unchanged from above, despite new info on disk). */
    if (flushed_oinfo.addr != refreshed_oinfo.addr) PROCESS_ERROR;
    if (flushed_oinfo.type != refreshed_oinfo.type) PROCESS_ERROR;
    if (flushed_oinfo.hdr.version != refreshed_oinfo.hdr.version) PROCESS_ERROR;
    if (flushed_oinfo.hdr.flags != refreshed_oinfo.hdr.flags) PROCESS_ERROR;
    if (flushed_oinfo.num_attrs != refreshed_oinfo.num_attrs) PROCESS_ERROR;
    if (flushed_oinfo.hdr.nmesgs != refreshed_oinfo.hdr.nmesgs) PROCESS_ERROR;
    if (flushed_oinfo.hdr.nchunks != refreshed_oinfo.hdr.nchunks) PROCESS_ERROR;
    if (flushed_oinfo.hdr.space.total != refreshed_oinfo.hdr.space.total) PROCESS_ERROR;

    /* Refresh object */
    /* The H5*refresh function called depends on which object we are trying
     * to refresh. (MIKE: add desired refresh call as parameter so adding new
     * test cases is easy). */
    if ((strcmp(obj_pathname, D1) == 0) || 
        (strcmp(obj_pathname, D2) == 0)) {
        if (H5Drefresh(oid) < 0) PROCESS_ERROR;
    } /* end if */
    else if ((strcmp(obj_pathname, G1) == 0) || 
        (strcmp(obj_pathname, G2) == 0)) {
        if (H5Grefresh(oid) < 0) PROCESS_ERROR;
    } /* end if */
    else if ((strcmp(obj_pathname, T1) == 0) || 
        (strcmp(obj_pathname, T2) == 0)) {
        if (H5Trefresh(oid) < 0) PROCESS_ERROR;
    } /* end if */
    else if ((strcmp(obj_pathname, D3) == 0) || 
        (strcmp(obj_pathname, G3) == 0) ||
        (strcmp(obj_pathname, T3) == 0)) {
        if (H5Orefresh(oid) < 0) PROCESS_ERROR;
    } /* end if */
    else {
        HDfprintf(stdout, "Error. %s is an unrecognized object.\n", obj_pathname);
        PROCESS_ERROR;
    } /* end else */

    /* Get object info. This should now accurately reflect the refreshed object on disk. */
    if ((status = H5Oget_info(oid, &refreshed_oinfo)) < 0) PROCESS_ERROR;
    
    /* Confirm following attributes are the same: */
    if (flushed_oinfo.addr != refreshed_oinfo.addr) PROCESS_ERROR;
    if (flushed_oinfo.type != refreshed_oinfo.type) PROCESS_ERROR;
    if (flushed_oinfo.hdr.version != refreshed_oinfo.hdr.version) PROCESS_ERROR;
    if (flushed_oinfo.hdr.flags != refreshed_oinfo.hdr.flags) PROCESS_ERROR;

    /* Confirm following attributes are different */
    if (flushed_oinfo.num_attrs == refreshed_oinfo.num_attrs) PROCESS_ERROR;
    if (flushed_oinfo.hdr.nmesgs == refreshed_oinfo.hdr.nmesgs) PROCESS_ERROR;
    if (flushed_oinfo.hdr.nchunks == refreshed_oinfo.hdr.nchunks) PROCESS_ERROR;
    if (flushed_oinfo.hdr.space.total == refreshed_oinfo.hdr.space.total) PROCESS_ERROR;

    /* Close objects */
    if (H5Oclose(oid) < 0) PROCESS_ERROR;
    if (H5Fclose(fid) < 0) PROCESS_ERROR;

    /* Return */
    return SUCCEED;

error:

    return FAIL;

} /* refresh_verification */