示例#1
0
        /// <exception cref="System.IO.IOException"/>
        private void OnGetFileChecksum(ChannelHandlerContext ctx)
        {
            MD5MD5CRC32FileChecksum checksum = null;
            string    nnId      = @params.NamenodeId();
            DFSClient dfsclient = NewDfsClient(nnId, conf);

            try
            {
                checksum = dfsclient.GetFileChecksum(path, long.MaxValue);
                dfsclient.Close();
                dfsclient = null;
            }
            finally
            {
                IOUtils.Cleanup(Log, dfsclient);
            }
            byte[] js = Sharpen.Runtime.GetBytesForString(JsonUtil.ToJsonString(checksum), Charsets
                                                          .Utf8);
            DefaultFullHttpResponse resp = new DefaultFullHttpResponse(HttpVersion.Http11, HttpResponseStatus
                                                                       .Ok, Unpooled.WrappedBuffer(js));

            resp.Headers().Set(HttpHeaders.Names.ContentType, ApplicationJsonUtf8);
            resp.Headers().Set(HttpHeaders.Names.ContentLength, js.Length);
            resp.Headers().Set(HttpHeaders.Names.Connection, HttpHeaders.Values.Close);
            ctx.WriteAndFlush(resp).AddListener(ChannelFutureListener.Close);
        }
示例#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();
            }
示例#3
0
 /// <exception cref="System.IO.IOException"/>
 /// <exception cref="Org.Apache.Hadoop.FS.UnresolvedLinkException"/>
 public override FileChecksum GetFileChecksum(Path f)
 {
     return(dfs.GetFileChecksum(GetUriPath(f), long.MaxValue));
 }