Java 类org.apache.hadoop.util.ServletUtil 实例源码

项目:hadoop    文件:HftpFileSystem.java   
private FileChecksum getFileChecksum(String f) throws IOException {
  final HttpURLConnection connection = openConnection(
      "/fileChecksum" + ServletUtil.encodePath(f),
      "ugi=" + getEncodedUgiParameter());
  try {
    final XMLReader xr = XMLReaderFactory.createXMLReader();
    xr.setContentHandler(this);
    xr.parse(new InputSource(connection.getInputStream()));
  } catch(SAXException e) {
    final Exception embedded = e.getException();
    if (embedded != null && embedded instanceof IOException) {
      throw (IOException)embedded;
    }
    throw new IOException("invalid xml directory content", e);
  } finally {
    connection.disconnect();
  }
  return filechecksum;
}
项目:hadoop    文件:HftpFileSystem.java   
@Override
public FSDataInputStream open(Path f, int buffersize) throws IOException {
  f = f.makeQualified(getUri(), getWorkingDirectory());
  String path = "/data" + ServletUtil.encodePath(f.toUri().getPath());
  String query = addDelegationTokenParam("ugi=" + getEncodedUgiParameter());
  URL u = getNamenodeURL(path, query);
  return new FSDataInputStream(new RangeHeaderInputStream(connectionFactory, u));
}
项目:hadoop    文件:HftpFileSystem.java   
private void fetchList(String path, boolean recur) throws IOException {
  try {
    XMLReader xr = XMLReaderFactory.createXMLReader();
    xr.setContentHandler(this);
    HttpURLConnection connection = openConnection(
        "/listPaths" + ServletUtil.encodePath(path),
        "ugi=" + getEncodedUgiParameter() + (recur ? "&recursive=yes" : ""));
    InputStream resp = connection.getInputStream();
    xr.parse(new InputSource(resp));
  } catch(SAXException e) {
    final Exception embedded = e.getException();
    if (embedded != null && embedded instanceof IOException) {
      throw (IOException)embedded;
    }
    throw new IOException("invalid xml directory content", e);
  }
}
项目:hadoop    文件:HftpFileSystem.java   
/**
 * Connect to the name node and get content summary.
 * @param path The path
 * @return The content summary for the path.
 * @throws IOException
 */
private ContentSummary getContentSummary(String path) throws IOException {
  final HttpURLConnection connection = openConnection(
      "/contentSummary" + ServletUtil.encodePath(path),
      "ugi=" + getEncodedUgiParameter());
  InputStream in = null;
  try {
    in = connection.getInputStream();

    final XMLReader xr = XMLReaderFactory.createXMLReader();
    xr.setContentHandler(this);
    xr.parse(new InputSource(in));
  } catch(FileNotFoundException fnfe) {
    //the server may not support getContentSummary
    return null;
  } catch(SAXException saxe) {
    final Exception embedded = saxe.getException();
    if (embedded != null && embedded instanceof IOException) {
      throw (IOException)embedded;
    }
    throw new IOException("Invalid xml format", saxe);
  } finally {
    if (in != null) {
      in.close();
    }
    connection.disconnect();
  }
  return contentsummary;
}
项目:hadoop    文件:FileChecksumServlets.java   
@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();
}
项目:hadoop    文件:ListPathsServlet.java   
/**
 * Build a map from the query string, setting values and defaults.
 */
