void open():Create empty edit log files.Initialize the output stream for logging.当open方法被都调用时,会把fsimage下所有的editlog文件流加到editStreams中。
public synchronized void open() throws IOException {
Iterator<StorageDirectory> it = fsimage.dirIterator(NameNodeDirType.EDITS);
while (it.hasNext()) {
StorageDirectory sd = it.next();
File eFile = getEditFile(sd);
EditLogOutputStream eStream = new EditLogFileOutputStream(eFile);
editStreams.add(eStream);
}
int loadFSEdits(EditLogInputStream edits,MetaRecoveryContext recovery):Load an edit log, and apply the changes to the in-memory structure.加载硬盘上的editlog,应用到内存文件树中。从硬盘中读取editlog后,根据每个opcode来构建文件树。
void rollEditLog():Closes the current edit log and opens edits.new. 对应着http://zy19982004.iyunv.com/admin/blogs/1870624三.2
void purgeEditLog():Removes the old edit log and renamed edits.new as edits. Reopens the edits file. 对应着http://zy19982004.iyunv.com/admin/blogs/1870624三.6的Roll edit.new