public static void main(String[] args) throws Exception { // -files option is also used by GenericOptionsParser // Make sure that is not the first argument for fsck int res = -1; if ((args.length == 0) || ("-files".equals(args[0]))) { printUsage(System.err); } else if (DFSUtil.parseHelpArgument(args, USAGE, System.out, true)) { res = 0; } else { res = ToolRunner.run(new DFSck(new HdfsConfiguration()), args); } System.exit(res); } }
private Path getResolvedPath(String dir) throws IOException { Configuration conf = getConf(); Path dirPath = new Path(dir); FileSystem fs = dirPath.getFileSystem(conf); return fs.resolvePath(dirPath); }
System.err.println("fsck: can only operate on one path at a time '" + args[idx] + "'"); printUsage(System.err); return -1; printUsage(System.err); return -1; URI namenodeAddress = null; try { dirpath = getResolvedPath(dir); namenodeAddress = getCurrentNamenodeAddress(dirpath); } catch (IOException ioe) { System.err.println("FileSystem is inaccessible due to:\n" return listCorruptFileBlocks(dir, url.toString());
args = DFSUtil.setGenericConf(args, getConf()); } catch (IllegalArgumentException e) { System.err.println(e.getMessage()); printUsage(); return -1; String fsName = getInfoServer(); if (args.length == 0) { printUsage(); return -1; return listCorruptFileBlocks(dir, limit, url.toString());
static String runFsck(Configuration conf, int expectedErrCode, boolean checkErrorCode,String... path) throws Exception { ByteArrayOutputStream bStream = new ByteArrayOutputStream(); PrintStream out = new PrintStream(bStream, true); ((Log4JLogger)FSPermissionChecker.LOG).getLogger().setLevel(Level.ALL); int errCode = ToolRunner.run(new DFSck(conf, out), path); if (checkErrorCode) assertEquals(expectedErrCode, errCode); ((Log4JLogger)FSPermissionChecker.LOG).getLogger().setLevel(Level.INFO); return bStream.toString(); }
String fsName = getInfoServer(); if (args.length == 0) { printUsage(); return -1;
@Override public int run(final String[] args) throws IOException { if (args.length == 0) { printUsage(System.err); return -1; } try { return UserGroupInformation.getCurrentUser().doAs( new PrivilegedExceptionAction<Integer>() { @Override public Integer run() throws Exception { return doWork(args); } }); } catch (InterruptedException e) { throw new IOException(e); } }
static String runFsck(Configuration conf, int expectedErrCode, boolean checkErrorCode, String... path) throws Exception { ByteArrayOutputStream bStream = new ByteArrayOutputStream(); PrintStream out = new PrintStream(bStream, true); int errCode = ToolRunner.run(new DFSck(conf, out), path); if (checkErrorCode) Assert.assertEquals(expectedErrCode, errCode); return bStream.toString(); } }
@Override public int run(final String[] args) throws IOException { if (args.length == 0) { printUsage(System.err); return -1; } try { return UserGroupInformation.getCurrentUser().doAs( new PrivilegedExceptionAction<Integer>() { @Override public Integer run() throws Exception { return doWork(args); } }); } catch (InterruptedException e) { throw new IOException(e); } }
public static void main(String[] args) throws Exception { // -files option is also used by GenericOptionsParser // Make sure that is not the first argument for fsck int res = -1; if ((args.length == 0 ) || ("-files".equals(args[0]))) printUsage(); else res = ToolRunner.run(new DFSck(new Configuration()), args); System.exit(res); } }
System.err.println("fsck: can only operate on one path at a time '" + args[idx] + "'"); printUsage(System.err); return -1; printUsage(System.err); return -1; URI namenodeAddress = null; try { dirpath = getResolvedPath(dir); namenodeAddress = getCurrentNamenodeAddress(dirpath); } catch (IOException ioe) { System.err.println("FileSystem is inaccessible due to:\n" return listCorruptFileBlocks(dir, url.toString());
static void runFsck(Configuration conf) throws Exception { ByteArrayOutputStream bStream = new ByteArrayOutputStream(); PrintStream out = new PrintStream(bStream, true); int errCode = ToolRunner.run(new DFSck(conf, out), new String[]{"/", "-files"}); String result = bStream.toString(); System.out.println("output from fsck:\n" + result); assertEquals(0, errCode); assertTrue(result.contains("/test1")); assertTrue(result.contains("/test2")); } }
/** * Derive the namenode http address from the current file system, * either default or as set by "-fs" in the generic options. * @return Returns http address or null if failure. * @throws IOException if we can't determine the active NN address */ private URI getCurrentNamenodeAddress(Path target) throws IOException { //String nnAddress = null; Configuration conf = getConf(); //get the filesystem object to verify it is an HDFS system final FileSystem fs = target.getFileSystem(conf); if (!(fs instanceof DistributedFileSystem)) { System.err.println("FileSystem is " + fs.getUri()); return null; } return DFSUtil.getInfoServer(HAUtil.getAddressOfActive(fs), conf, DFSUtil.getHttpClientScheme(conf)); }
@Override public int run(final String[] args) throws IOException { if (args.length == 0) { printUsage(System.err); return -1; } try { return UserGroupInformation.getCurrentUser().doAs( new PrivilegedExceptionAction<Integer>() { @Override public Integer run() throws Exception { return doWork(args); } }); } catch (InterruptedException e) { throw new IOException(e); } }
public static void main(String[] args) throws Exception { // -files option is also used by GenericOptionsParser // Make sure that is not the first argument for fsck int res = -1; if ((args.length == 0 ) || ("-files".equals(args[0]))) printUsage(); else res = ToolRunner.run(new DFSck(new Configuration()), args); System.exit(res); } }
System.err.println("fsck: can only operate on one path at a time '" + args[idx] + "'"); printUsage(System.err); return -1; printUsage(System.err); return -1; URI namenodeAddress = null; try { dirpath = getResolvedPath(dir); namenodeAddress = getCurrentNamenodeAddress(dirpath); } catch (IOException ioe) { System.err.println("FileSystem is inaccessible due to:\n" return listCorruptFileBlocks(dir, url.toString());
static String runFsck(Configuration conf, int expectedErrCode, boolean checkErrorCode,String... path) throws Exception { ByteArrayOutputStream bStream = new ByteArrayOutputStream(); PrintStream out = new PrintStream(bStream, true); ((Log4JLogger)FSPermissionChecker.LOG).getLogger().setLevel(Level.ALL); int errCode = ToolRunner.run(new DFSck(conf, out), path); if (checkErrorCode) { assertEquals(expectedErrCode, errCode); } ((Log4JLogger)FSPermissionChecker.LOG).getLogger().setLevel(Level.INFO); FSImage.LOG.error("OUTPUT = " + bStream.toString()); return bStream.toString(); }
private Path getResolvedPath(String dir) throws IOException { Configuration conf = getConf(); Path dirPath = new Path(dir); FileSystem fs = dirPath.getFileSystem(conf); return fs.resolvePath(dirPath); }
public static void main(String[] args) throws Exception { // -files option is also used by GenericOptionsParser // Make sure that is not the first argument for fsck int res = -1; if ((args.length == 0) || ("-files".equals(args[0]))) { printUsage(System.err); ToolRunner.printGenericCommandUsage(System.err); } else if (DFSUtil.parseHelpArgument(args, USAGE, System.out, true)) { res = 0; } else { res = ToolRunner.run(new DFSck(new HdfsConfiguration()), args); } System.exit(res); } }
/** * Test running fsck on a system with encryption zones. */ @Test(timeout = 60000) public void testFsckOnEncryptionZones() throws Exception { final int len = 8196; final Path zoneParent = new Path("/zones"); final Path zone1 = new Path(zoneParent, "zone1"); final Path zone1File = new Path(zone1, "file"); fsWrapper.mkdir(zone1, FsPermission.getDirDefault(), true); dfsAdmin.createEncryptionZone(zone1, TEST_KEY); DFSTestUtil.createFile(fs, zone1File, len, (short) 1, 0xFEED); ByteArrayOutputStream bStream = new ByteArrayOutputStream(); PrintStream out = new PrintStream(bStream, true); int errCode = ToolRunner.run(new DFSck(conf, out), new String[]{ "/" }); assertEquals("Fsck ran with non-zero error code", 0, errCode); String result = bStream.toString(); assertTrue("Fsck did not return HEALTHY status", result.contains(NamenodeFsck.HEALTHY_STATUS)); // Run fsck directly on the encryption zone instead of root errCode = ToolRunner.run(new DFSck(conf, out), new String[]{ zoneParent.toString() }); assertEquals("Fsck ran with non-zero error code", 0, errCode); result = bStream.toString(); assertTrue("Fsck did not return HEALTHY status", result.contains(NamenodeFsck.HEALTHY_STATUS)); }