-
Notifications
You must be signed in to change notification settings - Fork 188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Periodically reconcile the list of metadata files #2085
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,6 +82,7 @@ public class SingularityS3UploaderDriver extends WatchServiceHelper implements S | |
private final Map<S3UploadMetadata, CompletableFuture<Integer>> immediateUploadersFutures; | ||
|
||
private ScheduledFuture<?> future; | ||
private ScheduledFuture<?> fileSyncFuture; | ||
|
||
@Inject | ||
public SingularityS3UploaderDriver(SingularityRunnerBaseConfiguration baseConfiguration, SingularityS3UploaderConfiguration configuration, SingularityS3Configuration s3Configuration, | ||
|
@@ -187,6 +188,17 @@ public void startAndWait() { | |
} | ||
}, configuration.getCheckUploadsEverySeconds(), configuration.getCheckUploadsEverySeconds(), TimeUnit.SECONDS); | ||
|
||
fileSyncFuture = scheduler.scheduleAtFixedRate(() -> { | ||
runLock.lock(); | ||
try { | ||
readInitialFiles(); | ||
} catch (Throwable t) { | ||
throw new RuntimeException(t); | ||
} finally { | ||
runLock.unlock(); | ||
} | ||
}, configuration.getRecheckFilesEverySeconds(), configuration.getRecheckFilesEverySeconds(), TimeUnit.SECONDS); | ||
|
||
try { | ||
super.watch(); | ||
} catch (Throwable t) { | ||
|
@@ -209,6 +221,10 @@ public void shutdown() { | |
runLock.unlock(); | ||
} | ||
|
||
if (fileSyncFuture != null) { | ||
fileSyncFuture.cancel(true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why allow interrupts here but not for the upload future? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good Q, I don't remember why I put that there... Will take a second look at it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah right, this one is just checking for new files, interrupting in the middle won't actually interrupt an upload. The uploaders themselves we want to give a better chance to finish |
||
} | ||
|
||
if (future != null) { | ||
future.cancel(false); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
checking - do you know how long this process usually takes, and is there a concern that it'll hold the lock long enough to cause issues for the S3 uploads?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole process is async/background, nothing hits it live or like a service, and it only holds the lock for a second or two