• 源码-hadoop1.1.0-core-org.apache.hadoop



    按包的顺序类的顺序来吧,因为我不懂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.0
    11  *
    12  * Unless required by applicable law or agreed to in writing, software
    13  * 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 and
    16  * 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 version
    38    * @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' format
    50    */
    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


    希望大牛们多吐槽一下,谢谢。


    欲为大树,何与草争;心若不动,风又奈何。
  • 相关阅读:
    HDU 1509 Windows Message Queue
    sql批量更换dedecms文章来源和作者
    dedecms织梦网站时间标签strftime和MyDate解析
    JS代码站原创DEDECMS教程插件系列
    DEDECMS织梦自定义表单中必填项、电话邮箱过滤以及验证码规则
    dedecms标签(tags)页面伪静态设置
    dedecms几个小技巧
    dedecms 5.7 网站搬家后产生的问题记录
    dedecms织梦做中英文(多语言)网站步骤详解
    DedeCMS系统设置说明:站点设置
  • 原文地址:https://www.cnblogs.com/admln/p/hadoop.html
Copyright © 2020-2023  润新知