This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Grokking Bitcoin and have Kalle Rosenbaum on-line!
See this thread for details.
Win a copy of Grokking Bitcoin this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
Bartenders:
  • Carey Brown
  • salvin francis
  • Claude Moore

non-networked mode and locking  RSS feed

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

i've just had a thought regarding URLyBird and the non-networked mode and locking. It seems silly to think that in non-networked mode theres any use at all for locking records - i'm assuming that in this mode, theres only ever 1 client running and the db is not being shared.

So in my biz tier classes (book, search) my local biz class wont use the locking methods provided by the Data class at all.

However it just occured to me..what if a client in non-networked mode is running on the same machine as the server, and both are using the same database file? Has anyone considered this?

I'd really like to know if any thinks that any book() call should use locking, regardless of whether the client is in non-networked mode.

Regards,

Red
 
Red Marshall
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just came up with another brain teaser

scenario: My data.java is a singleton..i've done because it seemed logical as 2 clients accessing the same db file must be using the same instance of data.java.

but what happens when you have 2 clients, accessing different db files? The singleton pattern no longer works as 2 distinct instances of data.java are now needed for each db file.

There is a workaround to this by modifying the singleton pattern so that data.java now has a static map of data.java instances where the key is the db filename.

This seems like overkill..ne thoughts?
 
Ranch Hand
Posts: 442
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Red Marshall:
what if a client in non-networked mode is running on the same machine as the server, and both are using the same database file? Has anyone considered this?



No need to consider it, you may assume that at any given time at most one client is accessing the database, you'll find words to that effect in your instructions.
The "client" in this context includes your server as that's a database client.
 
Red Marshall
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the post

my follow up reply is still concerning me however. Its possible that 2 or more instances of this system will be running..each using different db files.

But this is prob ok if your program dosnt allow this - hopefully.

Does your business methods in the non-networked mode call any of the locking methods?

i.e.

book()
{
dataInstance.lock()
..processing
dataInstance.unlock()
}

my design at moment means that the data.java methods create/update/delete assume that only 1 client is calling the method at that time. So i was going to handle all the locking within the business methods. (Bad?)

In that case whats the point of using locking at all in the business methods for the non-networked mode.

all the best,

red
 
I'm not dead! I feel happy! I'd like to go for a walk! I'll even read a tiny ad:
Create Edit Print & Convert PDF Using Free API with Java
https://coderanch.com/wiki/703735/Create-Convert-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!