mirror of
https://github.com/HDFGroup/hdf5.git
synced 2026-09-25 04:09:44 +03:00
Squash merge of file locking fixes
This commit is contained in:
@@ -6687,6 +6687,51 @@ public class H5 implements java.io.Serializable {
|
||||
public synchronized static native void H5Pset_evict_on_close(long fapl_id, boolean evict_on_close)
|
||||
throws HDF5LibraryException;
|
||||
|
||||
/**
|
||||
* H5Pget_use_file_locking retrieves whether we are using file locking.
|
||||
*
|
||||
* @param fapl_id
|
||||
* IN: File access property list identifier
|
||||
*
|
||||
* @exception HDF5LibraryException
|
||||
* - Error from the HDF-5 Library.
|
||||
*
|
||||
**/
|
||||
public synchronized static native boolean H5Pget_use_file_locking(long fapl_id)
|
||||
throws HDF5LibraryException;
|
||||
|
||||
/**
|
||||
* H5Pget_use_file_locking retrieves whether we ignore file locks when they are disabled.
|
||||
*
|
||||
* @param fapl_id
|
||||
* IN: File access property list identifier
|
||||
*
|
||||
* @exception HDF5LibraryException
|
||||
* - Error from the HDF-5 Library.
|
||||
*
|
||||
**/
|
||||
public synchronized static native boolean H5Pget_ignore_disabled_file_locking(long fapl_id)
|
||||
throws HDF5LibraryException;
|
||||
|
||||
/**
|
||||
* H5Pset_file_locking sets parameters related to file locking.
|
||||
*
|
||||
* @param fapl_id
|
||||
* IN: File access property list identifier
|
||||
*
|
||||
* @param use_file_locking
|
||||
* IN: Whether the library will use file locking when opening files (mainly for SWMR semantics).
|
||||
*
|
||||
* @param ignore_when_disabled
|
||||
* IN: Whether file locking will be ignored when disabled on a file system (useful for Lustre).
|
||||
*
|
||||
* @exception HDF5LibraryException
|
||||
* - Error from the HDF-5 Library.
|
||||
*
|
||||
**/
|
||||
public synchronized static native void H5Pset_file_locking(long fapl_id, boolean use_file_locking, boolean ignore_when_disabled)
|
||||
throws HDF5LibraryException;
|
||||
|
||||
// ///// unimplemented /////
|
||||
// herr_t H5Pset_vol(hid_t plist_id, hid_t new_vol_id, const void *new_vol_info);
|
||||
// herr_t H5Pget_vol_id(hid_t plist_id, hid_t *vol_id);
|
||||
|
||||
@@ -1375,6 +1375,78 @@ done:
|
||||
return bval;
|
||||
} /* end Java_hdf_hdf5lib_H5_H5Pget_1evict_1on_1close */
|
||||
|
||||
/*
|
||||
* Class: hdf_hdf5lib_H5
|
||||
* Method: H5Pset_file_locking
|
||||
* Signature: (JZZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_hdf_hdf5lib_H5_H5Pset_1file_1locking
|
||||
(JNIEnv *env, jclass clss, jlong fapl_id, jboolean use_file_locking, jboolean ignore_when_disabled)
|
||||
{
|
||||
hbool_t use_file_locking_val = TRUE;
|
||||
hbool_t ignore_when_disabled_val = TRUE;
|
||||
|
||||
UNUSED(clss);
|
||||
|
||||
use_file_locking_val = (use_file_locking == JNI_TRUE) ? TRUE : FALSE;
|
||||
ignore_when_disabled_val = (ignore_when_disabled == JNI_TRUE) ? TRUE : FALSE;
|
||||
|
||||
if (H5Pset_file_locking((hid_t)fapl_id, use_file_locking_val, ignore_when_disabled_val) < 0)
|
||||
H5_LIBRARY_ERROR(ENVONLY);
|
||||
|
||||
done:
|
||||
return;
|
||||
} /* end Java_hdf_hdf5lib_H5_H5Pset_1file_1locking */
|
||||
|
||||
/*
|
||||
* Class: hdf_hdf5lib_H5
|
||||
* Method: H5Pget_use_file_locking
|
||||
* Signature: (J)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_hdf_hdf5lib_H5_H5Pget_1use_1file_1locking
|
||||
(JNIEnv *env, jclass clss, jlong fapl_id)
|
||||
{
|
||||
hbool_t use_file_locking_val = TRUE;
|
||||
hbool_t unused = TRUE;
|
||||
jboolean bval = JNI_FALSE;
|
||||
|
||||
UNUSED(clss);
|
||||
|
||||
if (H5Pget_file_locking((hid_t)fapl_id, &use_file_locking_val, &unused) < 0)
|
||||
H5_LIBRARY_ERROR(ENVONLY);
|
||||
|
||||
bval = (use_file_locking_val == TRUE) ? JNI_TRUE : JNI_FALSE;
|
||||
|
||||
done:
|
||||
return bval;
|
||||
} /* end Java_hdf_hdf5lib_H5_H5Pget_1use_1file_1locking */
|
||||
|
||||
/*
|
||||
* Class: hdf_hdf5lib_H5
|
||||
* Method: H5Pget_ignore_disabled_file_locking
|
||||
* Signature: (J)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_hdf_hdf5lib_H5_H5Pget_1ignore_1disabled_1file_1locking
|
||||
(JNIEnv *env, jclass clss, jlong fapl_id)
|
||||
{
|
||||
hbool_t ignore_when_disabled_val = TRUE;
|
||||
hbool_t unused = TRUE;
|
||||
jboolean bval = JNI_FALSE;
|
||||
|
||||
UNUSED(clss);
|
||||
|
||||
if (H5Pget_file_locking((hid_t)fapl_id, &unused, &ignore_when_disabled_val) < 0)
|
||||
H5_LIBRARY_ERROR(ENVONLY);
|
||||
|
||||
bval = (ignore_when_disabled_val == TRUE) ? JNI_TRUE : JNI_FALSE;
|
||||
|
||||
done:
|
||||
return bval;
|
||||
} /* end Java_hdf_hdf5lib_H5_H5Pget_1ignore_1disabled_1file_1locking */
|
||||
|
||||
/*
|
||||
* Class: hdf_hdf5lib_H5
|
||||
* Method: H5Pset_metadata_read_attempts
|
||||
|
||||
@@ -390,6 +390,33 @@ JNIEXPORT jboolean JNICALL
|
||||
Java_hdf_hdf5lib_H5_H5Pget_1evict_1on_1close
|
||||
(JNIEnv *, jclass, jlong);
|
||||
|
||||
/*
|
||||
* Class: hdf_hdf5lib_H5
|
||||
* Method: H5Pset_file_locking
|
||||
* Signature: (JZZ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_hdf_hdf5lib_H5_H5Pset_1file_1locking
|
||||
(JNIEnv *env, jclass clss, jlong fapl_id, jboolean use_file_locking, jboolean ignore_when_disabled);
|
||||
|
||||
/*
|
||||
* Class: hdf_hdf5lib_H5
|
||||
* Method: H5Pget_use_file_locking
|
||||
* Signature: (J)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_hdf_hdf5lib_H5_H5Pget_1use_1file_1locking
|
||||
(JNIEnv *env, jclass clss, jlong fapl_id);
|
||||
|
||||
/*
|
||||
* Class: hdf_hdf5lib_H5
|
||||
* Method: H5Pget_ignore_disabled_file_locking
|
||||
* Signature: (J)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_hdf_hdf5lib_H5_H5Pget_1ignore_1disabled_1file_1locking
|
||||
(JNIEnv *env, jclass clss, jlong fapl_id);
|
||||
|
||||
/*
|
||||
* Class: hdf_hdf5lib_H5
|
||||
* Method: H5Pset_metadata_read_attempts
|
||||
|
||||
@@ -1398,4 +1398,36 @@ public class TestH5Pfapl {
|
||||
fail("H5P_evict_on_close: " + err);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testH5P_file_locking() {
|
||||
boolean use_file_locking = false;
|
||||
boolean ignore_disabled_file_locking = false;
|
||||
try {
|
||||
// false values (usually not the default)
|
||||
H5.H5Pset_file_locking(fapl_id, false, false);
|
||||
use_file_locking = H5.H5Pget_use_file_locking(fapl_id);
|
||||
ignore_disabled_file_locking = H5.H5Pget_ignore_disabled_file_locking(fapl_id);
|
||||
assertFalse("H5P_file_locking", use_file_locking);
|
||||
assertFalse("H5P_file_locking", ignore_disabled_file_locking);
|
||||
|
||||
// true values (typically the default)
|
||||
H5.H5Pset_file_locking(fapl_id, true, true);
|
||||
use_file_locking = H5.H5Pget_use_file_locking(fapl_id);
|
||||
ignore_disabled_file_locking = H5.H5Pget_ignore_disabled_file_locking(fapl_id);
|
||||
assertTrue("H5P_file_locking", use_file_locking);
|
||||
assertTrue("H5P_file_locking", ignore_disabled_file_locking);
|
||||
}
|
||||
catch (HDF5PropertyListInterfaceException err) {
|
||||
// parallel is not supported
|
||||
if (err.getMinorErrorNumber() != HDF5Constants.H5E_UNSUPPORTED) {
|
||||
err.printStackTrace();
|
||||
fail("H5P_test_file_locking: " + err);
|
||||
}
|
||||
}
|
||||
catch (Throwable err) {
|
||||
err.printStackTrace();
|
||||
fail("H5P_test_file_locking: " + err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ JUnit version 4.11
|
||||
.testH5Pset_elink_fapl
|
||||
.testH5P_hyper_vector_size
|
||||
.testH5P_gc_references
|
||||
.testH5P_file_locking
|
||||
.testH5P_family_offset
|
||||
.testH5P_fapl_core
|
||||
.testH5P_fapl_muti
|
||||
@@ -37,5 +38,5 @@ JUnit version 4.11
|
||||
|
||||
Time: XXXX
|
||||
|
||||
OK (35 tests)
|
||||
OK (36 tests)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user