-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/dev-2.x' into swap-debug-clients
- Loading branch information
Showing
18 changed files
with
428 additions
and
248 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -117,12 +117,13 @@ jobs: | |
|
||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 18 | ||
node-version: 20 | ||
|
||
- name: Build GTFS GraphQL API documentation | ||
run: | | ||
npm install -g @magidoc/[email protected] | ||
magidoc generate | ||
npm install -g @magidoc/[email protected] | ||
cat src/main/resources/org/opentripplanner/apis/gtfs/schema.graphqls | ||
magidoc generate --stacktrace | ||
- name: Deploy compiled HTML to Github pages | ||
if: github.event_name == 'push' && (github.ref == 'refs/heads/dev-2.x' || github.ref == 'refs/heads/master') | ||
|
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
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
45 changes: 45 additions & 0 deletions
45
src/ext/java/org/opentripplanner/ext/siri/updater/AsyncEstimatedTimetableProcessor.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,45 @@ | ||
package org.opentripplanner.ext.siri.updater; | ||
|
||
import java.util.concurrent.Future; | ||
import java.util.function.Consumer; | ||
import org.opentripplanner.updater.spi.UpdateResult; | ||
import org.opentripplanner.updater.spi.WriteToGraphCallback; | ||
import org.opentripplanner.updater.trip.UpdateIncrementality; | ||
import uk.org.siri.siri20.ServiceDelivery; | ||
|
||
/** | ||
* Apply asynchronously estimated timetable updates in the graph-writer thread and forward the | ||
* result to an update result consumer. | ||
*/ | ||
public class AsyncEstimatedTimetableProcessor { | ||
|
||
private final EstimatedTimetableHandler estimatedTimetableHandler; | ||
private final WriteToGraphCallback saveResultOnGraph; | ||
private final Consumer<UpdateResult> updateResultConsumer; | ||
|
||
public AsyncEstimatedTimetableProcessor( | ||
EstimatedTimetableHandler estimatedTimetableHandler, | ||
WriteToGraphCallback saveResultOnGraph, | ||
Consumer<UpdateResult> updateResultConsumer | ||
) { | ||
this.estimatedTimetableHandler = estimatedTimetableHandler; | ||
this.saveResultOnGraph = saveResultOnGraph; | ||
this.updateResultConsumer = updateResultConsumer; | ||
} | ||
|
||
/** | ||
* Apply the estimated timetables to the transit model. | ||
* This method is non-blocking and applies the changes asynchronously. | ||
* @return a future indicating when the changes are applied. | ||
*/ | ||
public Future<?> processSiriData(ServiceDelivery serviceDelivery) { | ||
return saveResultOnGraph.execute((graph, transitModel) -> | ||
updateResultConsumer.accept( | ||
estimatedTimetableHandler.applyUpdate( | ||
serviceDelivery.getEstimatedTimetableDeliveries(), | ||
UpdateIncrementality.DIFFERENTIAL | ||
) | ||
) | ||
); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/ext/java/org/opentripplanner/ext/siri/updater/AsyncEstimatedTimetableSource.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,28 @@ | ||
package org.opentripplanner.ext.siri.updater; | ||
|
||
import java.util.concurrent.Future; | ||
import java.util.function.Function; | ||
import uk.org.siri.siri20.ServiceDelivery; | ||
|
||
/** | ||
* A source of estimated timetables produced by an asynchronous (push) SIRI-ET feed. | ||
*/ | ||
public interface AsyncEstimatedTimetableSource { | ||
/** | ||
* Start reading from the SIRI-ET feed and forward the estimated timetables to a consumer for | ||
* further processing. | ||
* <br>Starting the source includes all the necessary steps to set up the network | ||
* communication with the SIRI-ET feed as well as the (optional) processing of the message | ||
* backlog, that is the recent history of SIRI-ET messages produced by this feed and made | ||
* available by a message cache. | ||
* | ||
* @param serviceDeliveryConsumer apply asynchronously the updates to the transit model. Return a | ||
* future indicating when the updates are applied. | ||
*/ | ||
void start(Function<ServiceDelivery, Future<?>> serviceDeliveryConsumer); | ||
|
||
/** | ||
* Return true if the message backlog is processed and the source is ready to listen to the feed. | ||
*/ | ||
boolean isPrimed(); | ||
} |
69 changes: 69 additions & 0 deletions
69
src/ext/java/org/opentripplanner/ext/siri/updater/EstimatedTimetableHandler.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,69 @@ | ||
package org.opentripplanner.ext.siri.updater; | ||
|
||
import java.util.List; | ||
import org.opentripplanner.ext.siri.EntityResolver; | ||
import org.opentripplanner.ext.siri.SiriFuzzyTripMatcher; | ||
import org.opentripplanner.ext.siri.SiriTimetableSnapshotSource; | ||
import org.opentripplanner.transit.service.TransitService; | ||
import org.opentripplanner.updater.spi.UpdateResult; | ||
import org.opentripplanner.updater.trip.UpdateIncrementality; | ||
import uk.org.siri.siri20.EstimatedTimetableDeliveryStructure; | ||
|
||
/** | ||
* A consumer of estimated timetables that applies the real-time updates to the transit model. | ||
*/ | ||
public class EstimatedTimetableHandler { | ||
|
||
private final SiriTimetableSnapshotSource snapshotSource; | ||
private final SiriFuzzyTripMatcher fuzzyTripMatcher; | ||
private final EntityResolver entityResolver; | ||
/** | ||
* The ID for the static feed to which these real time updates are applied | ||
*/ | ||
private final String feedId; | ||
|
||
public EstimatedTimetableHandler( | ||
SiriTimetableSnapshotSource snapshotSource, | ||
boolean fuzzyMatching, | ||
TransitService transitService, | ||
String feedId | ||
) { | ||
this( | ||
snapshotSource, | ||
fuzzyMatching ? SiriFuzzyTripMatcher.of(transitService) : null, | ||
transitService, | ||
feedId | ||
); | ||
} | ||
|
||
/** | ||
* Constructor for tests only. | ||
*/ | ||
public EstimatedTimetableHandler( | ||
SiriTimetableSnapshotSource snapshotSource, | ||
SiriFuzzyTripMatcher siriFuzzyTripMatcher, | ||
TransitService transitService, | ||
String feedId | ||
) { | ||
this.snapshotSource = snapshotSource; | ||
this.fuzzyTripMatcher = siriFuzzyTripMatcher; | ||
this.entityResolver = new EntityResolver(transitService, feedId); | ||
this.feedId = feedId; | ||
} | ||
|
||
/** | ||
* Apply the update to the transit model. | ||
*/ | ||
public UpdateResult applyUpdate( | ||
List<EstimatedTimetableDeliveryStructure> estimatedTimetableDeliveries, | ||
UpdateIncrementality updateMode | ||
) { | ||
return snapshotSource.applyEstimatedTimetable( | ||
fuzzyTripMatcher, | ||
entityResolver, | ||
feedId, | ||
updateMode, | ||
estimatedTimetableDeliveries | ||
); | ||
} | ||
} |
Oops, something went wrong.