protected Map<String,String> buildRoot(HttpServletRequest request,
    XMLOutputter doc) {
  final String path = ServletUtil.getDecodedPath(request, "/listPaths");
  final String exclude = request.getParameter("exclude") != null
    ? request.getParameter("exclude") : "";
  final String filter = request.getParameter("filter") != null
    ? request.getParameter("filter") : ".*";
  final boolean recur = request.getParameter("recursive") != null
    && "yes".equals(request.getParameter("recursive"));

  Map<String, String> root = new HashMap<String, String>();
  root.put("path", path);
  root.put("recursive", recur ? "yes" : "no");
  root.put("filter", filter);
  root.put("exclude", exclude);
  root.put("time", df.get().format(new Date()));
  root.put("version", VersionInfo.getVersion());
  return root;
}
项目:big-c    文件:HftpFileSystem.java   
private void fetchList(String path, boolean recur) throws IOException {
  try {
    XMLReader xr = XMLReaderFactory.createXMLReader();
    xr.setContentHandler(this);
    HttpURLConnection connection = openConnection(
        "/listPaths" + ServletUtil.encodePath(path),
        "ugi=" + getEncodedUgiParameter() + (recur ? "&recursive=yes" : ""));
    InputStream resp = connection.getInputStream();
    xr.parse(new InputSource(resp));
  } catch(SAXException e) {
    final Exception embedded = e.getException();
    if (embedded != null && embedded instanceof IOException) {
      throw (IOException)embedded;
    }
    throw new IOException("invalid xml directory content", e);
  }
}
项目:big-c    文件:HftpFileSystem.java   
private FileChecksum getFileChecksum(String f) throws IOException {
  final HttpURLConnection connection = openConnection(
      "/fileChecksum" + ServletUtil.encodePath(f),
      "ugi=" + getEncodedUgiParameter());
  try {
    final XMLReader xr = XMLReaderFactory.createXMLReader();
    xr.setContentHandler(this);
    xr.parse(new InputSource(connection.getInputStream()));
  } catch(SAXException e) {
    final Exception embedded = e.getException();
    if (embedded != null && embedded instanceof IOException) {
      throw (IOException)embedded;
    }
    throw new IOException("invalid xml directory content", e);
  } finally {
    connection.disconnect();
  }
  return filechecksum;
}
项目:big-c    文件:FileChecksumServlets.java   
@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();
}
项目:big-c    文件:ListPathsServlet.java   
/**
 * Build a map from the query string, setting values and defaults.
 */
protected Map<String,String> buildRoot(HttpServletRequest request,
    XMLOutputter doc) {
  final String path = ServletUtil.getDecodedPath(request, "/listPaths");
  final String exclude = request.getParameter("exclude") != null
    ? request.getParameter("exclude") : "";
  final String filter = request.getParameter("filter") != null
    ? request.getParameter("filter") : ".*";
  final boolean recur = request.getParameter("recursive") != null
    && "yes".equals(request.getParameter("recursive"));

  Map<String, String> root = new HashMap<String, String>();
  root.put("path", path);
  root.put("recursive", recur ? "yes" : "no");
  root.put("filter", filter);
  root.put("exclude", exclude);
  root.put("time", df.get().format(new Date()));
  root.put("version", VersionInfo.getVersion());
  return root;
}
项目:hadoop-2.6.0-cdh5.4.3    文件:HftpFileSystem.java   
private void fetchList(String path, boolean recur) throws IOException {
  try {
    XMLReader xr = XMLReaderFactory.createXMLReader();
    xr.setContentHandler(this);
    HttpURLConnection connection = openConnection(
        "/listPaths" + ServletUtil.encodePath(path),
        "ugi=" + getEncodedUgiParameter() + (recur ? "&recursive=yes" : ""));
    InputStream resp = connection.getInputStream();
    xr.parse(new InputSource(resp));
  } catch(SAXException e) {
    final Exception embedded = e.getException();
    if (embedded != null && embedded instanceof IOException) {
      throw (IOException)embedded;
    }
    throw new IOException("invalid xml directory content", e);
  }
}
项目:hadoop-2.6.0-cdh5.4.3    文件:HftpFileSystem.java   
private FileChecksum getFileChecksum(String f) throws IOException {
  final HttpURLConnection connection = openConnection(
      "/fileChecksum" + ServletUtil.encodePath(f),
      "ugi=" + getEncodedUgiParameter());
  try {
    final XMLReader xr = XMLReaderFactory.createXMLReader();
    xr.setContentHandler(this);
    xr.parse(new InputSource(connection.getInputStream()));
  } catch(SAXException e) {
    final Exception embedded = e.getException();
    if (embedded != null && embedded instanceof IOException) {
      throw (IOException)embedded;
    }
    throw new IOException("invalid xml directory content", e);
  } finally {
    connection.disconnect();
  }
  return filechecksum;
}
项目:hadoop-2.6.0-cdh5.4.3    文件:FileChecksumServlets.java   
@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();
}
项目:hadoop-2.6.0-cdh5.4.3    文件:ListPathsServlet.java   
/**
 * Build a map from the query string, setting values and defaults.
 */
