From 8d18f511814689045e0d0685a4bff8a2356a360b Mon Sep 17 00:00:00 2001 From: Matt Lehman Date: Sat, 9 Mar 2024 20:52:52 -0800 Subject: [PATCH] Remove waitForCompletion parameter to download method which is always 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. --- .../netflix/priam/restore/AbstractRestore.java | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/priam/src/main/java/com/netflix/priam/restore/AbstractRestore.java b/priam/src/main/java/com/netflix/priam/restore/AbstractRestore.java index fdab811ef..9b3d89495 100644 --- a/priam/src/main/java/com/netflix/priam/restore/AbstractRestore.java +++ b/priam/src/main/java/com/netflix/priam/restore/AbstractRestore.java @@ -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; @@ -94,7 +93,7 @@ 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()) @@ -102,8 +101,7 @@ public static final boolean isRestoreEnabled(IConfiguration conf, InstanceInfo i return (isRestoreMode && isBackedupRac); } - private List> download( - Iterator fsIterator, boolean waitForCompletion) throws Exception { + private List> download(Iterator fsIterator) throws Exception { List> futureList = new ArrayList<>(); while (fsIterator.hasNext()) { AbstractBackupPath temp = fsIterator.next(); @@ -126,10 +124,6 @@ private List> 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; } @@ -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())); @@ -225,8 +219,7 @@ public void restore(DateUtil.DateRange dateRange) throws Exception { } // Download snapshot which is listed in the meta file. - List> futureList = new ArrayList<>(); - futureList.addAll(download(allFiles.iterator(), false)); + List> futureList = new ArrayList<>(download(allFiles.iterator())); // Wait for all the futures to finish. waitForCompletion(futureList);