diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index ebc20081be0..ffcef6dbd7c 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -161,6 +161,8 @@ Release 2.0.1-alpha - UNRELEASED HDFS-3666. Plumb more exception messages to terminate. (eli) + HDFS-3673. libhdfs: fix some compiler warnings. (Colin Patrick McCabe via eli) + OPTIMIZATIONS HDFS-2982. Startup performance suffers when there are many edit log diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/hdfs.c b/hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/hdfs.c index acbda54dfe9..592f6807816 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/hdfs.c +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/hdfs.c @@ -275,7 +275,7 @@ done: */ static int jStrToCstr(JNIEnv *env, jstring jstr, char **cstr) { - char *tmp; + const char *tmp; tmp = (*env)->GetStringUTFChars(env, jstr, NULL); *cstr = strdup(tmp); @@ -632,7 +632,7 @@ done: if (ret) errno = ret; - return gFsRef; + return (hdfsFS)gFsRef; } int hdfsDisconnect(hdfsFS fs) @@ -667,7 +667,7 @@ int hdfsDisconnect(hdfsFS fs) } //Release unnecessary references - (*env)->DeleteGlobalRef(env, fs); + (*env)->DeleteGlobalRef(env, jFS); return 0; } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/hdfs.h b/hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/hdfs.h index d5cef6e84a9..8da21ab7956 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/hdfs.h +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/hdfs.h @@ -81,15 +81,6 @@ extern "C" { */ int hdfsFileIsOpenForWrite(hdfsFile file); - /** - * Disable the direct read optimization for a file. - * - * This is mainly provided for unit testing purposes. - * - * @param file The HDFS file - */ - void hdfsFileDisableDirectRead(hdfsFile file); - /** * hdfsConnectAsUser - Connect to a hdfs file system as a specific user * Connect to the hdfs. @@ -101,7 +92,6 @@ extern "C" { */ hdfsFS hdfsConnectAsUser(const char* nn, tPort port, const char *user); - /** * hdfsConnect - Connect to a hdfs file system. * Connect to the hdfs. diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/hdfs_test.h b/hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/hdfs_test.h index ec59ba3367b..b3ff4f2a637 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/hdfs_test.h +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/hdfs_test.h @@ -19,7 +19,7 @@ #ifndef LIBHDFS_HDFS_TEST_H #define LIBHDFS_HDFS_TEST_H -struct hdfs_internal; +struct hdfsFile_internal; /** * Some functions that are visible only for testing. @@ -38,7 +38,16 @@ extern "C" { * @return 1 if the file is using the direct read optimization, * 0 otherwise. */ - int hdfsFileUsesDirectRead(struct hdfs_internal *file); + int hdfsFileUsesDirectRead(struct hdfsFile_internal *file); + + /** + * Disable the direct read optimization for a file. + * + * This is mainly provided for unit testing purposes. + * + * @param file The HDFS file + */ + void hdfsFileDisableDirectRead(struct hdfsFile_internal *file); #ifdef __cplusplus } #endif diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/jni_helper.c b/hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/jni_helper.c index 6978655893e..97f92942f9c 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/jni_helper.c +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/jni_helper.c @@ -550,7 +550,8 @@ JNIEnv* getJNIEnv(void) ret = pthread_key_create(&gTlsKey, hdfsThreadDestructor); if (ret) { pthread_mutex_unlock(&jvmMutex); - fprintf("pthread_key_create failed with error %d\n", ret); + fprintf(stderr, "getJNIEnv: pthread_key_create failed with " + "error %d\n", ret); return NULL; } gTlsKeyInitialized = 1; @@ -569,7 +570,7 @@ JNIEnv* getJNIEnv(void) } tls = calloc(1, sizeof(struct hdfsTls)); if (!tls) { - fprintf(stderr, "getJNIEnv: OOM allocating %d bytes\n", + fprintf(stderr, "getJNIEnv: OOM allocating %zd bytes\n", sizeof(struct hdfsTls)); return NULL; } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/test/test_libhdfs_read.c b/hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/test/test_libhdfs_read.c index 423f703e1cc..464a4d142ff 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/test/test_libhdfs_read.c +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/test/test_libhdfs_read.c @@ -35,7 +35,6 @@ int main(int argc, char **argv) { } const char* rfile = argv[1]; - tSize fileTotalSize = strtoul(argv[2], NULL, 10); tSize bufferSize = strtoul(argv[3], NULL, 10); hdfsFile readFile = hdfsOpenFile(fs, rfile, O_RDONLY, bufferSize, 0, 0); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/test_libhdfs_threaded.c b/hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/test_libhdfs_threaded.c index 5c404266ade..e96daa9ed64 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/test_libhdfs_threaded.c +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/native/libhdfs/test_libhdfs_threaded.c @@ -25,6 +25,7 @@ #include #include #include +#include #define TLH_MAX_THREADS 100