aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes About UrlyBird data layer design Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "About UrlyBird data layer design" Watch "About UrlyBird data layer design" New topic
Author

About UrlyBird data layer design

daming wang
Greenhorn

Joined: Jul 28, 2004
Posts: 27
hello,everybody!
can someone comments on my design?
my version is 1.1.3,I study others' design,decide to cache all data in memory,put them in a arraylist(i am not sure it is right),recno start from 0,the record deleted also in it and have recno.
the most confuse me that the locking,I don't need record level,but I want It can multi read at the same time,so I want synchronize the arraylist when lock unlock update.Can someone give me some advice.

thx,sorry for my poor english


scjp,scjd,scea
Michael Couck
Ranch Hand

Joined: Nov 15, 2003
Posts: 46
Hi Daming,

Don't worry about locking at the record level for each record, lock the whole list. The other threads can wait to read while you update a record. Locking at the record level is not necessary, so somehing like this, in the DB class, or the implementor:


I locked each record at the record level, and had a queue on the lists, and I lost marks, so keep it simple. Lock the whole list, modify, then unlock, simple. You don't have to have bullet proof code like DB2, and efficiency you don't have to worry about.

Hope this helps.

Michael
daming wang
Greenhorn

Joined: Jul 28, 2004
Posts: 27
thank you,michael

my interface has not the declare:
public synchronized int lock(int recno) ;instead of
public int lock(int recno) ;
and I cache all the data in a arraylist,so I synchronized the arraylist
do you think it is proper
Michael Couck
Ranch Hand

Joined: Nov 15, 2003
Posts: 46
Hi daming,

Sorry about the long delay, don't look at these forums every day.

If I understand you correctly, your interface is:

And you don't want to break the method signature. But you can change some modifiers.
That is no problem, you can change the implementation of that method and include a "synchronized" modifier, no problem. But you said that you are synchronising on the list, that is also ok. Most of the people synchronised on the Data class, I think because it is easier. But synchronising on the list should be fine.

See ya

Michael
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: About UrlyBird data layer design