简体   繁体   English

Hadoop HDFS Java客户端用法

[英]Hadoop HDFS java client usage

I have a java application which needs to read and write files to HDFS. 我有一个Java应用程序,需要读取和写入文件到HDFS。 I do use FileSystem fs = FileSystem.get(configuration); 我确实使用FileSystem fs = FileSystem.get(configuration);

And it works well. 而且效果很好。

Now the question is : should I keep this reference and use it as a singleton or should I use it only once and get a new one each time? 现在的问题是:我应该保留此引用并将其作为单例使用,还是仅使用一次并每次获取一个新的引用?

If it matters, I need to say that the application targets a quite high traffic. 如果重要的话,我需要说该应用程序针对的流量很高。

Thanks 谢谢

I think the answer depends on relation of two numbers - network bandwidth (between HDFS client and HDFS cluster) and amount of data per second you can feed to HDFS client. 我认为答案取决于两个数字的关系-网络带宽(HDFS客户端和HDFS群集之间)和每秒可以馈入HDFS客户端的数据量。 If first is higher - then having a few connections in the same time makes sense. 如果第一个更高-那么同时具有几个连接是有意义的。
Usually 2-3 concurrent connections are optimal 通常,2-3个并发连接是最佳的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM