我正在编写一些访问HBase的代码,并且正在编写单元测试,这些单元测试将创建一个MiniDFSCluster作为测试设置的一部分。
(defn test-config [& options]
(let [testing-utility (HBaseTestingUtility.)]
(.startMiniCluster testing-utility 1)
(let [config (.getConfiguration testing-utility)]
(if (not= options nil)
(doseq [[key value] options]
(.set config key value)))
config)))
;; For those who don't read Clojure, lines 2 and 3 cause
;; the failure and are equivalent to the following Java
;;
;; HBaseTestingUtility testingUtility = new HBaseTestingUtility();
;; testingUtility.startMiniCluster(1); // blows up on Linux but not Mac OSX这在带有Java HotSpot的Mac上运行良好:
$ java -version
java version "1.6.0_51"
Java(TM) SE Runtime Environment (build 1.6.0_51-b11-457-11M4509)
Java HotSpot(TM) 64-Bit Server VM (build 20.51-b01-457, mixed mode)
$ lein test
lein test hbase.config-test
lein test hbase.table-test
2013-07-12 17:44:13.488 java[27384:1203] Unable to load realm info from SCDynamicStore
Starting DataNode 0 with dfs.data.dir: /Users/dwilliams/Desktop/Repos/mobiusinversion/hbase/target/test-data/fe0199fd-0168-48d9-98ce-b4a5e62d3257/dfscluster_bbad1095-58d1-4571-ba12-4d4f1c24203f/dfs/data/data1,/Users/dwilliams/Desktop/Repos/mobiusinversion/hbase/target/test-data/fe0199fd-0168-48d9-98ce-b4a5e62d3257/dfscluster_bbad1095-58d1-4571-ba12-4d4f1c24203f/dfs/data/data2
Cluster is active
Ran 11 tests containing 14 assertions.
0 failures, 0 errors.但是当它在Linux环境中运行时,会出现以下错误:
ERROR in (create-table) (MiniDFSCluster.java:426)
Uncaught exception, not in assertion.
expected: nil
actual: java.lang.NullPointerException: null
at org.apache.hadoop.hdfs.MiniDFSCluster.startDataNodes (MiniDFSCluster.java:426)
org.apache.hadoop.hdfs.MiniDFSCluster.<init> (MiniDFSCluster.java:284)
org.apache.hadoop.hbase.HBaseTestingUtility.startMiniDFSCluster (HBaseTestingUtility.java:444)
org.apache.hadoop.hbase.HBaseTestingUtility.startMiniCluster (HBaseTestingUtility.java:612)
org.apache.hadoop.hbase.HBaseTestingUtility.startMiniCluster (HBaseTestingUtility.java:568)
org.apache.hadoop.hbase.HBaseTestingUtility.startMiniCluster (HBaseTestingUtility.java:555)我提交了一张travis-ci的罚单,因为这是第一次在那里表现出来,我认为这可能是因为他们的环境。
https://github.com/travis-ci/travis-ci/issues/1240
然而,在与travis支持人员讨论后,我能够在CentOS上重现该错误。我在Linux上尝试了Sun和OpenJDK,两者都产生了相同的错误。这是怎么回事?这是一个微不足道的配置问题吗?也许在Mac的ENV中设置的Linux ENV中没有设置一些东西?
如果您想运行测试,请克隆存储库
https://github.com/mobiusinversion/hbase
然后运行lein测试。非常感谢您的帮助!
更新:
已提交此HBASE Jira罚单
发布于 2013-07-16 07:11:26
简而言之:在运行测试之前设置"umask 022“。
长答案:这是从HBaseTestingUtility内部使用的Hadoop1.x版本运行MiniDFSCluster的常见环境问题。它已经在Hadoop 0.22+ (包括2.0+,但目前不是1.x )中得到了有效的修复。
潜在的问题是https://issues.apache.org/jira/browse/HDFS-2556。
当MiniDFSCluster启动时,它会创建用于datanode进程的临时存储目录(配置为"dfs.data.dir")。这些将使用您当前设置的umask创建。当每个数据节点启动时,它会检查"dfs.data.dir“中配置的目录是否存在,以及目录权限是否与预期值(设置为"dfs.datanode.data.dir.perm")匹配。如果目录权限与预期值(默认情况下为“755”)不匹配,则datanode进程退出。
默认情况下,在Hadoop1.x中,此值设置为"755",因此如果您将umask设置为"022",数据目录将以正确的权限结束。但是,如果权限与预期值不匹配,datanode将中止,并且您将在测试日志文件中看到类似以下的错误:
WARN [main] datanode.DataNode(1577): Invalid directory in dfs.data.dir: Incorrect permission for /.../dfs/data/data2, expected: rwxr-xr-x, while actual: rwxrwxr-x在更高版本的Hadoop中,如果目录权限不匹配,datanode将尝试将其更改为预期值。仅当此操作失败时,datanode才会中止。HDFS-2556建议将此更改向后移植到1.x版本,但尚未修复。
https://stackoverflow.com/questions/17625938
复制相似问题