Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2007

Tip: Looking for answers? Try searching our database.

MappedByteBuffer force does not write to disk

Thread view: 
vissuyk@yahoo.com - 20 Jun 2007 04:32 GMT
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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.