remoteData.length, abfsStatistics.getBytesRead()); assertEquals("bytes written in " + stats, sourceData.length, abfsStatistics.getBytesWritten());
@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()); }
@Test public void testStatistics() throws IOException, URISyntaxException { URI fsUri = getFsUri(); Statistics stats = FileContext.getStatistics(fsUri); Assert.assertEquals(0, stats.getBytesRead()); Path filePath = fileContextTestHelper .getTestRootPath(fc, "file1"); createFile(fc, filePath, numBlocks, blockSize); Assert.assertEquals(0, stats.getBytesRead()); verifyWrittenBytes(stats); FSDataInputStream fstr = fc.open(filePath); byte[] buf = new byte[blockSize]; int bytesRead = fstr.read(buf, 0, blockSize); fstr.read(0, buf, 0, blockSize); Assert.assertEquals(blockSize, bytesRead); verifyReadBytes(stats); verifyWrittenBytes(stats); verifyReadBytes(FileContext.getStatistics(getFsUri())); Map<URI, Statistics> statsMap = FileContext.getAllStatistics(); URI exactUri = getSchemeAuthorityUri(); verifyWrittenBytes(statsMap.get(exactUri)); fc.delete(filePath, true); }
@Test(timeout=60000) public void testStatisticsOperations() throws Exception { final Statistics stats = new Statistics("file"); Assert.assertEquals(0L, stats.getBytesRead()); Assert.assertEquals(0L, stats.getBytesWritten()); Assert.assertEquals(0, stats.getWriteOps()); Assert.assertEquals(0, stats.getWriteOps()); Assert.assertEquals(0L, stats.getBytesWritten()); Assert.assertEquals(0L, stats.getBytesRead()); Assert.assertEquals(124, stats2.getWriteOps()); Assert.assertEquals(1000L, stats2.getBytesWritten()); Assert.assertEquals(0L, stats2.getBytesRead());
@Test(timeout=60000) public void testStatisticsOperations() throws Exception { final Statistics stats = new Statistics("file"); Assert.assertEquals(0L, stats.getBytesRead()); Assert.assertEquals(0L, stats.getBytesWritten()); Assert.assertEquals(0, stats.getWriteOps()); Assert.assertEquals(0, stats.getWriteOps()); Assert.assertEquals(0L, stats.getBytesWritten()); Assert.assertEquals(0L, stats.getBytesRead()); Assert.assertEquals(124, stats2.getWriteOps()); Assert.assertEquals(1000L, stats2.getBytesWritten()); Assert.assertEquals(0L, stats2.getBytesRead());
/** * When tests are ran in parallel, this tests will fail because * FileSystem.Statistics is per FileSystem class. */ @SuppressWarnings("deprecation") private void testStatistics(NativeAzureFileSystem fs) 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"); writeStringToFile(fs, newFile, "12345678"); assertEquals(8, stats.getBytesWritten()); assertEquals(0, stats.getBytesRead()); String readBack = readStringFromFile(fs, 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()); } }
@Test public void testStatistics() throws IOException, URISyntaxException { URI fsUri = getFsUri(); Statistics stats = FileContext.getStatistics(fsUri); Assert.assertEquals(0, stats.getBytesRead()); Path filePath = fileContextTestHelper .getTestRootPath(fc, "file1"); createFile(fc, filePath, numBlocks, blockSize); Assert.assertEquals(0, stats.getBytesRead()); verifyWrittenBytes(stats); FSDataInputStream fstr = fc.open(filePath); byte[] buf = new byte[blockSize]; int bytesRead = fstr.read(buf, 0, blockSize); fstr.read(0, buf, 0, blockSize); Assert.assertEquals(blockSize, bytesRead); verifyReadBytes(stats); verifyWrittenBytes(stats); verifyReadBytes(FileContext.getStatistics(getFsUri())); Map<URI, Statistics> statsMap = FileContext.getAllStatistics(); URI exactUri = getSchemeAuthorityUri(); verifyWrittenBytes(statsMap.get(exactUri)); fc.delete(filePath, true); }
void updateCounters() { long newReadBytes = stats.getBytesRead(); long newWriteBytes = stats.getBytesWritten(); if (prevReadBytes != newReadBytes) { if (readCounter == null) { readCounter = counters.findCounter(FILESYSTEM_COUNTER_GROUP, counterNames[0]); } readCounter.increment(newReadBytes - prevReadBytes); prevReadBytes = newReadBytes; } if (prevWriteBytes != newWriteBytes) { if (writeCounter == null) { writeCounter = counters.findCounter(FILESYSTEM_COUNTER_GROUP, counterNames[1]); } writeCounter.increment(newWriteBytes - prevWriteBytes); prevWriteBytes = newWriteBytes; } } }
void updateCounters() { long newReadBytes = stats.getBytesRead(); long newWriteBytes = stats.getBytesWritten(); if (prevReadBytes != newReadBytes) { if (readCounter == null) { readCounter = counters.findCounter(read); } readCounter.increment(newReadBytes - prevReadBytes); prevReadBytes = newReadBytes; } if (prevWriteBytes != newWriteBytes) { if (writeCounter == null) { writeCounter = counters.findCounter(write); } writeCounter.increment(newWriteBytes - prevWriteBytes); prevWriteBytes = newWriteBytes; } } }
private long getInputBytes(List<Statistics> stats) { if (stats == null) return 0; long bytesRead = 0; for (Statistics stat: stats) { bytesRead = bytesRead + stat.getBytesRead(); } return bytesRead; } }
private long getInputBytes(List<Statistics> stats) { if (stats == null) return 0; long bytesRead = 0; for (Statistics stat: stats) { bytesRead = bytesRead + stat.getBytesRead(); } return bytesRead; } }
@Override protected void verifyReadBytes(Statistics stats) { // one blockSize for read, one for pread Assert.assertEquals(2*blockSize, stats.getBytesRead()); }
private long getInputBytes(List<Statistics> stats) { if (stats == null) return 0; long bytesRead = 0; for (Statistics stat: stats) { bytesRead = bytesRead + stat.getBytesRead(); } return bytesRead; } }
private long getInputBytes(List<Statistics> stats) { if (stats == null) return 0; long bytesRead = 0; for (Statistics stat: stats) { bytesRead = bytesRead + stat.getBytesRead(); } return bytesRead; } }
private long getInputBytes(List<Statistics> stats) { if (stats == null) return 0; long bytesRead = 0; for (Statistics stat: stats) { bytesRead = bytesRead + stat.getBytesRead(); } return bytesRead; } }
private long getInputBytes(List<Statistics> stats) { if (stats == null) return 0; long bytesRead = 0; for (Statistics stat: stats) { bytesRead = bytesRead + stat.getBytesRead(); } return bytesRead; } }
private long getInputBytes(List<Statistics> stats) { if (stats == null) return 0; long bytesRead = 0; for (Statistics stat: stats) { bytesRead = bytesRead + stat.getBytesRead(); } return bytesRead; } }
private long getInputBytes(List<Statistics> stats) { if (stats == null) return 0; long bytesRead = 0; for (Statistics stat: stats) { bytesRead = bytesRead + stat.getBytesRead(); } return bytesRead; } }
@Override protected void verifyReadBytes(Statistics stats) { // one blockSize for read, one for pread Assert.assertEquals(2*blockSize, stats.getBytesRead()); }
private static FileSystem.Statistics combineFileSystemStatistics(final FileSystem.Statistics s1, final FileSystem.Statistics s2) { FileSystem.Statistics result = new FileSystem.Statistics(s1); result.incrementReadOps(s2.getReadOps()); result.incrementLargeReadOps(s2.getLargeReadOps()); result.incrementWriteOps(s2.getWriteOps()); result.incrementBytesRead(s2.getBytesRead()); result.incrementBytesWritten(s2.getBytesWritten()); return result; }