Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

Switch to Threaded View
HDFS >> mail # dev >> hdfs.h C API


Copy link to this message
-
Re: hdfs.h C API
Hi!,

Assuming you have a "hadoop" command available (i.e. the
$HADOOP_HOME/bin/hadoop script), try to do:

export CLASSPATH=`hadoop classpath`

And then try to run your ./a.out.

Does this help?

Also, user questions may go to [EMAIL PROTECTED]. The
[EMAIL PROTECTED] is for Apache HDFS project
developer/development discussions alone. I've moved your thread to the
proper place.

On Thu, Feb 28, 2013 at 4:59 PM, Philip Herron <[EMAIL PROTECTED]> wrote:
> Hey all
>
> I am trying to use the c api to access hdfs:
>
> #include <stdio.h>
> #include <stdlib.h>
>
> #include <string.h>
> #include <assert.h>
>
> #include <hdfs.h>
>
> int main (int argc, char ** argv)
> {
>   hdfsFS fs = hdfsConnect ("default", 0);
>   assert (fs);
>
>   const char * wp = "test";
>   hdfsFile wf = hdfsOpenFile (fs, wp, O_WRONLY | O_CREAT,
>                               0, 0, 0);
>   if (!wf)
>     {
>       fprintf (stderr, "Failed to open %s for writing!\n", wp);
>       exit (-1);
>     }
>
>   const char * buffer = "Hello, World!";
>   tSize num_written_bytes = hdfsWrite (fs, wf, (void *) buffer,
>                                        strlen (buffer) + 1);
>   assert (num_written_bytes);
>   if (hdfsFlush (fs, wf))
>     {
>       fprintf (stderr, "Failed to 'flush' %s\n", wp);
>       exit (-1);
>     }
>   hdfsCloseFile(fs, wf);
>
>   return 0;
> }
>
> --
>
> gcc t.c -lhdfs -lpthread -L/usr/java/default/lib/amd64/server -ljvm -Wall
>
> But i am getting:
>
> Environment variable CLASSPATH not set!
> getJNIEnv: getGlobalJNIEnv failed
> a.out: t.c:12: main: Assertion `fs' failed.
> Aborted
>
> Not sure what i need to do now to get this example working.
>
> --Phil

--
Harsh J
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB