forked from HSLdevcom/OpenTripPlanner
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request opentripplanner#5974 from entur/publish_timetable_…
…snapshot_in_background Publish timetable snapshot in background
- Loading branch information
Showing
11 changed files
with
286 additions
and
250 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/main/java/org/opentripplanner/updater/spi/TimetableSnapshotFlush.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package org.opentripplanner.updater.spi; | ||
|
||
import org.opentripplanner.ext.siri.SiriTimetableSnapshotSource; | ||
import org.opentripplanner.updater.trip.TimetableSnapshotSource; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* Flush the timetable snapshot buffer by committing pending changes. | ||
* Exceptions occurring during the flush are caught and ignored: the scheduler can then retry | ||
* the task later. | ||
*/ | ||
public class TimetableSnapshotFlush implements Runnable { | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(TimetableSnapshotFlush.class); | ||
|
||
private final SiriTimetableSnapshotSource siriTimetableSnapshotSource; | ||
private final TimetableSnapshotSource gtfsTimetableSnapshotSource; | ||
|
||
public TimetableSnapshotFlush( | ||
SiriTimetableSnapshotSource siriTimetableSnapshotSource, | ||
TimetableSnapshotSource gtfsTimetableSnapshotSource | ||
) { | ||
this.siriTimetableSnapshotSource = siriTimetableSnapshotSource; | ||
this.gtfsTimetableSnapshotSource = gtfsTimetableSnapshotSource; | ||
} | ||
|
||
@Override | ||
public void run() { | ||
try { | ||
LOG.debug("Flushing timetable snapshot buffer"); | ||
if (siriTimetableSnapshotSource != null) { | ||
siriTimetableSnapshotSource.flushBuffer(); | ||
} | ||
if (gtfsTimetableSnapshotSource != null) { | ||
gtfsTimetableSnapshotSource.flushBuffer(); | ||
} | ||
LOG.debug("Flushed timetable snapshot buffer"); | ||
} catch (Throwable t) { | ||
LOG.error("Error flushing timetable snapshot buffer", t); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.