• <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>
            面對現實,超越自己
            逆水行舟,不進則退
            posts - 269,comments - 32,trackbacks - 0
            1、元數據(Metadata):維護HDFS文件系統中文件和目錄的信息,分為內存元數據和元數據文件兩種。NameNode維護整個元數據。
            HDFS實現時,沒有采用定期導出元數據的方法,而是采用元數據鏡像文件(FSImage)+日子文件(edits)的備份機制。
            2、Block:文件內容而言。
            尋路徑流程:
                      路徑信息                         bocks[]                                   triplets[]          
            Client ------------》INode---------------------》BlockInfo --------------------------》DataNode。
            INode:文件的基本元素:文件和目錄
            BlockInfo: 文件內容對象
            DatanodeDescriptor:具體存儲對象。
            3 、 FSImage和edits的checkPoint。FSImage有2個狀態,分別是FsImage和FsImage.ckpt,后者表示正在checkpoint的過程中,上傳后將會修改為FSImage文件,同理edits也有兩個狀態,edits和edits.new。
            4、NameNode format情景分析:
            • 遍歷元數據存儲目錄,提示用戶是否格式化?(NameNode.java里format函數)
            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.   }  
            • 創建元數據內存鏡像,包括類FSNamesystem實例化對象,類FSDirectory實例化對象,類FSImage對象,類Edits對象。創建FsNameSystem對象主要完成:BlockManager,FSDirectory對象以及初始化成員變量。FSImage對象主要完成對layoutVersion、namespaceID,CTime賦值為0,實例化FSEditLog。在類FSDirectory,創建了HDFS根目錄節點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.   }  
            • 對內存鏡像數據中的數據結構進行初始化:主要有FSImage的format函數完成,layoutVersion:軟件所處的版本。namespaceID:在Format時候產生,當data node注冊到Name Node后,會獲得該NameNode的NameSpaceID,并作為后續與NameNode通訊的身份標識。對于未知身份的Data Node,NameNode拒絕通信。CTime:表示FSimage產生的時間。checkpointTime:表示NameSpace第一次checkpoint的時間。  
            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.  }  
            • 對內存鏡像寫入元數據備份目錄。FSImage的format方法會遍歷所有的目錄進行備份。如果是FSImage的文件目錄,則調用saveFSImage保存FSImage,如果是Edits,則調用editLog.createEditLogFile,最后調用sd.write方法創建fstime和VERSION文件。VERSION文件通常最后寫入。
            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.   }  
            最后分析一下元數據應用的場景:
            1、格式化時。
            2、Hadoop啟動時。
            3、元數據更新操作時。
            4、如果NameNode與Secondary NameNode、Backup Node或checkpoint Node配合使用時,會進行checkPoint操作。

            本文轉自:
            http://blog.csdn.net/kntao/article/details/7769199
            posted on 2013-05-24 15:18 王海光 閱讀(1015) 評論(0)  編輯 收藏 引用 所屬分類: Linux
            久久伊人亚洲AV无码网站| 国产91色综合久久免费| 久久久久99精品成人片| 亚洲国产精品久久久天堂| 国产精品gz久久久| 久久久久无码精品国产不卡| 伊人久久无码精品中文字幕| 伊人久久综合热线大杳蕉下载| 亚洲中文久久精品无码| 综合久久精品色| 久久er99热精品一区二区| 欧美激情精品久久久久久| 中文国产成人精品久久不卡| 久久成人精品视频| 久久国产精品一区二区| 中文字幕精品久久| 亚洲嫩草影院久久精品| 久久亚洲国产成人精品性色| 婷婷久久香蕉五月综合加勒比| 久久国产精品国语对白| 久久夜色撩人精品国产| 久久久久久综合一区中文字幕| 精品久久一区二区| 亚洲精品高清国产一线久久| 久久精品亚洲欧美日韩久久| 久久精品国产亚洲av高清漫画| 一97日本道伊人久久综合影院| 精品久久久久久无码中文字幕| 丁香五月网久久综合| 99国产欧美精品久久久蜜芽| 久久久女人与动物群交毛片| 亚洲熟妇无码另类久久久| 三级三级久久三级久久| 久久久无码人妻精品无码| 国产精品久久新婚兰兰| 最新久久免费视频| 波多野结衣久久| 无码人妻久久久一区二区三区| 久久精品成人欧美大片| 久久99国产精品二区不卡| 久久亚洲AV成人无码电影|