Esempio n. 1
0
            /// <exception cref="System.Exception"/>
            public Void Run()
            {
                string       path = ServletUtil.GetDecodedPath(request, "/contentSummary");
                PrintWriter  @out = response.GetWriter();
                XMLOutputter xml  = new XMLOutputter(@out, "UTF-8");

                xml.Declaration();
                try
                {
                    ClientProtocol nnproxy = this._enclosing.CreateNameNodeProxy();
                    ContentSummary cs      = nnproxy.GetContentSummary(path);
                    xml.StartTag(typeof(ContentSummary).FullName);
                    if (cs != null)
                    {
                        xml.Attribute("length", string.Empty + cs.GetLength());
                        xml.Attribute("fileCount", string.Empty + cs.GetFileCount());
                        xml.Attribute("directoryCount", string.Empty + cs.GetDirectoryCount());
                        xml.Attribute("quota", string.Empty + cs.GetQuota());
                        xml.Attribute("spaceConsumed", string.Empty + cs.GetSpaceConsumed());
                        xml.Attribute("spaceQuota", string.Empty + cs.GetSpaceQuota());
                    }
                    xml.EndTag();
                }
                catch (IOException ioe)
                {
                    this._enclosing.WriteXml(ioe, path, xml);
                }
                xml.EndDocument();
                return(null);
            }
Esempio n. 2
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();
            }