Ejemplo n.º 1
0
        /// <exception cref="Org.Apache.Hadoop.Security.AccessControlException"/>
        /// <exception cref="System.IO.FileNotFoundException"/>
        /// <exception cref="System.IO.IOException"/>
        public override FileStatus GetFileStatus(Path f)
        {
            InodeTree.ResolveResult <FileSystem> res = fsState.Resolve(GetUriPath(f), true);
            FileStatus status = res.targetFileSystem.GetFileStatus(res.remainingPath);

            return(FixFileStatus(status, this.MakeQualified(f)));
        }
Ejemplo n.º 2
0
 /// <exception cref="System.IO.IOException"/>
 public override bool Rename(Path src, Path dst)
 {
     // passing resolveLastComponet as false to catch renaming a mount point to
     // itself. We need to catch this as an internal operation and fail.
     InodeTree.ResolveResult <FileSystem> resSrc = fsState.Resolve(GetUriPath(src), false
                                                                   );
     if (resSrc.IsInternalDir())
     {
         throw ReadOnlyMountTable("rename", src);
     }
     InodeTree.ResolveResult <FileSystem> resDst = fsState.Resolve(GetUriPath(dst), false
                                                                   );
     if (resDst.IsInternalDir())
     {
         throw ReadOnlyMountTable("rename", dst);
     }
     //
     // Alternate 3 : renames ONLY within the the same mount links.
     //
     if (resSrc.targetFileSystem != resDst.targetFileSystem)
     {
         throw new IOException("Renames across Mount points not supported");
     }
     return(resSrc.targetFileSystem.Rename(resSrc.remainingPath, resDst.remainingPath));
 }
Ejemplo n.º 3
0
 /// <exception cref="System.IO.IOException"/>
 public override BlockLocation[] GetFileBlockLocations(FileStatus fs, long start,
                                                       long len)
 {
     InodeTree.ResolveResult <FileSystem> res = fsState.Resolve(GetUriPath(fs.GetPath()
                                                                           ), true);
     return(res.targetFileSystem.GetFileBlockLocations(new ViewFsFileStatus(fs, res.remainingPath
                                                                            ), start, len));
 }
Ejemplo n.º 4
0
        /// <exception cref="System.IO.IOException"/>
        private Path GetChrootedPath(InodeTree.ResolveResult <FileSystem> res, FileStatus
                                     status, Path f)
        {
            string suffix = ((ChRootedFileSystem)res.targetFileSystem).StripOutRoot(status.GetPath
                                                                                        ());

            return(this.MakeQualified(suffix.Length == 0 ? f : new Path(res.resolvedPath, suffix
                                                                        )));
        }
Ejemplo n.º 5
0
 /// <exception cref="Org.Apache.Hadoop.Security.AccessControlException"/>
 /// <exception cref="System.IO.FileNotFoundException"/>
 /// <exception cref="System.IO.IOException"/>
 public override bool Delete(Path f, bool recursive)
 {
     InodeTree.ResolveResult <FileSystem> res = fsState.Resolve(GetUriPath(f), true);
     // If internal dir or target is a mount link (ie remainingPath is Slash)
     if (res.IsInternalDir() || res.remainingPath == InodeTree.SlashPath)
     {
         throw ReadOnlyMountTable("delete", f);
     }
     return(res.targetFileSystem.Delete(res.remainingPath, recursive));
 }
Ejemplo n.º 6
0
 public override short GetDefaultReplication(Path f)
 {
     try
     {
         InodeTree.ResolveResult <FileSystem> res = fsState.Resolve(GetUriPath(f), true);
         return(res.targetFileSystem.GetDefaultReplication(res.remainingPath));
     }
     catch (FileNotFoundException)
     {
         throw new NotInMountpointException(f, "getDefaultReplication");
     }
 }
Ejemplo n.º 7
0
        /// <exception cref="System.IO.FileNotFoundException"/>
        /// <exception cref="System.IO.IOException"/>
        protected internal override RemoteIterator <LocatedFileStatus> ListLocatedStatus(Path
                                                                                         f, PathFilter filter)
        {
            InodeTree.ResolveResult <FileSystem> res        = fsState.Resolve(GetUriPath(f), true);
            RemoteIterator <LocatedFileStatus>   statusIter = res.targetFileSystem.ListLocatedStatus
                                                                  (res.remainingPath);

            if (res.IsInternalDir())
            {
                return(statusIter);
            }
            return(new _RemoteIterator_422(this, statusIter, res, f));
        }
