public virtual void InitServer(string fsimage) { FSImageLoader loader = FSImageLoader.Load(fsimage); bootstrap.ChildHandler(new _ChannelInitializer_92(this, loader)); channel = bootstrap.Bind(address).Sync().Channel(); allChannels.AddItem(channel); address = (IPEndPoint)channel.LocalAddress(); Log.Info("WebImageViewer started. Listening on " + address.ToString() + ". Press Ctrl+C to stop the viewer." ); }
/// <exception cref="System.IO.IOException"/> public virtual void Visit(RandomAccessFile file) { Configuration conf = new Configuration(); if (!FSImageUtil.CheckFileFormat(file)) { throw new IOException("Unrecognized FSImage"); } FsImageProto.FileSummary summary = FSImageUtil.LoadSummary(file); using (FileInputStream fin = new FileInputStream(file.GetFD())) { InputStream @is; AList <FsImageProto.FileSummary.Section> sections = Lists.NewArrayList(summary.GetSectionsList ()); sections.Sort(new _IComparer_427()); foreach (FsImageProto.FileSummary.Section section in sections) { fin.GetChannel().Position(section.GetOffset()); @is = FSImageUtil.WrapInputStreamForCompression(conf, summary.GetCodec(), new BufferedInputStream (new LimitInputStream(fin, section.GetLength()))); switch (FSImageFormatProtobuf.SectionName.FromString(section.GetName())) { case FSImageFormatProtobuf.SectionName.StringTable: { stringTable = FSImageLoader.LoadStringTable(@is); break; } default: { break; } } } LoadDirectories(fin, sections, summary, conf); LoadINodeDirSection(fin, sections, summary, conf); metadataMap.Sync(); Output(conf, summary, fin, sections); } }
public _ChannelInitializer_92(WebImageViewer _enclosing, FSImageLoader loader) { this._enclosing = _enclosing; this.loader = loader; }
/// <exception cref="System.IO.IOException"/> internal FSImageHandler(FSImageLoader image, ChannelGroup activeChannels) { this.image = image; this.activeChannels = activeChannels; }
protected internal override string GetEntry(string parent, FsImageProto.INodeSection.INode inode) { StringBuilder buffer = new StringBuilder(); string inodeName = inode.GetName().ToStringUtf8(); Path path = new Path(parent.IsEmpty() ? "/" : parent, inodeName.IsEmpty() ? "/" : inodeName); buffer.Append(path.ToString()); PermissionStatus p = null; switch (inode.GetType()) { case FsImageProto.INodeSection.INode.Type.File: { FsImageProto.INodeSection.INodeFile file = inode.GetFile(); p = GetPermission(file.GetPermission()); Append(buffer, file.GetReplication()); Append(buffer, FormatDate(file.GetModificationTime())); Append(buffer, FormatDate(file.GetAccessTime())); Append(buffer, file.GetPreferredBlockSize()); Append(buffer, file.GetBlocksCount()); Append(buffer, FSImageLoader.GetFileSize(file)); Append(buffer, 0); // NS_QUOTA Append(buffer, 0); // DS_QUOTA break; } case FsImageProto.INodeSection.INode.Type.Directory: { FsImageProto.INodeSection.INodeDirectory dir = inode.GetDirectory(); p = GetPermission(dir.GetPermission()); Append(buffer, 0); // Replication Append(buffer, FormatDate(dir.GetModificationTime())); Append(buffer, FormatDate(0)); // Access time. Append(buffer, 0); // Block size. Append(buffer, 0); // Num blocks. Append(buffer, 0); // Num bytes. Append(buffer, dir.GetNsQuota()); Append(buffer, dir.GetDsQuota()); break; } case FsImageProto.INodeSection.INode.Type.Symlink: { FsImageProto.INodeSection.INodeSymlink s = inode.GetSymlink(); p = GetPermission(s.GetPermission()); Append(buffer, 0); // Replication Append(buffer, FormatDate(s.GetModificationTime())); Append(buffer, FormatDate(s.GetAccessTime())); Append(buffer, 0); // Block size. Append(buffer, 0); // Num blocks. Append(buffer, 0); // Num bytes. Append(buffer, 0); // NS_QUOTA Append(buffer, 0); // DS_QUOTA break; } default: { break; } } System.Diagnostics.Debug.Assert(p != null); Append(buffer, p.GetPermission().ToString()); Append(buffer, p.GetUserName()); Append(buffer, p.GetGroupName()); return(buffer.ToString()); }