Search in sources :

Example 1 with HiveLockManagerCtx

use of org.apache.hadoop.hive.ql.lockmgr.HiveLockManagerCtx in project hive by apache.

the class TestZookeeperLockManager method testMetrics.

@Test
public void testMetrics() throws Exception {
    conf.setVar(HiveConf.ConfVars.HIVE_ZOOKEEPER_QUORUM, "localhost");
    conf.setVar(HiveConf.ConfVars.HIVE_ZOOKEEPER_CLIENT_PORT, String.valueOf(server.getPort()));
    conf.setBoolVar(HiveConf.ConfVars.HIVE_SERVER2_METRICS_ENABLED, true);
    conf.setBoolVar(HiveConf.ConfVars.HIVE_SUPPORT_CONCURRENCY, false);
    conf.setVar(HiveConf.ConfVars.HIVE_METRICS_REPORTER, MetricsReporting.JSON_FILE.name() + "," + MetricsReporting.JMX.name());
    MetricsFactory.init(conf);
    CodahaleMetrics metrics = (CodahaleMetrics) MetricsFactory.getInstance();
    HiveLockManagerCtx ctx = new HiveLockManagerCtx(conf);
    ZooKeeperHiveLockManager zMgr = new ZooKeeperHiveLockManager();
    zMgr.setContext(ctx);
    ZooKeeperHiveLock curLock = zMgr.lock(hiveLock, HiveLockMode.SHARED, false);
    String json = metrics.dumpJson();
    MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.COUNTER, MetricsConstant.ZOOKEEPER_HIVE_SHAREDLOCKS, 1);
    zMgr.unlock(curLock);
    json = metrics.dumpJson();
    MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.COUNTER, MetricsConstant.ZOOKEEPER_HIVE_SHAREDLOCKS, 0);
    zMgr.close();
}
Also used : CodahaleMetrics(org.apache.hadoop.hive.common.metrics.metrics2.CodahaleMetrics) HiveLockManagerCtx(org.apache.hadoop.hive.ql.lockmgr.HiveLockManagerCtx) Test(org.junit.Test)

Aggregations

CodahaleMetrics (org.apache.hadoop.hive.common.metrics.metrics2.CodahaleMetrics)1 HiveLockManagerCtx (org.apache.hadoop.hive.ql.lockmgr.HiveLockManagerCtx)1 Test (org.junit.Test)1