protected Map<String,String> buildRoot(HttpServletRequest request,
    XMLOutputter doc) {
  final String path = ServletUtil.getDecodedPath(request, "/listPaths");
  final String exclude = request.getParameter("exclude") != null
    ? request.getParameter("exclude") : "";
  final String filter = request.getParameter("filter") != null
    ? request.getParameter("filter") : ".*";
  final boolean recur = request.getParameter("recursive") != null
    && "yes".equals(request.getParameter("recursive"));

  Map<String, String> root = new HashMap<String, String>();
  root.put("path", path);
  root.put("recursive", recur ? "yes" : "no");
  root.put("filter", filter);
  root.put("exclude", exclude);
  root.put("time", df.get().format(new Date()));
  root.put("version", VersionInfo.getVersion());
  return root;
}
项目:hadoop-plus    文件:HftpFileSystem.java   
private void fetchList(String path, boolean recur) throws IOException {
  try {
    XMLReader xr = XMLReaderFactory.createXMLReader();
    xr.setContentHandler(this);
    HttpURLConnection connection = openConnection(
        "/listPaths" + ServletUtil.encodePath(path),
        "ugi=" + getEncodedUgiParameter() + (recur ? "&recursive=yes" : ""));
    InputStream resp = connection.getInputStream();
    xr.parse(new InputSource(resp));
  } catch(SAXException e) {
    final Exception embedded = e.getException();
    if (embedded != null && embedded instanceof IOException) {
      throw (IOException)embedded;
    }
    throw new IOException("invalid xml directory content", e);
  }
}
项目:hadoop-plus    文件:HftpFileSystem.java   
private FileChecksum getFileChecksum(String f) throws IOException {
  final HttpURLConnection connection = openConnection(
      "/fileChecksum" + ServletUtil.encodePath(f), 
      "ugi=" + getEncodedUgiParameter());
  try {
    final XMLReader xr = XMLReaderFactory.createXMLReader();
    xr.setContentHandler(this);
    xr.parse(new InputSource(connection.getInputStream()));
  } catch(SAXException e) {
    final Exception embedded = e.getException();
    if (embedded != null && embedded instanceof IOException) {
      throw (IOException)embedded;
    }
    throw new IOException("invalid xml directory content", e);
  } finally {
    connection.disconnect();
  }
  return filechecksum;
}
项目:hadoop-plus    文件:FileChecksumServlets.java   
/** Create a redirection URL */
private URL createRedirectURL(UserGroupInformation ugi, DatanodeID host,
    HttpServletRequest request, NameNode nn) 
    throws IOException {
  final String hostname = host instanceof DatanodeInfo 
      ? ((DatanodeInfo)host).getHostName() : host.getIpAddr();
  final String scheme = request.getScheme();
  final int port = "https".equals(scheme)
      ? (Integer)getServletContext().getAttribute(DFSConfigKeys.DFS_DATANODE_HTTPS_PORT_KEY)
      : host.getInfoPort();
  final String encodedPath = ServletUtil.getRawPath(request, "/fileChecksum");

  String dtParam = "";
  if (UserGroupInformation.isSecurityEnabled()) {
    String tokenString = ugi.getTokens().iterator().next().encodeToUrlString();
    dtParam = JspHelper.getDelegationTokenUrlParam(tokenString);
  }
  String addr = nn.getNameNodeAddressHostPortString();
  String addrParam = JspHelper.getUrlParam(JspHelper.NAMENODE_ADDRESS, addr);

  return new URL(scheme, hostname, port, 
      "/getFileChecksum" + encodedPath + '?' +
      "ugi=" + ServletUtil.encodeQueryValue(ugi.getShortUserName()) + 
      dtParam + addrParam);
}
项目:hadoop-plus    文件:FileChecksumServlets.java   
@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();
}
项目:hadoop-plus    文件:ListPathsServlet.java   
/**
 * Build a map from the query string, setting values and defaults.
 */