Ejemplo n.º 8
0
 /// <exception cref="Org.Apache.Hadoop.Security.AccessControlException"/>
 /// <exception cref="System.IO.FileNotFoundException"/>
 /// <exception cref="System.IO.IOException"/>
 public override FileStatus[] ListStatus(Path f)
 {
     InodeTree.ResolveResult <FileSystem> res = fsState.Resolve(GetUriPath(f), true);
     FileStatus[] statusLst = res.targetFileSystem.ListStatus(res.remainingPath);
     if (!res.IsInternalDir())
     {
         // We need to change the name in the FileStatus as described in
         // {@link #getFileStatus }
         int i = 0;
         foreach (FileStatus status in statusLst)
         {
             statusLst[i++] = FixFileStatus(status, GetChrootedPath(res, status, f));
         }
     }
     return(statusLst);
 }
Ejemplo n.º 9
0
        public virtual void TestGetFileChecksum()
        {
            FileSystem mockFS = Org.Mockito.Mockito.Mock <FileSystem>();

            InodeTree.ResolveResult <FileSystem> res = new InodeTree.ResolveResult <FileSystem>
                                                           (null, mockFS, null, new Path("someFile"));
            InodeTree <FileSystem> fsState = Org.Mockito.Mockito.Mock <InodeTree>();

            Org.Mockito.Mockito.When(fsState.Resolve("/tmp/someFile", true)).ThenReturn(res);
            ViewFileSystem vfs = Org.Mockito.Mockito.Mock <ViewFileSystem>();

            vfs.fsState = fsState;
            Org.Mockito.Mockito.When(vfs.GetFileChecksum(new Path("/tmp/someFile"))).ThenCallRealMethod
                ();
            vfs.GetFileChecksum(new Path("/tmp/someFile"));
            Org.Mockito.Mockito.Verify(mockFS).GetFileChecksum(new Path("someFile"));
        }
Ejemplo n.º 10
0
        public virtual void TestGetFileChecksum()
        {
            AbstractFileSystem mockAFS = Org.Mockito.Mockito.Mock <AbstractFileSystem>();

            InodeTree.ResolveResult <AbstractFileSystem> res = new InodeTree.ResolveResult <AbstractFileSystem
                                                                                            >(null, mockAFS, null, new Path("someFile"));
            InodeTree <AbstractFileSystem> fsState = Org.Mockito.Mockito.Mock <InodeTree>();

            Org.Mockito.Mockito.When(fsState.Resolve(Org.Mockito.Mockito.AnyString(), Org.Mockito.Mockito
                                                     .AnyBoolean())).ThenReturn(res);
            ViewFs vfs = Org.Mockito.Mockito.Mock <ViewFs>();

            vfs.fsState = fsState;
            Org.Mockito.Mockito.When(vfs.GetFileChecksum(new Path("/tmp/someFile"))).ThenCallRealMethod
                ();
            vfs.GetFileChecksum(new Path("/tmp/someFile"));
            Org.Mockito.Mockito.Verify(mockAFS).GetFileChecksum(new Path("someFile"));
        }
Ejemplo n.º 11
0
 /// <exception cref="System.IO.IOException"/>
 public override bool Truncate(Path f, long newLength)
 {
     InodeTree.ResolveResult <FileSystem> res = fsState.Resolve(GetUriPath(f), true);
     return(res.targetFileSystem.Truncate(f, newLength));
 }
Ejemplo n.º 12
0
 /// <exception cref="System.IO.IOException"/>
 public override IList <string> ListXAttrs(Path path)
 {
     InodeTree.ResolveResult <FileSystem> res = fsState.Resolve(GetUriPath(path), true);
     return(res.targetFileSystem.ListXAttrs(res.remainingPath));
 }
Ejemplo n.º 13
0
 /// <exception cref="System.IO.IOException"/>
 public override void RemoveXAttr(Path path, string name)
 {
     InodeTree.ResolveResult <FileSystem> res = fsState.Resolve(GetUriPath(path), true);
     res.targetFileSystem.RemoveXAttr(res.remainingPath, name);
 }
Ejemplo n.º 14
0
 /// <exception cref="System.IO.IOException"/>
 public override void SetXAttr(Path path, string name, byte[] value, EnumSet <XAttrSetFlag
                                                                              > flag)
 {
     InodeTree.ResolveResult <FileSystem> res = fsState.Resolve(GetUriPath(path), true);
     res.targetFileSystem.SetXAttr(res.remainingPath, name, value, flag);
 }
Ejemplo n.º 15
0
 /// <exception cref="System.IO.IOException"/>
 public override IDictionary <string, byte[]> GetXAttrs(Path path, IList <string> names
                                                        )
 {
     InodeTree.ResolveResult <FileSystem> res = fsState.Resolve(GetUriPath(path), true);
     return(res.targetFileSystem.GetXAttrs(res.remainingPath, names));
 }
