读书人

Raid惯用代码片段备忘

发布时间: 2012-08-16 12:02:16 作者: rapoo

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;

读书人网 >网络基础

热点推荐