org.apache.hadoop-hadoopVersionAnnotation

來源:互聯網
上載者:User

標籤:style   blog   http   color   io   os   ar   java   for   

按包的順序類的順序來吧,因為我不懂hadoop類的具體體系和類之間的聯絡,如果有一定知識積累的可以看下別人寫的hadoop源碼解讀類的書,類似的有 http://pan.baidu.com/s/1i3GGvvZ  。我看的模模糊糊,因為沒基礎。

 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中經常可以看到20 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

 

希望大牛們多吐槽一下,謝謝。

 

org.apache.hadoop-hadoopVersionAnnotation

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.