Skip to content

Conversation

@szetszwo
Copy link
Contributor

What changes were proposed in this pull request?

Provide a general mechanism to support CodecBuffer for the codecs with protobuf v3 data.

What is the link to the Apache JIRA

HDDS-8572

How was this patch tested?

By existing tests.

@szetszwo szetszwo requested a review from adoroszlai May 12, 2023 14:15
Copy link
Contributor

@adoroszlai adoroszlai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @szetszwo for the patch, LGTM, just one question.

Comment on lines +36 to +46
private static final ConcurrentMap<Class<? extends MessageLite>,
Codec<? extends MessageLite>> CODECS
= new ConcurrentHashMap<>();

/**
* @return the {@link Codec} for the given class.
*/
public static <T extends MessageLite> Codec<T> get(Class<T> clazz) {
final Codec<?> codec = CODECS.computeIfAbsent(clazz, Proto3Codec::new);
return (Codec<T>) codec;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the benefit of saving codec instances to the map? Are we likely to have multiple uses of the same proto message in different domain objects?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The map is to enforce singleton. We may consider Proto3Codec::new expensive since it uses reflection to create an object. Suppose we return a new object as below

  public static <T extends MessageLite> Codec<T> getNew(Class<T> clazz) {
    return new Proto3Codec(clazz);
  }

Then, it can possibly be misused as

getNew().toCodecBuffer(message, allocator);

i.e. it creates a new codec for each serialization.

@szetszwo szetszwo merged commit 6fdc54a into apache:master May 14, 2023
@szetszwo
Copy link
Contributor Author

@adoroszlai , thanks a lot for reviewing this!

@szetszwo
Copy link
Contributor Author

@adoroszlai , oops, just found you have not approved this. Sorry! We may revert the commit if you have further questions or comments.

errose28 added a commit to errose28/ozone that referenced this pull request May 17, 2023
* master: (78 commits)
  HDDS-8575. Intermittent failure in TestCloseContainerEventHandler.testCloseContainerWithDelayByLeaseManager (apache#4688)
  HDDS-7241. EC: Reconstruction could fail with orphan blocks. (apache#4718)
  HDDS-8577. [Snapshot] Disable compaction log when loading metadata for snapshot (apache#4697)
  HDDS-7080. EC: Offline reconstruction needs better logging (apache#4719)
  HDDS-8626. Config thread pool in ReplicationServer (apache#4715)
  HDDS-8616. Underreplication not fixed if all replicas start decommissioning (apache#4711)
  HDDS-8254. Close containers when volume reaches utilisation threshold (apache#4583)
  HDDS-8254. Close containers when volume reaches utilisation threshold (apache#4583)
  HDDS-8615. Explicitly show EC block type in 'ozone debug chunkinfo' command output (apache#4706)
  HDDS-8623. Delete duplicate getBucketInfo in OMKeyCommitRequest (apache#4712)
  HDDS-8339. Recon Show the number of keys marked for Deletion in Recon UI. (apache#4519)
  HDDS-8572. Support CodecBuffer for protobuf v3 codecs. (apache#4693)
  HDDS-8010. Improve DN warning message when getBlock does not find the block. (apache#4698)
  HDDS-8621. IOException is never thrown in SCMRatisServer.getRatisRoles(). (apache#4710)
  HDDS-8463. S3 key uniqueness in deletedTable (apache#4660)
  HDDS-8584. Hadoop client write slowly when stream enabled (apache#4703)
  HDDS-7732. EC: Verify block deletion from missing EC containers (apache#4705)
  HDDS-8581. Avoid random ports in integration tests (apache#4699)
  HDDS-8504. ReplicationManager: Pass used and excluded node separately for Under and Mis-Replication (apache#4694)
  HDDS-8576. Close RocksDB instance in RDBStore if RDBStore's initialization fails after RocksDB instance creation (apache#4692)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants