use of org.apache.hadoop.metrics2.MetricsRecordBuilder in project hadoop by apache.
the class TestBatchIbr method logIbrCounts.
static void logIbrCounts(List<DataNode> datanodes) {
final String name = "IncrementalBlockReportsNumOps";
for (DataNode dn : datanodes) {
final MetricsRecordBuilder m = MetricsAsserts.getMetrics(dn.getMetrics().name());
final long ibr = MetricsAsserts.getLongCounter(name, m);
LOG.info(dn.getDisplayName() + ": " + name + "=" + ibr);
}
}
use of org.apache.hadoop.metrics2.MetricsRecordBuilder in project hadoop by apache.
the class TestFSNamesystemLock method testDetailedHoldMetrics.
@Test
public void testDetailedHoldMetrics() throws Exception {
Configuration conf = new Configuration();
conf.setBoolean(DFSConfigKeys.DFS_NAMENODE_LOCK_DETAILED_METRICS_KEY, true);
FakeTimer timer = new FakeTimer();
MetricsRegistry registry = new MetricsRegistry("Test");
MutableRatesWithAggregation rates = registry.newRatesWithAggregation("Test");
FSNamesystemLock fsLock = new FSNamesystemLock(conf, rates, timer);
fsLock.readLock();
timer.advance(1);
fsLock.readUnlock("foo");
fsLock.readLock();
timer.advance(2);
fsLock.readUnlock("foo");
fsLock.readLock();
timer.advance(1);
fsLock.readLock();
timer.advance(1);
fsLock.readUnlock("bar");
fsLock.readUnlock("bar");
fsLock.writeLock();
timer.advance(1);
fsLock.writeUnlock("baz");
MetricsRecordBuilder rb = MetricsAsserts.mockMetricsRecordBuilder();
rates.snapshot(rb, true);
assertGauge("FSNReadLockFooAvgTime", 1.5, rb);
assertCounter("FSNReadLockFooNumOps", 2L, rb);
assertGauge("FSNReadLockBarAvgTime", 2.0, rb);
assertCounter("FSNReadLockBarNumOps", 1L, rb);
assertGauge("FSNWriteLockBazAvgTime", 1.0, rb);
assertCounter("FSNWriteLockBazNumOps", 1L, rb);
}
use of org.apache.hadoop.metrics2.MetricsRecordBuilder in project hadoop by apache.
the class TestNameNodeMetrics method testCapacityMetrics.
/**
* Test that capacity metrics are exported and pass
* basic sanity tests.
*/
@Test(timeout = 1800)
public void testCapacityMetrics() throws Exception {
MetricsRecordBuilder rb = getMetrics(NS_METRICS);
long capacityTotal = MetricsAsserts.getLongGauge("CapacityTotal", rb);
assert (capacityTotal != 0);
long capacityUsed = MetricsAsserts.getLongGauge("CapacityUsed", rb);
long capacityRemaining = MetricsAsserts.getLongGauge("CapacityRemaining", rb);
long capacityUsedNonDFS = MetricsAsserts.getLongGauge("CapacityUsedNonDFS", rb);
// considered.
assert (capacityUsed + capacityRemaining + capacityUsedNonDFS <= capacityTotal);
}
use of org.apache.hadoop.metrics2.MetricsRecordBuilder in project hadoop by apache.
the class TestNameNodeMetrics method testFileAdd.
/** Test metrics associated with addition of a file */
@Test
public void testFileAdd() throws Exception {
// Add files with 100 blocks
final Path file = getTestPath("testFileAdd");
createFile(file, 3200, (short) 3);
final long blockCount = 32;
int blockCapacity = namesystem.getBlockCapacity();
assertGauge("BlockCapacity", blockCapacity, getMetrics(NS_METRICS));
MetricsRecordBuilder rb = getMetrics(NN_METRICS);
// File create operations is 1
// Number of files created is depth of <code>file</code> path
assertCounter("CreateFileOps", 1L, rb);
assertCounter("FilesCreated", (long) file.depth(), rb);
// Add 1 for root
long filesTotal = file.depth() + 1;
rb = getMetrics(NS_METRICS);
assertGauge("FilesTotal", filesTotal, rb);
assertGauge("BlocksTotal", blockCount, rb);
fs.delete(file, true);
// reduce the filecount for deleted file
filesTotal--;
rb = waitForDnMetricValue(NS_METRICS, "FilesTotal", filesTotal);
assertGauge("BlocksTotal", 0L, rb);
assertGauge("PendingDeletionBlocks", 0L, rb);
rb = getMetrics(NN_METRICS);
// Delete file operations and number of files deleted must be 1
assertCounter("DeleteFileOps", 1L, rb);
assertCounter("FilesDeleted", 1L, rb);
}
use of org.apache.hadoop.metrics2.MetricsRecordBuilder in project hadoop by apache.
the class TestNameNodeMetrics method testRenameMetrics.
@Test
public void testRenameMetrics() throws Exception {
Path src = getTestPath("src");
createFile(src, 100, (short) 1);
Path target = getTestPath("target");
createFile(target, 100, (short) 1);
fs.rename(src, target, Rename.OVERWRITE);
MetricsRecordBuilder rb = getMetrics(NN_METRICS);
assertCounter("FilesRenamed", 1L, rb);
assertCounter("FilesDeleted", 1L, rb);
}
Aggregations