• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            面對(duì)現(xiàn)實(shí),超越自己
            逆水行舟,不進(jìn)則退
            posts - 269,comments - 32,trackbacks - 0
            1、元數(shù)據(jù)(Metadata):維護(hù)HDFS文件系統(tǒng)中文件和目錄的信息,分為內(nèi)存元數(shù)據(jù)和元數(shù)據(jù)文件兩種。NameNode維護(hù)整個(gè)元數(shù)據(jù)。
            HDFS實(shí)現(xiàn)時(shí),沒(méi)有采用定期導(dǎo)出元數(shù)據(jù)的方法,而是采用元數(shù)據(jù)鏡像文件(FSImage)+日子文件(edits)的備份機(jī)制。
            2、Block:文件內(nèi)容而言。
            尋路徑流程:
                      路徑信息                         bocks[]                                   triplets[]          
            Client ------------》INode---------------------》BlockInfo --------------------------》DataNode。
            INode:文件的基本元素:文件和目錄
            BlockInfo: 文件內(nèi)容對(duì)象
            DatanodeDescriptor:具體存儲(chǔ)對(duì)象。
            3 、 FSImage和edits的checkPoint。FSImage有2個(gè)狀態(tài),分別是FsImage和FsImage.ckpt,后者表示正在checkpoint的過(guò)程中,上傳后將會(huì)修改為FSImage文件,同理edits也有兩個(gè)狀態(tài),edits和edits.new。
            4、NameNode format情景分析:
            • 遍歷元數(shù)據(jù)存儲(chǔ)目錄,提示用戶(hù)是否格式化?(NameNode.java里format函數(shù))
            1. private static boolean format( Configuration conf ,  
            2.                                 boolean isConfirmationNeeded )  
            3.       throws IOException {  
            4.     Collection<URI > dirsToFormat = FSNamesystem. getNamespaceDirs(conf );  
            5.     Collection<URI > editDirsToFormat =  
            6.                  FSNamesystem .getNamespaceEditsDirs (conf );  
            7.     for( Iterator< URI> it = dirsToFormat.iterator (); it. hasNext() ;) {  
            8.       File curDir = new File (it .next (). getPath()) ;  
            9.       if (! curDir. exists())  
            10.         continue;  
            11.       if (isConfirmationNeeded ) {  
            12.         System .err .print ("Re-format filesystem in " + curDir + " ? (Y or N) ");  
            13.         if (! (System .in .read () == 'Y')) {  
            14.           System .err .println ("Format aborted in " + curDir );  
            15.           return true ;  
            16.         }  
            17.         while(System .in .read () != '\n') ; // discard the enter-key  
            18.       }  
            19.     }  
            20.   
            21.     FSNamesystem nsys = new FSNamesystem (new FSImage(dirsToFormat ,  
            22.                                          editDirsToFormat ), conf) ;  
            23.     nsys.dir.fsImage .format ();  
            24.     return false;  
            25.   }  
            • 創(chuàng)建元數(shù)據(jù)內(nèi)存鏡像,包括類(lèi)FSNamesystem實(shí)例化對(duì)象,類(lèi)FSDirectory實(shí)例化對(duì)象,類(lèi)FSImage對(duì)象,類(lèi)Edits對(duì)象。創(chuàng)建FsNameSystem對(duì)象主要完成:BlockManager,F(xiàn)SDirectory對(duì)象以及初始化成員變量。FSImage對(duì)象主要完成對(duì)layoutVersion、namespaceID,CTime賦值為0,實(shí)例化FSEditLog。在類(lèi)FSDirectory,創(chuàng)建了HDFS根目錄節(jié)點(diǎn)rootDir。
            1. FSNamesystem( FSImage fsImage, Configuration conf ) throws IOException {  
            2.     this. blockManager = new BlockManager (this, conf) ;  
            3.     setConfigurationParameters (conf );  
            4.     this. dir = new FSDirectory(fsImage , this, conf );  
            5.     dtSecretManager = createDelegationTokenSecretManager (conf );  
            6.   }  
            7.   
            8.   FSImage( Collection< URI> fsDirs , Collection< URI> fsEditsDirs )  
            9.       throws IOException {  
            10.     this() ;  
            11.     setStorageDirectories( fsDirs, fsEditsDirs );  
            12.   }  
            13.   
            14.  void setStorageDirectories(Collection <URI > fsNameDirs,  
            15.                              Collection< URI> fsEditsDirs ) throws IOException {  
            16.     this. storageDirs = new ArrayList <StorageDirectory >() ;  
            17.     this. removedStorageDirs = new ArrayList <StorageDirectory >() ;  
            18.      
            19.    // Add all name dirs with appropriate NameNodeDirType  
            20.     for (URI dirName : fsNameDirs ) {  
            21.       checkSchemeConsistency (dirName );  
            22.       boolean isAlsoEdits = false;  
            23.       for (URI editsDirName : fsEditsDirs) {  
            24.         if (editsDirName .compareTo (dirName ) == 0) {  
            25.           isAlsoEdits = true;  
            26.           fsEditsDirs .remove (editsDirName );  
            27.           break;  
            28.         }  
            29.       }  
            30.       NameNodeDirType dirType = (isAlsoEdits ) ?  
            31.                           NameNodeDirType .IMAGE_AND_EDITS :  
            32.                           NameNodeDirType .IMAGE ;  
            33.       // Add to the list of storage directories, only if the  
            34.       // URI is of type file://  
            35.       if(dirName .getScheme (). compareTo( JournalType.FILE .name (). toLowerCase())  
            36.           == 0){  
            37.         this.addStorageDir (new StorageDirectory(new File(dirName. getPath()) ,  
            38.             dirType ));  
            39.       }  
            40.     }  
            41.      
            42.     // Add edits dirs if they are different from name dirs  
            43.     for (URI dirName : fsEditsDirs ) {  
            44.       checkSchemeConsistency (dirName );  
            45.       // Add to the list of storage directories, only if the  
            46.       // URI is of type file://  
            47.       if(dirName .getScheme (). compareTo( JournalType.FILE .name (). toLowerCase())  
            48.           == 0)  
            49.         this.addStorageDir (new StorageDirectory(new File(dirName. getPath()) ,  
            50.                     NameNodeDirType .EDITS ));  
            51.     }  
            52.   }  
            • 對(duì)內(nèi)存鏡像數(shù)據(jù)中的數(shù)據(jù)結(jié)構(gòu)進(jìn)行初始化:主要有FSImage的format函數(shù)完成,layoutVersion:軟件所處的版本。namespaceID:在Format時(shí)候產(chǎn)生,當(dāng)data node注冊(cè)到Name Node后,會(huì)獲得該NameNode的NameSpaceID,并作為后續(xù)與NameNode通訊的身份標(biāo)識(shí)。對(duì)于未知身份的Data Node,NameNode拒絕通信。CTime:表示FSimage產(chǎn)生的時(shí)間。checkpointTime:表示NameSpace第一次checkpoint的時(shí)間。  
            1. public void format () throws IOException {  
            2.    this. layoutVersion = FSConstants .LAYOUT_VERSION ;  
            3.    this. namespaceID = newNamespaceID ();  
            4.    this. cTime = 0L ;  
            5.    this. checkpointTime = FSNamesystem .now ();  
            6.    for (Iterator <StorageDirectory > it =  
            7.                           dirIterator (); it. hasNext() ;) {  
            8.      StorageDirectory sd = it .next ();  
            9.      format (sd );  
            10.    }  
            11.  }  
            • 對(duì)內(nèi)存鏡像寫(xiě)入元數(shù)據(jù)備份目錄。FSImage的format方法會(huì)遍歷所有的目錄進(jìn)行備份。如果是FSImage的文件目錄,則調(diào)用saveFSImage保存FSImage,如果是Edits,則調(diào)用editLog.createEditLogFile,最后調(diào)用sd.write方法創(chuàng)建fstime和VERSION文件。VERSION文件通常最后寫(xiě)入。
            1. void format(StorageDirectory sd ) throws IOException {  
            2.     sd.clearDirectory (); // create currrent dir  
            3.     sd.lock ();  
            4.     try {  
            5.       saveCurrent (sd );  
            6.     } finally {  
            7.       sd .unlock ();  
            8.     }  
            9.     LOG.info ("Storage directory " + sd. getRoot()  
            10.              + " has been successfully formatted.");  
            11.   }  
            最后分析一下元數(shù)據(jù)應(yīng)用的場(chǎng)景:
            1、格式化時(shí)。
            2、Hadoop啟動(dòng)時(shí)。
            3、元數(shù)據(jù)更新操作時(shí)。
            4、如果NameNode與Secondary NameNode、Backup Node或checkpoint Node配合使用時(shí),會(huì)進(jìn)行checkPoint操作。

            本文轉(zhuǎn)自:
            http://blog.csdn.net/kntao/article/details/7769199
            posted on 2013-05-24 15:18 王海光 閱讀(1026) 評(píng)論(0)  編輯 收藏 引用 所屬分類(lèi): Linux
            激情五月综合综合久久69| 精品国产福利久久久| 久久精品国产亚洲Aⅴ香蕉| 久久精品成人| 少妇久久久久久被弄高潮| 久久精品国产久精国产思思| 国产精自产拍久久久久久蜜| 伊人久久亚洲综合影院| 国产成人精品免费久久久久| 婷婷综合久久中文字幕| 中文字幕久久久久人妻| 97精品伊人久久久大香线蕉 | 一本久久a久久精品亚洲| 久久久久亚洲AV无码永不| 欧美777精品久久久久网| 久久天天躁狠狠躁夜夜不卡| 2021国产成人精品久久| 久久人人爽人人爽人人片AV麻烦| 日本久久久久久中文字幕| 亚洲精品乱码久久久久久自慰| 国内精品伊人久久久久影院对白| 亚洲AV日韩精品久久久久| 亚洲欧洲精品成人久久奇米网| 久久国产精品久久久| 精品国际久久久久999波多野 | 激情伊人五月天久久综合| 久久综合色老色| 综合久久一区二区三区| 欧美一级久久久久久久大片| 91亚洲国产成人久久精品| 久久精品视频网| 99久久精品国产一区二区| 久久综合88熟人妻| 狼狼综合久久久久综合网| 亚洲乱码精品久久久久..| 人妻丰满AV无码久久不卡 | 伊人色综合久久天天网| 亚洲精品乱码久久久久久不卡| 久久久综合香蕉尹人综合网| 久久本道久久综合伊人| 一本久久综合亚洲鲁鲁五月天亚洲欧美一区二区 |