@Override public void doGet(HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException { final PrintWriter out = response.getWriter(); final String path = ServletUtil.getDecodedPath(request, "/getFileChecksum"); final XMLOutputter xml = new XMLOutputter(out, "UTF-8"); xml.declaration(); final ServletContext context = getServletContext(); final DataNode datanode = (DataNode) context.getAttribute("datanode"); final Configuration conf = new HdfsConfiguration(datanode.getConf()); try { final DFSClient dfs = DatanodeJspHelper.getDFSClient(request, datanode, conf, getUGI(request, conf)); final MD5MD5CRC32FileChecksum checksum = dfs.getFileChecksum(path, Long.MAX_VALUE); MD5MD5CRC32FileChecksum.write(xml, checksum); } catch(IOException ioe) { writeXml(ioe, path, xml); } catch (InterruptedException e) { writeXml(e, path, xml); } xml.endDocument(); }
@Override public void doGet(HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException { final PrintWriter out = response.getWriter(); final String path = ServletUtil.getDecodedPath(request, "/getFileChecksum"); final XMLOutputter xml = new XMLOutputter(out, "UTF-8"); xml.declaration(); final ServletContext context = getServletContext(); final DataNode datanode = (DataNode) context.getAttribute("datanode"); final Configuration conf = new HdfsConfiguration(datanode.getConf()); try { final DFSClient dfs = DatanodeJspHelper.getDFSClient(request, datanode, conf, getUGI(request, conf)); final MD5MD5CRC32FileChecksum checksum = dfs.getFileChecksum(path); MD5MD5CRC32FileChecksum.write(xml, checksum); } catch(IOException ioe) { writeXml(ioe, path, xml); } catch (InterruptedException e) { writeXml(e, path, xml); } xml.endDocument(); }
@Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { final PrintWriter out = response.getWriter(); final String path = ServletUtil.getDecodedPath(request, "/getFileChecksum"); final XMLOutputter xml = new XMLOutputter(out, "UTF-8"); xml.declaration(); final ServletContext context = getServletContext(); final DataNode datanode = (DataNode) context.getAttribute("datanode"); final Configuration conf = new HdfsConfiguration(datanode.getConf()); try { final DFSClient dfs = DatanodeJspHelper .getDFSClient(request, datanode, conf, getUGI(request, conf)); final MD5MD5CRC32FileChecksum checksum = dfs.getFileChecksum(path); MD5MD5CRC32FileChecksum.write(xml, checksum); } catch (IOException | InterruptedException ioe) { writeXml(ioe, path, xml); } xml.endDocument(); }
protected DFSClient getDFSClient(HttpServletRequest request) throws IOException, InterruptedException { final Configuration conf = (Configuration) getServletContext().getAttribute(JspHelper.CURRENT_CONF); UserGroupInformation ugi = getUGI(request, conf); final ServletContext context = getServletContext(); final DataNode datanode = (DataNode) context.getAttribute("datanode"); return DatanodeJspHelper.getDFSClient(request, datanode, conf, ugi); }
protected DFSClient getDFSClient(HttpServletRequest request) throws IOException, InterruptedException { final Configuration conf = (Configuration) getServletContext() .getAttribute(JspHelper.CURRENT_CONF); UserGroupInformation ugi = getUGI(request, conf); final ServletContext context = getServletContext(); final DataNode datanode = (DataNode) context.getAttribute("datanode"); return DatanodeJspHelper.getDFSClient(request, datanode, conf, ugi); }