use of org.apache.hadoop.metrics2.annotation.Metrics in project hadoop by apache.
the class TestStartupProgressMetrics method testFinalState.
@Test
public void testFinalState() {
setStartupProgressForFinalState(startupProgress);
MetricsRecordBuilder builder = getMetrics(metrics, true);
assertTrue(getLongCounter("ElapsedTime", builder) >= 0L);
assertGauge("PercentComplete", 1.0f, builder);
assertCounter("LoadingFsImageCount", 100L, builder);
assertTrue(getLongCounter("LoadingFsImageElapsedTime", builder) >= 0L);
assertCounter("LoadingFsImageTotal", 100L, builder);
assertGauge("LoadingFsImagePercentComplete", 1.0f, builder);
assertCounter("LoadingEditsCount", 200L, builder);
assertTrue(getLongCounter("LoadingEditsElapsedTime", builder) >= 0L);
assertCounter("LoadingEditsTotal", 200L, builder);
assertGauge("LoadingEditsPercentComplete", 1.0f, builder);
assertCounter("SavingCheckpointCount", 300L, builder);
assertTrue(getLongCounter("SavingCheckpointElapsedTime", builder) >= 0L);
assertCounter("SavingCheckpointTotal", 300L, builder);
assertGauge("SavingCheckpointPercentComplete", 1.0f, builder);
assertCounter("SafeModeCount", 400L, builder);
assertTrue(getLongCounter("SafeModeElapsedTime", builder) >= 0L);
assertCounter("SafeModeTotal", 400L, builder);
assertGauge("SafeModePercentComplete", 1.0f, builder);
}
use of org.apache.hadoop.metrics2.annotation.Metrics in project hadoop by apache.
the class TestStartupProgressMetrics method testInitialState.
@Test
public void testInitialState() {
MetricsRecordBuilder builder = getMetrics(metrics, true);
assertCounter("ElapsedTime", 0L, builder);
assertGauge("PercentComplete", 0.0f, builder);
assertCounter("LoadingFsImageCount", 0L, builder);
assertCounter("LoadingFsImageElapsedTime", 0L, builder);
assertCounter("LoadingFsImageTotal", 0L, builder);
assertGauge("LoadingFsImagePercentComplete", 0.0f, builder);
assertCounter("LoadingEditsCount", 0L, builder);
assertCounter("LoadingEditsElapsedTime", 0L, builder);
assertCounter("LoadingEditsTotal", 0L, builder);
assertGauge("LoadingEditsPercentComplete", 0.0f, builder);
assertCounter("SavingCheckpointCount", 0L, builder);
assertCounter("SavingCheckpointElapsedTime", 0L, builder);
assertCounter("SavingCheckpointTotal", 0L, builder);
assertGauge("SavingCheckpointPercentComplete", 0.0f, builder);
assertCounter("SafeModeCount", 0L, builder);
assertCounter("SafeModeElapsedTime", 0L, builder);
assertCounter("SafeModeTotal", 0L, builder);
assertGauge("SafeModePercentComplete", 0.0f, builder);
}
use of org.apache.hadoop.metrics2.annotation.Metrics in project hadoop by apache.
the class RollingWindowManager method snapshot.
/**
* Take a snapshot of current top users in the past period.
*
* @param time the current time
* @return a TopWindow describing the top users for each metric in the
* window.
*/
public TopWindow snapshot(long time) {
TopWindow window = new TopWindow(windowLenMs);
Set<String> metricNames = metricMap.keySet();
LOG.debug("iterating in reported metrics, size={} values={}", metricNames.size(), metricNames);
for (Map.Entry<String, RollingWindowMap> entry : metricMap.entrySet()) {
String metricName = entry.getKey();
RollingWindowMap rollingWindows = entry.getValue();
TopN topN = getTopUsersForMetric(time, metricName, rollingWindows);
final int size = topN.size();
if (size == 0) {
continue;
}
Op op = new Op(metricName, topN.getTotal());
window.addOp(op);
// Reverse the users from the TopUsers using a stack,
// since we'd like them sorted in descending rather than ascending order
Stack<NameValuePair> reverse = new Stack<NameValuePair>();
for (int i = 0; i < size; i++) {
reverse.push(topN.poll());
}
for (int i = 0; i < size; i++) {
NameValuePair userEntry = reverse.pop();
User user = new User(userEntry.getName(), userEntry.getValue());
op.addUser(user);
}
}
return window;
}
use of org.apache.hadoop.metrics2.annotation.Metrics 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.annotation.Metrics 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);
}
Aggregations