deniskuzZ commented on a change in pull request #2074:
URL: https://github.com/apache/hive/pull/2074#discussion_r595112171
##########
File path:
ql/src/test/org/apache/hadoop/hive/ql/txn/compactor/TestCompactionMetrics.java
##########
@@ -347,6 +348,38 @@ public void testAgeMetricsOrder() {
Assert.assertTrue(Metrics.getOrCreateGauge(MetricsConstants.COMPACTION_OLDEST_ENQUEUE_AGE).intValue()
> 10);
}
+ @Test
+ public void testDBMetrics() throws Exception {
+ MetastoreConf.setBoolVar(conf, MetastoreConf.ConfVars.METRICS_ENABLED,
true);
+ Metrics.initialize(conf);
+
+ Table t = newTable("default", "dcamc", false);
+ burnThroughTransactions(t.getDbName(), t.getTableName(), 24);
+
+ LockComponent comp = new LockComponent(LockType.SHARED_WRITE,
LockLevel.TABLE, t.getDbName());
+ comp.setTablename(t.getTableName());
+ comp.setOperationType(DataOperationType.UPDATE);
+
+ long txnid = openTxn();
+
+ LockRequest req = new LockRequest(Lists.newArrayList(comp), "me",
"localhost");
+ req.setTxnid(txnid);
+ LockResponse res = txnHandler.lock(req);
+ Assert.assertEquals(LockState.ACQUIRED, res.getState());
+
+ long writeid = allocateWriteId(t.getDbName(), t.getTableName(), txnid);
+ Assert.assertEquals(25, writeid);
+ txnHandler.commitTxn(new CommitTxnRequest(txnid));
+
+ // The metrics will appear after the next AcidMetricsService run
+ runAcidMetricService();
+
+ Assert.assertEquals(25,
+ Metrics.getOrCreateGauge(MetricsConstants.COMPACTION_STATUS_PREFIX +
"txn_to_writeid").intValue());
+ Assert.assertEquals(1,
Review comment:
added
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]