Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Suraj Singh <surajrider@gmail.com>
  • Loading branch information
dreamer-89 committed Sep 2, 2022
1 parent 3f0ec9f commit 2098db2
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions server/src/main/java/org/opensearch/index/store/Store.java
Original file line number Diff line number Diff line change
Expand Up @@ -1147,8 +1147,7 @@ public Map<String, StoreFileMetadata> asMap() {
/**
* Returns a diff between the two snapshots that can be used for recovery. The given snapshot is treated as the
* recovery target and this snapshot as the source. This method is also used for segment replication where
* per-segment missing files are not considered inconsistent due to replication lag between primary and
* replica in file copy operation.
* per-segment missing files does not result in the entire segment group being marked as different.
* The returned diff will hold a list
* of files that are:
* <ul>
Expand Down Expand Up @@ -1182,12 +1181,12 @@ public Map<String, StoreFileMetadata> asMap() {
* NOTE: this diff will not contain the {@code segments.gen} file. This file is omitted on recovery.
*
* @param recoveryTargetSnapshot recovery target snapshot to diff against
* @param ignoreMissingFiles when false treats missing files as exception state. It ignores remaining identical files
* @param enforceGroupConsistency when false treats missing files as exception state. It ignores remaining identical files
* in per-segment group and add them to different field in returned object, when true treats
* missing files as norm and returns different field where files are actually different
*
*/
public RecoveryDiff recoveryDiff(MetadataSnapshot recoveryTargetSnapshot, boolean ignoreMissingFiles) {
public RecoveryDiff recoveryDiff(MetadataSnapshot recoveryTargetSnapshot, boolean enforceGroupConsistency) {
final List<StoreFileMetadata> identical = new ArrayList<>();
final List<StoreFileMetadata> different = new ArrayList<>();
final List<StoreFileMetadata> missing = new ArrayList<>();
Expand All @@ -1213,7 +1212,7 @@ public RecoveryDiff recoveryDiff(MetadataSnapshot recoveryTargetSnapshot, boolea
for (StoreFileMetadata meta : segmentFiles) {
StoreFileMetadata storeFileMetadata = recoveryTargetSnapshot.get(meta.name());
if (storeFileMetadata == null) {
consistent = ignoreMissingFiles ? consistent : false;
consistent = enforceGroupConsistency ? false : consistent;
missing.add(meta);
} else if (storeFileMetadata.isSame(meta) == false) {
consistent = false;
Expand Down Expand Up @@ -1243,7 +1242,7 @@ public RecoveryDiff recoveryDiff(MetadataSnapshot recoveryTargetSnapshot, boolea
}

public RecoveryDiff recoveryDiff(MetadataSnapshot recoveryTargetSnapshot) {
return recoveryDiff(recoveryTargetSnapshot, false);
return recoveryDiff(recoveryTargetSnapshot, true);
}

/**
Expand Down

0 comments on commit 2098db2

Please sign in to comment.