Skip to content

Commit

Permalink
Revised the backporting strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
ArafatKhan2198 committed Apr 29, 2024
1 parent 0d03da5 commit dd1016d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,11 @@ public static String constructFullPath(OmKeyInfo omKeyInfo,
if (nsSummary == null) {
break;
}
if (!hasParentIdField(nsSummary)) {
// Call reprocess method if parentId is missing
if (nsSummary.getParentId() == -1) {
// Call reprocess method if parentId is negative, as it has not been set for this yet.
reconNamespaceSummaryManager.rebuildNSSummaryTree(omMetadataManager);
return constructFullPath(omKeyInfo, reconNamespaceSummaryManager,
omMetadataManager);
}
fullPath.insert(0, nsSummary.getDirName() + OM_KEY_PREFIX);

Expand All @@ -298,20 +300,6 @@ public static String constructFullPath(OmKeyInfo omKeyInfo,
return fullPath.toString();
}

public static boolean hasParentIdField(NSSummary nsSummary) {
Field field;
try {
// This line attempts to get the Field object representing the parentId
// field from the NSSummary class. If the parentId field does not exist,
// a NoSuchFieldException will be thrown.
field = NSSummary.class.getDeclaredField("parentId");
return true;
} catch (NoSuchFieldException e) {
return false; // Field not present
}
}


/**
* Make HTTP GET call on the URL and return HttpURLConnection instance.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ public class NSSummary {
private int[] fileSizeBucket;
private Set<Long> childDir;
private String dirName;
private long parentId = -1;
private long parentId = 0;

public NSSummary() {
this(0, 0L, new int[ReconConstants.NUM_OF_FILE_SIZE_BINS],
new HashSet<>(), "", -1); // -1 can be a default value indicating no parent
new HashSet<>(), "", 0);
}

public NSSummary(int numOfFiles,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,6 @@ 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];
Expand All @@ -123,6 +121,12 @@ public NSSummary fromPersistedFormat(byte[] rawData) throws IOException {
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);
return res;
}
res.setParentId(parentId);
return res;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,10 @@
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.lang.reflect.Field;
import java.util.Map;

import static org.apache.hadoop.ozone.recon.ReconServerConfigKeys.OZONE_RECON_NSSUMMARY_FLUSH_TO_DB_MAX_THRESHOLD;
import static org.apache.hadoop.ozone.recon.ReconServerConfigKeys.OZONE_RECON_NSSUMMARY_FLUSH_TO_DB_MAX_THRESHOLD_DEFAULT;
import static org.apache.hadoop.ozone.recon.ReconUtils.hasParentIdField;

/**
* Class for holding all NSSummaryTask methods
Expand Down Expand Up @@ -128,10 +126,6 @@ protected void handlePutDirEvent(OmDirectoryInfo directoryInfo,
// If we don't have it in this batch we try to get it from the DB
curNSSummary = reconNamespaceSummaryManager.getNSSummary(objectId);
}
if (!hasParentIdField(curNSSummary)) {
reconNamespaceSummaryManager.rebuildNSSummaryTree(reconOMMetadataManager);
return;
}
if (curNSSummary == null) {
// If we don't have it locally and in the DB we create a new instance
// as this is a new ID
Expand All @@ -151,10 +145,6 @@ protected void handlePutDirEvent(OmDirectoryInfo directoryInfo,
// If we don't have it in this batch we try to get it from the DB
nsSummary = reconNamespaceSummaryManager.getNSSummary(parentObjectId);
}
if (!hasParentIdField(nsSummary)) {
reconNamespaceSummaryManager.rebuildNSSummaryTree(reconOMMetadataManager);
return;
}
if (nsSummary == null) {
// If we don't have it locally and in the DB we create a new instance
// as this is a new ID
Expand Down

0 comments on commit dd1016d

Please sign in to comment.