Skip to content

Commit

Permalink
Improve method
Browse files Browse the repository at this point in the history
  • Loading branch information
gthea committed Aug 30, 2024
1 parent 176b267 commit bba392a
Showing 1 changed file with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,17 +152,29 @@ public SplitTaskExecutionInfo execute() {
}

private boolean targetChangeNumberIsOutdated() {
if (mTargetSegmentsChangeNumber == null && mTargetLargeSegmentsChangeNumber == null) {
return false;
}

long segmentsTarget = Utils.getOrDefault(mTargetSegmentsChangeNumber, -1L);
long largeSegmentsTarget = Utils.getOrDefault(mTargetLargeSegmentsChangeNumber, -1L);

long msStorageChangeNumber = mMySegmentsStorage.getTill();
long lsStorageChangeNumber = mMyLargeSegmentsStorage.getTill();

return segmentsTarget <= msStorageChangeNumber && largeSegmentsTarget <= lsStorageChangeNumber;
// In case both targets are present, both CN in storage should be newer for the targets to be considered outdated
if (mTargetSegmentsChangeNumber != null && mTargetLargeSegmentsChangeNumber != null) {
return segmentsTarget <= msStorageChangeNumber && largeSegmentsTarget <= lsStorageChangeNumber;
}

// If only LS target is set, there's no need to check MS storage CN
if (mTargetLargeSegmentsChangeNumber != null) {
return largeSegmentsTarget <= lsStorageChangeNumber;
}

// If only MS target is set, there's no need to check LS storage CN
if (mTargetSegmentsChangeNumber != null) {
return segmentsTarget <= msStorageChangeNumber;
}

// If no targets are set, consider it not outdated
return false;
}

private void fetch(int initialRetries) throws HttpFetcherException, InterruptedException {
Expand Down

0 comments on commit bba392a

Please sign in to comment.