有没有一种方法可以使用webhdfs restapi检查文件是否存在?

zwghvu4y  于 2021-06-01  发布在  Hadoop
关注(0)|答案(1)|浏览(430)

有没有办法通过webhdfsrestapi检查hdfs路径上是否存在同名文件?
我的示例url:

http://my-sample-url:port/webhdfs/v15/tmp/mydata/sample.txt?op=CREATE&user.name=john&namenoderpcaddress=prodaddress&createflag=&createparent=true&overwrite=false

我正在通过httpclient应用程序调用这个api。如何检查hdfs路径上是否存在同名文件,以便决定进一步处理?
我在找单线解决方案。

dohp0rv5

dohp0rv51#

您可以使用getfilestatus rest调用检查文件是否存在。 http://[HOST]:[PORT]/webhdfs/v1/<PATH>?op=GETFILESTATUS 供参考:https://hadoop.apache.org/docs/r1.0.4/webhdfs.html#getfilestatus

相关问题