예제 #1
0
        /// <summary>Create a redirection URL</summary>
        /// <exception cref="System.IO.IOException"/>
        private Uri CreateRedirectURL(string path, string encodedPath, HdfsFileStatus status
                                      , UserGroupInformation ugi, ClientProtocol nnproxy, HttpServletRequest request,
                                      string dt)
        {
            string        scheme = request.GetScheme();
            LocatedBlocks blks   = nnproxy.GetBlockLocations(status.GetFullPath(new Path(path))
                                                             .ToUri().GetPath(), 0, 1);
            Configuration conf = NameNodeHttpServer.GetConfFromContext(GetServletContext());
            DatanodeID    host = PickSrcDatanode(blks, status, conf);
            string        hostname;

            if (host is DatanodeInfo)
            {
                hostname = host.GetHostName();
            }
            else
            {
                hostname = host.GetIpAddr();
            }
            int    port    = "https".Equals(scheme) ? host.GetInfoSecurePort() : host.GetInfoPort();
            string dtParam = string.Empty;

            if (dt != null)
            {
                dtParam = JspHelper.GetDelegationTokenUrlParam(dt);
            }
            // Add namenode address to the url params
            NameNode nn        = NameNodeHttpServer.GetNameNodeFromContext(GetServletContext());
            string   addr      = nn.GetNameNodeAddressHostPortString();
            string   addrParam = JspHelper.GetUrlParam(JspHelper.NamenodeAddress, addr);

            return(new Uri(scheme, hostname, port, "/streamFile" + encodedPath + '?' + "ugi="
                           + ServletUtil.EncodeQueryValue(ugi.GetShortUserName()) + dtParam + addrParam));
        }
예제 #2
0
 /// <exception cref="System.Exception"/>
 private void VerifyRecursively(Path parent, HdfsFileStatus status)
 {
     if (status.IsDir())
     {
         Path             fullPath = parent == null ? new Path("/") : status.GetFullPath(parent);
         DirectoryListing children = this.dfs.GetClient().ListPaths(fullPath.ToString(), HdfsFileStatus
                                                                    .EmptyName, true);
         foreach (HdfsFileStatus child in children.GetPartialListing())
         {
             this.VerifyRecursively(fullPath, child);
         }
     }
     else
     {
         if (!status.IsSymlink())
         {
             // is file
             this.VerifyFile(parent, status, null);
         }
     }
 }
예제 #3
0
            /// <exception cref="System.IO.IOException"/>
            public Void Run()
            {
                ClientProtocol nn = this._enclosing.CreateNameNodeProxy();

                doc.Declaration();
                doc.StartTag("listing");
                foreach (KeyValuePair <string, string> m in root)
                {
                    doc.Attribute(m.Key, m.Value);
                }
                HdfsFileStatus @base = nn.GetFileInfo(filePath);

                if ((@base != null) && @base.IsDir())
                {
                    ListPathsServlet.WriteInfo(@base.GetFullPath(new Path(path)), @base, doc);
                }
                Stack <string> pathstack = new Stack <string>();

                pathstack.Push(path);
                while (!pathstack.Empty())
                {
                    string p = pathstack.Pop();
                    try
                    {
                        byte[]           lastReturnedName = HdfsFileStatus.EmptyName;
                        DirectoryListing thisListing;
                        do
                        {
                            System.Diagnostics.Debug.Assert(lastReturnedName != null);
                            thisListing = nn.GetListing(p, lastReturnedName, false);
                            if (thisListing == null)
                            {
                                if (lastReturnedName.Length == 0)
                                {
                                    DfsServlet.Log.Warn("ListPathsServlet - Path " + p + " does not exist");
                                }
                                break;
                            }
                            HdfsFileStatus[] listing = thisListing.GetPartialListing();
                            foreach (HdfsFileStatus i in listing)
                            {
                                Path   fullpath  = i.GetFullPath(new Path(p));
                                string localName = fullpath.GetName();
                                if (exclude.Matcher(localName).Matches() || !filter.Matcher(localName).Matches())
                                {
                                    continue;
                                }
                                if (recur && i.IsDir())
                                {
                                    pathstack.Push(new Path(p, localName).ToUri().GetPath());
                                }
                                ListPathsServlet.WriteInfo(fullpath, i, doc);
                            }
                            lastReturnedName = thisListing.GetLastName();
                        }while (thisListing.HasMore());
                    }
                    catch (IOException re)
                    {
                        this._enclosing.WriteXml(re, p, doc);
                    }
                }
                return(null);
            }