Skip to content

Commit

Permalink
WIP 4
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleAure committed Jul 12, 2024
1 parent 884cab7 commit fb1c1fa
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,21 @@ public void applicationStarting(ApplicationInfo appInfo) throws StateChangeExcep
public void applicationStarted(ApplicationInfo appInfo) throws StateChangeException {
Collection<FutureEMBuilder> futures = futureEMBuilders.remove(appInfo.getName());
if (futures != null) {
boolean beforeCheckpoint = !CheckpointPhase.getPhase().restored();
for (FutureEMBuilder futureEMBuilder : futures) {
// This delays createEMBuilder until restore.
// While this works by avoiding all connections to the data source, it does make restore much slower.
// TODO figure out how to do more work on restore without having to make a connection to the data source
CheckpointPhase.onRestore(() -> futureEMBuilder.completeAsync(futureEMBuilder::createEMBuilder, executor));
if (beforeCheckpoint)
try {
// Run the task in the foreground if before a checkpoint.
// This is necessary to ensure this task completes before the checkpoint.
// Application startup performance is not as important before checkpoint
// and this ensures we don't do this work on restore side which will make
// restore faster.
futureEMBuilder.complete(futureEMBuilder.createEMBuilder());
} catch (Throwable x) {
futureEMBuilder.completeExceptionally(x);
}
else
futureEMBuilder.completeAsync(futureEMBuilder::createEMBuilder, executor);
}
}
}
Expand Down

0 comments on commit fb1c1fa

Please sign in to comment.