aswinshakil commented on code in PR #8565:
URL: https://github.com/apache/ozone/pull/8565#discussion_r2137314833
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/checksum/ContainerChecksumTreeManager.java:
##########
@@ -395,6 +385,7 @@ public ByteString
getContainerChecksumInfo(KeyValueContainerData data) throws IO
* Callers are not required to hold a lock while calling this since writes
are done to a tmp file and atomically
* swapped into place.
*/
+ // TODO HDDS-12824 Once data checksum is stored in RocksDB this method can
be removed.
Review Comment:
Not related to this patch, but we can use this function to create a debug
tool to read the on-disk `.tree` file. Right now, it is only readable by the
reconciliation process. A debug tool would be helpful.
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/checksum/ContainerChecksumTreeManager.java:
##########
@@ -329,21 +306,34 @@ private Lock getLock(long containerID) {
}
/**
+ * Reads the checksum info of the specified container. If the tree file with
the information does not exist, an empty
+ * instance is returned.
* Callers are not required to hold a lock while calling this since writes
are done to a tmp file and atomically
* swapped into place.
*/
- public Optional<ContainerProtos.ContainerChecksumInfo> read(ContainerData
data) throws IOException {
+ public ContainerProtos.ContainerChecksumInfo read(ContainerData data) throws
IOException {
try {
- return captureLatencyNs(metrics.getReadContainerMerkleTreeLatencyNS(),
() -> readChecksumInfo(data));
+ return captureLatencyNs(metrics.getReadContainerMerkleTreeLatencyNS(),
() ->
+
readChecksumInfo(data).orElse(ContainerProtos.ContainerChecksumInfo.newBuilder().build()));
} catch (IOException ex) {
metrics.incrementMerkleTreeReadFailures();
- throw new IOException(ex);
+ throw ex;
}
}
- private Optional<ContainerProtos.ContainerChecksumInfo.Builder>
readBuilder(ContainerData data) throws IOException {
- Optional<ContainerProtos.ContainerChecksumInfo> checksumInfo = read(data);
- return checksumInfo.map(ContainerProtos.ContainerChecksumInfo::toBuilder);
+ /**
+ * Reads the checksum info of the specified container. If the tree file with
the information does not exist, or there
+ * is an exception trying to read the file, an empty instance is returned.
+ */
+ private ContainerProtos.ContainerChecksumInfo readOrCreate(ContainerData
data) {
+ try {
+ // If the file is not present, we will create the data for the first
time. This happens under a write lock.
Review Comment:
We already have this comment here. We can remove the redundant comments
where this function is called.
--
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]