[ https://issues.apache.org/jira/browse/HIVE-25048?focusedWorklogId=684641&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-684641 ]
ASF GitHub Bot logged work on HIVE-25048: ----------------------------------------- Author: ASF GitHub Bot Created on: 22/Nov/21 11:37 Start Date: 22/Nov/21 11:37 Worklog Time Spent: 10m Work Description: dengzhhu653 commented on a change in pull request #2441: URL: https://github.com/apache/hive/pull/2441#discussion_r754179495 ########## File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java ########## @@ -913,74 +900,6 @@ private static void logAndAudit(final String m) { logAuditEvent(m); } - private String startFunction(String function, String extraLogInfo) { - incrementCounter(function); - logAndAudit((getThreadLocalIpAddress() == null ? "" : "source:" + getThreadLocalIpAddress() + " ") + - function + extraLogInfo); - com.codahale.metrics.Timer timer = - Metrics.getOrCreateTimer(MetricsConstants.API_PREFIX + function); Review comment: yes, we have double counted the metrics of api calling by the startFunction and the PerfLogger, e.g, the total call count and the active count of the api. ########## File path: standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreEndFunctionListener.java ########## @@ -83,7 +86,7 @@ public void testEndFunctionListener() throws Exception { listSize = DummyEndFunctionListener.funcNameList.size(); String func_name = DummyEndFunctionListener.funcNameList.get(listSize-1); MetaStoreEndFunctionContext context = DummyEndFunctionListener.contextList.get(listSize-1); - assertEquals(func_name,"get_database"); + assertEquals(func_name,"get_database_req"); Review comment: Thanks a lot for the feedback! you are right, this is where may break compatibility, including the MetaStoreEndFunctionContext(we cannot retrieve inputTableName by method `getInputTableName()` any more). I not so sure if we can make such changes though this can help clean some codes... ########## File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/HMSHandler.java ########## @@ -4059,7 +3806,7 @@ public Partition append_partition_with_environment_context(final String dbName, String location; PartValEqWrapperLite(Partition partition) { - this.values = partition.isSetValues()? partition.getValues() : null; + this.values = partition.isSetValues()? new ArrayList<>(partition.getValues()) : null; Review comment: Not a bug really, just to clean up the codes. The following pieces of codes can be simply treated as `lhsValues.equals(rhsValues)` by `equals` of an ArrayList. if (lhsValues.size() != rhsValues.size()) { return false; } for (int i=0; i<lhsValues.size(); ++i) { String lhsValue = lhsValues.get(i); String rhsValue = rhsValues.get(i); if ((lhsValue == null && rhsValue != null) || (lhsValue != null && !lhsValue.equals(rhsValue))) { return false; } } return true;` ########## File path: standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreAuditLogBuilder.java ########## @@ -0,0 +1,124 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.hadoop.hive.metastore; + +import java.util.List; +import java.util.Map; + +import org.apache.hadoop.hive.common.TableName; + +import static org.apache.commons.lang3.StringUtils.join; + +/** + * Generate the audit log in a builder manner. + */ +public class MetaStoreAuditLogBuilder { + // the function + private final String functionName; + private final StringBuilder builder; + + private MetaStoreAuditLogBuilder(String functionName) { + this.functionName = functionName; + this.builder = new StringBuilder(); + } + + public static MetaStoreAuditLogBuilder functionName(String functionName) { + MetaStoreAuditLogBuilder builder = new MetaStoreAuditLogBuilder(functionName); + return builder; + } + + public MetaStoreAuditLogBuilder connectorName(String connectorName) { + builder.append("connector=").append(connectorName).append(" "); + return this; + } + + public MetaStoreAuditLogBuilder catalogName(String catalogName) { + builder.append("catName=").append(catalogName).append(" "); + return this; + } + + public MetaStoreAuditLogBuilder dbName(String dbName) { + builder.append("db=").append(dbName).append(" "); + return this; + } + + public MetaStoreAuditLogBuilder tableName(String tableName) { + builder.append("tbl=").append(tableName).append(" "); + return this; + } + + public MetaStoreAuditLogBuilder packageName(String packageName) { + builder.append("package=").append(packageName).append(" "); + return this; + } + + public MetaStoreAuditLogBuilder typeName(String typeName) { + builder.append("type=").append(typeName).append(" "); + return this; + } + + public MetaStoreAuditLogBuilder pattern(String pattern) { + builder.append("pat=").append(pattern).append(" "); + return this; + } + + public MetaStoreAuditLogBuilder extraInfo(String extraInfo) { Review comment: Make sense, let me take a look. Thank you! -- 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. To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking ------------------- Worklog Id: (was: 684641) Time Spent: 4h 40m (was: 4.5h) > Refine the start/end functions in HMSHandler > -------------------------------------------- > > Key: HIVE-25048 > URL: https://issues.apache.org/jira/browse/HIVE-25048 > Project: Hive > Issue Type: Improvement > Components: Standalone Metastore > Reporter: Zhihua Deng > Assignee: Zhihua Deng > Priority: Major > Labels: pull-request-available > Time Spent: 4h 40m > Remaining Estimate: 0h > > Some start/end functions are incomplete or wrong in the HMSHandler, these > functions audit actions, monitor the performance, and notify the end function > listeners. We have already measured the performance of the HMSHandler in > PerfLogger, and covered more methods than these functions that have done, so > we can remove the monitoring from the start/end functions, move the end > function listeners to the RetryingHMSHandler to eliminate the try-finally > blocks that spread across many different methods. After these, we can try to > cleanup the functions to make HMSHandler be more simplified. > -- This message was sent by Atlassian Jira (v8.20.1#820001)