Java Code Examples for org.apache.hadoop.hdfs.DistributedFileSystem#getContentSummary()
The following examples show how to use
org.apache.hadoop.hdfs.DistributedFileSystem#getContentSummary() .
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: TestMain.java From Hue-Ctrip-DI with MIT License | 6 votes |
public void test() throws IOException { Configuration conf = new Configuration(); conf.addResource("conf/hdfs/test-hdfs-client-conf.xml"); System.setProperty("HADOOP_USER_NAME", "hdfs"); DistributedFileSystem fs = (DistributedFileSystem) FileSystem.get(conf); DatanodeInfo[] dataNodeStatus = fs.getDataNodeStats(); for (DatanodeInfo dninfo : dataNodeStatus) { System.out.println(dninfo.getHostName() + ", Is Decommission:" + dninfo.isDecommissioned()); System.out.println(dninfo.getHostName() + ", Dump Data node:" + dninfo.dumpDatanode()); } System.out.println("Default block size:" + fs.getDefaultBlockSize()); ContentSummary contentSummary = fs.getContentSummary(new Path("/")); System.out.println("Content Summary:" + contentSummary); FsStatus fsstatus = fs.getStatus(); System.out.println(fsstatus.getCapacity()); }
Example 2
Source File: TestHDFSFileContextMainOperations.java From hadoop with Apache License 2.0 | 5 votes |
@Test public void testTruncate() throws Exception { final short repl = 3; final int blockSize = 1024; final int numOfBlocks = 2; DistributedFileSystem fs = cluster.getFileSystem(); Path dir = getTestRootPath(fc, "test/hadoop"); Path file = getTestRootPath(fc, "test/hadoop/file"); final byte[] data = FileSystemTestHelper.getFileData( numOfBlocks, blockSize); FileSystemTestHelper.createFile(fs, file, data, blockSize, repl); final int newLength = blockSize; boolean isReady = fc.truncate(file, newLength); Assert.assertTrue("Recovery is not expected.", isReady); FileStatus fileStatus = fc.getFileStatus(file); Assert.assertEquals(fileStatus.getLen(), newLength); AppendTestUtil.checkFullFile(fs, file, newLength, data, file.toString()); ContentSummary cs = fs.getContentSummary(dir); Assert.assertEquals("Bad disk space usage", cs.getSpaceConsumed(), newLength * repl); Assert.assertTrue(fs.delete(dir, true)); }
Example 3
Source File: TestHDFSFileContextMainOperations.java From big-c with Apache License 2.0 | 5 votes |
@Test public void testTruncate() throws Exception { final short repl = 3; final int blockSize = 1024; final int numOfBlocks = 2; DistributedFileSystem fs = cluster.getFileSystem(); Path dir = getTestRootPath(fc, "test/hadoop"); Path file = getTestRootPath(fc, "test/hadoop/file"); final byte[] data = FileSystemTestHelper.getFileData( numOfBlocks, blockSize); FileSystemTestHelper.createFile(fs, file, data, blockSize, repl); final int newLength = blockSize; boolean isReady = fc.truncate(file, newLength); Assert.assertTrue("Recovery is not expected.", isReady); FileStatus fileStatus = fc.getFileStatus(file); Assert.assertEquals(fileStatus.getLen(), newLength); AppendTestUtil.checkFullFile(fs, file, newLength, data, file.toString()); ContentSummary cs = fs.getContentSummary(dir); Assert.assertEquals("Bad disk space usage", cs.getSpaceConsumed(), newLength * repl); Assert.assertTrue(fs.delete(dir, true)); }