看过路fsimage这个文件的存储,再看看其它三个文件的存储,其它三个文件的存储都很简单,先来看edits文件,
editLog.createEditLogFile(getImageFile(sd, NameNodeFile.EDITS));
public synchronized void createEditLogFile(File name) throws IOException {
EditLogOutputStream eStream = new EditLogFileOutputStream(name);
eStream.create();
eStream.close();
}
void create() throws IOException {
fc.truncate(0);
fc.position(0);
bufCurrent.writeInt(FSConstants.LAYOUT_VERSION);
setReadyToFlush();
flush();
}
很清晰地看到create方法写进了一个int数据(LAYOUT_VERSION)
刚刚格式化自己的hdfs后,到自己的dfs.name.dir下的current/edits 查看下edits的状态,可以看到显示的大小为4,也就使4个字节。
下面来看最后一部分: // write version and time files
sd.write();
public void write() throws IOException {
corruptPreUpgradeStorage(root);
write(getVersionFile());
}
这里只提一下 corruptPreUpgradeStorage(root);这个方法是创建root目录下image目录用来记录old版本的fsimage。其它的太简单了,实在不想写了。