/// <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); }
/// <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(); }
/// <summary>Service a GET request as described below.</summary> /// <remarks> /// Service a GET request as described below. /// Request: /// <c>GET http://<nn>:<port>/listPaths[/<path>][<?option>[&option]*] HTTP/1.1 /// </c> /// Where <i>option</i> (default) in: /// recursive ("no") /// filter (".*") /// exclude ("\..*\.crc") /// Response: A flat list of files/directories in the following format: /// <c> /// <listing path="..." recursive="(yes|no)" filter="..." /// time="yyyy-MM-dd hh:mm:ss UTC" version="..."> /// <directory path="..." modified="yyyy-MM-dd hh:mm:ss"/> /// <file path="..." modified="yyyy-MM-dd'T'hh:mm:ssZ" accesstime="yyyy-MM-dd'T'hh:mm:ssZ" /// blocksize="..." /// replication="..." size="..."/> /// </listing> /// </c> /// </remarks> /// <exception cref="Javax.Servlet.ServletException"/> /// <exception cref="System.IO.IOException"/> protected override void DoGet(HttpServletRequest request, HttpServletResponse response ) { PrintWriter @out = response.GetWriter(); XMLOutputter doc = new XMLOutputter(@out, "UTF-8"); IDictionary <string, string> root = BuildRoot(request, doc); string path = root["path"]; string filePath = ServletUtil.GetDecodedPath(request, "/listPaths"); try { bool recur = "yes".Equals(root["recursive"]); Sharpen.Pattern filter = Sharpen.Pattern.Compile(root["filter"]); Sharpen.Pattern exclude = Sharpen.Pattern.Compile(root["exclude"]); Configuration conf = (Configuration)GetServletContext().GetAttribute(JspHelper.CurrentConf ); GetUGI(request, conf).DoAs(new _PrivilegedExceptionAction_149(this, doc, root, filePath , path, exclude, filter, recur)); } catch (IOException ioe) { WriteXml(ioe, path, doc); } catch (Exception e) { Log.Warn("ListPathServlet encountered InterruptedException", e); response.SendError(400, e.Message); } finally { if (doc != null) { doc.EndDocument(); } if (@out != null) { @out.Close(); } } }