You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by cu...@apache.org on 2007/01/18 18:52:00 UTC
svn commit: r497513 - in /lucene/hadoop/trunk: CHANGES.txt
src/c++/libhdfs/hdfs.c
Author: cutting
Date: Thu Jan 18 09:51:59 2007
New Revision: 497513
URL: http://svn.apache.org/viewvc?view=rev&rev=497513
Log:
HADOOP-899. Update libhdfs for changes in HADOOP-871. Contributed by Sameer.
Modified:
lucene/hadoop/trunk/CHANGES.txt
lucene/hadoop/trunk/src/c++/libhdfs/hdfs.c
Modified: lucene/hadoop/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/CHANGES.txt?view=diff&rev=497513&r1=497512&r2=497513
==============================================================================
--- lucene/hadoop/trunk/CHANGES.txt (original)
+++ lucene/hadoop/trunk/CHANGES.txt Thu Jan 18 09:51:59 2007
@@ -38,6 +38,9 @@
10. HADOOP-897. Add a "javac.args" property to build.xml that permits
one to pass arbitrary options to javac. (Milind Bhandarkar via cutting)
+11. HADOOP-899. Update libhdfs for changes in HADOOP-871.
+ (Sameer Paranjpye via cutting)
+
Release 0.10.1 - 2007-01-10
Modified: lucene/hadoop/trunk/src/c++/libhdfs/hdfs.c
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/c%2B%2B/libhdfs/hdfs.c?view=diff&rev=497513&r1=497512&r2=497513
==============================================================================
--- lucene/hadoop/trunk/src/c++/libhdfs/hdfs.c (original)
+++ lucene/hadoop/trunk/src/c++/libhdfs/hdfs.c Thu Jan 18 09:51:59 2007
@@ -29,6 +29,8 @@
#define HADOOP_ISTRM "org/apache/hadoop/fs/FSDataInputStream"
#define HADOOP_OSTRM "org/apache/hadoop/fs/FSDataOutputStream"
#define JAVA_NET_ISA "java/net/InetSocketAddress"
+#define JAVA_NET_URI "java/net/URI"
+
/* Macros for constructing method signatures */
@@ -57,7 +59,8 @@
*/
static void destroyLocalReference(JNIEnv *env, jobject jObject)
{
- (*env)->DeleteLocalRef(env, jObject);
+ if (jObject)
+ (*env)->DeleteLocalRef(env, jObject);
}
@@ -102,9 +105,14 @@
// return fs;
JNIEnv *env = 0;
- jobject jConfiguration;
+ jobject jConfiguration = NULL;
jobject jFS = NULL;
+ jobject jURI = NULL;
+ jstring jURIString = NULL;
jvalue jVal;
+ char *cURI = 0;
+ jobject gFsRef = NULL;
+
//Get the JNIEnv* corresponding to current thread
env = getJNIEnv();
@@ -122,14 +130,17 @@
//Check what type of FileSystem the caller wants...
if (host == NULL) {
- //fs = new LocalFileSystem(conf);
- jFS = constructNewObjectOfClass(env, HADOOP_LOCALFS,
- JMETHOD1(JPARAM(HADOOP_CONF), "V"),
- jConfiguration);
- if (jFS == NULL) {
- errno = EINTERNAL;
- goto done;
+ // fs = FileSytem::getLocal(conf);
+ if (invokeMethod(env, &jVal, STATIC, NULL, HADOOP_FS, "getLocal",
+ JMETHOD1(JPARAM(HADOOP_CONF),
+ JPARAM(HADOOP_LOCALFS)),
+ jConfiguration) != 0) {
+ fprintf(stderr, "Call to org.apache.hadoop.fs."
+ "FileSystem::getLocal failed!\n");
+ errno = EINTERNAL;
+ goto done;
}
+ jFS = jVal.l;
}
else if (!strcmp(host, "default") && port == 0) {
//fs = FileSystem::get(conf);
@@ -146,39 +157,43 @@
jFS = jVal.l;
}
else {
- //fs = new DistributedFileSystem(new InetSocketAddress(host, port), conf)
- jstring jHostName = (*env)->NewStringUTF(env, host);
- jobject jNameNodeAddr =
- constructNewObjectOfClass(env, JAVA_NET_ISA,
- "(Ljava/lang/String;I)V",
- jHostName, port);
-
- destroyLocalReference(env, jHostName);
- if (jNameNodeAddr == NULL) {
- errno = EINTERNAL;
- goto done;
+ // fs = FileSystem::get(URI, conf);
+ cURI = malloc(strlen(host)+16);
+ sprintf(cURI, "hdfs://%s:%d", host, (int)(port));
+
+ jURIString = (*env)->NewStringUTF(env, cURI);
+ if (invokeMethod(env, &jVal, STATIC, NULL, JAVA_NET_URI,
+ "create", "(Ljava/lang/String;)Ljava/net/URI;",
+ jURIString) != 0) {
+ fprintf(stderr, "Call to java.net.URI::create failed!\n");
+ errno = EINTERNAL;
+ goto done;
}
-
- jFS = constructNewObjectOfClass(env, HADOOP_DFS,
- JMETHOD2(JPARAM(JAVA_NET_ISA),
- JPARAM(HADOOP_CONF), "V"),
- jNameNodeAddr, jConfiguration);
+ jURI = jVal.l;
- destroyLocalReference(env, jNameNodeAddr);
- if (jFS == NULL) {
- errno = EINTERNAL;
- goto done;
+ if (invokeMethod(env, &jVal, STATIC, NULL, HADOOP_FS, "get",
+ JMETHOD2(JPARAM(JAVA_NET_URI),
+ JPARAM(HADOOP_CONF), JPARAM(HADOOP_FS)),
+ jURI, jConfiguration) != 0) {
+ fprintf(stderr, "Call to org.apache.hadoop.fs."
+ "FileSystem::get(URI, Configuration) failed!\n");
+ errno = EINTERNAL;
+ goto done;
}
+
+ jFS = jVal.l;
}
done:
- //Release unnecessary local references
+ // Release unnecessary local references
destroyLocalReference(env, jConfiguration);
+ destroyLocalReference(env, jURIString);
+ destroyLocalReference(env, jURI);
- /* Create a global reference for this fs */
- jobject gFsRef = NULL;
+ if (cURI) free(cURI);
+ /* Create a global reference for this fs */
if (jFS) {
gFsRef = (*env)->NewGlobalRef(env, jFS);
destroyLocalReference(env, jFS);