Ejemplo n.º 1
0
            /// <exception cref="Javax.Servlet.ServletException"/>
            /// <exception cref="System.IO.IOException"/>
            protected override void DoGet(HttpServletRequest request, HttpServletResponse response
                                          )
            {
                PrintWriter  @out = response.GetWriter();
                string       path = ServletUtil.GetDecodedPath(request, "/getFileChecksum");
                XMLOutputter xml  = new XMLOutputter(@out, "UTF-8");

                xml.Declaration();
                ServletContext context  = GetServletContext();
                DataNode       datanode = (DataNode)context.GetAttribute("datanode");
                Configuration  conf     = new HdfsConfiguration(datanode.GetConf());

                try
                {
                    DFSClient dfs = DatanodeJspHelper.GetDFSClient(request, datanode, conf, GetUGI(request
                                                                                                   , conf));
                    MD5MD5CRC32FileChecksum checksum = dfs.GetFileChecksum(path, long.MaxValue);
                    MD5MD5CRC32FileChecksum.Write(xml, checksum);
                }
                catch (IOException ioe)
                {
                    WriteXml(ioe, path, xml);
                }
                catch (Exception e)
                {
                    WriteXml(e, path, xml);
                }
                xml.EndDocument();
            }
Ejemplo n.º 2
0
        /* Return a DFS client to use to make the given HTTP request */
        /// <exception cref="System.IO.IOException"/>
        /// <exception cref="System.Exception"/>
        protected internal virtual DFSClient GetDFSClient(HttpServletRequest request)
        {
            Configuration conf = (Configuration)GetServletContext().GetAttribute(JspHelper.CurrentConf
                                                                                 );
            UserGroupInformation ugi      = GetUGI(request, conf);
            ServletContext       context  = GetServletContext();
            DataNode             datanode = (DataNode)context.GetAttribute("datanode");

            return(DatanodeJspHelper.GetDFSClient(request, datanode, conf, ugi));
        }