diff options
author | Allen Byrne <byrn@hdfgroup.org> | 2016-03-09 14:55:45 (GMT) |
---|---|---|
committer | Allen Byrne <byrn@hdfgroup.org> | 2016-03-09 14:55:45 (GMT) |
commit | c5eec3d9917e136d73dc1ddfd33f54bdb42a533b (patch) | |
tree | 2230ee527126074aeaaae8eecc294ca636f61ebc | |
parent | f16244254bc4d8c5dc538f824e2b3cf16cd8b6a7 (diff) | |
download | hdf5-c5eec3d9917e136d73dc1ddfd33f54bdb42a533b.zip hdf5-c5eec3d9917e136d73dc1ddfd33f54bdb42a533b.tar.gz hdf5-c5eec3d9917e136d73dc1ddfd33f54bdb42a533b.tar.bz2 |
[svn-r29371] HDFFV-9624: SWMR apis added
-rw-r--r-- | MANIFEST | 3 | ||||
-rw-r--r-- | java/src/Makefile.am | 2 | ||||
-rw-r--r-- | java/src/hdf/hdf5lib/CMakeLists.txt | 2 | ||||
-rw-r--r-- | java/src/hdf/hdf5lib/H5.java | 99 | ||||
-rw-r--r-- | java/src/hdf/hdf5lib/HDF5Constants.java | 6 | ||||
-rw-r--r-- | java/src/hdf/hdf5lib/callbacks/H5D_append_cb.java | 21 | ||||
-rw-r--r-- | java/src/hdf/hdf5lib/callbacks/H5D_append_t.java | 22 | ||||
-rw-r--r-- | java/src/jni/h5Constants.c | 6 | ||||
-rw-r--r-- | java/src/jni/h5fImp.c | 73 | ||||
-rw-r--r-- | java/src/jni/h5fImp.h | 32 | ||||
-rw-r--r-- | java/src/jni/h5pImp.c | 160 | ||||
-rw-r--r-- | java/src/jni/h5pImp.h | 24 | ||||
-rw-r--r-- | java/src/jni/h5tImp.c | 6 | ||||
-rw-r--r-- | java/src/jni/h5tImp.h | 4 | ||||
-rw-r--r-- | java/test/CMakeLists.txt | 1 | ||||
-rw-r--r-- | java/test/JUnit-interface.txt | 4 | ||||
-rw-r--r-- | java/test/Makefile.am | 1 | ||||
-rw-r--r-- | java/test/TestAll.java | 2 | ||||
-rw-r--r-- | java/test/TestH5Fswmr.java | 93 | ||||
-rw-r--r-- | java/test/TestH5Pfapl.java | 56 |
20 files changed, 608 insertions, 9 deletions
@@ -2670,6 +2670,8 @@ ./java/src/hdf/hdf5lib/callbacks/H5A_iterate_t.java ./java/src/hdf/hdf5lib/callbacks/H5D_iterate_cb.java ./java/src/hdf/hdf5lib/callbacks/H5D_iterate_t.java +./java/src/hdf/hdf5lib/callbacks/H5D_append_cb.java +./java/src/hdf/hdf5lib/callbacks/H5D_append_t.java ./java/src/hdf/hdf5lib/callbacks/H5E_walk_cb.java ./java/src/hdf/hdf5lib/callbacks/H5E_walk_t.java ./java/src/hdf/hdf5lib/callbacks/H5L_iterate_cb.java @@ -2872,6 +2874,7 @@ ./java/test/TestH5Fparams.java ./java/test/TestH5Fbasic.java ./java/test/TestH5F.java +./java/test/TestH5Fswmr.java ./java/test/TestH5Gbasic.java ./java/test/TestH5G.java ./java/test/TestH5Giterate.java diff --git a/java/src/Makefile.am b/java/src/Makefile.am index 7615973..6a33724 100644 --- a/java/src/Makefile.am +++ b/java/src/Makefile.am @@ -47,6 +47,8 @@ hdf5_java_JAVA = \ ${pkgpath}/callbacks/Callbacks.java \ ${pkgpath}/callbacks/H5A_iterate_cb.java \ ${pkgpath}/callbacks/H5A_iterate_t.java \ + ${pkgpath}/callbacks/H5D_append_cb.java \ + ${pkgpath}/callbacks/H5D_append_t.java \ ${pkgpath}/callbacks/H5D_iterate_cb.java \ ${pkgpath}/callbacks/H5D_iterate_t.java \ ${pkgpath}/callbacks/H5E_walk_cb.java \ diff --git a/java/src/hdf/hdf5lib/CMakeLists.txt b/java/src/hdf/hdf5lib/CMakeLists.txt index 56c1e59..ab4b6a3 100644 --- a/java/src/hdf/hdf5lib/CMakeLists.txt +++ b/java/src/hdf/hdf5lib/CMakeLists.txt @@ -17,6 +17,8 @@ SET_GLOBAL_VARIABLE (HDF5_JAVA_SOURCE_PACKAGES set (HDF5_JAVA_HDF_HDF5_CALLBACKS_SRCS callbacks/H5A_iterate_cb.java callbacks/H5A_iterate_t.java + callbacks/H5D_append_cb.java + callbacks/H5D_append_t.java callbacks/H5D_iterate_cb.java callbacks/H5D_iterate_t.java callbacks/H5E_walk_cb.java diff --git a/java/src/hdf/hdf5lib/H5.java b/java/src/hdf/hdf5lib/H5.java index fbfc40a..c56ad4e 100644 --- a/java/src/hdf/hdf5lib/H5.java +++ b/java/src/hdf/hdf5lib/H5.java @@ -2824,8 +2824,63 @@ public class H5 implements java.io.Serializable { **/ public synchronized static native void H5Fclear_elink_file_cache(long file_id) throws HDF5LibraryException; + /** + * H5Fstart_swmr_write will activate SWMR writing mode for a file associated with file_id. This routine will + * prepare and ensure the file is safe for SWMR writing. + * + * @param file_id + * IN: Identifier of the target file. + * + * @exception HDF5LibraryException + * - Error from the HDF-5 Library. + **/ + public synchronized static native void H5Fstart_swmr_write(long file_id) throws HDF5LibraryException; + + /** + * H5Fstart_mdc_logging starts logging metadata cache events if logging was previously enabled. + * + * @param file_id + * IN: Identifier of the target file. + * + * @exception HDF5LibraryException + * - Error from the HDF-5 Library. + **/ + public synchronized static native void H5Fstart_mdc_logging(long file_id) throws HDF5LibraryException; + + /** + * H5Fstop_mdc_logging stops logging metadata cache events if logging was previously enabled and is currently ongoing. + * + * @param file_id + * IN: Identifier of the target file. + * + * @exception HDF5LibraryException + * - Error from the HDF-5 Library. + **/ + public synchronized static native void H5Fstop_mdc_logging(long file_id) throws HDF5LibraryException; + + /** + * H5Fget_mdc_logging_status gets the current metadata cache logging status. + * + * @param file_id + * IN: Identifier of the target file. + * + * @param mdc_logging_status, the status + * mdc_logging_status[0] = is_enabled, whether logging is enabled + * mdc_logging_status[1] = is_currently_logging, whether events are currently being logged + * + * @exception HDF5LibraryException + * - Error from the HDF-5 Library. + * @exception NullPointerException + * - mdc_logging_status is null. + **/ + public synchronized static native void H5Fget_mdc_logging_status(long file_id, boolean[] mdc_logging_status) + throws HDF5LibraryException, NullPointerException; + + + // /////// unimplemented //////// // ssize_t H5Fget_file_image(hid_t file_id, void * buf_ptr, size_t buf_len); + // herr_t H5Fget_metadata_read_retry_info(hid_t file_id, H5F_retry_info_t *info); // ssize_t H5Fget_free_sections(hid_t file_id, H5F_mem_t type, size_t nsects, H5F_sect_info_t *sect_info/*out*/); // /** @@ -5579,6 +5634,45 @@ public class H5 implements java.io.Serializable { public synchronized static native void H5Pset_elink_file_cache_size(long fapl_id, int efc_size) throws HDF5LibraryException; + /** + * H5Pset_mdc_log_options sets metadata cache logging options. + * + * @param fapl_id + * IN: File access property list identifier + * @param is_enabled + * IN: Whether logging is enabled. + * @param location + * IN: Location of log in UTF-8/ASCII (file path/name) (On Windows, this must be ASCII). + * @param start_on_access + * IN: Whether the logging begins as soon as the file is opened or created. + * + * @exception HDF5LibraryException + * - Error from the HDF-5 Library. + * @exception NullPointerException + * - location is null. + * + **/ + public synchronized static native void H5Pset_mdc_log_options(long fapl_id, boolean is_enabled, String location, boolean start_on_access) + throws HDF5LibraryException, NullPointerException; + + /** + * H5Pget_mdc_log_options gets metadata cache logging options. + * + * @param fapl_id + * IN: File access property list identifier + * @param mdc_log_options, the options + * mdc_logging_options[0] = is_enabled, whether logging is enabled + * mdc_logging_options[1] = start_on_access, whether the logging begins as soon as the file is opened or created + * + * @return the location of log in UTF-8/ASCII (file path/name) (On Windows, this must be ASCII). + * + * @exception HDF5LibraryException + * - Error from the HDF-5 Library. + * + **/ + public synchronized static native String H5Pget_mdc_log_options(long fapl_id, boolean[] mdc_log_options) + throws HDF5LibraryException; + // Dataset creation property list (DCPL) routines // /** @@ -6107,6 +6201,11 @@ public class H5 implements java.io.Serializable { **/ public synchronized static native long H5Pget_virtual_printf_gap(long dapl_id) throws HDF5LibraryException; + // public synchronized static native void H5Pset_append_flush(long plist_id, int ndims, long[] boundary, H5D_append_cb func, H5D_append_t udata) throws HDF5LibraryException; + + // public synchronized static native void H5Pget_append_flush(long plist_id, int dims, long[] boundary, H5D_append_cb func, H5D_append_t udata) throws HDF5LibraryException; + + // Dataset xfer property list (DXPL) routines // /** diff --git a/java/src/hdf/hdf5lib/HDF5Constants.java b/java/src/hdf/hdf5lib/HDF5Constants.java index 8089544..acd3eb5 100644 --- a/java/src/hdf/hdf5lib/HDF5Constants.java +++ b/java/src/hdf/hdf5lib/HDF5Constants.java @@ -201,6 +201,8 @@ public class HDF5Constants { public static final int H5F_ACC_RDWR = H5F_ACC_RDWR(); public static final int H5F_ACC_TRUNC = H5F_ACC_TRUNC(); public static final int H5F_ACC_DEFAULT = H5F_ACC_DEFAULT(); + public static final int H5F_ACC_SWMR_READ = H5F_ACC_SWMR_READ(); + public static final int H5F_ACC_SWMR_WRITE = H5F_ACC_SWMR_WRITE(); public static final int H5F_CLOSE_DEFAULT = H5F_CLOSE_DEFAULT(); public static final int H5F_CLOSE_SEMI = H5F_CLOSE_SEMI(); public static final int H5F_CLOSE_STRONG = H5F_CLOSE_STRONG(); @@ -984,6 +986,10 @@ public class HDF5Constants { private static native final int H5F_ACC_DEFAULT(); + private static native final int H5F_ACC_SWMR_READ(); + + private static native final int H5F_ACC_SWMR_WRITE(); + private static native final int H5F_CLOSE_DEFAULT(); private static native final int H5F_CLOSE_SEMI(); diff --git a/java/src/hdf/hdf5lib/callbacks/H5D_append_cb.java b/java/src/hdf/hdf5lib/callbacks/H5D_append_cb.java new file mode 100644 index 0000000..1b66e34 --- /dev/null +++ b/java/src/hdf/hdf5lib/callbacks/H5D_append_cb.java @@ -0,0 +1,21 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package hdf.hdf5lib.callbacks; + +//Information class for link callback(for H5Pset/get_append_flush) +public interface H5D_append_cb extends Callbacks { + int callback(long dataset_id, long[] cur_dims, H5D_append_t op_data); +} diff --git a/java/src/hdf/hdf5lib/callbacks/H5D_append_t.java b/java/src/hdf/hdf5lib/callbacks/H5D_append_t.java new file mode 100644 index 0000000..dcbd331 --- /dev/null +++ b/java/src/hdf/hdf5lib/callbacks/H5D_append_t.java @@ -0,0 +1,22 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package hdf.hdf5lib.callbacks; + +public interface H5D_append_t { +/** public ArrayList iterdata = new ArrayList(); + * Any derived interfaces must define the single public variable as above. + */ +} diff --git a/java/src/jni/h5Constants.c b/java/src/jni/h5Constants.c index f1d49be..1b94315 100644 --- a/java/src/jni/h5Constants.c +++ b/java/src/jni/h5Constants.c @@ -200,6 +200,8 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5F_1ACC_1RDONLY(JNIEnv *e JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5F_1ACC_1RDWR(JNIEnv *env, jclass cls) { return H5F_ACC_RDWR; } JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5F_1ACC_1TRUNC(JNIEnv *env, jclass cls) { return H5F_ACC_TRUNC; } JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5F_1ACC_1DEFAULT(JNIEnv *env, jclass cls) { return H5F_ACC_DEFAULT; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5F_1ACC_1SWMR_1READ(JNIEnv *env, jclass cls) { return H5F_ACC_SWMR_READ; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5F_1ACC_1SWMR_1WRITE(JNIEnv *env, jclass cls) { return H5F_ACC_SWMR_WRITE; } #pragma GCC diagnostic pop JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5F_1CLOSE_1DEFAULT(JNIEnv *env, jclass cls) { return H5F_CLOSE_DEFAULT; } @@ -375,8 +377,8 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1GROUP_1ACCESS(JNIEnv JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1DATATYPE_1CREATE(JNIEnv *env, jclass cls){return H5P_DATATYPE_CREATE;} JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1DATATYPE_1ACCESS(JNIEnv *env, jclass cls){return H5P_DATATYPE_ACCESS;} JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1STRING_1CREATE(JNIEnv *env, jclass cls){return H5P_STRING_CREATE;} -JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1ATTRIBUTE_1CREATE(JNIEnv *env, jclass cls){return H5P_ATTRIBUTE_CREATE;} JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1ATTRIBUTE_1ACCESS(JNIEnv *env, jclass cls){return H5P_ATTRIBUTE_ACCESS;} +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1ATTRIBUTE_1CREATE(JNIEnv *env, jclass cls){return H5P_ATTRIBUTE_CREATE;} JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1OBJECT_1COPY(JNIEnv *env, jclass cls){return H5P_OBJECT_COPY;} JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1LINK_1CREATE(JNIEnv *env, jclass cls){return H5P_LINK_CREATE;} JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1LINK_1ACCESS(JNIEnv *env, jclass cls){return H5P_LINK_ACCESS;} @@ -390,8 +392,8 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1GROUP_1CREATE_1DEFAU JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1GROUP_1ACCESS_1DEFAULT(JNIEnv *env, jclass cls){return H5P_GROUP_ACCESS_DEFAULT;} JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1DATATYPE_1CREATE_1DEFAULT(JNIEnv *env, jclass cls){return H5P_DATATYPE_CREATE_DEFAULT;} JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1DATATYPE_1ACCESS_1DEFAULT(JNIEnv *env, jclass cls){return H5P_DATATYPE_ACCESS_DEFAULT;} -JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1ATTRIBUTE_1CREATE_1DEFAULT(JNIEnv *env, jclass cls){return H5P_ATTRIBUTE_CREATE_DEFAULT;} JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1ATTRIBUTE_1ACCESS_1DEFAULT(JNIEnv *env, jclass cls){return H5P_ATTRIBUTE_ACCESS_DEFAULT;} +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1ATTRIBUTE_1CREATE_1DEFAULT(JNIEnv *env, jclass cls){return H5P_ATTRIBUTE_CREATE_DEFAULT;} JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1OBJECT_1COPY_1DEFAULT(JNIEnv *env, jclass cls){return H5P_OBJECT_COPY_DEFAULT;} JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1LINK_1CREATE_1DEFAULT(JNIEnv *env, jclass cls){return H5P_LINK_CREATE_DEFAULT;} JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5P_1LINK_1ACCESS_1DEFAULT(JNIEnv *env, jclass cls){return H5P_LINK_ACCESS_DEFAULT;} diff --git a/java/src/jni/h5fImp.c b/java/src/jni/h5fImp.c index b484fb2..1666940 100644 --- a/java/src/jni/h5fImp.c +++ b/java/src/jni/h5fImp.c @@ -510,6 +510,79 @@ Java_hdf_hdf5lib_H5_H5Fclear_1elink_1file_1cache(JNIEnv *env, jclass cls, jlong h5libraryError(env); } /* end Java_hdf_hdf5lib_H5_H5Fclear_1elink_1file_1cache */ +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Fstart_swmr_write + * Signature: (J)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Fstart_1swmr_1write(JNIEnv *env, jclass cls, jlong file_id) +{ + if (H5Fstart_swmr_write((hid_t)file_id) < 0) + h5libraryError(env); +} /* end Java_hdf_hdf5lib_H5_H5Fstart_1swmr_1write */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Fstart_mdc_logging + * Signature: (J)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Fstart_1mdc_1logging(JNIEnv *env, jclass cls, jlong file_id) +{ + if (H5Fstart_mdc_logging((hid_t)file_id) < 0) + h5libraryError(env); +} /* end Java_hdf_hdf5lib_H5_H5Fstart_1mdc_1logging */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Fstop_mdc_logging + * Signature: (J)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Fstop_1mdc_1logging (JNIEnv *env, jclass cls, jlong file_id) +{ + if (H5Fstop_mdc_logging((hid_t)file_id) < 0) + h5libraryError(env); +} /* end Java_hdf_hdf5lib_H5_H5Fstop_1mdc_1logging */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Fget_mdc_logging_status + * Signature: (J[Z)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Fget_1mdc_1logging_1status(JNIEnv *env, jclass cls, jlong file_id, + jbooleanArray mdc_logging_status) +{ + hbool_t is_enabled; + hbool_t is_currently_logging; + jboolean *mdc_logging_status_ptr; + jint size; + jboolean isCopy; + + if (mdc_logging_status == NULL) { + h5nullArgument(env, "H5Fget_mdc_logging_status: mdc_logging_status is NULL"); + } /* end if */ + else { + size = (int)ENVPTR->GetArrayLength(ENVPAR mdc_logging_status); + if (size < 2) { + h5badArgument(env, "H5Fget_mdc_logging_status: length of mdc_logging_status < 2."); + } /* end if */ + else { + if (H5Fget_mdc_logging_status((hid_t)file_id, &is_enabled, &is_currently_logging) < 0) { + h5libraryError(env); + } /* end if */ + else { + mdc_logging_status_ptr = ENVPTR->GetBooleanArrayElements(ENVPAR mdc_logging_status, &isCopy); + mdc_logging_status_ptr[0] = (jboolean)is_enabled; + mdc_logging_status_ptr[1] = (jboolean)is_currently_logging; + ENVPTR->ReleaseBooleanArrayElements(ENVPAR mdc_logging_status, mdc_logging_status_ptr, 0); + } /* end else */ + } /* end else */ + } /* end else */ +} /* end Java_hdf_hdf5lib_H5_H5Fget_1mdc_1logging_1status */ + #ifdef __cplusplus } /* end extern "C" */ diff --git a/java/src/jni/h5fImp.h b/java/src/jni/h5fImp.h index 5a72fab..909d1b8 100644 --- a/java/src/jni/h5fImp.h +++ b/java/src/jni/h5fImp.h @@ -191,6 +191,38 @@ JNIEXPORT jobject JNICALL Java_hdf_hdf5lib_H5_H5Fget_1info JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Fclear_1elink_1file_1cache (JNIEnv *, jclass, jlong); +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Fstart_swmr_write + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Fstart_1swmr_1write + (JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Fstart_mdc_logging + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Fstart_1mdc_1logging + (JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Fstop_mdc_logging + * Signature: (J)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Fstop_1mdc_1logging + (JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Fget_mdc_logging_status + * Signature: (J[Z)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Fget_1mdc_1logging_1status + (JNIEnv *, jclass, jlong, jbooleanArray); + #ifdef __cplusplus } /* end extern "C" */ #endif /* __cplusplus */ diff --git a/java/src/jni/h5pImp.c b/java/src/jni/h5pImp.c index f4fee74..eb83bb0 100644 --- a/java/src/jni/h5pImp.c +++ b/java/src/jni/h5pImp.c @@ -4880,6 +4880,166 @@ H5P_cls_close_cb(hid_t prop_id, void *close_data) /* * Class: hdf_hdf5lib_H5 + * Method: H5Pset_mdc_log_options + * Signature: (JZLjava/lang/String;Z)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1mdc_1log_1options(JNIEnv *env, jclass clss, jlong fapl_id, jboolean is_enabled, jstring location, jboolean start_on_access) +{ + herr_t retVal = -1; + const char *lstr; + + PIN_JAVA_STRING0(location, lstr); + + retVal = H5Pset_mdc_log_options((hid_t)fapl_id, (hbool_t)is_enabled, lstr, (hbool_t)start_on_access); + + UNPIN_JAVA_STRING(location, lstr); + + if (retVal < 0) { + h5libraryError(env); + } +} /* end Java_hdf_hdf5lib_H5_H5Pset_1mdc_1log_1options */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_mdc_log_options + * Signature: (J[Z)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1mdc_1log_1options(JNIEnv *env, jclass clss, jlong fapl_id, jbooleanArray mdc_log_options) +{ + hbool_t is_enabled; + hbool_t start_on_access; + jboolean *mdc_log_options_ptr; + char *lname; + size_t location_size; + ssize_t status; + jstring str = NULL; + jint size; + jboolean isCopy; + + if (mdc_log_options == NULL) { + h5nullArgument(env, "H5Fget_mdc_log_options: mdc_log_options is NULL"); + } /* end if */ + else { + size = (int)ENVPTR->GetArrayLength(ENVPAR mdc_log_options); + if (size < 2) { + h5badArgument(env, "H5Fget_mdc_log_options: length of mdc_log_options < 2."); + } /* end if */ + else { + /* get the length of the filename */ + H5Pget_mdc_log_options((hid_t)fapl_id, &is_enabled, NULL, &location_size, &start_on_access); + if (location_size < 0) { + h5badArgument(env, "H5Pget_mdc_log_options: location_size < 0"); + }/* end if */ + else if (location_size > 0) { + location_size++; /* add extra space for the null terminator */ + lname = (char *)HDmalloc(sizeof(char) * location_size); + if (lname == NULL) { + h5outOfMemory(env, "H5Pget_mdc_log_options: malloc failed"); + } /* end if */ + else { + status = H5Pget_mdc_log_options((hid_t)fapl_id, &is_enabled, lname, &location_size, &start_on_access); + + if (status < 0) { + HDfree(lname); + h5libraryError(env); + } /* end if */ + else { + str = ENVPTR->NewStringUTF(ENVPAR lname); + HDfree(lname); + if (str == NULL) { + h5JNIFatalError(env, "H5Pget_mdc_log_options: return string not allocated"); + } /* end if */ + else { + mdc_log_options_ptr = ENVPTR->GetBooleanArrayElements(ENVPAR mdc_log_options, &isCopy); + mdc_log_options_ptr[0] = (jboolean)is_enabled; + mdc_log_options_ptr[1] = (jboolean)start_on_access; + ENVPTR->ReleaseBooleanArrayElements(ENVPAR mdc_log_options, mdc_log_options_ptr, 0); + } /* end else */ + } /* end else */ + } /* end else */ + } /* end else if*/ + } /* end else */ + } /* end else */ + + return (jstring)str; +} /* end if */ + +static herr_t +H5D_append_cb(hid_t dataset_id, hsize_t *cur_dims, void *op_data) +{ + JNIEnv *cbenv; + jint status; + jclass cls; + jmethodID mid; + jlongArray cur_dimsArray; + jsize size; + + if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) != 0) { + JVMPTR->DetachCurrentThread(JVMPAR); + return -1; + } /* end if */ + cls = CBENVPTR->GetObjectClass(CBENVPAR visit_callback); + if (cls == 0) { + JVMPTR->DetachCurrentThread(JVMPAR); + return -1; + } /* end if */ + mid = CBENVPTR->GetMethodID(CBENVPAR cls, "callback", "(J[JLhdf/hdf5lib/callbacks/H5D_append_t;)I"); + if (mid == 0) { + JVMPTR->DetachCurrentThread(JVMPAR); + return -1; + } /* end if */ + + if (cur_dims == NULL) { + JVMPTR->DetachCurrentThread(JVMPAR); + return -1; + } /* end if */ + + cur_dimsArray = CBENVPTR->NewLongArray(CBENVPAR 2); + if (cur_dimsArray == NULL) { + JVMPTR->DetachCurrentThread(JVMPAR); + return -1; + } /* end if */ + CBENVPTR->SetLongArrayRegion(CBENVPAR cur_dimsArray, 0, 2, (const jlong *)cur_dims); + + status = CBENVPTR->CallIntMethod(CBENVPAR visit_callback, mid, dataset_id, cur_dims, op_data); + + JVMPTR->DetachCurrentThread(JVMPAR); + + return status; +} /* end H5D_append_cb */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_append_flush + * Signature: (JI[JLjava/lang/Object;Ljava/lang/Object;)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1append_1flush(JNIEnv *env, jclass clss, jlong plist_id, jint ndims, jlongArray boundary, + jobject callback_op, jobject op_data) +{ + herr_t status = -1; + + ENVPTR->GetJavaVM(ENVPAR &jvm); + visit_callback = callback_op; + + if (op_data == NULL) { + h5nullArgument(env, "H5Ovisit: op_data is NULL"); + } /* end if */ + else if (callback_op == NULL) { + h5nullArgument(env, "H5Ovisit: callback_op is NULL"); + } /* end if */ + else { + status = H5Pset_append_flush((hid_t)plist_id, (unsigned)ndims, (const hsize_t*)boundary, (H5D_append_cb_t)H5D_append_cb, (void*)op_data); + + if (status < 0) + h5libraryError(env); + } /* end else */ +} /* end Java_hdf_hdf5lib_H5_H5Pset_1append_1flush */ + +/* + * Class: hdf_hdf5lib_H5 * Method: _H5Pcreate_class_nocb * Signature: (JLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)J */ diff --git a/java/src/jni/h5pImp.h b/java/src/jni/h5pImp.h index ea1ee52..22c817e 100644 --- a/java/src/jni/h5pImp.h +++ b/java/src/jni/h5pImp.h @@ -1252,6 +1252,30 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pset_1file_1space /* * Class: hdf_hdf5lib_H5 + * Method: H5Pset_mdc_log_options + * Signature: (JZLjava/lang/String;Z)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pset_1mdc_1log_1options +(JNIEnv *, jclass, jlong, jboolean, jstring, jboolean); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_mdc_log_options + * Signature: (J[Z)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Pget_1mdc_1log_1options +(JNIEnv *, jclass, jlong, jbooleanArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_append_flush + * Signature: (JI[JLjava/lang/Object;Ljava/lang/Object;)V + */ +JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Pset_1append_1flush + (JNIEnv*, jclass, jlong, jint, jlongArray, jobject, jobject); + +/* + * Class: hdf_hdf5lib_H5 * Method: _H5Pcreate_class_nocb * Signature: (JLjava/lang/String;)J */ diff --git a/java/src/jni/h5tImp.c b/java/src/jni/h5tImp.c index 1f587de..83882a0 100644 --- a/java/src/jni/h5tImp.c +++ b/java/src/jni/h5tImp.c @@ -1386,9 +1386,9 @@ Java_hdf_hdf5lib_H5_H5Tis_1variable_1str(JNIEnv *env, jclass clss, jlong type_id /* * Class: hdf_hdf5lib_H5 * Method: H5Tget_native_type - * Signature: (JI)J + * Signature: (JI)I */ -JNIEXPORT jlong JNICALL +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5__1H5Tget_1native_1type(JNIEnv *env, jclass clss, jlong type_id, jint direction) { hid_t native_tid = -1; @@ -1398,7 +1398,7 @@ Java_hdf_hdf5lib_H5__1H5Tget_1native_1type(JNIEnv *env, jclass clss, jlong type_ if (native_tid < 0) h5libraryError(env); - return (jlong)native_tid; + return (jint)native_tid; } /* end Java_hdf_hdf5lib_H5__1H5Tget_1native_1type */ /* diff --git a/java/src/jni/h5tImp.h b/java/src/jni/h5tImp.h index 9755a91..f9e6985 100644 --- a/java/src/jni/h5tImp.h +++ b/java/src/jni/h5tImp.h @@ -498,9 +498,9 @@ JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Tis_1variable_1str /* * Class: hdf_hdf5lib_H5 * Method: H5Tget_native_type - * Signature: (JI)J + * Signature: (JI)I */ -JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Tget_1native_1type +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5__1H5Tget_1native_1type (JNIEnv *, jclass, jlong, jint); /* diff --git a/java/test/CMakeLists.txt b/java/test/CMakeLists.txt index 2632b18..949eb05 100644 --- a/java/test/CMakeLists.txt +++ b/java/test/CMakeLists.txt @@ -16,6 +16,7 @@ set (HDF5_JAVA_TEST_SRCS TestH5Fparams.java TestH5Fbasic.java TestH5F.java + TestH5Fswmr.java TestH5Gbasic.java TestH5G.java TestH5Giterate.java diff --git a/java/test/JUnit-interface.txt b/java/test/JUnit-interface.txt index f065dd4..5847198 100644 --- a/java/test/JUnit-interface.txt +++ b/java/test/JUnit-interface.txt @@ -93,6 +93,7 @@ JUnit version 4.11 .testH5Fget_intent_rdonly .testH5Fget_create_plist .testH5Fget_obj_count +.testH5Fstart_swmr_write .testH5Gget_info_by_name_not_exists .testH5Gget_info_by_idx_not_exists .testH5Gget_info_by_name @@ -490,6 +491,7 @@ JUnit version 4.11 .testH5P_fapl_family .testH5P_chunk_cache .testH5P_meta_block_size +.testH5Fmdc_logging .testH5Pget_elink_fapl .testH5Pset_mdc_config .testH5P_small_data_block_size @@ -626,7 +628,7 @@ JUnit version 4.11 Time: XXXX -OK (624 tests) +OK (626 tests) HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #000: (file name) line (number) in H5Fopen(): can't set access and transfer property lists diff --git a/java/test/Makefile.am b/java/test/Makefile.am index 1cb41df..2c960ee 100644 --- a/java/test/Makefile.am +++ b/java/test/Makefile.am @@ -43,6 +43,7 @@ noinst_JAVA = \ TestH5Fparams.java \ TestH5Fbasic.java \ TestH5F.java \ + TestH5Fswmr.java \ TestH5Gbasic.java \ TestH5G.java \ TestH5Giterate.java \ diff --git a/java/test/TestAll.java b/java/test/TestAll.java index e3abe21..a4b44c3 100644 --- a/java/test/TestAll.java +++ b/java/test/TestAll.java @@ -23,7 +23,7 @@ import org.junit.runners.Suite; TestH5Eregister.class, TestH5Edefault.class, TestH5E.class, - TestH5Fparams.class, TestH5Fbasic.class, TestH5F.class, + TestH5Fparams.class, TestH5Fbasic.class, TestH5F.class, TestH5Fswmr.class, TestH5Gbasic.class, TestH5G.class, TestH5Giterate.class, TestH5Sbasic.class, TestH5S.class, TestH5Tparams.class, TestH5Tbasic.class, TestH5T.class, diff --git a/java/test/TestH5Fswmr.java b/java/test/TestH5Fswmr.java new file mode 100644 index 0000000..21c3642 --- /dev/null +++ b/java/test/TestH5Fswmr.java @@ -0,0 +1,93 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.io.File; + +import hdf.hdf5lib.H5; +import hdf.hdf5lib.HDF5Constants; +import hdf.hdf5lib.exceptions.HDF5LibraryException; + +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TestName; + +public class TestH5Fswmr { + @Rule public TestName testname = new TestName(); + private static final String H5_FILE = "testswmr.h5"; + + long H5fid = -1; + long H5fapl = -1; + long H5fcpl = -1; + + private final void _deleteFile(String filename) { + File file = new File(filename); + + if (file.exists()) { + try {file.delete();} catch (SecurityException e) {} + } + } + + @Before + public void createH5file() + throws HDF5LibraryException, NullPointerException { + assertTrue("H5 open ids is 0",H5.getOpenIDCount()==0); + System.out.print(testname.getMethodName()); + + H5fapl = H5.H5Pcreate(HDF5Constants.H5P_FILE_ACCESS); + H5fcpl = H5.H5Pcreate(HDF5Constants.H5P_FILE_CREATE); + H5.H5Pset_libver_bounds(H5fapl, HDF5Constants.H5F_LIBVER_LATEST, HDF5Constants.H5F_LIBVER_LATEST); + + H5fid = H5.H5Fcreate(H5_FILE, HDF5Constants.H5F_ACC_TRUNC, H5fcpl, H5fapl); + H5.H5Fflush(H5fid, HDF5Constants.H5F_SCOPE_LOCAL); + } + + @After + public void deleteH5file() throws HDF5LibraryException { + if (H5fapl > 0) { + try {H5.H5Pclose(H5fapl);} catch (Exception ex) {} + H5fapl = -1; + } + if (H5fcpl > 0) { + try {H5.H5Pclose(H5fcpl);} catch (Exception ex) {} + H5fcpl = -1; + } + if (H5fid > 0) { + try {H5.H5Fclose(H5fid);} catch (Exception ex) {} + H5fid = -1; + } + _deleteFile(H5_FILE); + System.out.println(); + } + + @Test + public void testH5Fstart_swmr_write() { + long plist = -1; + + try { + H5.H5Fstart_swmr_write(H5fid); + } + catch (Throwable err) { + fail("H5.H5Fstart_swmr_write: " + err); + } + } +} diff --git a/java/test/TestH5Pfapl.java b/java/test/TestH5Pfapl.java index 555afe0..e888e20 100644 --- a/java/test/TestH5Pfapl.java +++ b/java/test/TestH5Pfapl.java @@ -16,6 +16,7 @@ package test; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -1322,4 +1323,59 @@ public class TestH5Pfapl { } } } + + @Test + public void testH5Fmdc_logging() { + boolean[] mdc_logging_status = {false, false}; + boolean[] mdc_log_options = {false, false}; + + try { + boolean is_enabled = true; + boolean start_on_access = false; + H5.H5Pset_mdc_log_options(fapl_id, is_enabled, H5_LOG_FILE, start_on_access); + + String location = H5.H5Pget_mdc_log_options(fapl_id, mdc_log_options); + assertTrue("H5.H5Pget_mdc_log_options: is_enabled", mdc_log_options[0]); + assertFalse("H5.H5Pget_mdc_log_options: start_on_access_out", mdc_log_options[1]); + + H5.H5Pset_libver_bounds(fapl_id, HDF5Constants.H5F_LIBVER_LATEST, HDF5Constants.H5F_LIBVER_LATEST); + } + catch (Throwable err) { + err.printStackTrace(); + fail("mdc_log_option: " + err); + } + _createH5File(fapl_id); + + try { + H5.H5Fget_mdc_logging_status(H5fid, mdc_logging_status); + } + catch (Throwable err) { + fail("H5.H5Fget_mdc_logging_status: " + err); + } + assertTrue("initial: is_enabled", mdc_logging_status[0]); + assertFalse("initial: is_currently_logging", mdc_logging_status[1]); + + try { + H5.H5Fstart_mdc_logging(H5fid); + H5.H5Fget_mdc_logging_status(H5fid, mdc_logging_status); + } + catch (Throwable err) { + fail("start H5.H5Fget_mdc_logging_status: " + err); + } + assertTrue("start: is_enabled", mdc_logging_status[0]); + assertTrue("start: is_currently_logging", mdc_logging_status[1]); + + try { + H5.H5Fstop_mdc_logging(H5fid); + H5.H5Fget_mdc_logging_status(H5fid, mdc_logging_status); + } + catch (Throwable err) { + fail("stop H5.H5Fget_mdc_logging_status: " + err); + } +// assertFalse("stop: is_enabled", mdc_logging_status[0]); + assertFalse("stop: is_currently_logging", mdc_logging_status[1]); + + deleteH5file(); + _deleteLogFile(); + } } |