sumitagrawl commented on code in PR #6492:
URL: https://github.com/apache/ozone/pull/6492#discussion_r1583238548
##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/codec/NSSummaryCodec.java:
##########
@@ -117,6 +120,14 @@ public NSSummary fromPersistedFormat(byte[] rawData)
throws IOException {
assert (bytesRead == strLen);
String dirName = stringCodec.fromPersistedFormat(buffer);
res.setDirName(dirName);
+ long parentId = in.readLong();
+ if (parentId == 0) {
+ // Set the parent ID to -1 to indicate that it is old data from
+ // the cluster and the value has not yet been set.
+ res.setParentId(-1);
Review Comment:
parentId "0" and "-1" seems represent same case, no-exist parentId. do this
have any other differentiation, if no, then can use only one.
##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/ReconUtils.java:
##########
@@ -246,25 +253,74 @@ public void untarCheckpointFile(File tarFile, Path
destPath)
}
}
+
+ /**
+ * Constructs the full path of a key from its OmKeyInfo using a bottom-up
approach, starting from the leaf node.
+ * <p>
+ * The method begins with the leaf node (the key itself) and recursively
prepends parent directory names, fetched
+ * via NSSummary objects, until reaching the parent bucket (parentId is -1).
It effectively builds the path from
+ * bottom to top, finally prepending the volume and bucket names to complete
the full path.
+ *
+ * @param omKeyInfo The OmKeyInfo object for the key
+ * @return The constructed full path of the key as a String.
+ * @throws IOException
+ */
+ public static String constructFullPath(OmKeyInfo omKeyInfo,
+ ReconNamespaceSummaryManager
reconNamespaceSummaryManager,
+ ReconOMMetadataManager
omMetadataManager)
+ throws IOException {
+ StringBuilder fullPath = new StringBuilder(omKeyInfo.getKeyName());
+ long parentId = omKeyInfo.getParentObjectID();
+ boolean isDirectoryPresent = false;
+ while (parentId != -1) {
+ NSSummary nsSummary =
reconNamespaceSummaryManager.getNSSummary(parentId);
+ if (nsSummary == null) {
+ break;
+ }
+ if (nsSummary.getParentId() == -1) {
+ // Call reprocess method if parentId is negative, as it has not been
set for this yet.
+ reconNamespaceSummaryManager.rebuildNSSummaryTree(omMetadataManager);
Review Comment:
This will block the request and multiple request may trigger rebuild again
and again parallely
##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/codec/NSSummaryCodec.java:
##########
@@ -110,13 +113,17 @@ public NSSummary fromPersistedFormat(byte[] rawData)
throws IOException {
int strLen = in.readInt();
if (strLen == 0) {
+ long parentId = in.readLong(); // Deserialize parentId
+ res.setParentId(parentId);
return res;
}
byte[] buffer = new byte[strLen];
int bytesRead = in.read(buffer);
assert (bytesRead == strLen);
String dirName = stringCodec.fromPersistedFormat(buffer);
res.setDirName(dirName);
+ long parentId = in.readLong();
Review Comment:
for old format, readLong() will throw IndexOutOfBoundsException or
IndexOutOfBoundsException for old format
--
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]