示例#1
0
 /// <summary>Select a datanode to service this request.</summary>
 /// <remarks>
 /// Select a datanode to service this request.
 /// Currently, this looks at no more than the first five blocks of a file,
 /// selecting a datanode randomly from the most represented.
 /// </remarks>
 /// <param name="conf"></param>
 /// <exception cref="System.IO.IOException"/>
 private DatanodeID PickSrcDatanode(LocatedBlocks blks, HdfsFileStatus i, Configuration
                                    conf)
 {
     if (i.GetLen() == 0 || blks.GetLocatedBlocks().Count <= 0)
     {
         // pick a random datanode
         NameNode nn = NameNodeHttpServer.GetNameNodeFromContext(GetServletContext());
         return(NamenodeJspHelper.GetRandomDatanode(nn));
     }
     return(JspHelper.BestNode(blks, conf));
 }
示例#2
0
            /// <exception cref="Javax.Servlet.ServletException"/>
            /// <exception cref="System.IO.IOException"/>
            protected override void DoGet(HttpServletRequest request, HttpServletResponse response
                                          )
            {
                ServletContext       context  = GetServletContext();
                Configuration        conf     = NameNodeHttpServer.GetConfFromContext(context);
                UserGroupInformation ugi      = GetUGI(request, conf);
                NameNode             namenode = NameNodeHttpServer.GetNameNodeFromContext(context);
                DatanodeID           datanode = NamenodeJspHelper.GetRandomDatanode(namenode);

                try
                {
                    response.SendRedirect(CreateRedirectURL(ugi, datanode, request, namenode).ToString
                                              ());
                }
                catch (IOException e)
                {
                    response.SendError(400, e.Message);
                }
            }