public void load(File file, boolean requireSameLayoutVersion) throws IOException { Preconditions.checkState(impl == null, "Image already loaded!"); FileInputStream is = null; try { is = new FileInputStream(file); byte[] magic = new byte[FSImageUtil.MAGIC_HEADER.length]; IOUtils.readFully(is, magic, 0, magic.length); if (Arrays.equals(magic, FSImageUtil.MAGIC_HEADER)) { FSImageFormatProtobuf.Loader loader = new FSImageFormatProtobuf.Loader( conf, fsn, requireSameLayoutVersion); impl = loader; loader.load(file); } else { Loader loader = new Loader(conf, fsn); impl = loader; loader.load(file); } } finally { IOUtils.cleanupWithLogger(LOG, is); } } }
List<BlockProto> bp = f.getBlocksList(); BlockType blockType = PBHelperClient.convert(f.getBlockType()); LoaderContext state = parent.getLoaderContext(); boolean isStriped = f.hasErasureCodingPolicyID(); assert ((!isStriped) || (isStriped && !f.hasReplication())); parent.getLoaderContext().getStringTable());
loadNameSystemSection(in); break; case STRING_TABLE: loadStringTableSection(in); break; case INODE: { Step step = new Step(StepType.DELEGATION_TOKENS); prog.beginStep(Phase.LOADING_FSIMAGE, step); loadSecretManagerSection(in, prog, step); prog.endStep(Phase.LOADING_FSIMAGE, step); Step step = new Step(StepType.CACHE_POOLS); prog.beginStep(Phase.LOADING_FSIMAGE, step); loadCacheManagerSection(in, prog, step); prog.endStep(Phase.LOADING_FSIMAGE, step); Step step = new Step(StepType.ERASURE_CODING_POLICIES); prog.beginStep(Phase.LOADING_FSIMAGE, step); loadErasureCodingSection(in); prog.endStep(Phase.LOADING_FSIMAGE, step); break;
loadNameSystemSection(in); break; case STRING_TABLE: loadStringTableSection(in); break; case INODE: { Step step = new Step(StepType.DELEGATION_TOKENS); prog.beginStep(Phase.LOADING_FSIMAGE, step); loadSecretManagerSection(in); prog.endStep(Phase.LOADING_FSIMAGE, step); Step step = new Step(StepType.CACHE_POOLS); prog.beginStep(Phase.LOADING_FSIMAGE, step); loadCacheManagerSection(in); prog.endStep(Phase.LOADING_FSIMAGE, step);
loadNameSystemSection(in); break; case STRING_TABLE: loadStringTableSection(in); break; case INODE: { Step step = new Step(StepType.DELEGATION_TOKENS); prog.beginStep(Phase.LOADING_FSIMAGE, step); loadSecretManagerSection(in); prog.endStep(Phase.LOADING_FSIMAGE, step); Step step = new Step(StepType.CACHE_POOLS); prog.beginStep(Phase.LOADING_FSIMAGE, step); loadCacheManagerSection(in); prog.endStep(Phase.LOADING_FSIMAGE, step);
final LoaderContext state = parent.getLoaderContext();
final LoaderContext state = parent.getLoaderContext();
throws IOException { final FileDiffList diffs = new FileDiffList(); final LoaderContext state = parent.getLoaderContext(); for (int i = 0; i < size; i++) { SnapshotDiffSection.FileDiff pbf = SnapshotDiffSection.FileDiff
throws IOException { final FileDiffList diffs = new FileDiffList(); final LoaderContext state = parent.getLoaderContext(); for (int i = 0; i < size; i++) { SnapshotDiffSection.FileDiff pbf = SnapshotDiffSection.FileDiff
List<BlockProto> bp = f.getBlocksList(); short replication = (short) f.getReplication(); LoaderContext state = parent.getLoaderContext(); parent.getLoaderContext().getStringTable());
List<BlockProto> bp = f.getBlocksList(); short replication = (short) f.getReplication(); LoaderContext state = parent.getLoaderContext(); parent.getLoaderContext().getStringTable());
/** * Load the snapshot diff section from fsimage. */ public void loadSnapshotDiffSection(InputStream in) throws IOException { final List<INodeReference> refList = parent.getLoaderContext() .getRefList(); while (true) { SnapshotDiffSection.DiffEntry entry = SnapshotDiffSection.DiffEntry .parseDelimitedFrom(in); if (entry == null) { break; } long inodeId = entry.getInodeId(); INode inode = fsDir.getInode(inodeId); SnapshotDiffSection.DiffEntry.Type type = entry.getType(); switch (type) { case FILEDIFF: loadFileDiffList(in, inode.asFile(), entry.getNumOfDiff()); break; case DIRECTORYDIFF: loadDirectoryDiffList(in, inode.asDirectory(), entry.getNumOfDiff(), refList); break; } } }
/** * Load the snapshot diff section from fsimage. */ public void loadSnapshotDiffSection(InputStream in) throws IOException { final List<INodeReference> refList = parent.getLoaderContext() .getRefList(); while (true) { SnapshotDiffSection.DiffEntry entry = SnapshotDiffSection.DiffEntry .parseDelimitedFrom(in); if (entry == null) { break; } long inodeId = entry.getInodeId(); INode inode = fsDir.getInode(inodeId); SnapshotDiffSection.DiffEntry.Type type = entry.getType(); switch (type) { case FILEDIFF: loadFileDiffList(in, inode.asFile(), entry.getNumOfDiff()); break; case DIRECTORYDIFF: loadDirectoryDiffList(in, inode.asDirectory(), entry.getNumOfDiff(), refList); break; } } }
private void loadRootINode(INodeSection.INode p) { INodeDirectory root = loadINodeDirectory(p, parent.getLoaderContext()); final QuotaCounts q = root.getQuotaCounts(); final long nsQuota = q.getNameSpace(); final long dsQuota = q.getStorageSpace(); if (nsQuota != -1 || dsQuota != -1) { dir.rootDir.getDirectoryWithQuotaFeature().setQuota(nsQuota, dsQuota); } final EnumCounters<StorageType> typeQuotas = q.getTypeSpaces(); if (typeQuotas.anyGreaterOrEqual(0)) { dir.rootDir.getDirectoryWithQuotaFeature().setQuota(typeQuotas); } dir.rootDir.cloneModificationTime(root); dir.rootDir.clonePermissionStatus(root); final AclFeature af = root.getFeature(AclFeature.class); if (af != null) { dir.rootDir.addAclFeature(af); } // root dir supports having extended attributes according to POSIX final XAttrFeature f = root.getXAttrFeature(); if (f != null) { dir.rootDir.addXAttrFeature(f); } dir.addRootDirToEncryptionZone(f); } }
private void loadRootINode(INodeSection.INode p) { INodeDirectory root = loadINodeDirectory(p, parent.getLoaderContext()); final QuotaCounts q = root.getQuotaCounts(); final long nsQuota = q.getNameSpace(); final long dsQuota = q.getStorageSpace(); if (nsQuota != -1 || dsQuota != -1) { dir.rootDir.getDirectoryWithQuotaFeature().setQuota(nsQuota, dsQuota); } final EnumCounters<StorageType> typeQuotas = q.getTypeSpaces(); if (typeQuotas.anyGreaterOrEqual(0)) { dir.rootDir.getDirectoryWithQuotaFeature().setQuota(typeQuotas); } dir.rootDir.cloneModificationTime(root); dir.rootDir.clonePermissionStatus(root); final AclFeature af = root.getFeature(AclFeature.class); if (af != null) { dir.rootDir.addAclFeature(af); } // root dir supports having extended attributes according to POSIX final XAttrFeature f = root.getXAttrFeature(); if (f != null) { dir.rootDir.addXAttrFeature(f); } dir.addRootDirToEncryptionZone(f); } }
public void load(File file, boolean requireSameLayoutVersion) throws IOException { Preconditions.checkState(impl == null, "Image already loaded!"); FileInputStream is = null; try { is = new FileInputStream(file); byte[] magic = new byte[FSImageUtil.MAGIC_HEADER.length]; IOUtils.readFully(is, magic, 0, magic.length); if (Arrays.equals(magic, FSImageUtil.MAGIC_HEADER)) { FSImageFormatProtobuf.Loader loader = new FSImageFormatProtobuf.Loader( conf, fsn, requireSameLayoutVersion); impl = loader; loader.load(file); } else { Loader loader = new Loader(conf, fsn); impl = loader; loader.load(file); } } finally { IOUtils.cleanup(LOG, is); } } }
public void load(File file, boolean requireSameLayoutVersion) throws IOException { Preconditions.checkState(impl == null, "Image already loaded!"); FileInputStream is = null; try { is = new FileInputStream(file); byte[] magic = new byte[FSImageUtil.MAGIC_HEADER.length]; IOUtils.readFully(is, magic, 0, magic.length); if (Arrays.equals(magic, FSImageUtil.MAGIC_HEADER)) { FSImageFormatProtobuf.Loader loader = new FSImageFormatProtobuf.Loader( conf, fsn, requireSameLayoutVersion); impl = loader; loader.load(file); } else { Loader loader = new Loader(conf, fsn); impl = loader; loader.load(file); } } finally { IOUtils.cleanup(LOG, is); } } }
void loadINodeDirectorySection(InputStream in) throws IOException { final List<INodeReference> refList = parent.getLoaderContext() .getRefList(); while (true) { INodeDirectorySection.DirEntry e = INodeDirectorySection.DirEntry .parseDelimitedFrom(in); // note that in is a LimitedInputStream if (e == null) { break; } INodeDirectory p = dir.getInode(e.getParent()).asDirectory(); for (long id : e.getChildrenList()) { INode child = dir.getInode(id); addToParent(p, child); } for (int refId : e.getRefChildrenList()) { INodeReference ref = refList.get(refId); addToParent(p, ref); } } }
void loadINodeDirectorySection(InputStream in) throws IOException { final List<INodeReference> refList = parent.getLoaderContext() .getRefList(); while (true) { INodeDirectorySection.DirEntry e = INodeDirectorySection.DirEntry .parseDelimitedFrom(in); // note that in is a LimitedInputStream if (e == null) { break; } INodeDirectory p = dir.getInode(e.getParent()).asDirectory(); for (long id : e.getChildrenList()) { INode child = dir.getInode(id); addToParent(p, child); } for (int refId : e.getRefChildrenList()) { INodeReference ref = refList.get(refId); addToParent(p, ref); } } }
/** * The sequence of the ref node in refList must be strictly the same with * the sequence in fsimage */ public void loadINodeReferenceSection(InputStream in) throws IOException { final List<INodeReference> refList = parent.getLoaderContext() .getRefList(); while (true) { INodeReferenceSection.INodeReference e = INodeReferenceSection .INodeReference.parseDelimitedFrom(in); if (e == null) { break; } INodeReference ref = loadINodeReference(e); refList.add(ref); } }