Class RetryTracker<T>
java.lang.Object
net.preibisch.mvrecon.process.export.RetryTracker<T>
Simple utility to track retry attempts and handle retry logic for failed
blocks. Keeps the parallelization code separate while avoiding retry logic
duplication.
-
Constructor Summary
ConstructorsConstructorDescriptionRetryTracker(Function<T, String> keyExtractor, String operationName, int maxRetries, boolean giveUpOnFailure, long retryDelayMs, boolean triggerGC, int totalBlocks) -
Method Summary
Modifier and TypeMethodDescriptionbooleanCall this before each retry cycle.createFailedBlocksMap(Collection<T> grid) Create the map of all blocks, from which we then remove each one that succeeded piece by piecestatic RetryTracker<long[][]> forGridBlocks(String operationName, int totalBlocks) Convenience constructor for grid blocks with default settingsintbooleanprocessFailures(Set<T> failedBlocks) Remove successful blocks from the failed set and update retry counts.processWithFutures(List<Future<T>> futures, Collection<T> grid) Method to process all results when running with a service that returns futures.
-
Constructor Details
-
RetryTracker
-
-
Method Details
-
forGridBlocks
Convenience constructor for grid blocks with default settings- Parameters:
operationName- any descriptive name for the operation for output messagestotalBlocks- number of blocks that will be processed- Returns:
- the RetryTracker instance
-
keyExtractor
-
beginAttempt
public boolean beginAttempt()Call this before each retry cycle. Returns false if max total attempts exceeded.- Returns:
- if begin was successful
-
createFailedBlocksMap
Create the map of all blocks, from which we then remove each one that succeeded piece by piece- Parameters:
grid- - all blocks- Returns:
- HashMap from created unique key to block
-
processWithFutures
Method to process all results when running with a service that returns futures. When running with Spark, this method needs to be adjusted.- Parameters:
futures- - list of Futuresgrid- - list blocks that were processed- Returns:
- set of failed blocks
-
processFailures
Remove successful blocks from the failed set and update retry counts. Returns false if should stop due to too many individual block failures.- Parameters:
failedBlocks- failed block to re-process- Returns:
- if it did not give up now
-
getTotalAttempts
public int getTotalAttempts()
-