diff --git a/common/src/java/org/apache/hadoop/hive/common/metrics/common/MetricsConstant.java b/common/src/java/org/apache/hadoop/hive/common/metrics/common/MetricsConstant.java index 3477187..deca7e8 100644 --- a/common/src/java/org/apache/hadoop/hive/common/metrics/common/MetricsConstant.java +++ b/common/src/java/org/apache/hadoop/hive/common/metrics/common/MetricsConstant.java @@ -44,7 +44,11 @@ public static final String INIT_TOTAL_TABLES = "init_total_count_tables"; public static final String INIT_TOTAL_PARTITIONS = "init_total_count_partitions"; - public static final String DELTA_TOTAL_DATABASES = "delta_total_count_dbs"; - public static final String DELTA_TOTAL_TABLES = "delta_total_count_tables"; - public static final String DELTA_TOTAL_PARTITIONS = "delta_total_count_partitions"; -} + public static final String CREATE_TOTAL_DATABASES = "create_total_count_dbs"; + public static final String CREATE_TOTAL_TABLES = "create_total_count_tables"; + public static final String CREATE_TOTAL_PARTITIONS = "create_total_count_partitions"; + + public static final String DELETE_TOTAL_DATABASES = "delete_total_count_dbs"; + public static final String DELETE_TOTAL_TABLES = "delete_total_count_tables"; + public static final String DELETE_TOTAL_PARTITIONS = "delete_total_count_partitions"; +} \ No newline at end of file diff --git a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreMetrics.java b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreMetrics.java index 58d48ae..ca21bb6 100644 --- a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreMetrics.java +++ b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreMetrics.java @@ -108,9 +108,13 @@ public void testMetaDataCounts() throws Exception { //give timer thread a chance to print the metrics CodahaleMetrics metrics = (CodahaleMetrics) MetricsFactory.getInstance(); String json = metrics.dumpJson(); - MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.COUNTER, MetricsConstant.DELTA_TOTAL_DATABASES, 1); - MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.COUNTER, MetricsConstant.DELTA_TOTAL_TABLES, 4); - MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.COUNTER, MetricsConstant.DELTA_TOTAL_PARTITIONS, 6); + MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.COUNTER, MetricsConstant.CREATE_TOTAL_DATABASES, 2); + MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.COUNTER, MetricsConstant.CREATE_TOTAL_TABLES, 7); + MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.COUNTER, MetricsConstant.CREATE_TOTAL_PARTITIONS, 9); + + MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.COUNTER, MetricsConstant.DELETE_TOTAL_DATABASES, 1); + MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.COUNTER, MetricsConstant.DELETE_TOTAL_TABLES, 3); + MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.COUNTER, MetricsConstant.DELETE_TOTAL_PARTITIONS, 3); //to test initial metadata count metrics. hiveConf.setVar(HiveConf.ConfVars.METASTORE_RAW_STORE_IMPL, ObjectStore.class.getName()); diff --git a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/hbase/TestHBaseMetastoreMetrics.java b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/hbase/TestHBaseMetastoreMetrics.java index e8f218e..3ed88f2 100644 --- a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/hbase/TestHBaseMetastoreMetrics.java +++ b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/hbase/TestHBaseMetastoreMetrics.java @@ -108,9 +108,13 @@ public void testMetaDataCounts() throws Exception { driver.run("drop database tempdb cascade"); String json = metrics.dumpJson(); - MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.COUNTER, MetricsConstant.DELTA_TOTAL_DATABASES, 1); - MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.COUNTER, MetricsConstant.DELTA_TOTAL_TABLES, 4); - MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.COUNTER, MetricsConstant.DELTA_TOTAL_PARTITIONS, 6); + MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.COUNTER, MetricsConstant.CREATE_TOTAL_DATABASES, 2); + MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.COUNTER, MetricsConstant.CREATE_TOTAL_TABLES, 7); + MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.COUNTER, MetricsConstant.CREATE_TOTAL_PARTITIONS, 9); + + MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.COUNTER, MetricsConstant.DELETE_TOTAL_DATABASES, 1); + MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.COUNTER, MetricsConstant.DELETE_TOTAL_TABLES, 3); + MetricsTestUtils.verifyMetricsJson(json, MetricsTestUtils.COUNTER, MetricsConstant.DELETE_TOTAL_PARTITIONS, 3); //to test initial metadata count metrics. diff --git a/metastore/src/java/org/apache/hadoop/hive/metastore/HMSMetricsListener.java b/metastore/src/java/org/apache/hadoop/hive/metastore/HMSMetricsListener.java index fa5922f..6830cf7 100644 --- a/metastore/src/java/org/apache/hadoop/hive/metastore/HMSMetricsListener.java +++ b/metastore/src/java/org/apache/hadoop/hive/metastore/HMSMetricsListener.java @@ -49,7 +49,7 @@ public HMSMetricsListener(Configuration config, Metrics metrics) { public void onCreateDatabase(CreateDatabaseEvent dbEvent) throws MetaException { if (metrics != null) { try { - metrics.incrementCounter(MetricsConstant.DELTA_TOTAL_DATABASES); + metrics.incrementCounter(MetricsConstant.CREATE_TOTAL_DATABASES); } catch (IOException e) { LOGGER.warn("Error updating metadata metrics", e); } @@ -60,7 +60,7 @@ public void onCreateDatabase(CreateDatabaseEvent dbEvent) throws MetaException { public void onDropDatabase(DropDatabaseEvent dbEvent) throws MetaException { if (metrics != null) { try { - metrics.decrementCounter(MetricsConstant.DELTA_TOTAL_DATABASES); + metrics.incrementCounter(MetricsConstant.DELETE_TOTAL_DATABASES); } catch (IOException e) { LOGGER.warn("Error updating metadata metrics", e); } @@ -71,7 +71,7 @@ public void onDropDatabase(DropDatabaseEvent dbEvent) throws MetaException { public void onCreateTable(CreateTableEvent tableEvent) throws MetaException { if (metrics != null) { try { - metrics.incrementCounter(MetricsConstant.DELTA_TOTAL_TABLES); + metrics.incrementCounter(MetricsConstant.CREATE_TOTAL_TABLES); } catch (IOException e) { LOGGER.warn("Error updating metadata metrics", e); } @@ -82,7 +82,7 @@ public void onCreateTable(CreateTableEvent tableEvent) throws MetaException { public void onDropTable(DropTableEvent tableEvent) throws MetaException { if (metrics != null) { try { - metrics.decrementCounter(MetricsConstant.DELTA_TOTAL_TABLES); + metrics.incrementCounter(MetricsConstant.DELETE_TOTAL_TABLES); } catch (IOException e) { LOGGER.warn("Error updating metadata metrics", e); } @@ -93,7 +93,7 @@ public void onDropTable(DropTableEvent tableEvent) throws MetaException { public void onDropPartition(DropPartitionEvent partitionEvent) throws MetaException { if (metrics != null) { try { - metrics.decrementCounter(MetricsConstant.DELTA_TOTAL_PARTITIONS); + metrics.incrementCounter(MetricsConstant.DELETE_TOTAL_PARTITIONS); } catch (IOException e) { LOGGER.warn("Error updating metadata metrics", e); } @@ -104,7 +104,7 @@ public void onDropPartition(DropPartitionEvent partitionEvent) throws MetaExcept public void onAddPartition(AddPartitionEvent partitionEvent) throws MetaException { if (metrics != null) { try { - metrics.incrementCounter(MetricsConstant.DELTA_TOTAL_PARTITIONS); + metrics.incrementCounter(MetricsConstant.CREATE_TOTAL_PARTITIONS); } catch (IOException e) { LOGGER.warn("Error updating metadata metrics", e); }