use of org.opentripplanner.updater.GraphWriterRunnable in project OpenTripPlanner by opentripplanner.
the class GtfsRealtimeAlertsUpdater method runPolling.
@Override
protected void runPolling() {
try {
InputStream data = HttpUtils.getData(url);
if (data == null) {
throw new RuntimeException("Failed to get data from url " + url);
}
final FeedMessage feed = FeedMessage.PARSER.parseFrom(data);
long feedTimestamp = feed.getHeader().getTimestamp();
if (feedTimestamp <= lastTimestamp) {
LOG.info("Ignoring feed with an old timestamp.");
return;
}
// Handle update in graph writer runnable
updaterManager.execute(new GraphWriterRunnable() {
@Override
public void run(Graph graph) {
updateHandler.update(feed);
}
});
lastTimestamp = feedTimestamp;
} catch (Exception e) {
LOG.error("Error reading gtfs-realtime feed from " + url, e);
}
}
use of org.opentripplanner.updater.GraphWriterRunnable in project OpenTripPlanner by opentripplanner.
the class BikeParkUpdater method setup.
@Override
public void setup() throws InterruptedException, ExecutionException {
// Creation of network linker library will not modify the graph
linker = new SimpleStreetSplitter(graph);
// Adding a bike park station service needs a graph writer runnable
updaterManager.executeBlocking(new GraphWriterRunnable() {
@Override
public void run(Graph graph) {
bikeService = graph.getService(BikeRentalStationService.class, true);
}
});
}
Aggregations