sumitagrawl commented on code in PR #8699: URL: https://github.com/apache/ozone/pull/8699#discussion_r2198165231
########## hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/types/ReconBasicOmKeyInfo.java: ########## @@ -0,0 +1,279 @@ +/* + * 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.ozone.recon.api.types; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Objects; +import org.apache.hadoop.hdds.client.ReplicationConfig; +import org.apache.hadoop.hdds.utils.db.Codec; +import org.apache.hadoop.hdds.utils.db.DelegatedCodec; +import org.apache.hadoop.hdds.utils.db.Proto2Codec; +import org.apache.hadoop.ozone.om.helpers.QuotaUtil; +import org.apache.hadoop.ozone.om.helpers.WithParentObjectId; +import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos; + +/** + * Lightweight OmKeyInfo class. + */ +@JsonIgnoreProperties({ + "metadata", "objectID", "updateID", "parentObjectID", "objectInfo" +}) +public final class ReconBasicOmKeyInfo extends WithParentObjectId { Review Comment: ReconBasicOmKeyInfo is coupled with response format defining json property. Do this class can be used anywhere in recon if required or any other usecase in recon generic be used? ########## hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/types/ReconBasicOmKeyInfo.java: ########## @@ -0,0 +1,279 @@ +/* + * 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.ozone.recon.api.types; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Objects; +import org.apache.hadoop.hdds.client.ReplicationConfig; +import org.apache.hadoop.hdds.utils.db.Codec; +import org.apache.hadoop.hdds.utils.db.DelegatedCodec; +import org.apache.hadoop.hdds.utils.db.Proto2Codec; +import org.apache.hadoop.ozone.om.helpers.QuotaUtil; +import org.apache.hadoop.ozone.om.helpers.WithParentObjectId; +import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos; + +/** + * Lightweight OmKeyInfo class. + */ +@JsonIgnoreProperties({ + "metadata", "objectID", "updateID", "parentObjectID", "objectInfo" +}) +public final class ReconBasicOmKeyInfo extends WithParentObjectId { + + private final String volumeName; + private final String bucketName; + private final String keyName; + private final long dataSize; + private final long creationTime; + private final long modificationTime; + + /** This is key table key of rocksDB and will help UI to implement pagination + * where UI will use the last record key to send in API as preKeyPrefix. */ + @JsonProperty("key") + private String key; + + /** Path of a key/file. */ + @JsonProperty("path") + private String path; + + @JsonProperty("replicatedSize") + private final long replicatedSize; + + @JsonProperty("replicationInfo") + private final ReplicationConfig replicationConfig; + + private final boolean isFile; + private long parentId; + + public static Codec<ReconBasicOmKeyInfo> getCodec() { + return new DelegatedCodec<>( + Proto2Codec.get(OzoneManagerProtocolProtos.KeyInfoProtoLight.getDefaultInstance()), + ReconBasicOmKeyInfo::getFromProtobuf, + ReconBasicOmKeyInfo::toProtobuf, Review Comment: Instead of defining method for every case, we can define as below, above can be changed as, ``` DelegateCodec.decodeOnly( Proto2Codec.get(OzoneManagerProtocolProtos.KeyInfoProtoLight.getDefaultInstance()), ReconBasicOmKeyInfo::getFromProtobuf ReconBasicOmKeyInfo.class); ``` ``` public static <T, DELEGATE> DelegatedCodec<T, DELEGATE> decodeOnly( Codec<DELEGATE> delegate, CheckedFunction<DELEGATE, T, CodecException> forward, Class<T> clazz) { return new DelegatedCodec<>(delegate, forward, unsupportedBackward(), clazz, CopyType.DEEP); } private static <A, B> CheckedFunction<A, B, CodecException> unsupportedBackward() { return a -> { throw new UnsupportedOperationException("Unsupported backward conversion"); }; } ########## hadoop-ozone/interface-client/src/main/proto/OmClientProtocol.proto: ########## @@ -1172,6 +1172,22 @@ message KeyInfo { optional uint64 expectedDataGeneration = 22; } +message KeyInfoProtoLight { Review Comment: add comment for this type specifying its sub-part of keyInfo with selected fields only and keeping index same. -- 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]
