hadoop是否在静态变量的本地和分布式模式下表现不同

时间:2015-07-28 11:14:09

标签: hadoop mapreduce

假设我在映射器中有一个分配给类变量的静态变量,静态变量的值取决于作业,因此它与在该作业的作业跟踪器节点中执行的一组输入拆分相同因此我可以直接将作业特定变量分配为我的Mapper中的静态变量(在作业跟踪器节点中运行的JVM)。

对于Some Some Job,这些值会因为它是一个不同的Job而改变,并且对于它自己的Job有不同的Class Path Variables,但我相信它不会影响前面提到的作业,因为它们在不同的JVM中运行(Jobtracker)

现在如果我在本地模式下尝试这个,上面的不同作业将在同一个JVM中运行,因此当这个不同的作业试图超过我的formar Job设置的作业特定类变量时,会导致问题为了我以前的工作。

所以我们可以说本地和分布式模式下相同代码的行为总是不一样。

我设置的类变量只是一些资源级别和分布式缓存值。

我知道用例并不好,但只是想知道这是否是静态变量时会发生的事情。

感谢。

1 个答案:

答案 0 :(得分:1)

The usage of static variables is not encouraged for the same reason you mentioned. The behavior is surely different based on the mode in which Hadoop is running. if the static is just a resource name and you are just reading it, the usage is fine. But if trying to modify, it will impact in standalone mode. Also, as you know, the standalone and psuedo is just for beginners and learning. Usecases should not dictate our learning :) Happy learning.