File Read in 2 JVM

Discussion in 'Java' started by moleskyca1@yahoo.com, Jan 12, 2007.

  1. Guest

    I am going to read file in one JVM that someone create in another JVM.
    Writer JVM is older class, but I can ask them to modify it for me.

    This is in linux.

    I am worried about dirty reads. Reading the file when writer JVM is not
    done writing. What is good way to handle this? The file is huge (like
    40-60 gigs) and will not fit in memory.
    , Jan 12, 2007
    #1
    1. Advertising

  2. Guest

    wrote:
    > I am going to read file in one JVM that someone create in another JVM.
    > Writer JVM is older class, but I can ask them to modify it for me.
    >
    > This is in linux.
    >
    > I am worried about dirty reads. Reading the file when writer JVM is not
    > done writing. What is good way to handle this? The file is huge (like
    > 40-60 gigs) and will not fit in memory.


    Usually only one process can open a file for writing at one time, but
    this depends on which API was used and the implementation of the
    underlying OS, so it's not a very reliable approach.

    Three possible solutions:

    0. Have the reader lock the file so that no other process can write to
    it. If you can't get the lock, then it means another process is
    writing to it.

    1. Have the writer create a secondary status file, which is deleted
    once the process has been completed. The java.io.File.deleteOnExit()
    method can make this easier.

    2. Have the writer create the file with a different name/extension, and
    then rename it after closing it.
    , Jan 12, 2007
    #2
    1. Advertising

  3. Chris Uppal Guest

    wrote:

    > Three possible solutions:
    >
    > 0. Have the reader lock the file so that no other process can write to
    > it. If you can't get the lock, then it means another process is
    > writing to it.
    >
    > 1. Have the writer create a secondary status file, which is deleted
    > once the process has been completed. The java.io.File.deleteOnExit()
    > method can make this easier.
    >
    > 2. Have the writer create the file with a different name/extension, and
    > then rename it after closing it.


    ....also...

    3. Have the writer write a unique end-marker to the output file.

    -- chris
    Chris Uppal, Jan 12, 2007
    #3
  4. Guest

    Chris Uppal wrote:
    > wrote:
    >
    > > Three possible solutions:
    > >
    > > 0. Have the reader lock the file so that no other process can write to
    > > it. If you can't get the lock, then it means another process is
    > > writing to it.
    > >
    > > 1. Have the writer create a secondary status file, which is deleted
    > > once the process has been completed. The java.io.File.deleteOnExit()
    > > method can make this easier.
    > >
    > > 2. Have the writer create the file with a different name/extension, and
    > > then rename it after closing it.

    >
    > ...also...
    >
    > 3. Have the writer write a unique end-marker to the output file.


    That's a very good suggestion, as long as there's absolutely no
    potential for data being written to the file to be identical to the
    end-marker character sequence.
    , Jan 12, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kevin Hooke

    Re: Handling both MS JVM and Sun JVM

    Kevin Hooke, Aug 26, 2003, in forum: Java
    Replies:
    2
    Views:
    873
  2. Lasse
    Replies:
    1
    Views:
    698
    Jon A. Cruz
    Jan 5, 2004
  3. Young-Jin Lee

    MS JVM and Sun JVM problem

    Young-Jin Lee, Jan 20, 2004, in forum: Java
    Replies:
    3
    Views:
    571
    Mickey Segal
    Jan 21, 2004
  4. Sreejith K
    Replies:
    24
    Views:
    1,011
    Sreejith K
    Mar 24, 2009
  5. Alex Dowad
    Replies:
    4
    Views:
    268
    Michel Demazure
    May 1, 2010
Loading...

Share This Page