Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: srlch <[email protected]>
  • Loading branch information
srlch committed Jan 13, 2025
1 parent 79fd688 commit 21bf08a
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.apache.logging.log4j.Logger;

import java.io.IOException;
import java.util.Comparator;
import java.util.Map;
import java.util.TreeMap;

Expand All @@ -51,7 +52,7 @@ public class ClusterSnapshotMgr implements GsonPostProcessable {
@SerializedName(value = "automatedSnapshot")
private ClusterSnapshot automatedSnapshot = null;
@SerializedName(value = "historyAutomatedSnapshotJobs")
private TreeMap<Long, ClusterSnapshotJob> historyAutomatedSnapshotJobs = new TreeMap<>();
private TreeMap<Long, ClusterSnapshotJob> historyAutomatedSnapshotJobs = new TreeMap<>(Comparator.reverseOrder());

public ClusterSnapshotMgr() {}

Expand Down Expand Up @@ -151,7 +152,7 @@ public boolean containsAutomatedSnapshot() {
public synchronized void addJob(ClusterSnapshotJob job) {
if (Config.max_historical_automated_cluster_snapshot_jobs >= 2 &&
historyAutomatedSnapshotJobs.size() == Config.max_historical_automated_cluster_snapshot_jobs) {
historyAutomatedSnapshotJobs.pollFirstEntry();
historyAutomatedSnapshotJobs.pollLastEntry();
}
historyAutomatedSnapshotJobs.put(job.getId(), job);
}
Expand All @@ -161,17 +162,17 @@ public synchronized long getValidDeletionTimeMsByAutomatedSnapshot() {
return Long.MAX_VALUE;
}

boolean findFirstSuccess = false;
boolean findLastSuccess = false;
long previousAutomatedSnapshotCreatedTimsMs = 0;
for (Long key : historyAutomatedSnapshotJobs.descendingKeySet()) {
for (Long key : historyAutomatedSnapshotJobs.keySet()) {
ClusterSnapshotJob job = historyAutomatedSnapshotJobs.get(key);
if (job.isSuccess()) {
if (findFirstSuccess) {
if (findLastSuccess) {
previousAutomatedSnapshotCreatedTimsMs = job.getCreatedTimeMs();
break;
}

findFirstSuccess = true;
findLastSuccess = true;
continue;
}
}
Expand Down

0 comments on commit 21bf08a

Please sign in to comment.