@Test public void testHFileV1DetectorWithCorruptFiles() throws Exception { Path tablePath = new Path(hbaseRootDir, "foo"); FileStatus[] regionsDir = fs.listStatus(tablePath); if (regionsDir == null) throw new IOException("No Regions found for table " + "foo"); Path columnFamilyDir = null; Path targetRegion = null; for (FileStatus s : regionsDir) { if (fs.exists(new Path(s.getPath(), HRegionFileSystem.REGION_INFO_FILE))) { targetRegion = s.getPath(); break; } } FileStatus[] cfs = fs.listStatus(targetRegion); for (FileStatus f : cfs) { if (f.isDirectory()) { columnFamilyDir = f.getPath(); break; } } LOG.debug("target columnFamilyDir: " + columnFamilyDir); Path corruptFile = new Path(columnFamilyDir, "corrupt_file"); if (!fs.createNewFile(corruptFile)) throw new IOException("Couldn't create corrupt file: " + corruptFile); assertEquals(1, ToolRunner.run(TEST_UTIL.getConfiguration(), new HFileV1Detector(), null)); FileSystem.get(TEST_UTIL.getConfiguration()).delete(corruptFile, false); }
@Override public int run(String[] args) throws Exception { if (!parseOption(args)) { printUsage(); return -1; } if (checkForHFileV1) { int res = doHFileV1Check(); if (res == 0) LOG.info("No HFileV1 found."); else { LOG.warn("There are some HFileV1, or corrupt files (files with incorrect major version)."); } return res; } else if (upgrade) { if (isAnyHBaseProcessAlive()) { LOG.error("Some HBase processes are still alive, or znodes not expired yet. " + "Please stop them before upgrade or try after some time."); throw new IOException("Some HBase processes are still alive, or znodes not expired yet"); } return executeUpgrade(); } return -1; }
UpgradeTo96 extends Configured implements Tool { @Override public int run(String[] args) throws Exception { if (!parseOption(args)) { printUsage(); return -1; } if (checkForHFileV1) { int res = doHFileV1Check(); if (res == 0) LOG.info("No HFileV1 found."); else { LOG.warn("There are some HFileV1, or corrupt files (files with incorrect major version)."); } return res; } else if (upgrade) { if (isAnyHBaseProcessAlive()) { LOG.error("Some HBase processes are still alive, or znodes not expired yet. " + "Please stop them before upgrade or try after some time."); throw new IOException("Some HBase processes are still alive, or znodes not expired yet"); } return executeUpgrade(); } return -1; } }
UpgradeTo96 extends Configured implements Tool { @Override public int run(String[] args) throws Exception { if (!parseOption(args)) { printUsage(); return -1; } if (checkForHFileV1) { int res = doHFileV1Check(); if (res == 0) LOG.info("No HFileV1 found."); else { LOG.warn("There are some HFileV1, or corrupt files (files with incorrect major version)."); } return res; } else if (upgrade) { if (isAnyHBaseProcessAlive()) { LOG.error("Some HBase processes are still alive, or znodes not expired yet. " + "Please stop them before upgrade or try after some time."); throw new IOException("Some HBase processes are still alive, or znodes not expired yet"); } return executeUpgrade(); } return -1; } UpgradeTo96(); }
UpgradeTo96 extends Configured implements Tool { @Override public int run(String[] args) throws Exception { if (!parseOption(args)) { printUsage(); return -1; } if (checkForHFileV1) { int res = doHFileV1Check(); if (res == 0) LOG.info("No HFileV1 found."); else { LOG.warn("There are some HFileV1, or corrupt files (files with incorrect major version)."); } return res; } else if (upgrade) { if (isAnyHBaseProcessAlive()) { LOG.error("Some HBase processes are still alive, or znodes not expired yet. " + "Please stop them before upgrade or try after some time."); throw new IOException("Some HBase processes are still alive, or znodes not expired yet"); } return executeUpgrade(); } return -1; } UpgradeTo96(); @Override int run(String[] args); static void main(String[] args); }
UpgradeTo96 extends Configured implements Tool { @Override public int run(String[] args) throws Exception { if (!parseOption(args)) { printUsage(); return -1; } if (checkForHFileV1) { int res = doHFileV1Check(); if (res == 0) LOG.info("No HFileV1 found."); else { LOG.warn("There are some HFileV1, or corrupt files (files with incorrect major version)."); } return res; } else if (upgrade) { if (isAnyHBaseProcessAlive()) { LOG.error("Some HBase processes are still alive, or znodes not expired yet. " + "Please stop them before upgrade or try after some time."); throw new IOException("Some HBase processes are still alive, or znodes not expired yet"); } return executeUpgrade(); } return -1; } UpgradeTo96(); @Override int run(String[] args); static void main(String[] args);  }