当前位置: 首页>>代码示例>>Java>>正文


Java MD5MD5CRC32FileChecksum类代码示例

本文整理汇总了Java中org.apache.hadoop.fs.MD5MD5CRC32FileChecksum的典型用法代码示例。如果您正苦于以下问题:Java MD5MD5CRC32FileChecksum类的具体用法?Java MD5MD5CRC32FileChecksum怎么用?Java MD5MD5CRC32FileChecksum使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MD5MD5CRC32FileChecksum类属于org.apache.hadoop.fs包,在下文中一共展示了MD5MD5CRC32FileChecksum类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doGet

import org.apache.hadoop.fs.MD5MD5CRC32FileChecksum; //导入依赖的package包/类
@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();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:26,代码来源:FileChecksumServlets.java

示例2: onGetFileChecksum

import org.apache.hadoop.fs.MD5MD5CRC32FileChecksum; //导入依赖的package包/类
private void onGetFileChecksum(ChannelHandlerContext ctx) throws IOException {
  MD5MD5CRC32FileChecksum checksum = null;
  final String nnId = params.namenodeId();
  DFSClient dfsclient = newDfsClient(nnId, conf);
  try {
    checksum = dfsclient.getFileChecksum(path, Long.MAX_VALUE);
    dfsclient.close();
    dfsclient = null;
  } finally {
    IOUtils.cleanup(LOG, dfsclient);
  }
  final byte[] js = JsonUtil.toJsonString(checksum).getBytes(Charsets.UTF_8);
  DefaultFullHttpResponse resp =
    new DefaultFullHttpResponse(HTTP_1_1, OK, Unpooled.wrappedBuffer(js));

  resp.headers().set(CONTENT_TYPE, APPLICATION_JSON_UTF8);
  resp.headers().set(CONTENT_LENGTH, js.length);
  resp.headers().set(CONNECTION, CLOSE);
  ctx.writeAndFlush(resp).addListener(ChannelFutureListener.CLOSE);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:WebHdfsHandler.java

示例3: doGet

import org.apache.hadoop.fs.MD5MD5CRC32FileChecksum; //导入依赖的package包/类
@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();
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:26,代码来源:FileChecksumServlets.java

示例4: doGet

import org.apache.hadoop.fs.MD5MD5CRC32FileChecksum; //导入依赖的package包/类
@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();
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:24,代码来源:FileChecksumServlets.java

示例5: doGet

import org.apache.hadoop.fs.MD5MD5CRC32FileChecksum; //导入依赖的package包/类
/** {@inheritDoc} */
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();

  final Configuration conf = new Configuration(DataNode.getDataNode().getConf());
  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 ClientProtocol nnproxy = DFSClient.createNamenode(conf);

  try {
    final MD5MD5CRC32FileChecksum checksum = DFSClient.getFileChecksum(
        filename, nnproxy, socketFactory, socketTimeout);
    MD5MD5CRC32FileChecksum.write(xml, checksum);
  } catch(IOException ioe) {
    new RemoteException(ioe.getClass().getName(), ioe.getMessage()
        ).writeXml(filename, xml);
  }
  xml.endDocument();
}
 
开发者ID:thisisvoa,项目名称:hadoop-0.20,代码行数:27,代码来源:FileChecksumServlets.java

示例6: startElement

