首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网络技术 > 网络基础 >

Raid惯用代码片段备忘

2012-08-16 
Raid常用代码片段备忘DistributedRaidFileSystem其实就是装饰者设计模式中的装饰者,对DistributedFileSyst

Raid常用代码片段备忘

DistributedRaidFileSystem其实就是装饰者设计模式中的装饰者,对DistributedFileSystem进行了封装,关键是DistributedRaidFileSystem.ExtFSDataInputStream.ExtFsInputStream对FSInputStream.read(byte[] b, int offset, int len)封装,捕获BlockMissingException,ChecksumException用unraid恢复。

?

Configuration使用了DistributedRaidFileSystem,要得到DistributedFileSystem:

??? FileSystem fs = (new Path(path)).getFileSystem(conf);
??? // if we got a raid fs, get the underlying fs
??? if (fs instanceof DistributedRaidFileSystem) {
????? fs = ((DistributedRaidFileSystem) fs).getFileSystem();
??? }

??? // check that we have a distributed fs
??? if (!(fs instanceof DistributedFileSystem)) {
????? throw new IOException("expected DistributedFileSystem but got " +
??????????????? fs.getClass().getName());
??? }

??? final DistributedFileSystem dfs = (DistributedFileSystem) fs;

热点排行