protected Map<String,String> buildRoot(HttpServletRequest request,
    XMLOutputter doc) {
  final String path = ServletUtil.getDecodedPath(request, "/listPaths");
  final String exclude = request.getParameter("exclude") != null
    ? request.getParameter("exclude") : "";
  final String filter = request.getParameter("filter") != null
    ? request.getParameter("filter") : ".*";
  final boolean recur = request.getParameter("recursive") != null
    && "yes".equals(request.getParameter("recursive"));

  Map<String, String> root = new HashMap<String, String>();
  root.put("path", path);
  root.put("recursive", recur ? "yes" : "no");
  root.put("filter", filter);
  root.put("exclude", exclude);
  root.put("time", df.get().format(new Date()));
  root.put("version", VersionInfo.getVersion());
  return root;
}
项目:FlexMap    文件:HftpFileSystem.java   
private void fetchList(String path, boolean recur) throws IOException {
  try {
    XMLReader xr = XMLReaderFactory.createXMLReader();
    xr.setContentHandler(this);
    HttpURLConnection connection = openConnection(
        "/listPaths" + ServletUtil.encodePath(path),
        "ugi=" + getEncodedUgiParameter() + (recur ? "&recursive=yes" : ""));
    InputStream resp = connection.getInputStream();
    xr.parse(new InputSource(resp));
  } catch(SAXException e) {
    final Exception embedded = e.getException();
    if (embedded != null && embedded instanceof IOException) {
      throw (IOException)embedded;
    }
    throw new IOException("invalid xml directory content", e);
  }
}
项目:FlexMap    文件:HftpFileSystem.java   
private FileChecksum getFileChecksum(String f) throws IOException {
  final HttpURLConnection connection = openConnection(
      "/fileChecksum" + ServletUtil.encodePath(f),
      "ugi=" + getEncodedUgiParameter());
  try {
    final XMLReader xr = XMLReaderFactory.createXMLReader();
    xr.setContentHandler(this);
    xr.parse(new InputSource(connection.getInputStream()));
  } catch(SAXException e) {
    final Exception embedded = e.getException();
    if (embedded != null && embedded instanceof IOException) {
      throw (IOException)embedded;
    }
    throw new IOException("invalid xml directory content", e);
  } finally {
    connection.disconnect();
  }
  return filechecksum;
}
项目:FlexMap    文件:FileChecksumServlets.java   
@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();
}
项目:FlexMap    文件:ListPathsServlet.java   
/**
 * Build a map from the query string, setting values and defaults.
 */
