Skip to content

Loading routing information from a read only file system. #217

Closed

Description

@joseSilvaIpn

Hello, I was having trouble loading the routing information from an obb file because the file system created when i mounted the obb was an read only file system. I was using the following code:
GraphHopper tmpHoppFOOT = new GraphHopper().forMobile();
tmpHoppFOOT.setCHShortcuts("fastest");
tmpHoppFOOT.setEncodingManager(new EncodingManager("FOOT"));
tmpHoppFOOT.load(mapsFolder + currentAreaFOOT);

and getting the following error:

The load causes the following error message: AndroidRuntime(3498): Caused by: java.lang.RuntimeException: java.io.FileNotFoundException: /mnt/obb/07f4c5780b38b1ae526b333f8087a627/FootPortugal-gh/edges (Read-only file system)

The problem was graphhopper opened the map files as read/write. I changed the following lines in MMapDataAccess:
line 68:
from:
raFile = new RandomAccessFile(getFullName(), "rw");
to
raFile = new RandomAccessFile(getFullName(), "r");

line 176:
from:
buf = raFile.getChannel().map(FileChannel.MapMode.READ_WRITE, offset, byteCount);

to:
buf = raFile.getChannel().map(FileChannel.MapMode.READ_ONLY, offset, byteCount);

With this changes I was able to successfully load the map and routing information from the obb file system.

Activity

  1. karussell commented on Jun 11, 2014

    @karussell
    Member

    Thanks! Maybe you have time to create a pull request which makes this configurable? Of course we shouldn't use this as default but on systems like Android we can and should do it.

  2. karussell commented on Jun 23, 2014

    @karussell
    Member

    This here should use the new variable introduced in #112: graphHopper.setAllowWrites(false)

  3. added this to the 0.4 milestone on Jun 23, 2014
  4. modified the milestones: 0.4, 0.5 on Aug 18, 2014
  5. modified the milestones: 0.4, 0.5 on Nov 6, 2014
  6. devemux86 commented on Nov 7, 2014

    @devemux86
    Contributor

    That's probably related to my post here.

    I have tried the new GH version but it does not work on mounted shared folders, I still receive messages like:
    Couldn't map buffer 0 of 2 at position 100 for 2097052 bytes with offset 100, new file Length:2097252

    Emux
    Cruiser - Atlas

  7. devemux86 commented on Nov 7, 2014

    @devemux86
    Contributor

    I spoke too soon, even with the warnings now the routing is working!

    Emux
    Cruiser - Atlas

  8. karussell commented on Nov 7, 2014

    @karussell
    Member

    Hmmh, does it really work in every area? Shared folders is probably not really possible for memory mapping? (But for small areas you could easily switch to RAM_STORE, should be also a lot faster for the queries but requires more RAM)

  9. devemux86 commented on Nov 7, 2014

    @devemux86
    Contributor

    The thing is I want to avoid moving all the time the graphs to the Android emulators / devices, as I change them frequently with various tests.

    I have to rebuild now all my graphs (Version of edges unsupported: 7, expected:9), but initial tests seem to work. I'll report any unfortunate results.

    Emux
    Cruiser - Atlas

  10. karussell commented on Nov 7, 2014

    @karussell
    Member

    The error looks bad - would you mind to add the getFullName to the exception in MMapDataAccess?

    throw new RuntimeException("Couldn't map buffer " + i + " of " + segmentsToMap
                    + " at position " + bufferStart + " for " + byteCount
                    + " bytes with offset " + offset + ", new fileLength:" + newFileLength
                    + ", file:" + getFullName(), ex);
    

    Maybe we need some additional escaping or something ...

    I have to rebuild now all my graphs

    Yes, sorry for the inconvenience. See here #281 for hopefully less recreation work in the future.

  11. devemux86 commented on Nov 7, 2014

    @devemux86
    Contributor

    Ok with the graphHopper.setAllowWrites(false) I have no warnings and all seem to work.

    Using your snippet the previous warnings were like:
    Couldn't map buffer 0 of 2 at position 100 for 2097052 bytes with offset 100, new file Length:2097252, file:/mnt/shared/graphs/cyprus-gh/nodes

    Emux
    Cruiser - Atlas

  12. karussell commented on Nov 7, 2014

    @karussell
    Member

    Nice, thanks for the update! Please reopen or create a new issue if you find something strange

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    androidgood first issue

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions