Author: cdouglas
Date: Wed May 28 14:39:24 2008
New Revision: 661099
URL: http://svn.apache.org/viewvc?rev=661099&view=rev
Log:
HADOOP-3451. Update libhdfs to use FileSystem::getFileBlockLocations
instead of removed getFileCacheHints. Contributed by lohit vijayarenu.
Modified:
hadoop/core/trunk/CHANGES.txt
hadoop/core/trunk/src/c++/libhdfs/hdfs.c
Modified: hadoop/core/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/hadoop/core/trunk/CHANGES.txt?rev=661099&r1=661098&r2=661099&view=diff
==============================================================================
--- hadoop/core/trunk/CHANGES.txt (original)
+++ hadoop/core/trunk/CHANGES.txt Wed May 28 14:39:24 2008
@@ -345,6 +345,9 @@
HADOOP-3259. Makes failure to read system properties due to a
security manager non-fatal. (Edward Yoon via omalley)
+ HADOOP-3451. Update libhdfs to use FileSystem::getFileBlockLocations
+ instead of removed getFileCacheHints. (lohit vijayarenu via cdouglas)
+
Release 0.17.0 - 2008-05-18
INCOMPATIBLE CHANGES
Modified: hadoop/core/trunk/src/c++/libhdfs/hdfs.c
URL:
http://svn.apache.org/viewvc/hadoop/core/trunk/src/c%2B%2B/libhdfs/hdfs.c?rev=661099&r1=661098&r2=661099&view=diff
==============================================================================
--- hadoop/core/trunk/src/c++/libhdfs/hdfs.c (original)
+++ hadoop/core/trunk/src/c++/libhdfs/hdfs.c Wed May 28 14:39:24 2008
@@ -25,6 +25,7 @@
#define HADOOP_PATH "org/apache/hadoop/fs/Path"
#define HADOOP_LOCALFS "org/apache/hadoop/fs/LocalFileSystem"
#define HADOOP_FS "org/apache/hadoop/fs/FileSystem"
+#define HADOOP_BLK_LOC "org/apache/hadoop/fs/BlockLocation"
#define HADOOP_DFS "org/apache/hadoop/dfs/DistributedFileSystem"
#define HADOOP_ISTRM "org/apache/hadoop/fs/FSDataInputStream"
#define HADOOP_OSTRM "org/apache/hadoop/fs/FSDataOutputStream"
@@ -1118,7 +1119,7 @@
hdfsGetHosts(hdfsFS fs, const char* path, tOffset start, tOffset length)
{
// JAVA EQUIVALENT:
- // fs.getFileCacheHints(new Path(path), start, length);
+ // fs.getFileBlockLoctions(new Path(path), start, length);
//Get the JNIEnv* corresponding to current thread
JNIEnv* env = getJNIEnv();
@@ -1131,25 +1132,26 @@
return NULL;
}
- //org.apache.hadoop.fs.FileSystem::getFileCacheHints
+ //org.apache.hadoop.fs.FileSystem::getFileBlockLocations
char*** blockHosts = NULL;
- jobjectArray jFileCacheHints;
+ jobjectArray jBlockLocations;;
jvalue jVal;
if (invokeMethod(env, &jVal, INSTANCE, jFS,
- HADOOP_FS, "getFileCacheHints",
- "(Lorg/apache/hadoop/fs/Path;JJ)[[Ljava/lang/String;",
+ HADOOP_FS, "getFileBlockLocations",
+ "(Lorg/apache/hadoop/fs/Path;JJ)"
+ "[Lorg/apache/hadoop/fs/BlockLocation;",
jPath, start, length) != 0) {
fprintf(stderr, "Call to org.apache.hadoop.fs."
- "FileSystem::getFileCacheHints failed!\n");
+ "FileSystem::getFileBlockLocations failed!\n");
errno = EINTERNAL;
destroyLocalReference(env, jPath);
return NULL;
}
- jFileCacheHints = jVal.l;
+ jBlockLocations = jVal.l;
- //Figure out no of entries in jFileCacheHints
+ //Figure out no of entries in jBlockLocations
//Allocate memory and add NULL at the end
- jsize jNumFileBlocks = (*env)->GetArrayLength(env, jFileCacheHints);
+ jsize jNumFileBlocks = (*env)->GetArrayLength(env, jBlockLocations);
blockHosts = malloc(sizeof(char**) * (jNumFileBlocks+1));
if (blockHosts == NULL) {
@@ -1165,10 +1167,24 @@
//Now parse each block to get hostnames
int i = 0;
for (i=0; i < jNumFileBlocks; ++i) {
- jobjectArray jFileBlockHosts =
- (*env)->GetObjectArrayElement(env, jFileCacheHints, i);
-
- //Figure out no of entries in jFileCacheHints
+ jobject jFileBlock =
+ (*env)->GetObjectArrayElement(env, jBlockLocations, i);
+
+ jvalue jVal;
+ jobjectArray jFileBlockHosts;
+ if (invokeMethod(env, &jVal, INSTANCE, jFileBlock, HADOOP_BLK_LOC,
+ "getHosts", "()[Ljava/lang/String;") ||
+ jVal.l == NULL) {
+ fprintf(stderr, "Call to org.apache.hadoop.fs.BlockLocation::"
+ "getHosts failed!\n");
+ errno = EINTERNAL;
+ destroyLocalReference(env, jPath);
+ destroyLocalReference(env, jBlockLocations);
+ return NULL;
+ }
+
+ jFileBlockHosts = jVal.l;
+ //Figure out no of hosts in jFileBlockHosts
//Allocate memory and add NULL at the end
jsize jNumBlockHosts = (*env)->GetArrayLength(env, jFileBlockHosts);
blockHosts[i] = malloc(sizeof(char*) * (jNumBlockHosts+1));
@@ -1205,7 +1221,7 @@
//Delete unnecessary local references
destroyLocalReference(env, jPath);
- destroyLocalReference(env, jFileCacheHints);
+ destroyLocalReference(env, jBlockLocations);
return blockHosts;
}