protected Map<String,String> buildRoot(HttpServletRequest request,
    XMLOutputter doc) {
  final String path = ServletUtil.getDecodedPath(request, "/listPaths");
  final String exclude = request.getParameter("exclude") != null
    ? request.getParameter("exclude") : "";
  final String filter = request.getParameter("filter") != null
    ? request.getParameter("filter") : ".*";
  final boolean recur = request.getParameter("recursive") != null
    && "yes".equals(request.getParameter("recursive"));

  Map<String, String> root = new HashMap<String, String>();
  root.put("path", path);
  root.put("recursive", recur ? "yes" : "no");
  root.put("filter", filter);
  root.put("exclude", exclude);
  root.put("time", df.get().format(new Date()));
  root.put("version", VersionInfo.getVersion());
  return root;
}
项目:hops    文件:HftpFileSystem.java   
private void fetchList(String path, boolean recur) throws IOException {
  try {
    XMLReader xr = XMLReaderFactory.createXMLReader();
    xr.setContentHandler(this);
    HttpURLConnection connection =
        openConnection("/listPaths" + ServletUtil.encodePath(path),
            "ugi=" + getEncodedUgiParameter() +
                (recur ? "&recursive=yes" : ""));
    InputStream resp = connection.getInputStream();
    xr.parse(new InputSource(resp));
  } catch (SAXException e) {
    final Exception embedded = e.getException();
    if (embedded != null && embedded instanceof IOException) {
      throw (IOException) embedded;
    }
    throw new IOException("invalid xml directory content", e);
  }
}
项目:hops    文件:HftpFileSystem.java   
private FileChecksum getFileChecksum(String f) throws IOException {
  final HttpURLConnection connection =
      openConnection("/fileChecksum" + ServletUtil.encodePath(f),
          "ugi=" + getEncodedUgiParameter());
  try {
    final XMLReader xr = XMLReaderFactory.createXMLReader();
    xr.setContentHandler(this);
    xr.parse(new InputSource(connection.getInputStream()));
  } catch (SAXException e) {
    final Exception embedded = e.getException();
    if (embedded != null && embedded instanceof IOException) {
      throw (IOException) embedded;
    }
    throw new IOException("invalid xml directory content", e);
  } finally {
    connection.disconnect();
  }
  return filechecksum;
}
项目:hops    文件:FileChecksumServlets.java   
@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();
}
项目:hops    文件:ListPathsServlet.java   
/**
 * Build a map from the query string, setting values and defaults.
 */
protected Map<String, String> buildRoot(HttpServletRequest request,
    XMLOutputter doc) {
  final String path = ServletUtil.getDecodedPath(request, "/listPaths");
  final String exclude = request.getParameter("exclude") != null ?
      request.getParameter("exclude") : "";
  final String filter = request.getParameter("filter") != null ?
      request.getParameter("filter") : ".*";
  final boolean recur = request.getParameter("recursive") != null &&
      "yes".equals(request.getParameter("recursive"));

  Map<String, String> root = new HashMap<>();
  root.put("path", path);
  root.put("recursive", recur ? "yes" : "no");
  root.put("filter", filter);
  root.put("exclude", exclude);
  root.put("time", df.get().format(new Date()));
  root.put("version", VersionInfo.getVersion());
  return root;
}
项目:hadoop-TCP    文件:HftpFileSystem.java   
private void fetchList(String path, boolean recur) throws IOException {
  try {
    XMLReader xr = XMLReaderFactory.createXMLReader();
    xr.setContentHandler(this);
    HttpURLConnection connection = openConnection(
        "/listPaths" + ServletUtil.encodePath(path),
        "ugi=" + getEncodedUgiParameter() + (recur ? "&recursive=yes" : ""));
    InputStream resp = connection.getInputStream();
    xr.parse(new InputSource(resp));
  } catch(SAXException e) {
    final Exception embedded = e.getException();
    if (embedded != null && embedded instanceof IOException) {
      throw (IOException)embedded;
    }
    throw new IOException("invalid xml directory content", e);
  }
}
项目:hadoop-TCP    文件:HftpFileSystem.java   
private FileChecksum getFileChecksum(String f) throws IOException {
  final HttpURLConnection connection = openConnection(
      "/fileChecksum" + ServletUtil.encodePath(f), 
      "ugi=" + getEncodedUgiParameter());
  try {
    final XMLReader xr = XMLReaderFactory.createXMLReader();
    xr.setContentHandler(this);
    xr.parse(new InputSource(connection.getInputStream()));
  } catch(SAXException e) {
    final Exception embedded = e.getException();
    if (embedded != null && embedded instanceof IOException) {
      throw (IOException)embedded;
    }
    throw new IOException("invalid xml directory content", e);
  } finally {
    connection.disconnect();
  }
  return filechecksum;
}
项目:hadoop-TCP    文件:FileChecksumServlets.java   
@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();
}
项目:hadoop-TCP    文件:ListPathsServlet.java   
/**
 * Build a map from the query string, setting values and defaults.
 */
