Skip to content

Support for turning the fares calculation off, even when fares are#2912

Merged
abyrd merged 8 commits into
opentripplanner:dev-2.xfrom
entur:otp2_NoopFareService
Jan 10, 2020
Merged

Support for turning the fares calculation off, even when fares are#2912
abyrd merged 8 commits into
opentripplanner:dev-2.xfrom
entur:otp2_NoopFareService

Conversation

@t2gran

@t2gran t2gran commented Dec 18, 2019

Copy link
Copy Markdown
Member

When testing the OTP2 with the Netherlands GTFS file set OTP2 performed poor due to a lot of fare rules. There is no way to turn off this, when the GTFS data contains such rules; Hence it would be nice to be able to turn off fares, so it does not block running OTP when there is a problem with the fares.

This PR vil use a Noop implementation to disable the FareService during the build operation. The fares are still processed while loading the GTFS files, but they have no effect.

To be completed by pull request submitter:

  • issue: I did not create an issue for such a small change, and we (Sven Boor, Moopmobility; Andrew Byrd, Conveyal; Grad Mellestrand, Entur and Thomas Gran, Entur) discussed this and agreed that this should be done.
  • roadmap: Not considered big enough.
  • tests: No tests are added - The new code does nothing - that is the purpose of it. I have manually tested that the configuration works, and disable the Fare Service.
  • formatting: Have you followed the suggested code style?
  • documentation: If you are adding a new configuration option, have you added an explanation to the configuration documentation tables and sections?
  • changelog: add a bullet point to the changelog file with description and link to the linked issue

To be completed by @opentripplanner/plc:

  • reviews and approvals by 2 members, ideally from different organizations
  • after merging: update the relevant card on the roadmap

@t2gran t2gran requested a review from a team December 18, 2019 13:42
@t2gran t2gran added the OTP2 label Dec 18, 2019
@sven4all

sven4all commented Jan 6, 2020

Copy link
Copy Markdown
Contributor

I tried to test this PR a few times during the last weeks, until now not able to get it working.

What I tried is:

  1. checkout this branch https://github.com/entur/OpenTripPlanner/tree/otp2_NoopFareService
  2. build this branch with mvn install
  3. build graph with new otp-2.0.0-SNAPSHOT-shaded.jar
  4. tried to start otp with new graph and otp-2.0.0-SNAPSHOT-shaded.jar

