Browse Source

HADOOP-3968. Fix getFileBlockLocations calls to use FileStatus instead of Path reflecting the new API. (Pete Wyckoff via lohit)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/trunk@692700 13f79535-47bb-0310-9956-ffa450edef68
Lohit Vijaya Renu 17 years ago
parent
commit
87c6ef0643
2 changed files with 23 additions and 3 deletions
  1. 3 0
      CHANGES.txt
  2. 20 3
      src/c++/libhdfs/hdfs.c

+ 3 - 0
CHANGES.txt

@@ -472,6 +472,9 @@ Trunk (unreleased changes)
     HADOOP-4078. Create test files for TestKosmosFileSystem in separate
     directory under test.build.data. (lohit)
 
+    HADOOP-3968. Fix getFileBlockLocations calls to use FileStatus instead
+    of Path reflecting the new API. (Pete Wyckoff via lohit)
+
 Release 0.18.1 - Unreleased
 
   BUG FIXES

+ 20 - 3
src/c++/libhdfs/hdfs.c

@@ -1191,6 +1191,20 @@ hdfsGetHosts(hdfsFS fs, const char* path, tOffset start, tOffset length)
         return NULL;
     }
 
+    jvalue jFSVal;
+    jthrowable jFSExc = NULL;
+    if (invokeMethod(env, &jFSVal, &jFSExc, INSTANCE, jFS,
+                     HADOOP_FS, "getFileStatus", 
+                     "(Lorg/apache/hadoop/fs/Path;)"
+                     "Lorg/apache/hadoop/fs/FileStatus;",
+                     jPath) != 0) {
+        errno = errnoFromException(jFSExc, env, "org.apache.hadoop.fs."
+                                   "FileSystem::getFileStatus");
+        destroyLocalReference(env, jPath);
+        return NULL;
+    }
+    jobject jFileStatus = jFSVal.l;
+
     //org.apache.hadoop.fs.FileSystem::getFileBlockLocations
     char*** blockHosts = NULL;
     jobjectArray jBlockLocations;;
@@ -1198,12 +1212,13 @@ hdfsGetHosts(hdfsFS fs, const char* path, tOffset start, tOffset length)
     jthrowable jExc = NULL;
     if (invokeMethod(env, &jVal, &jExc, INSTANCE, jFS,
                      HADOOP_FS, "getFileBlockLocations", 
-                     "(Lorg/apache/hadoop/fs/Path;JJ)"
+                     "(Lorg/apache/hadoop/fs/FileStatus;JJ)"
                      "[Lorg/apache/hadoop/fs/BlockLocation;",
-                     jPath, start, length) != 0) {
+                     jFileStatus, start, length) != 0) {
         errno = errnoFromException(jExc, env, "org.apache.hadoop.fs."
-                                   "FileSystem::getFileCacheHints");
+                                   "FileSystem::getFileBlockLocations");
         destroyLocalReference(env, jPath);
+        destroyLocalReference(env, jFileStatus);
         return NULL;
     }
     jBlockLocations = jVal.l;
@@ -1237,6 +1252,7 @@ hdfsGetHosts(hdfsFS fs, const char* path, tOffset start, tOffset length)
             errno = errnoFromException(jExc, env, "org.apache.hadoop.fs."
                                        "BlockLocation::getHosts");
             destroyLocalReference(env, jPath);
+            destroyLocalReference(env, jFileStatus);
             destroyLocalReference(env, jBlockLocations);
             return NULL;
         }
@@ -1279,6 +1295,7 @@ hdfsGetHosts(hdfsFS fs, const char* path, tOffset start, tOffset length)
 
     //Delete unnecessary local references
     destroyLocalReference(env, jPath);
+    destroyLocalReference(env, jFileStatus);
     destroyLocalReference(env, jBlockLocations);
 
     return blockHosts;