Hi All,
I have been playing with MappedByteBuffer and file channels (NIO). I
have been to read a FileInputStream succesfully. When I then update
(using mappedbytebuffer.put(byte[]), it does write the update to disk.
Next time I restart the Java program and perform the read, it does not
have the update.
I did mappedbytebuffer.close but that did not help. Any tips are
appreciated. JDk = 1.5, OS = Linux 32 bit RHAT
Thanks
Vissu
vissuyk@yahoo.com - 20 Jun 2007 04:39 GMT
BTW, I have been able to read the updated date in memroy. When the
program terminated and retstarted the update is not seen which means
it was not persistent. I was under the assumption that when using
mapped byte buffer the OS automatically propagates the writes to disk.
I opened RandomAccessFile() in rw mode, then obtained filechannel from
it, then got hold of MappedByteBuffer by maping the length of the
file.
viss...@yahoo.com wrote:
> Hi All,
>
[quoted text clipped - 10 lines]
>
> Vissu
Esmond Pitt - 21 Jun 2007 02:21 GMT
> I have been playing with MappedByteBuffer and file channels (NIO). I
> have been to read a FileInputStream succesfully. When I then update
> (using mappedbytebuffer.put(byte[]), it does write the update to disk.
> Next time I restart the Java program and perform the read, it does not
> have the update.
I don't understand. These two statements are mutually contradictory. If
the update went to the disk, it would have been there next run. Is there
a 'not' missing somewhere.
vissuyk@yahoo.com - 21 Jun 2007 03:19 GMT
> viss...@yahoo.com wrote:
> > I have been playing with MappedByteBuffer and file channels (NIO). I
[quoted text clipped - 6 lines]
> the update went to the disk, it would have been there next run. Is there
> a 'not' missing somewhere.
OOPS, the updates DID NOT make it to the disk. However, once updated,
the updated values can be read from memory location.
Esmond Pitt - 22 Jun 2007 02:05 GMT
> OOPS, the updates DID NOT make it to the disk. However, once updated,
> the updated values can be read from memory location.
Of course. So you're saying you called MappedByteBuffer.force() and
nothing happened to the disk? and no exception was thrown?
vissuyk@yahoo.com - 25 Jun 2007 16:56 GMT
On Jun 21, 9:05 pm, Esmond Pitt <esmond.p...@nospam.bigpond.com>
wrote:
> viss...@yahoo.com wrote:
> > OOPS, the updates DID NOT make it to the disk. However, once updated,
> > the updated values can be read from memory location.
>
> Of course. So you're saying you called MappedByteBuffer.force() and
> nothing happened to the disk? and no exception was thrown?
Thats' right. Called force, then program terminates. Another program
starts and accesses the file and it sees old content - not the updated
content.