graphhopper: setAllowWrites(false) makes GraphHopper.load() fail even though no write access is needed.

Describe the bug When setting setAllowWrites(false) for non-writable file systems the GraphHopper.load() function fails in the subfunction prepareCH() because prepareCH() requires write access, even when there are no CHProfiles to be prepared.

The prepareCH() function throws an IllegalStateException("Writes are not allowed!").

To Reproduce

GraphHopperConfig config = new GraphHopperConfig(); // iniitalize parameter map
config.putObject("index.max_region_search", 8); // define more iterations to find the points more accurately
config.getProfiles().add(new Profile("car").setVehicle("car").setWeighting("fastest")); // add the profile
config.getCHProfiles().add(new CHProfile("car")); // set the rofile for speed mode

GraphHopper hopper = new GraphHopper().setGraphHopperLocation(distancesFolder.getAbsolutePath()) // set working directory
                                   .setPreciseIndexResolution(1000) // define higher resolution to find the points more accurately
                                   .init(config) // start graphhopper instance
                                   .setAllowWrites(false) // only read the file
                                   .setGraphHopperLocation(distancesFolder.getAbsolutePath());
hopper.load(); // load gaphhopper

Expected behavior The prepareCH() function should not throw an IllegalStateException("Writes are not allowed!") if no CHProfile has to be prepared.

System Information

operating system: Ubuntu 20.04 JDK: java-11-openjdk-amd64 GraphHopper: current master branch

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 17 (13 by maintainers)

Most upvoted comments

I think our data files should be our lock files in this scenario. If an import starts and there is e.g. the nodes file already it should just crash. The files should just be created the moment we request a new DataAccess, just like we do (and have to do) for MMAP already. Then there is no need for a lock file and no need for the HashMap in Directory either.

Since we aren’t there yet, maybe we can just create the lock file for the import command. The server command will crash upon its second invocation anyway, because the port will be used already.

Do you mean instead of the lower level “don’t allow writes” the user should be able to specify “don’t modify graph”?

I think the user should be able to specify things like ‘import’, ‘load’ etc., see my list of five usage patterns above. Something like ‘clean load’ would imply ‘don’t modify graph’, yes.