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


Java FSImageTestUtil.corruptVersionFile方法代码示例

本文整理汇总了Java中org.apache.hadoop.hdfs.server.namenode.FSImageTestUtil.corruptVersionFile方法的典型用法代码示例。如果您正苦于以下问题:Java FSImageTestUtil.corruptVersionFile方法的具体用法?Java FSImageTestUtil.corruptVersionFile怎么用?Java FSImageTestUtil.corruptVersionFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.hdfs.server.namenode.FSImageTestUtil的用法示例。


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

示例1: testUpgradeFromCorruptRel22Image

import org.apache.hadoop.hdfs.server.namenode.FSImageTestUtil; //导入方法依赖的package包/类
/**
 * Test upgrade from 0.22 image with corrupt md5, make sure it
 * fails to upgrade
 */
@Test
public void testUpgradeFromCorruptRel22Image() throws IOException {
  unpackStorage(HADOOP22_IMAGE, HADOOP_DFS_DIR_TXT);
  
  // Overwrite the md5 stored in the VERSION files
  File baseDir = new File(MiniDFSCluster.getBaseDirectory());
  FSImageTestUtil.corruptVersionFile(
      new File(baseDir, "name1/current/VERSION"),
      "imageMD5Digest", "22222222222222222222222222222222");
  FSImageTestUtil.corruptVersionFile(
      new File(baseDir, "name2/current/VERSION"),
      "imageMD5Digest", "22222222222222222222222222222222");
  
  // Attach our own log appender so we can verify output
  final LogVerificationAppender appender = new LogVerificationAppender();
  final Logger logger = Logger.getRootLogger();
  logger.addAppender(appender);

  // Upgrade should now fail
  try {
    upgradeAndVerify(new MiniDFSCluster.Builder(upgradeConf).
        numDataNodes(4), null);
    fail("Upgrade did not fail with bad MD5");
  } catch (IOException ioe) {
    String msg = StringUtils.stringifyException(ioe);
    if (!msg.contains("Failed to load an FSImage file")) {
      throw ioe;
    }
    int md5failures = appender.countExceptionsWithMessage(
        " is corrupt with MD5 checksum of ");
    assertEquals("Upgrade did not fail with bad MD5", 1, md5failures);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:38,代码来源:TestDFSUpgradeFromImage.java

示例2: testUpgradeFromCorruptRel22Image

import org.apache.hadoop.hdfs.server.namenode.FSImageTestUtil; //导入方法依赖的package包/类
/**
 * Test upgrade from 0.22 image with corrupt md5, make sure it
 * fails to upgrade
 */
@Test
public void testUpgradeFromCorruptRel22Image() throws IOException {
  unpackStorage(HADOOP22_IMAGE, HADOOP_DFS_DIR_TXT);
  
  // Overwrite the md5 stored in the VERSION files
  File[] nnDirs = MiniDFSCluster.getNameNodeDirectory(MiniDFSCluster.getBaseDirectory(), 0, 0);
  FSImageTestUtil.corruptVersionFile(
      new File(nnDirs[0], "current/VERSION"),
      "imageMD5Digest", "22222222222222222222222222222222");
  FSImageTestUtil.corruptVersionFile(
      new File(nnDirs[1], "current/VERSION"),
      "imageMD5Digest", "22222222222222222222222222222222");
  
  // Attach our own log appender so we can verify output
  final LogVerificationAppender appender = new LogVerificationAppender();
  final Logger logger = Logger.getRootLogger();
  logger.addAppender(appender);

  // Upgrade should now fail
  try {
    upgradeAndVerify(new MiniDFSCluster.Builder(upgradeConf).
        numDataNodes(4), null);
    fail("Upgrade did not fail with bad MD5");
  } catch (IOException ioe) {
    String msg = StringUtils.stringifyException(ioe);
    if (!msg.contains("Failed to load an FSImage file")) {
      throw ioe;
    }
    int md5failures = appender.countExceptionsWithMessage(
        " is corrupt with MD5 checksum of ");
    assertEquals("Upgrade did not fail with bad MD5", 1, md5failures);
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:38,代码来源:TestDFSUpgradeFromImage.java

示例3: testUpgradeFromCorruptRel22Image

import org.apache.hadoop.hdfs.server.namenode.FSImageTestUtil; //导入方法依赖的package包/类
/**
 * Test upgrade from 0.22 image with corrupt md5, make sure it
 * fails to upgrade
 */
@Test
public void testUpgradeFromCorruptRel22Image() throws IOException {
  unpackStorage(HADOOP22_IMAGE);
  
  // Overwrite the md5 stored in the VERSION files
  File baseDir = new File(MiniDFSCluster.getBaseDirectory());
  FSImageTestUtil.corruptVersionFile(
      new File(baseDir, "name1/current/VERSION"),
      "imageMD5Digest", "22222222222222222222222222222222");
  FSImageTestUtil.corruptVersionFile(
      new File(baseDir, "name2/current/VERSION"),
      "imageMD5Digest", "22222222222222222222222222222222");
  
  // Attach our own log appender so we can verify output
  final LogVerificationAppender appender = new LogVerificationAppender();
  final Logger logger = Logger.getRootLogger();
  logger.addAppender(appender);

  // Upgrade should now fail
  try {
    upgradeAndVerify(new MiniDFSCluster.Builder(upgradeConf).
        numDataNodes(4));
    fail("Upgrade did not fail with bad MD5");
  } catch (IOException ioe) {
    String msg = StringUtils.stringifyException(ioe);
    if (!msg.contains("Failed to load an FSImage file")) {
      throw ioe;
    }
    int md5failures = appender.countExceptionsWithMessage(
        " is corrupt with MD5 checksum of ");
    assertEquals("Upgrade did not fail with bad MD5", 1, md5failures);
  }
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:38,代码来源:TestDFSUpgradeFromImage.java

示例4: testUpgradeFromCorruptRel22Image

import org.apache.hadoop.hdfs.server.namenode.FSImageTestUtil; //导入方法依赖的package包/类
/**
 * Test upgrade from 0.22 image with corrupt md5, make sure it
 * fails to upgrade
 */
@Test
public void testUpgradeFromCorruptRel22Image() throws IOException {
  unpackStorage(HADOOP22_IMAGE, HADOOP_DFS_DIR_TXT);
  
  // Overwrite the md5 stored in the VERSION files
  File baseDir = new File(MiniDFSCluster.getBaseDirectory());
  FSImageTestUtil.corruptVersionFile(
      new File(baseDir, "name1/current/VERSION"),
      "imageMD5Digest", "22222222222222222222222222222222");
  FSImageTestUtil.corruptVersionFile(
      new File(baseDir, "name2/current/VERSION"),
      "imageMD5Digest", "22222222222222222222222222222222");
  
  // Attach our own log appender so we can verify output
  final LogVerificationAppender appender = new LogVerificationAppender();
  final Logger logger = Logger.getRootLogger();
  logger.addAppender(appender);

  // Upgrade should now fail
  try {
    upgradeAndVerify(new MiniDFSCluster.Builder(upgradeConf).
        numDataNodes(4));
    fail("Upgrade did not fail with bad MD5");
  } catch (IOException ioe) {
    String msg = StringUtils.stringifyException(ioe);
    if (!msg.contains("Failed to load an FSImage file")) {
      throw ioe;
    }
    int md5failures = appender.countExceptionsWithMessage(
        " is corrupt with MD5 checksum of ");
    assertEquals("Upgrade did not fail with bad MD5", 1, md5failures);
  }
}
 
开发者ID:yncxcw,项目名称:FlexMap,代码行数:38,代码来源:TestDFSUpgradeFromImage.java


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