org.apache.hadoop.hdfs.server.namenode.NamenodeFsck Java Examples
The following examples show how to use
org.apache.hadoop.hdfs.server.namenode.NamenodeFsck.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestClientReportBadBlock.java From hadoop with Apache License 2.0 | 5 votes |
private static void verifyFsckHealth(String expected) throws Exception { // Fsck health has error code 0. // Make sure filesystem is in healthy state String outStr = runFsck(conf, 0, true, "/"); LOG.info(outStr); Assert.assertTrue(outStr.contains(NamenodeFsck.HEALTHY_STATUS)); if (!expected.equals("")) { Assert.assertTrue(outStr.contains(expected)); } }
Example #2
Source File: TestEncryptionZones.java From hadoop with Apache License 2.0 | 5 votes |
/** * 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)); }
Example #3
Source File: TestClientReportBadBlock.java From big-c with Apache License 2.0 | 5 votes |
private static void verifyFsckHealth(String expected) throws Exception { // Fsck health has error code 0. // Make sure filesystem is in healthy state String outStr = runFsck(conf, 0, true, "/"); LOG.info(outStr); Assert.assertTrue(outStr.contains(NamenodeFsck.HEALTHY_STATUS)); if (!expected.equals("")) { Assert.assertTrue(outStr.contains(expected)); } }
Example #4
Source File: TestEncryptionZones.java From big-c with Apache License 2.0 | 5 votes |
/** * 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)); }
Example #5
Source File: TestClientReportBadBlock.java From hadoop with Apache License 2.0 | 4 votes |
private static void verifyFsckBlockCorrupted() throws Exception { String outStr = runFsck(conf, 1, true, "/"); LOG.info(outStr); Assert.assertTrue(outStr.contains(NamenodeFsck.CORRUPT_STATUS)); }
Example #6
Source File: TestClientReportBadBlock.java From big-c with Apache License 2.0 | 4 votes |
private static void verifyFsckBlockCorrupted() throws Exception { String outStr = runFsck(conf, 1, true, "/"); LOG.info(outStr); Assert.assertTrue(outStr.contains(NamenodeFsck.CORRUPT_STATUS)); }
Example #7
Source File: DFSck.java From RDFS with Apache License 2.0 | 4 votes |
/** * @param args */ public int run(String[] args) throws Exception { try { 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; } StringBuffer url = new StringBuffer("http://"+fsName+"/fsck?path="); String dir = "/"; int limit = 500; // limit output. // find top-level dir first for (int idx = 0; idx < args.length; ) { if (args[idx].equals("-limit")) { idx++; // Skip over limit value } else if (!args[idx].startsWith("-")) { dir = args[idx]; break; } idx++; } url.append(URLEncoder.encode(dir, "UTF-8")); boolean doListCorruptFileBlocks = false; for (int idx = 0; idx < args.length; ) { if (args[idx].equals("-move")) { url.append("&move=1"); } else if (args[idx].equals("-delete")) { url.append("&delete=1"); } else if (args[idx].equals("-files")) { url.append("&files=1"); } else if (args[idx].equals("-openforwrite")) { url.append("&openforwrite=1"); } else if (args[idx].equals("-blocks")) { url.append("&blocks=1"); } else if (args[idx].equals("-locations")) { url.append("&locations=1"); } else if (args[idx].equals("-racks")) { url.append("&racks=1"); } else if (args[idx].equals("-list-corruptfileblocks")) { url.append("&listcorruptfileblocks=1"); doListCorruptFileBlocks = true; } else if (args[idx].equals("-limit")) { idx++; limit = Integer.parseInt(args[idx]); } else if (args[idx].equals("-list-decommissioningblocks")) { url.append("&decommissioning=1"); } idx++; } if (doListCorruptFileBlocks) { return listCorruptFileBlocks(dir, limit, url.toString()); } URL path = new URL(url.toString()); System.err.println("Connecting to : " + path); URLConnection connection = path.openConnection(); InputStream stream = connection.getInputStream(); BufferedReader input = new BufferedReader(new InputStreamReader( stream, "UTF-8")); String line = null; String lastLine = null; int errCode = -1; try { while ((line = input.readLine()) != null) { out.println(line); lastLine = line; } } finally { input.close(); } if (lastLine.endsWith(NamenodeFsck.HEALTHY_STATUS)) { errCode = 0; } else if (lastLine.endsWith(NamenodeFsck.CORRUPT_STATUS)) { errCode = 1; } else if (lastLine.endsWith(NamenodeFsck.NONEXISTENT_STATUS)) { errCode = 0; } return errCode; }
Example #8
Source File: DFSck.java From hadoop-gpu with Apache License 2.0 | 4 votes |
/** * @param args */ public int run(String[] args) throws Exception { String fsName = getInfoServer(); if (args.length == 0) { printUsage(); return -1; } StringBuffer url = new StringBuffer("http://"+fsName+"/fsck?path="); String dir = "/"; // find top-level dir first for (int idx = 0; idx < args.length; idx++) { if (!args[idx].startsWith("-")) { dir = args[idx]; break; } } url.append(URLEncoder.encode(dir, "UTF-8")); for (int idx = 0; idx < args.length; idx++) { if (args[idx].equals("-move")) { url.append("&move=1"); } else if (args[idx].equals("-delete")) { url.append("&delete=1"); } else if (args[idx].equals("-files")) { url.append("&files=1"); } else if (args[idx].equals("-openforwrite")) { url.append("&openforwrite=1"); } else if (args[idx].equals("-blocks")) { url.append("&blocks=1"); } else if (args[idx].equals("-locations")) { url.append("&locations=1"); } else if (args[idx].equals("-racks")) { url.append("&racks=1"); } } URL path = new URL(url.toString()); URLConnection connection = path.openConnection(); InputStream stream = connection.getInputStream(); BufferedReader input = new BufferedReader(new InputStreamReader( stream, "UTF-8")); String line = null; String lastLine = null; int errCode = -1; try { while ((line = input.readLine()) != null) { System.out.println(line); lastLine = line; } } finally { input.close(); } if (lastLine.endsWith(NamenodeFsck.HEALTHY_STATUS)) { errCode = 0; } else if (lastLine.endsWith(NamenodeFsck.CORRUPT_STATUS)) { errCode = 1; } else if (lastLine.endsWith(NamenodeFsck.NONEXISTENT_STATUS)) { errCode = 0; } return errCode; }