Ejemplo n.º 16
0
 /// <exception cref="System.IO.IOException"/>
 public override void SetAcl(Path path, IList <AclEntry> aclSpec)
 {
     InodeTree.ResolveResult <FileSystem> res = fsState.Resolve(GetUriPath(path), true);
     res.targetFileSystem.SetAcl(res.remainingPath, aclSpec);
 }
Ejemplo n.º 17
0
 /// <exception cref="System.IO.IOException"/>
 public override AclStatus GetAclStatus(Path path)
 {
     InodeTree.ResolveResult <FileSystem> res = fsState.Resolve(GetUriPath(path), true);
     return(res.targetFileSystem.GetAclStatus(res.remainingPath));
 }
Ejemplo n.º 18
0
 /// <exception cref="Org.Apache.Hadoop.Security.AccessControlException"/>
 /// <exception cref="System.IO.FileNotFoundException"/>
 /// <exception cref="System.IO.IOException"/>
 public override void SetTimes(Path f, long mtime, long atime)
 {
     InodeTree.ResolveResult <FileSystem> res = fsState.Resolve(GetUriPath(f), true);
     res.targetFileSystem.SetTimes(res.remainingPath, mtime, atime);
 }
Ejemplo n.º 19
0
 /// <exception cref="System.IO.IOException"/>
 public override void RemoveAcl(Path path)
 {
     InodeTree.ResolveResult <FileSystem> res = fsState.Resolve(GetUriPath(path), true);
     res.targetFileSystem.RemoveAcl(res.remainingPath);
 }
Ejemplo n.º 20
0
 /// <exception cref="Org.Apache.Hadoop.Security.AccessControlException"/>
 /// <exception cref="System.IO.FileNotFoundException"/>
 /// <exception cref="System.IO.IOException"/>
 public override FileChecksum GetFileChecksum(Path f)
 {
     InodeTree.ResolveResult <FileSystem> res = fsState.Resolve(GetUriPath(f), true);
     return(res.targetFileSystem.GetFileChecksum(res.remainingPath));
 }
Ejemplo n.º 21
0
 /// <exception cref="Org.Apache.Hadoop.Security.AccessControlException"/>
 /// <exception cref="System.IO.FileNotFoundException"/>
 /// <exception cref="System.IO.IOException"/>
 public override bool SetReplication(Path f, short replication)
 {
     InodeTree.ResolveResult <FileSystem> res = fsState.Resolve(GetUriPath(f), true);
     return(res.targetFileSystem.SetReplication(res.remainingPath, replication));
 }
Ejemplo n.º 22
0
 /// <exception cref="Org.Apache.Hadoop.Security.AccessControlException"/>
 /// <exception cref="System.IO.FileNotFoundException"/>
 /// <exception cref="System.IO.IOException"/>
 public override void Access(Path path, FsAction mode)
 {
     InodeTree.ResolveResult <FileSystem> res = fsState.Resolve(GetUriPath(path), true);
     res.targetFileSystem.Access(res.remainingPath, mode);
 }
Ejemplo n.º 23
0
 /// <exception cref="System.IO.IOException"/>
 public override FsServerDefaults GetServerDefaults(Path f)
 {
     InodeTree.ResolveResult <FileSystem> res = fsState.Resolve(GetUriPath(f), true);
     return(res.targetFileSystem.GetServerDefaults(res.remainingPath));
 }
Ejemplo n.º 24
0
 public _RemoteIterator_422(ViewFileSystem _enclosing, RemoteIterator <LocatedFileStatus
                                                                       > statusIter, InodeTree.ResolveResult <FileSystem> res, Path f)
 {
     this._enclosing = _enclosing;
     this.statusIter = statusIter;
     this.res        = res;
     this.f          = f;
 }
Ejemplo n.º 25
0
 /// <exception cref="Org.Apache.Hadoop.Security.AccessControlException"/>
 /// <exception cref="System.IO.FileNotFoundException"/>
 /// <exception cref="System.IO.IOException"/>
 public override FSDataInputStream Open(Path f, int bufferSize)
 {
     InodeTree.ResolveResult <FileSystem> res = fsState.Resolve(GetUriPath(f), true);
     return(res.targetFileSystem.Open(res.remainingPath, bufferSize));
 }
Ejemplo n.º 26
0
 /// <exception cref="System.IO.IOException"/>
 public override bool Mkdirs(Path dir, FsPermission permission)
 {
     InodeTree.ResolveResult <FileSystem> res = fsState.Resolve(GetUriPath(dir), false);
     return(res.targetFileSystem.Mkdirs(res.remainingPath, permission));
 }
