• <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
            97久久精品人人澡人人爽| 综合久久精品色| 久久99久久99小草精品免视看| 偷窥少妇久久久久久久久| 久久国产色AV免费看| 99久久国产综合精品五月天喷水| 日韩中文久久| 精品久久久无码人妻中文字幕豆芽| 久久精品国产色蜜蜜麻豆| 77777亚洲午夜久久多喷| 99国内精品久久久久久久| 精品国产99久久久久久麻豆| 久久精品国产久精国产| 国产欧美久久久精品影院| 国产一区二区精品久久岳| 激情伊人五月天久久综合 | 精品熟女少妇AV免费久久| 青青草国产精品久久| 伊人久久大香线蕉亚洲五月天| 国产免费福利体检区久久| 久久精品国产99久久久| 久久精品国产亚洲AV久| 午夜精品久久影院蜜桃| AA级片免费看视频久久| 精品国产一区二区三区久久| 日日噜噜夜夜狠狠久久丁香五月| 人妻少妇精品久久| 久久久网中文字幕| 精品国产综合区久久久久久| 国产精品久久久久久久久免费 | 91麻精品国产91久久久久| 色狠狠久久AV五月综合| 伊人久久大香线蕉AV色婷婷色| 综合久久一区二区三区 | 无码伊人66久久大杳蕉网站谷歌| 久久综合精品国产一区二区三区 | 91精品国产高清91久久久久久| 久久久久精品国产亚洲AV无码| 日本五月天婷久久网站| 久久久高清免费视频| 亚洲AV日韩精品久久久久 |