[ 
https://issues.apache.org/jira/browse/HDFS-4712?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13644694#comment-13644694
 ] 

Colin Patrick McCabe commented on HDFS-4712:
--------------------------------------------

bq. +    dataNodeInfoList = calloc(jNumDataNodeInfos, 
sizeof(hdfsDataNodeInfo**));

Should be sizeof(hdfsDataNodeInfo*)... although it doesn't matter, since those 
pointers will be the same size :)

bq.+    dataNodeInfos->location =
+         (const char*)((*env)->GetStringUTFChars(env, jVal.l, NULL));

Need to check to make sure this didn't fail.  If it failed, an exception will 
be raised.  I suggest using {{newCStr}}, which handles the exception issues for 
you.

bq. +        dataNodeInfoList[i] = (hdfsDataNodeInfo*) 
malloc(sizeof(hdfsDataNodeInfo));

You need to check if this failed (we check all the other allocation sites.)

{code}
+    if (jExc) {
+        printExceptionAndFree( env,jExc,PRINT_EXC_ALL,
+        "org.apache.hadoop.hdfs.DistributedFileSystem::getDataNodeStats");
+        errno = EPERM;
+        goto done;
+    }
+
+
+    jobjectArray jDatanodeInfos = NULL;
{code}

Please don't use C99-style declarations after the start of the function.  They 
don't work well with gotos.  For example, in this case, if you follow that 
goto, jDatanodeInfos has undefined contents (which is likely to cause crashes 
when you try to clean up).  Put all the declarations at the top, except scoped 
declarations.
                
> New libhdfs method hdfsGetDataNodes
> -----------------------------------
>
>                 Key: HDFS-4712
>                 URL: https://issues.apache.org/jira/browse/HDFS-4712
>             Project: Hadoop HDFS
>          Issue Type: New Feature
>          Components: libhdfs
>            Reporter: andrea manzi
>         Attachments: HDFS-4712.patch, hdfs.c.diff, hdfs.h.diff
>
>
> we have implemented a possible extension to libhdfs to retrieve information 
> about the available datanodes ( there was a mail on the hadoop-hdsf-dev 
> mailing list initially abut this :
> http://mail-archives.apache.org/mod_mbox/hadoop-hdfs-dev/201204.mbox/%3CCANhO-
> s0mvororrxpjnjbql6brkj4c7l+u816xkdc+2r0whj...@mail.gmail.com%3E)
> i would like to know how to proceed to create a patch, cause on the wiki 
> http://wiki.apache.org/hadoop/HowToContribute i can see info about JAVA 
> patches but nothing related to extensions in C.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to