/// <summary>Create Inode Tree from the specified mount-table specified in Config</summary> /// <param name="config"> /// - the mount table keys are prefixed with /// FsConstants.CONFIG_VIEWFS_PREFIX /// </param> /// <param name="viewName">- the name of the mount table - if null use defaultMT name /// </param> /// <exception cref="Org.Apache.Hadoop.FS.UnsupportedFileSystemException"/> /// <exception cref="URISyntaxException"/> /// <exception cref="Org.Apache.Hadoop.FS.FileAlreadyExistsException"/> /// <exception cref="System.IO.IOException"/> protected internal InodeTree(Configuration config, string viewName) { string vName = viewName; if (vName == null) { vName = Constants.ConfigViewfsDefaultMountTable; } homedirPrefix = ConfigUtil.GetHomeDirValue(config, vName); root = new InodeTree.INodeDir <T>("/", UserGroupInformation.GetCurrentUser()); root.InodeDirFs = GetTargetFileSystem(root); root.isRoot = true; string mtPrefix = Constants.ConfigViewfsPrefix + "." + vName + "."; string linkPrefix = Constants.ConfigViewfsLink + "."; string linkMergePrefix = Constants.ConfigViewfsLinkMerge + "."; bool gotMountTableEntry = false; UserGroupInformation ugi = UserGroupInformation.GetCurrentUser(); foreach (KeyValuePair <string, string> si in config) { string key = si.Key; if (key.StartsWith(mtPrefix)) { gotMountTableEntry = true; bool isMergeLink = false; string src = Runtime.Substring(key, mtPrefix.Length); if (src.StartsWith(linkPrefix)) { src = Runtime.Substring(src, linkPrefix.Length); } else { if (src.StartsWith(linkMergePrefix)) { // A merge link isMergeLink = true; src = Runtime.Substring(src, linkMergePrefix.Length); } else { if (src.StartsWith(Constants.ConfigViewfsHomedir)) { // ignore - we set home dir from config continue; } else { throw new IOException("ViewFs: Cannot initialize: Invalid entry in Mount table in config: " + src); } } } string target = si.Value; // link or merge link CreateLink(src, target, isMergeLink, ugi); } } if (!gotMountTableEntry) { throw new IOException("ViewFs: Cannot initialize: Empty Mount table in config for " + vName == null ? "viewfs:///" : ("viewfs://" + vName + "/")); } }