Java Code Examples for org.apache.hadoop.fs.FileSystem.getStatistics()

The following are Jave code examples for showing how to use getStatistics() of the org.apache.hadoop.fs.FileSystem class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: hadoop   File: NativeAzureFileSystemBaseTest.java   Source Code and License Vote up 6 votes
@Test
public void testStatistics() throws Exception {
  FileSystem.clearStatistics();
  FileSystem.Statistics stats = FileSystem.getStatistics("wasb",
      NativeAzureFileSystem.class);
  assertEquals(0, stats.getBytesRead());
  assertEquals(0, stats.getBytesWritten());
  Path newFile = new Path("testStats");
  writeString(newFile, "12345678");
  assertEquals(8, stats.getBytesWritten());
  assertEquals(0, stats.getBytesRead());
  String readBack = readString(newFile);
  assertEquals("12345678", readBack);
  assertEquals(8, stats.getBytesRead());
  assertEquals(8, stats.getBytesWritten());
  assertTrue(fs.delete(newFile, true));
  assertEquals(8, stats.getBytesRead());
  assertEquals(8, stats.getBytesWritten());
}
 
Example 2
Project: hadoop   File: DFSTestUtil.java   Source Code and License Vote up 4 votes
public static Statistics getStatistics(FileSystem fs) {
  return FileSystem.getStatistics(fs.getUri().getScheme(), fs.getClass());
}