Skip to content

Commit

Permalink
Remove waitForCompletion parameter to download method which is always…
Browse files Browse the repository at this point in the history
… false in practice.

Remove final modifier on static method.
Make static property an instance variable instead.
Use parameterized constructor call in place of two lines.
  • Loading branch information
mattl-netflix committed May 4, 2024
1 parent ce6c7c1 commit 8d18f51
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions priam/src/main/java/com/netflix/priam/restore/AbstractRestore.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,12 @@

/**
* A means to perform a restore. This class contains the following characteristics: - It is agnostic
* to the source type of the restore, this is determine by the injected IBackupFileSystem. - This
* to the source type of the restore, this is determined by the injected IBackupFileSystem. - This
* class can be scheduled, i.e. it is a "Task". - When this class is executed, it uses its own
* thread pool to execute the restores.
*/
public abstract class AbstractRestore extends Task implements IRestoreStrategy {
private static final Logger logger = LoggerFactory.getLogger(AbstractRestore.class);
private static BigInteger restoreToken;
final IBackupFileSystem fs;
final Sleeper sleeper;
private final BackupRestoreUtil backupRestoreUtil;
Expand Down Expand Up @@ -94,16 +93,15 @@ public AbstractRestore(
this.postRestoreHook = postRestoreHook;
}

public static final boolean isRestoreEnabled(IConfiguration conf, InstanceInfo instanceInfo) {
public static boolean isRestoreEnabled(IConfiguration conf, InstanceInfo instanceInfo) {
boolean isRestoreMode = StringUtils.isNotBlank(conf.getRestoreSnapshot());
boolean isBackedupRac =
(CollectionUtils.isEmpty(conf.getBackupRacs())
|| conf.getBackupRacs().contains(instanceInfo.getRac()));
return (isRestoreMode && isBackedupRac);
}

private List<Future<Path>> download(
Iterator<AbstractBackupPath> fsIterator, boolean waitForCompletion) throws Exception {
private List<Future<Path>> download(Iterator<AbstractBackupPath> fsIterator) throws Exception {
List<Future<Path>> futureList = new ArrayList<>();
while (fsIterator.hasNext()) {
AbstractBackupPath temp = fsIterator.next();
Expand All @@ -126,10 +124,6 @@ private List<Future<Path>> download(
+ localFileHandler.getName());
futureList.add(downloadFile(temp));
}

// Wait for all download to finish that were started from this method.
if (waitForCompletion) waitForCompletion(futureList);

return futureList;
}

Expand Down Expand Up @@ -182,7 +176,7 @@ public void restore(DateUtil.DateRange dateRange) throws Exception {

try {
if (config.isRestoreClosestToken()) {
restoreToken =
BigInteger restoreToken =
tokenSelector.getClosestToken(
new BigInteger(origToken),
new Date(dateRange.getStartTime().toEpochMilli()));
Expand Down Expand Up @@ -225,8 +219,7 @@ public void restore(DateUtil.DateRange dateRange) throws Exception {
}

// Download snapshot which is listed in the meta file.
List<Future<Path>> futureList = new ArrayList<>();
futureList.addAll(download(allFiles.iterator(), false));
List<Future<Path>> futureList = new ArrayList<>(download(allFiles.iterator()));

// Wait for all the futures to finish.
waitForCompletion(futureList);
Expand Down

0 comments on commit 8d18f51

Please sign in to comment.