Multiples Hadoop FileSystem instances

后端 未结 2 1645
长情又很酷
长情又很酷 2021-02-06 13:12

I have a class (I removes try/catch for readability):

public class HadoopFileSystem {

    private FileSystem m_fileSystem = null;

    public HadoopFileSystem()         


        
相关标签:
2条回答
  • 2021-02-06 13:35

    You are creating an object based on a configuration which is hard-coded. This basically means that you're creating 2 identical objects. Because these objects are identical, the JVM will reference to the same object. So h1 and h2 are referencing the same object.

    The reason for this is because you're getting an existing instance of an object based on a configuration file. If the configuration is different for h1 and h2, it will not be the same instance anymore.

    0 讨论(0)
  • 2021-02-06 13:40

    m_fileSystem = FileSystem.get(l_configuration ); is a static call even if you have two different objects created. You need to find a way to not make this call static for two different objects.

    Try this out to do away with the problem,

    conf.setBoolean("fs.hdfs.impl.disable.cache", true);
    
    0 讨论(0)
提交回复
热议问题