protected Map<String,String> buildRoot(HttpServletRequest request,
    XMLOutputter doc) {
  final String path = ServletUtil.getDecodedPath(request, "/listPaths");
  final String exclude = request.getParameter("exclude") != null
    ? request.getParameter("exclude") : "";
  final String filter = request.getParameter("filter") != null
    ? request.getParameter("filter") : ".*";
  final boolean recur = request.getParameter("recursive") != null
    && "yes".equals(request.getParameter("recursive"));

  Map<String, String> root = new HashMap<String, String>();
  root.put("path", path);
  root.put("recursive", recur ? "yes" : "no");
  root.put("filter", filter);
  root.put("exclude", exclude);
  root.put("time", df.get().format(new Date()));
  root.put("version", VersionInfo.getVersion());
  return root;
}
项目:hardfs    文件:HftpFileSystem.java   
private void fetchList(String path, boolean recur) throws IOException {
  try {
    XMLReader xr = XMLReaderFactory.createXMLReader();
    xr.setContentHandler(this);
    HttpURLConnection connection = openConnection(
        "/listPaths" + ServletUtil.encodePath(path),
        "ugi=" + getEncodedUgiParameter() + (recur ? "&recursive=yes" : ""));
    InputStream resp = connection.getInputStream();
    xr.parse(new InputSource(resp));
  } catch(SAXException e) {
    final Exception embedded = e.getException();
    if (embedded != null && embedded instanceof IOException) {
      throw (IOException)embedded;
    }
    throw new IOException("invalid xml directory content", e);
  }
}
项目:hardfs    文件:HftpFileSystem.java   
private FileChecksum getFileChecksum(String f) throws IOException {
  final HttpURLConnection connection = openConnection(
      "/fileChecksum" + ServletUtil.encodePath(f), 
      "ugi=" + getEncodedUgiParameter());
  try {
    final XMLReader xr = XMLReaderFactory.createXMLReader();
    xr.setContentHandler(this);
    xr.parse(new InputSource(connection.getInputStream()));
  } catch(SAXException e) {
    final Exception embedded = e.getException();
    if (embedded != null && embedded instanceof IOException) {
      throw (IOException)embedded;
    }
    throw new IOException("invalid xml directory content", e);
  } finally {
    connection.disconnect();
  }
  return filechecksum;
}
项目:hardfs    文件:FileChecksumServlets.java   
@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();
}
项目:hardfs    文件:ListPathsServlet.java   
/**
 * Build a map from the query string, setting values and defaults.
 */