Ejemplo n.º 27
0
 /// <exception cref="System.IO.IOException"/>
 public override ContentSummary GetContentSummary(Path f)
 {
     InodeTree.ResolveResult <FileSystem> res = fsState.Resolve(GetUriPath(f), true);
     return(res.targetFileSystem.GetContentSummary(res.remainingPath));
 }
Ejemplo n.º 28
0
 /// <exception cref="Org.Apache.Hadoop.Security.AccessControlException"/>
 /// <exception cref="System.IO.FileNotFoundException"/>
 /// <exception cref="System.IO.IOException"/>
 public override void SetOwner(Path f, string username, string groupname)
 {
     InodeTree.ResolveResult <FileSystem> res = fsState.Resolve(GetUriPath(f), true);
     res.targetFileSystem.SetOwner(res.remainingPath, username, groupname);
 }
Ejemplo n.º 29
0
        /// <summary>Resolve the pathname p relative to root InodeDir</summary>
        /// <param name="p">- inout path</param>
        /// <param name="resolveLastComponent"></param>
        /// <returns>ResolveResult which allows further resolution of the remaining path</returns>
        /// <exception cref="System.IO.FileNotFoundException"/>
        internal virtual InodeTree.ResolveResult <T> Resolve(string p, bool resolveLastComponent
                                                             )
        {
            // TO DO: - more efficient to not split the path, but simply compare
            string[] path = BreakIntoPathComponents(p);
            if (path.Length <= 1)
            {
                // special case for when path is "/"
                InodeTree.ResolveResult <T> res = new InodeTree.ResolveResult <T>(InodeTree.ResultKind
                                                                                  .isInternalDir, root.InodeDirFs, root.fullPath, SlashPath);
                return(res);
            }
            InodeTree.INodeDir <T> curInode = root;
            int i;

            // ignore first slash
            for (i = 1; i < path.Length - (resolveLastComponent ? 0 : 1); i++)
            {
                InodeTree.INode <T> nextInode = curInode.ResolveInternal(path[i]);
                if (nextInode == null)
                {
                    StringBuilder failedAt = new StringBuilder(path[0]);
                    for (int j = 1; j <= i; ++j)
                    {
                        failedAt.Append('/').Append(path[j]);
                    }
                    throw (new FileNotFoundException(failedAt.ToString()));
                }
                if (nextInode is InodeTree.INodeLink)
                {
                    InodeTree.INodeLink <T> link = (InodeTree.INodeLink <T>)nextInode;
                    Path remainingPath;
                    if (i >= path.Length - 1)
                    {
                        remainingPath = SlashPath;
                    }
                    else
                    {
                        StringBuilder remainingPathStr = new StringBuilder("/" + path[i + 1]);
                        for (int j = i + 2; j < path.Length; ++j)
                        {
                            remainingPathStr.Append('/').Append(path[j]);
                        }
                        remainingPath = new Path(remainingPathStr.ToString());
                    }
                    InodeTree.ResolveResult <T> res = new InodeTree.ResolveResult <T>(InodeTree.ResultKind
                                                                                      .isExternalDir, link.targetFileSystem, nextInode.fullPath, remainingPath);
                    return(res);
                }
                else
                {
                    if (nextInode is InodeTree.INodeDir)
                    {
                        curInode = (InodeTree.INodeDir <T>)nextInode;
                    }
                }
            }
            // We have resolved to an internal dir in mount table.
            Path remainingPath_1;

            if (resolveLastComponent)
            {
                remainingPath_1 = SlashPath;
            }
            else
            {
                // note we have taken care of when path is "/" above
                // for internal dirs rem-path does not start with / since the lookup
                // that follows will do a children.get(remaningPath) and will have to
                // strip-out the initial /
                StringBuilder remainingPathStr = new StringBuilder("/" + path[i]);
                for (int j = i + 1; j < path.Length; ++j)
                {
                    remainingPathStr.Append('/').Append(path[j]);
                }
                remainingPath_1 = new Path(remainingPathStr.ToString());
            }
            InodeTree.ResolveResult <T> res_1 = new InodeTree.ResolveResult <T>(InodeTree.ResultKind
                                                                                .isInternalDir, curInode.InodeDirFs, curInode.fullPath, remainingPath_1);
            return(res_1);
        }
Ejemplo n.º 30
0
 /// <exception cref="Org.Apache.Hadoop.Security.AccessControlException"/>
 /// <exception cref="System.IO.FileNotFoundException"/>
 /// <exception cref="System.IO.IOException"/>
 public override void SetPermission(Path f, FsPermission permission)
 {
     InodeTree.ResolveResult <FileSystem> res = fsState.Resolve(GetUriPath(f), true);
     res.targetFileSystem.SetPermission(res.remainingPath, permission);
 }