*
The moose likes Product and Other Certifications and the fly likes Record Store Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Product and Other Certifications
Bookmark "Record Store" Watch "Record Store" New topic
Author

Record Store

Thiago Albino
Greenhorn

Joined: Nov 14, 2005
Posts: 6
Hello People !!

"Record store implementations ensure that all individual record store operations are atomic, synchronous, and serialized, so no corruption will occur with multiple accesses.
However, if a MIDlet uses multiple threads to access a record store, it is the MIDlet´┐Żs responsibility to coordinate this access or unintended consequences may result."

I can't understand it !! Someone help me ! record store operations is synchronous and the method openRecordStore when the record store is already open returns a reference to the same RecordStore object. Why do midlet needs to control multiple threads to access a record store ? thanks !
Nobuhiro Watsuki
Ranch Hand

Joined: May 07, 2004
Posts: 81
Well, they don't
need
to.
It is just a feature.
I think they are warning you of the fact that the order in which runnable threads are chosen by the scheduler is not guaranteed. So older data could be overwritten by newer if the scheduler does't behave like you expect.
[ November 15, 2005: Message edited by: Nobuhiro Watsuki ]

SCJP, SCMAD, SCWCD, SCBCD, CCIE (written), IBM 287<a href="http://hollandiahaven.blogspot.com/" target="_blank" rel="nofollow">.</a>
Thiago Albino
Greenhorn

Joined: Nov 14, 2005
Posts: 6
Only warning, the midlet does not need to control multiple access to record store, ok !?! Thanks !! but , in the the exam , is this answer too ?


ob : sorry people, my english is very , very bad.
Nobuhiro Watsuki
Ranch Hand

Joined: May 07, 2004
Posts: 81
I don't know.
A small warning: what I said could be nonsense.
Thiago Albino
Greenhorn

Joined: Nov 14, 2005
Posts: 6
I believe what you said make sense !! the midlet specification became me confuse !! I am looking for answers !! thanks !
Thiago Albino
Greenhorn

Joined: Nov 14, 2005
Posts: 6
You was almost rigth !! read the text from specification : if two threads in a MIDlet both call RecordStore.setRecord() concurrently on the same record, the record store will serialize these calls properly, and no database corruption will occur as a result. However, one of the writes will be subsequently overwritten by the other, which may cause problems within the MIDlet.
Nobuhiro Watsuki
Ranch Hand

Joined: May 07, 2004
Posts: 81
Darn. Look like I was completely right!
Thiago Albino
Greenhorn

Joined: Nov 14, 2005
Posts: 6
ok !! Darn , you was completely rigth !! Thanks !! but say me your conclusion for the exam !!
Nobuhiro Watsuki
Ranch Hand

Joined: May 07, 2004
Posts: 81
Examwise it would fall under the objective

"Develop code that correctly implements adding, retrieving, modifying, and deleting individual records in a RecordStore, and converting RecordStore record data to and from byte arrays, and that reflects performance implications."

I'd use the Recordlistener interface to check if some other thread had changed something "prematurely".
You could also use getVersion() or getLastModified() (save the "before" values) if the RecordStore isn't of the shared type so other MIDlet suites somebody else wrote can't mess up the logic.
You could also use the keepUdated parameter of the enumerateRecords() method. (the RecordEnumeration registers itself as a RecordListener.)

By the way: I'm still worrying about the "reflects performance implications." part of the objective.
Knudsen mentions one should call closeRecordStore() (page 123) (saves memory) but he also says closing is time-consuming (I guess it is a tradeoff between time and memory).
He also says that when pulling many records out of a RecordStore you should create one array and use it over and over again (page 127).
He also warns that a RecordEnumeration that has a isKeptUpdated() that returns true is expensive (page 136) in terms of time if there are many RecordStore changes.

I wonder if there are other performance implications.
[ November 16, 2005: Message edited by: Nobuhiro Watsuki ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Record Store
 
Similar Threads
how to communicate between two midlet suits
using old RecordStore after upgrading MIDlet
How can I backup record stores for my midlet on phones?
My Locking Approach
Need to access Record Store from another midlet