protected Map<String,String> buildRoot(HttpServletRequest request,
    XMLOutputter doc) {
  final String path = ServletUtil.getDecodedPath(request, "/listPaths");
  final String exclude = request.getParameter("exclude") != null
    ? request.getParameter("exclude") : "";
  final String filter = request.getParameter("filter") != null
    ? request.getParameter("filter") : ".*";
  final boolean recur = request.getParameter("recursive") != null
    && "yes".equals(request.getParameter("recursive"));

  Map<String, String> root = new HashMap<String, String>();
  root.put("path", path);
  root.put("recursive", recur ? "yes" : "no");
  root.put("filter", filter);
  root.put("exclude", exclude);
  root.put("time", df.get().format(new Date()));
  root.put("version", VersionInfo.getVersion());
  return root;
}
项目:hadoop-on-lustre2    文件:HftpFileSystem.java   
private void fetchList(String path, boolean recur) throws IOException {
  try {
    XMLReader xr = XMLReaderFactory.createXMLReader();
    xr.setContentHandler(this);
    HttpURLConnection connection = openConnection(
        "/listPaths" + ServletUtil.encodePath(path),
        "ugi=" + getEncodedUgiParameter() + (recur ? "&recursive=yes" : ""));
    InputStream resp = connection.getInputStream();
    xr.parse(new InputSource(resp));
  } catch(SAXException e) {
    final Exception embedded = e.getException();
    if (embedded != null && embedded instanceof IOException) {
      throw (IOException)embedded;
    }
    throw new IOException("invalid xml directory content", e);
  }
}
项目:hadoop-on-lustre2    文件:HftpFileSystem.java   
private FileChecksum getFileChecksum(String f) throws IOException {
  final HttpURLConnection connection = openConnection(
      "/fileChecksum" + ServletUtil.encodePath(f),
      "ugi=" + getEncodedUgiParameter());
  try {
    final XMLReader xr = XMLReaderFactory.createXMLReader();
    xr.setContentHandler(this);
    xr.parse(new InputSource(connection.getInputStream()));
  } catch(SAXException e) {
    final Exception embedded = e.getException();
    if (embedded != null && embedded instanceof IOException) {
      throw (IOException)embedded;
    }
    throw new IOException("invalid xml directory content", e);
  } finally {
    connection.disconnect();
  }
  return filechecksum;
}
项目:hadoop-on-lustre2    文件:FileChecksumServlets.java   
@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();
}
项目:hadoop-on-lustre2    文件:ListPathsServlet.java   
/**
 * Build a map from the query string, setting values and defaults.
 */
protected Map<String,String> buildRoot(HttpServletRequest request,
    XMLOutputter doc) {
  final String path = ServletUtil.getDecodedPath(request, "/listPaths");
  final String exclude = request.getParameter("exclude") != null
    ? request.getParameter("exclude") : "";
  final String filter = request.getParameter("filter") != null
    ? request.getParameter("filter") : ".*";
  final boolean recur = request.getParameter("recursive") != null
    && "yes".equals(request.getParameter("recursive"));

  Map<String, String> root = new HashMap<String, String>();
  root.put("path", path);
  root.put("recursive", recur ? "yes" : "no");
  root.put("filter", filter);
  root.put("exclude", exclude);
  root.put("time", df.get().format(new Date()));
  root.put("version", VersionInfo.getVersion());
  return root;
}
项目:hadoop-oss    文件:LogLevel.java   
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response
    ) throws ServletException, IOException {

  // Do the authorization
  if (!HttpServer2.hasAdministratorAccess(getServletContext(), request,
      response)) {
    return;
  }

  PrintWriter out = ServletUtil.initHTML(response, "Log Level");
  String logName = ServletUtil.getParameter(request, "log");
  String level = ServletUtil.getParameter(request, "level");

  if (logName != null) {
    out.println("<br /><hr /><h3>Results</h3>");
    out.println(MARKER
        + "Submitted Class Name: <b>" + logName + "</b><br />");

    Log log = LogFactory.getLog(logName);
    out.println(MARKER
        + "Log Class: <b>" + log.getClass().getName() +"</b><br />");
    if (level != null) {
      out.println(MARKER + "Submitted Level: <b>" + level + "</b><br />");
    }

    if (log instanceof Log4JLogger) {
      process(((Log4JLogger)log).getLogger(), level, out);
    }
    else if (log instanceof Jdk14Logger) {
      process(((Jdk14Logger)log).getLogger(), level, out);
    }
    else {
      out.println("Sorry, " + log.getClass() + " not supported.<br />");
    }
  }

  out.println(FORMS);
  out.println(ServletUtil.HTML_TAIL);
}