I am trying to access a file in HDFS using the Java API, but every time I get the file not found. The code I use for access is: -
Configuration conf = new Configuration(); conf.addResource(FileUtilConstants.ENV_HADOOP_HOME + FileUtilConstants.REL_PATH_CORE_SITE); conf.addResource(FileUtilConstants.ENV_HADOOP_HOME + FileUtilConstants.REL_PATH_HDFS_SITE); try { FileSystem fs = FileSystem.get(conf); Path hdfsfilePath = new Path(hdfsPath); logger.info("Filesystem URI : " + fs.getUri()); logger.info("Filesystem Home Directory : " + fs.getHomeDirectory()); logger.info("Filesystem Working Directory : " + fs.getWorkingDirectory()); logger.info("HDFS File Path : " + hdfsfilePath); if (!fs.exists(hdfsfilePath)) { logger.error("File does not exists : " + hdfsPath); }
And now the code is displayed from the command line.
[ root@koversevms ~]
I am new to hadoop, so I donβt know what is going wrong.
Thanks Nayan
source share