import org.apache.hadoop.fs.MD5MD5CRC32FileChecksum; //导入依赖的package包/类
@Override
public void startElement(String ns, String localname, String qname,
            Attributes attrs) throws SAXException {
  if (!MD5MD5CRC32FileChecksum.class.getName().equals(qname)) {
    if (RemoteException.class.getSimpleName().equals(qname)) {
      throw new SAXException(RemoteException.valueOf(attrs));
    }
    throw new SAXException("Unrecognized entry: " + qname);
  }

  filechecksum = MD5MD5CRC32FileChecksum.valueOf(attrs);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:13,代码来源:HftpFileSystem.java

示例7: getFileChecksum

import org.apache.hadoop.fs.MD5MD5CRC32FileChecksum; //导入依赖的package包/类
@Override
public MD5MD5CRC32FileChecksum getFileChecksum(final Path p
    ) throws IOException {
  statistics.incrementReadOps(1);

  final HttpOpParam.Op op = GetOpParam.Op.GETFILECHECKSUM;
  return new FsPathResponseRunner<MD5MD5CRC32FileChecksum>(op, p) {
    @Override
    MD5MD5CRC32FileChecksum decodeResponse(Map<?,?> json) throws IOException {
      return JsonUtil.toMD5MD5CRC32FileChecksum(json);
    }
  }.run();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:14,代码来源:WebHdfsFileSystem.java

示例8: getFileChecksum

import org.apache.hadoop.fs.MD5MD5CRC32FileChecksum; //导入依赖的package包/类
@Override
public MD5MD5CRC32FileChecksum getFileChecksum(final Path p
) throws IOException {
  statistics.incrementReadOps(1);

  final HttpOpParam.Op op = GetOpParam.Op.GETFILECHECKSUM;
  return new FsPathResponseRunner<MD5MD5CRC32FileChecksum>(op, p) {
    @Override
    MD5MD5CRC32FileChecksum decodeResponse(Map<?,?> json) throws IOException {
      return JsonUtilClient.toMD5MD5CRC32FileChecksum(json);
    }
  }.run();
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:14,代码来源:WebHdfsFileSystem.java

示例9: startElement

import org.apache.hadoop.fs.MD5MD5CRC32FileChecksum; //导入依赖的package包/类
/** {@inheritDoc} */
public void startElement(String ns, String localname, String qname,
            Attributes attrs) throws SAXException {
  if (!MD5MD5CRC32FileChecksum.class.getName().equals(qname)) {
    if (RemoteException.class.getSimpleName().equals(qname)) {
      throw new SAXException(RemoteException.valueOf(attrs));
    }
    throw new SAXException("Unrecognized entry: " + qname);
  }

  filechecksum = MD5MD5CRC32FileChecksum.valueOf(attrs);
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:13,代码来源:HftpFileSystem.java

示例10: doGet

import org.apache.hadoop.fs.MD5MD5CRC32FileChecksum; //导入依赖的package包/类
/** {@inheritDoc} */
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();
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:32,代码来源:FileChecksumServlets.java

示例11: toJsonString

import org.apache.hadoop.fs.MD5MD5CRC32FileChecksum; //导入依赖的package包/类
/** Convert a MD5MD5CRC32FileChecksum to a Json string. */
public static String toJsonString(final MD5MD5CRC32FileChecksum checksum) {
  if (checksum == null) {
    return null;
  }

  final Map<String, Object> m = new TreeMap<String, Object>();
  m.put("algorithm", checksum.getAlgorithmName());
  m.put("length", checksum.getLength());
  m.put("bytes", StringUtils.byteToHexString(checksum.getBytes()));
  return toJsonString(FileChecksum.class, m);
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:13,代码来源:JsonUtil.java

示例12: getFileChecksum

import org.apache.hadoop.fs.MD5MD5CRC32FileChecksum; //导入依赖的package包/类
@Override
public MD5MD5CRC32FileChecksum getFileChecksum(final Path p
    ) throws IOException {
  statistics.incrementReadOps(1);

  final HttpOpParam.Op op = GetOpParam.Op.GETFILECHECKSUM;
  final Map<?, ?> m = run(op, p);
  return JsonUtil.toMD5MD5CRC32FileChecksum(m);
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:10,代码来源:WebHdfsFileSystem.java

示例13: getFileChecksum

import org.apache.hadoop.fs.MD5MD5CRC32FileChecksum; //导入依赖的package包/类
/**
 * Get the checksum of a file.
 * @param src The file path
 * @return The checksum 
 * @see DistributedFileSystem#getFileChecksum(Path)
 */
public MD5MD5CRC32FileChecksum getFileChecksum(String src) throws IOException {
  checkOpen();
  return getFileChecksum(src, clientName, namenode, socketFactory,
      dfsClientConf.socketTimeout, getDataEncryptionKey(),
      dfsClientConf.connectToDnViaHostname);
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:13,代码来源:DFSClient.java

示例14: toJsonString

import org.apache.hadoop.fs.MD5MD5CRC32FileChecksum; //导入依赖的package包/类
/**
 * Convert a MD5MD5CRC32FileChecksum to a Json string.
 */
public static String toJsonString(final MD5MD5CRC32FileChecksum checksum) {
  if (checksum == null) {
    return null;
  }

  final Map<String, Object> m = new TreeMap<>();
  m.put("algorithm", checksum.getAlgorithmName());
  m.put("length", checksum.getLength());
  m.put("bytes", StringUtils.byteToHexString(checksum.getBytes()));
  return toJsonString(FileChecksum.class, m);
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:15,代码来源:JsonUtil.java

示例15: startElement

import org.apache.hadoop.fs.MD5MD5CRC32FileChecksum; //导入依赖的package包/类
@Override
public void startElement(String ns, String localname, String qname,
    Attributes attrs) throws SAXException {
  if (!MD5MD5CRC32FileChecksum.class.getName().equals(qname)) {
    if (RemoteException.class.getSimpleName().equals(qname)) {
      throw new SAXException(RemoteException.valueOf(attrs));
    }
    throw new SAXException("Unrecognized entry: " + qname);
  }

  filechecksum = MD5MD5CRC32FileChecksum.valueOf(attrs);
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:13,代码来源:HftpFileSystem.java


注:本文中的org.apache.hadoop.fs.MD5MD5CRC32FileChecksum类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。