按包的順序類的順序來吧,因為我不懂hadoop類的具體體系和類之間的聯系,如果有一定知識積累的可以看下別人寫的hadoop源碼解讀類的書,類似的有 http://pan.baidu.com/s/1i3GGvvZ 。我看的模模糊糊,因為沒基礎。
這個包下面只有一個類 HadoopVersionAnnotation,它是一個注釋類
1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 *10 * http://www.apache.org/licenses/LICENSE-2.011 *12 * Unless required by applicable law or agreed to in writing, software13 * distributed under the License is distributed on an "AS IS" BASIS,14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either exPRess or implied.15 * See the License for the specific language governing permissions and16 * limitations under the License.17 */18 19 //apache的軟件所有權聲明,意思就是說hadoop所有權是屬于apache的。在其其他產品中如tomcat中經??梢钥吹?0 21 package org.apache.hadoop;22 23 import java.lang.annotation.*;24 //只導入了Java的注釋包中的類。一是說明它沒有級聯其他hadoop類,二是說明這個類基本上就是一個注釋類了25 /**26 * A package attribute that captures the version of Hadoop that was compiled.27 */28 //意思是這是個包屬性類,當hadoop編譯的時候捕捉其版本號29 @Retention(RetentionPolicy.RUNTIME)30 @Target(ElementType.PACKAGE)31 //兩個注釋。惡補了一下后知道第一個是注釋后能讓JVM實時通過反射得到注釋信息。32 //第二個就是指定這個注釋類的目標,就是用在什么地方,具體可以用在類上、屬性上等等,這個是說這個注釋類是33 //用來注釋包的34 public @interface HadoopVersionAnnotation {35 //@interface是說這個類是個注釋類。36 /**37 * Get the Hadoop version38 * @return the version string "0.6.3-dev"39 */40 String version();41 //得到hadoop的版本號42 /**43 * Get the username that compiled Hadoop.44 */45 String user();46 //得到編譯這個hadoop類時的所屬用戶47 /**48 * Get the date when Hadoop was compiled.49 * @return the date in unix 'date' format50 */51 String date();52 //當hadoop編譯的時候得到時間,而且是unix格式的時間53 /**54 * Get the url for the subversion repository.55 */56 String url();57 //得到SVN版本庫的地址58 /**59 * Get the subversion revision.60 * @return the revision number as a string (eg. "451451")61 */62 String revision();63 //得到SVN版本庫的補丁號64 }
可以看來這個注釋類作用體現在編譯hadoop的時候。
其中JDK注釋類的用法我也是惡補了一下才開始的。推薦 http://blog.csdn.net/foamflower/article/details/5946451,講的很清楚。
這個類我翻譯了一下另外一種格式,或許能看的更清楚。
1 package org.apache.hadoop; 2 3 import java.lang.annotation.*; 4 5 @Retention(RetentionPolicy.RUNTIME) 6 @Target(ElementType.PACKAGE) 7 public class HadoopVersionAnnotation extends java.lang.annotation.Annotation{ 8 9 private String version;10 11 public void setVersion(String version) {12 this.version = version;13 }14 public String getVersion{15 return version;16 }17 18 private String user;19 20 public void setUser(String user) {21 this.user = user;22 }23 public String getUser{24 return user;25 }26 27 private String date;28 29 public void setDate(String date) {30 this.date = date;31 }32 public String getDate{33 return date;34 }35 36 private String url;37 38 public void setUrl(String url) {39 this.url = url;40 }41 public String getUrl{42 return url;43 }44 45 private String revision;46 47 public void setRevision(String revision) {48 this.revision = revision;49 }50 public String getRevision{51 return revision;52 }53 54 }
在apihome.cn中因為hadoop版本不同多一個屬性:
大概是hash之類的,用來校驗的吧。不跟蹤,繼續hadoop1.1.0吧。
這里吐槽一下在apihome.cn中,因為沒有搜索框,并且排序都是按首字母排的,很多類分了很多頁,找起來很不方便。所以一個比較簡單的方法就是直接訪問,比如你要查看hadoop的
hadoopVersionAnnotation這個類,就訪問 http://www.apihome.cn/api/hadoop/HadoopVersionAnnotation.html這個地址,就找到了。
還有一個網址想推薦一下,是在讀hadoop實戰的時候得到的。里面干貨不多,但是有幾個mapreduce問題并且可以提交答案并驗證,類似藍橋。這對于我這種想找實戰環境的hadoop菜鳥來說挺不錯的。
http://cloudcomputing.ruc.edu.cn
希望大牛們多吐槽一下,謝謝。
新聞熱點
疑難解答