1 to 3 work fine, at step 4 I do get this error:
WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by com.esotericsoftware.kryo.util.UnsafeUtil (file:/home/otp/otp-2.0.0-SNAPSHOT-shaded.jar) to constructor java.nio.DirectByteBuffer(long,int,java.lang.Object) WARNING: Please consider reporting this to the maintainers of com.esotericsoftware.kryo.util.UnsafeUtil WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release 00:14 WARN: [kryo] Unable to load class org.opentripplanner.routing.impl.NoopFareServiceFactory$$Lambda$124/0x00000008003ec840 with kryo's ClassLoader. Retrying with current.. 15:20:15.601 ERROR (GraphLoader.java:40) Exception while loading graph: {} com.esotericsoftware.kryo.KryoException: Unable to find class: org.opentripplanner.routing.impl.NoopFareServiceFactory$$Lambda$124/0x00000008003ec840 Serialization trace: _services (org.opentripplanner.routing.graph.Graph) graph (org.opentripplanner.routing.graph.SerializedGraphObject) at com.esotericsoftware.kryo.util.DefaultClassResolver.readName(DefaultClassResolver.java:160) ~[otp-2.0.0-SNAPSHOT-shaded.jar:1.1] at com.esotericsoftware.kryo.util.DefaultClassResolver.readClass(DefaultClassResolver.java:133) ~[otp-2.0.0-SNAPSHOT-shaded.jar:1.1] at com.esotericsoftware.kryo.Kryo.readClass(Kryo.java:693) ~[otp-2.0.0-SNAPSHOT-shaded.jar:1.1] at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:804) ~[otp-2.0.0-SNAPSHOT-shaded.jar:1.1] at com.esotericsoftware.kryo.serializers.MapSerializer.read(MapSerializer.java:161) ~[otp-2.0.0-SNAPSHOT-shaded.jar:1.1] at com.esotericsoftware.kryo.serializers.MapSerializer.read(MapSerializer.java:39) ~[otp-2.0.0-SNAPSHOT-shaded.jar:1.1] at com.esotericsoftware.kryo.Kryo.readObject(Kryo.java:731) ~[otp-2.0.0-SNAPSHOT-shaded.jar:1.1] at com.esotericsoftware.kryo.serializers.ObjectField.read(ObjectField.java:125) ~[otp-2.0.0-SNAPSHOT-shaded.jar:1.1] at com.esotericsoftware.kryo.serializers.FieldSerializer.read(FieldSerializer.java:543) ~[otp-2.0.0-SNAPSHOT-shaded.jar:1.1] at com.esotericsoftware.kryo.Kryo.readObject(Kryo.java:731) ~[otp-2.0.0-SNAPSHOT-shaded.jar:1.1] at com.esotericsoftware.kryo.serializers.ObjectField.read(ObjectField.java:125) ~[otp-2.0.0-SNAPSHOT-shaded.jar:1.1] at com.esotericsoftware.kryo.serializers.FieldSerializer.read(FieldSerializer.java:543) ~[otp-2.0.0-SNAPSHOT-shaded.jar:1.1] at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:813) ~[otp-2.0.0-SNAPSHOT-shaded.jar:1.1] at org.opentripplanner.routing.graph.Graph.load(Graph.java:685) ~[otp-2.0.0-SNAPSHOT-shaded.jar:1.1] at org.opentripplanner.routing.impl.GraphLoader.loadGraph(GraphLoader.java:33) ~[otp-2.0.0-SNAPSHOT-shaded.jar:1.1] at org.opentripplanner.standalone.OTPMain.startOTPServer(OTPMain.java:107) ~[otp-2.0.0-SNAPSHOT-shaded.jar:1.1] at org.opentripplanner.standalone.OTPMain.main(OTPMain.java:32) ~[otp-2.0.0-SNAPSHOT-shaded.jar:1.1] Caused by: java.lang.ClassNotFoundException: org.opentripplanner.routing.impl.NoopFareServiceFactory$$Lambda$124/0x00000008003ec840 at java.base/java.lang.Class.forName0(Native Method) ~[na:na] at java.base/java.lang.Class.forName(Class.java:398) ~[na:na] at com.esotericsoftware.kryo.util.DefaultClassResolver.readName(DefaultClassResolver.java:154) ~[otp-2.0.0-SNAPSHOT-shaded.jar:1.1] ... 16 common frames omitted 15:20:15.602 ERROR (OTPMain.java:112) No router available for server or visualizer. Exiting.

@t2gran

t2gran commented Jan 6, 2020

Copy link
Copy Markdown
Member Author

Thank you for testing it, I will check the serialization support on the NoopFareServiceFactory. In the mean time you might use the --inMemory otp CLI parameter to skip the graph serialization in step 3, combining step 3 and 4.

@t2gran

t2gran commented Jan 6, 2020

Copy link
Copy Markdown
Member Author

I managed to reproduce the Serialization issue and fix it. The FareService did not extend the Serializable, witch it should. I changed this. Another minor error witch allowed this was that the Graph class holds a generic map of services with type Object. I changed this to Serializable to be a little more type-safe.

@t2gran

t2gran commented Jan 6, 2020

Copy link
Copy Markdown
Member Author

I merged this PR with the latest in ´dev-2.x´. Note that the graph name have changed from Graph.obj to ´graph.obj` as part of the merge.

@sven4all

sven4all commented Jan 7, 2020

Copy link
Copy Markdown
Contributor

Now it works!

Change is clean and well documented.

@t2gran

t2gran commented Jan 7, 2020

Copy link
Copy Markdown
Member Author

@sven4all thank you for testing it.
@abyrd would you mind doing a review of the code changes - it should be straight forward.

@t2gran t2gran assigned abyrd and unassigned sven4all Jan 7, 2020
@abyrd abyrd assigned t2gran and unassigned abyrd Jan 10, 2020
@abyrd abyrd merged commit f76183e into opentripplanner:dev-2.x Jan 10, 2020
@t2gran t2gran deleted the otp2_NoopFareService branch January 10, 2020 14:32
@abyrd abyrd added this to the 2.0 milestone Oct 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants