Package org.znerd.xmlenc

Examples of org.znerd.xmlenc.XMLOutputter


   * Tests that XMLBlockInfo does not throw NullPointerException if it finds a
   * null FSNamesystem.
   */
  @Test
  public void testXMLBlockInfoNullNamesystem() throws IOException {
    XMLOutputter doc = new XMLOutputter(mock(JspWriter.class), "UTF-8");
    new NamenodeJspHelper.XMLBlockInfo(null, 1L).toXML(doc);
  }
View Full Code Here


   * Tests that XMLCorruptBlockInfo does not throw NullPointerException if it
   * finds a null FSNamesystem.
   */
  @Test
  public void testXMLCorruptBlockInfoNullNamesystem() throws IOException {
    XMLOutputter doc = new XMLOutputter(mock(JspWriter.class), "UTF-8");
    new NamenodeJspHelper.XMLCorruptBlockInfo(null, mock(Configuration.class),
      10, 1L).toXML(doc);
  }
View Full Code Here

    @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();
    }
View Full Code Here

    @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();
    }
View Full Code Here

      ugi.doAs(new PrivilegedExceptionAction<Void>() {
        @Override
        public Void run() throws Exception {
          final String path = ServletUtil.getDecodedPath(request, "/contentSummary");
          final PrintWriter out = response.getWriter();
          final XMLOutputter xml = new XMLOutputter(out, "UTF-8");
          xml.declaration();
          try {
            //get content summary
            final ClientProtocol nnproxy = createNameNodeProxy();
            final ContentSummary cs = nnproxy.getContentSummary(path);

            //write xml
            xml.startTag(ContentSummary.class.getName());
            if (cs != null) {
              xml.attribute("length"        , "" + cs.getLength());
              xml.attribute("fileCount"     , "" + cs.getFileCount());
              xml.attribute("directoryCount", "" + cs.getDirectoryCount());
              xml.attribute("quota"         , "" + cs.getQuota());
              xml.attribute("spaceConsumed" , "" + cs.getSpaceConsumed());
              xml.attribute("spaceQuota"    , "" + cs.getSpaceQuota());
            }
            xml.endTag();
          } catch(IOException ioe) {
            writeXml(ioe, path, xml);
          }
          xml.endDocument();
          return null;
        }
      });
    } catch (InterruptedException e) {
      throw new IOException(e);
View Full Code Here

    public void doGet(HttpServletRequest request, HttpServletResponse response
        ) throws ServletException, IOException {
      final UnixUserGroupInformation ugi = getUGI(request);
      final PrintWriter out = response.getWriter();
      final String filename = getFilename(request, response);
      final XMLOutputter xml = new XMLOutputter(out, "UTF-8");
      xml.declaration();

      Configuration daemonConf = (Configuration) getServletContext()
        .getAttribute(HttpServer.CONF_CONTEXT_ATTRIBUTE);
      final Configuration conf = (daemonConf == null) ? new Configuration()
        : new Configuration(daemonConf);
      final int socketTimeout = conf.getInt("dfs.socket.timeout", HdfsConstants.READ_TIMEOUT);
      final SocketFactory socketFactory = NetUtils.getSocketFactory(conf, ClientProtocol.class);
      UnixUserGroupInformation.saveToConf(conf,
          UnixUserGroupInformation.UGI_PROPERTY_NAME, ugi);
      final ProtocolProxy<ClientProtocol> nnproxy =
        DFSClient.createRPCNamenode(conf);

      try {
        final MD5MD5CRC32FileChecksum checksum = DFSClient.getFileChecksum(
            DataTransferProtocol.DATA_TRANSFER_VERSION,
            filename, nnproxy.getProxy(), nnproxy, socketFactory, socketTimeout);
        MD5MD5CRC32FileChecksum.write(xml, checksum);
      } catch(IOException ioe) {
        new RemoteException(ioe.getClass().getName(), ioe.getMessage()
            ).writeXml(filename, xml);
      }
      xml.endDocument();
    }
View Full Code Here

TOP

Related Classes of org.znerd.xmlenc.XMLOutputter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.