use of org.apache.hadoop.hdfs.DFSOpsCountStatistics.OpType in project hadoop by apache.
the class TestDFSOpsCountStatistics method verifyStatistics.
/**
* We have the expected ops count in {@link #expectedOpsCountMap}, and this
* method is to verify that its ops count is the same as the one in
* {@link #statistics}.
*/
private void verifyStatistics() {
for (OpType opType : OpType.values()) {
assertNotNull(expectedOpsCountMap.get(opType));
assertNotNull(statistics.getLong(opType.getSymbol()));
assertEquals("Not expected count for operation " + opType.getSymbol(), expectedOpsCountMap.get(opType).longValue(), statistics.getLong(opType.getSymbol()).longValue());
}
}
use of org.apache.hadoop.hdfs.DFSOpsCountStatistics.OpType in project hadoop by apache.
the class TestDFSOpsCountStatistics method testOpTypeSymbolsAreUnique.
/**
* This is to test the the {@link OpType} symbols are unique.
*/
@Test
public void testOpTypeSymbolsAreUnique() {
final Set<String> opTypeSymbols = new HashSet<>();
for (OpType opType : OpType.values()) {
assertFalse(opTypeSymbols.contains(opType.getSymbol()));
opTypeSymbols.add(opType.getSymbol());
}
assertEquals(OpType.values().length, opTypeSymbols.size());
}
use of org.apache.hadoop.hdfs.DFSOpsCountStatistics.OpType in project hadoop by apache.
the class TestDFSOpsCountStatistics method incrementOpsCountByRandomNumbers.
/**
* This is helper method to increment the statistics by random data.
*/
private void incrementOpsCountByRandomNumbers() {
for (OpType opType : OpType.values()) {
final Long randomCount = RandomUtils.nextLong(0, 100);
expectedOpsCountMap.get(opType).addAndGet(randomCount);
for (long i = 0; i < randomCount; i++) {
statistics.incrementOpCounter(opType);
}
}
}
use of org.apache.hadoop.hdfs.DFSOpsCountStatistics.OpType in project hadoop by apache.
the class TestDFSOpsCountStatistics method testGetLongStatistics.
@Test
public void testGetLongStatistics() {
// number of the iter.hasNext()
short iterations = 0;
final Iterator<LongStatistic> iter = statistics.getLongStatistics();
while (iter.hasNext()) {
final LongStatistic longStat = iter.next();
assertNotNull(longStat);
final OpType opType = OpType.fromSymbol(longStat.getName());
assertNotNull(opType);
assertTrue(expectedOpsCountMap.containsKey(opType));
assertEquals(expectedOpsCountMap.get(opType).longValue(), longStat.getValue());
iterations++;
}
// check that all the OpType enum entries are iterated via iter
assertEquals(OpType.values().length, iterations);
}
use of org.apache.hadoop.hdfs.DFSOpsCountStatistics.OpType in project hadoop by apache.
the class TestDFSOpsCountStatistics method testReset.
@Test
public void testReset() {
statistics.reset();
for (OpType opType : OpType.values()) {
expectedOpsCountMap.get(opType).set(0);
}
final Iterator<LongStatistic> iter = statistics.getLongStatistics();
while (iter.hasNext()) {
final LongStatistic longStat = iter.next();
assertEquals(0, longStat.getValue());
}
incrementOpsCountByRandomNumbers();
verifyStatistics();
}
Aggregations