steveloughran commented on code in PR #6953: URL: https://github.com/apache/hadoop/pull/6953#discussion_r1707309727
########## hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/jmx/JMXJsonServlet.java: ########## @@ -43,8 +43,8 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import com.fasterxml.jackson.core.JsonFactory; import com.fasterxml.jackson.core.JsonGenerator; +import org.apache.hadoop.util.JacksonUtil; Review Comment: move into org.apache block ########## hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/JacksonUtil.java: ########## @@ -0,0 +1,122 @@ +/** + * 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.util; + +import com.fasterxml.jackson.core.JsonFactory; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.ObjectReader; +import com.fasterxml.jackson.databind.ObjectWriter; +import com.fasterxml.jackson.databind.json.JsonMapper; + +/** + * Utility for sharing code related to Jackson usage in Hadoop. + * + * @since 3.5.0 Review Comment: what about adding a hadoop jira ID, `@since HADOOP-19321` so even on a backport the entry is correct. ########## hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/JacksonUtil.java: ########## @@ -0,0 +1,122 @@ +/** + * 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.util; + +import com.fasterxml.jackson.core.JsonFactory; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.ObjectReader; +import com.fasterxml.jackson.databind.ObjectWriter; +import com.fasterxml.jackson.databind.json.JsonMapper; + +/** + * Utility for sharing code related to Jackson usage in Hadoop. + * + * @since 3.5.0 + */ +public final class JacksonUtil { Review Comment: tag as @Private so nobody can complain if it is changed in incompatible ways ########## hadoop-tools/hadoop-azure/src/main/java/org/apache/hadoop/fs/azurebfs/oauth2/AzureADAuthenticator.java: ########## @@ -29,9 +29,9 @@ import java.util.Hashtable; import java.util.Map; +import org.apache.hadoop.util.JacksonUtil; Review Comment: how about moving both of these? ########## hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-applications-catalog/hadoop-yarn-applications-catalog-webapp/src/main/java/org/apache/hadoop/yarn/appcatalog/application/YarnServiceClient.java: ########## @@ -46,6 +47,19 @@ public class YarnServiceClient { private static final Logger LOG = LoggerFactory.getLogger(YarnServiceClient.class); + + /** + * It is more performant to reuse ObjectMapper instances but keeping the instance Review Comment: not 100% sure about that performant: isn't there some synchronisation locking going on so performance with a single mapper across many threads worse than 1 mapper per thread? ########## hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/diskbalancer/datamodel/DiskBalancerCluster.java: ########## @@ -19,8 +19,8 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectReader; +import org.apache.hadoop.util.JacksonUtil; Review Comment: this should go below. that Preconditions entry is in the wrong place due to the move off guava being a search and replace ########## hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3a/impl/S3AEncryption.java: ########## @@ -22,7 +22,7 @@ import java.nio.charset.StandardCharsets; import java.util.Map; -import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.hadoop.util.JacksonUtil; Review Comment: to the block below ########## hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/util/CombinedHostsFileReader.java: ########## @@ -43,6 +41,7 @@ import org.apache.hadoop.classification.InterfaceStability; import org.apache.hadoop.hdfs.protocol.DatanodeAdminProperties; +import org.apache.hadoop.util.JacksonUtil; Review Comment: move into org.apache block ########## hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/MetricsJsonBuilder.java: ########## @@ -22,8 +22,8 @@ import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceStability; -import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectWriter; +import org.apache.hadoop.util.JacksonUtil; Review Comment: move into org.apache block -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
