You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "ashishkumar50 (via GitHub)" <gi...@apache.org> on 2023/05/19 10:05:46 UTC

[GitHub] [ozone] ashishkumar50 opened a new pull request, #4745: HDDS-8657. Remove Clone and make use of copyObject in OmDirectoryInfo and OmKeyInfo.

ashishkumar50 opened a new pull request, #4745:
URL: https://github.com/apache/ozone/pull/4745

   ## What changes were proposed in this pull request?
   
   Remove Clone and make use of copyObject in OmDirectoryInfo and OmKeyInfo to have better maintainability.
   
   ## What is the link to the Apache JIRA
   
   https://issues.apache.org/jira/browse/HDDS-8657
   
   ## How was this patch tested?
   
   Built locally and tested as same steps in HDDS-8292
   


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] ashishkumar50 commented on a diff in pull request #4745: HDDS-8657. Remove Clone and make use of copyObject in OmDirectoryInfo and OmKeyInfo.

Posted by "ashishkumar50 (via GitHub)" <gi...@apache.org>.
ashishkumar50 commented on code in PR #4745:
URL: https://github.com/apache/ozone/pull/4745#discussion_r1199244070


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneListStatusHelper.java:
##########
@@ -442,10 +443,19 @@ private void getCacheValues() {
         }
 
         // Copy cache value to local copy and work on it
-        Value copyOmInfo = ObjectUtils.clone(cacheOmInfo);
+        Value copyOmInfo = null;
+        try {
+          if (cacheOmInfo instanceof ICopyObjectInfo) {
+            Method m = cacheOmInfo.getClass().getMethod("copyObject");
+            copyOmInfo = (Value) m.invoke(cacheOmInfo);
+          }
+        } catch (Exception e) {
+          LOG.debug("No such method, use same cache copy");
+        }

Review Comment:
   @szetszwo, Thanks for the comments, All comments are fixed.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] szetszwo commented on a diff in pull request #4745: HDDS-8657. Remove Clone and make use of copyObject in OmDirectoryInfo and OmKeyInfo.

Posted by "szetszwo (via GitHub)" <gi...@apache.org>.
szetszwo commented on code in PR #4745:
URL: https://github.com/apache/ozone/pull/4745#discussion_r1199508920


##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/ICopyObject.java:
##########
@@ -0,0 +1,22 @@
+/*
+ * 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

Review Comment:
   @ashishkumar50 , we usually leave an empty line before and after the link; see "Source File Headers for Code Developed at the ASF" in https://www.apache.org/legal/src-headers.html
   
   BTW, the `<p>` tag is for javadoc.  That why we should remove it and leave an empty line.
   
   Since it can pass the [rat test](https://github.com/apache/ozone/actions/runs/5027082009/jobs/9019199077?pr=4745#step:7:1), let's just merge this.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] ashishkumar50 commented on pull request #4745: HDDS-8657. Remove Clone and make use of copyObject in OmDirectoryInfo and OmKeyInfo.

Posted by "ashishkumar50 (via GitHub)" <gi...@apache.org>.
ashishkumar50 commented on PR #4745:
URL: https://github.com/apache/ozone/pull/4745#issuecomment-1554338460

   @szetszwo, Please help to review, Thanks.


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] szetszwo commented on a diff in pull request #4745: HDDS-8657. Remove Clone and make use of copyObject in OmDirectoryInfo and OmKeyInfo.

Posted by "szetszwo (via GitHub)" <gi...@apache.org>.
szetszwo commented on code in PR #4745:
URL: https://github.com/apache/ozone/pull/4745#discussion_r1199112800


##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/ICopyObjectInfo.java:
##########
@@ -0,0 +1,24 @@
+/*
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.ozone.om.helpers;
+
+/**
+ * CopyObject Info interface.
+ */
+public interface ICopyObjectInfo {

Review Comment:
   Let's call it `ICopyObject`.



##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/ICopyObjectInfo.java:
##########
@@ -0,0 +1,24 @@
+/*
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>

Review Comment:
   Remove `<p>`.



##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneListStatusHelper.java:
##########
@@ -442,10 +443,19 @@ private void getCacheValues() {
         }
 
         // Copy cache value to local copy and work on it
-        Value copyOmInfo = ObjectUtils.clone(cacheOmInfo);
+        Value copyOmInfo = null;
+        try {
+          if (cacheOmInfo instanceof ICopyObjectInfo) {
+            Method m = cacheOmInfo.getClass().getMethod("copyObject");
+            copyOmInfo = (Value) m.invoke(cacheOmInfo);
+          }
+        } catch (Exception e) {
+          LOG.debug("No such method, use same cache copy");
+        }

Review Comment:
   We don't need reflection here.  Simply cast it as below
   ```java
   @@ -442,9 +442,8 @@ private void getCacheValues() {
            }
    
            // Copy cache value to local copy and work on it
   -        Value copyOmInfo = ObjectUtils.clone(cacheOmInfo);
   -        if (copyOmInfo != null) {
   -          cacheOmInfo = copyOmInfo;
   +        if (cacheOmInfo instanceof ICopyObject) {
   +          cacheOmInfo = ((ICopyObject) cacheOmInfo).copyObject();
            }
            if (StringUtils.isBlank(startKey)) {
              // startKey is null or empty, then the seekKeyInDB="1024/"
   ```



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


[GitHub] [ozone] szetszwo merged pull request #4745: HDDS-8657. Remove Clone and make use of copyObject in OmDirectoryInfo and OmKeyInfo.

Posted by "szetszwo (via GitHub)" <gi...@apache.org>.
szetszwo merged PR #4745:
URL: https://github.com/apache/ozone/pull/4745


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org