$ git clone http://git.apache.org/hadoop-common.git
$ cd hadoop-common
然而,git指令只检出了最新的Hadoop Common,即Hadoop Common开发的前沿。而我们只对代码树的Hadoop-0.20-append感兴趣,即分支branch-0.20-append。因为git默认不会从一个复制的代码库下载远端的分支,我们必须明确的指示它这样做:
# 检出Hadoop-0.20-append分支
# 只检出master tree (SVN的命令是trunk).
$ git checkout -t origin/branch-0.20-append
Branch branch-0.20-append set up to track remote branch branch-0.20-append from origin.
Switched to a new branch 'branch-0.20-append' 4.2.Hadoop-0.20.2与Hadoop-0.20-append的比较
到现在为止,你也许会问自己Hadoop的0.20.2版本和它的扩展分支到底有何分别。这就是答案:Hadoop-0.20-append分支实际上是Hadoop-0.20.2的超集。换句话说,Hadoop-0.20.2版本中没有哪一个“真正的”提交不在Hadoop-0.20-append里。这意味着Hadoop-0.20-append支持所有Hadoop-0.20.2版本的特性,棒极了!
运行以下git命令来验证这一点:
$ git show-branch release-0.20.2 branch-0.20-append
! [release-0.20.2] Hadoop 0.20.2 release
* [branch-0.20-append] HDFS-1554. New semantics for recoverLease. Contributed by Hairong Kuang.
--
* [branch-0.20-append] HDFS-1554. New semantics for recoverLease. Contributed by Hairong Kuang.
* [branch-0.20-append^] HDFS-1555. Disallow pipelien recovery if a file is already being lease recovered. Contributed by Hairong Kuang.
* [branch-0.20-append~2] Revert the change made to HDFS-1555: merge -c -1056483 https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.20-append
* [branch-0.20-append~3] HDFS-1555. Disallow pipeline recovery if a file is already being lease recovered. Contributed by Hairong Kuang.
[...]
* [branch-0.20-append~50] JDiff output for release 0.20.2
* [branch-0.20-append~51] HADOOP-1849. Merge -r 916528:916529 from trunk to branch-0.20.
+ [release-0.20.2] Hadoop 0.20.2 release
+ [release-0.20.2^] Hadoop 0.20.2-rc4
+* [branch-0.20-append~52] Prepare for 0.20.2-rc4
如你所见,Hadoop-0.20.2版本只有两个提交不在branch-0.20-append,分别叫做“Hadoop 0.20.2 release”和“Hadoop 0.20.2-rc4”。这两个提交都是简单的提交标记,即它们只是用作版本管理,而不会对Hadoop的源代码进行任何改动。 4.3.构建过程 4.3.1.构建命令
首先,我们要创建build.properties文件(见完整说明)。
这是我的文件的内容:
2011-04-06 09:40:28,666 INFO ipc.Server (Server.java:run(970)) - IPC Server handler 5 on 47574, call append(/bbw.test, DFSClient_1066000827) from 127.0.0.1:45323: error: org.apache.hadoop.hdfs.protocol.AlreadyBeingCreatedException: failed to create file /bbw.test for DFSClient_1066000827 on client 127.0.0.1, because this file is already being created by DFSClient_-95621936 on 127.0.0.1
at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.recoverLeaseInternal(FSNamesystem.java:1202)
at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.startFileInternal(FSNamesystem.java:1054)
at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.appendFile(FSNamesystem.java:1221)
at org.apache.hadoop.hdfs.server.namenode.NameNode.append(NameNode.java:396)
[...]
at org.apache.hadoop.ipc.Server$Handler.run(Server.java:955)
2011-04-06 09:40:28,667 INFO hdfs.TestFileAppend4 (TestFileAppend4.java:recoverFile(161)) - Failed open for append, waiting on lease recovery
[...]
Testcase: testRecoverFinalizedBlock took 5.555 sec
Caused an ERROR
No lease on /testRecoverFinalized File is not open for writing. Holder DFSClient_1816717192 does not have any open files.
org.apache.hadoop.hdfs.server.namenode.LeaseExpiredException: No lease on /testRecoverFinalized File is not open for writing. Holder DFSClient_1816717192 does not have any open files.
at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.checkLease(FSNamesystem.java:1439)
[...]
at org.apache.hadoop.hdfs.TestFileAppend4$1.run(TestFileAppend4.java:636)
万幸的是,这个错误并不意味着构建无法执行。我们知道这是branch-0.20-append单元测试的问题(见St.Ack对HBASE-3258的评论)。换句话说,这是个人所共知的测试错误,我们可以忽略它。咻!
偶然的,你可能发生构建失败或者构建错误。在我的机器上,举例来说,我也见过以下测试失败:
# 检验你本地的分支和官方的分支是一致的
$ git show-branch branch-0.20-append branch-0.20-append-yourbranch
! [branch-0.20-append] HDFS-1554. New semantics for recoverLease. Contributed by Hairong Kuang.
* [branch-0.20-append-yourbranch] HDFS-1554. New semantics for recoverLease. Contributed by Hairong Kuang.
--
+* [branch-0.20-append] HDFS-1554. New semantics for recoverLease. Contributed by Hairong Kuang.
# 还好,它们是一致的
将补丁应用到你的分支。在下面的例子中,我使用HDFS-611.branch-0.20-append.v1.patch文件,应用HDFS-611补丁的backport到branch-0.20-append。注意这个backport在HDFS-611页面是不存在的——我在HDFS-611的Hadoop-0.20.2版本补丁的基础上创建了它(HDFS-611.branch-20.v6.patch)。