Search in sources :

Example 1 with OzoneManagerDoubleBufferMetrics

use of org.apache.hadoop.ozone.om.ratis.metrics.OzoneManagerDoubleBufferMetrics in project ozone by apache.

the class TestOzoneManagerDoubleBufferWithDummyResponse method testDoubleBufferWithDummyResponse.

/**
 * This tests add's 100 bucket creation responses to doubleBuffer, and
 * check OM DB bucket table has 100 entries or not. In addition checks
 * flushed transaction count is matching with expected count or not.
 */
@Test(timeout = 300_000)
public void testDoubleBufferWithDummyResponse() throws Exception {
    String volumeName = UUID.randomUUID().toString();
    int bucketCount = 100;
    OzoneManagerDoubleBufferMetrics metrics = doubleBuffer.getOzoneManagerDoubleBufferMetrics();
    // As we have not flushed/added any transactions, all metrics should have
    // value zero.
    assertEquals(0, metrics.getTotalNumOfFlushOperations());
    assertEquals(0, metrics.getTotalNumOfFlushedTransactions());
    assertEquals(0, metrics.getMaxNumberOfTransactionsFlushedInOneIteration());
    for (int i = 0; i < bucketCount; i++) {
        doubleBuffer.add(createDummyBucketResponse(volumeName), trxId.incrementAndGet());
    }
    waitFor(() -> metrics.getTotalNumOfFlushedTransactions() == bucketCount, 100, 60000);
    assertTrue(metrics.getTotalNumOfFlushOperations() > 0);
    assertEquals(bucketCount, doubleBuffer.getFlushedTransactionCount());
    assertTrue(metrics.getMaxNumberOfTransactionsFlushedInOneIteration() > 0);
    assertEquals(bucketCount, omMetadataManager.countRowsInTable(omMetadataManager.getBucketTable()));
    assertTrue(doubleBuffer.getFlushIterations() > 0);
    assertTrue(metrics.getFlushTime().lastStat().numSamples() > 0);
    assertTrue(metrics.getAvgFlushTransactionsInOneIteration() > 0);
    // Assert there is only instance of OM Double Metrics.
    OzoneManagerDoubleBufferMetrics metricsCopy = OzoneManagerDoubleBufferMetrics.create();
    assertEquals(metrics, metricsCopy);
    // Check lastAppliedIndex is updated correctly or not.
    assertEquals(bucketCount, lastAppliedIndex);
    TransactionInfo transactionInfo = omMetadataManager.getTransactionInfoTable().get(TRANSACTION_INFO_KEY);
    assertNotNull(transactionInfo);
    Assert.assertEquals(lastAppliedIndex, transactionInfo.getTransactionIndex());
    Assert.assertEquals(term, transactionInfo.getTerm());
}
Also used : OzoneManagerDoubleBufferMetrics(org.apache.hadoop.ozone.om.ratis.metrics.OzoneManagerDoubleBufferMetrics) TransactionInfo(org.apache.hadoop.hdds.utils.TransactionInfo) Test(org.junit.Test)

Aggregations

TransactionInfo (org.apache.hadoop.hdds.utils.TransactionInfo)1 OzoneManagerDoubleBufferMetrics (org.apache.hadoop.ozone.om.ratis.metrics.OzoneManagerDoubleBufferMetrics)1 Test (org.junit.Test)1