有没有办法通过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路径上是否存在同名文件,以便决定进一步处理?
我在找单线解决方案。
1条答案
按热度按时间dohp0rv51#
您可以使用getfilestatus rest调用检查文件是否存在。
http://[HOST]:[PORT]/webhdfs/v1/<PATH>?op=GETFILESTATUS
供参考:https://hadoop.apache.org/docs/r1.0.4/webhdfs.html#getfilestatus