SCJP, SCJD, SCWCD<br />"Meekness is not weakness, but power under control"
Contains an internal, daemon thread which deals with deadlocks.
Why have you catered for deadlocks where a good multi-threaded solution should prevent such a thing from ever occurring?
The daemon thread should prove unnecessary.
SCJP, SCJD, SCWCD<br />"Meekness is not weakness, but power under control"
Ah , a dead lock rather than deadlock (LOL).
That makes more sense.
But if you are using Unreferenced, do you need this daemon thread?
SCJP, SCJD, SCWCD<br />"Meekness is not weakness, but power under control"
That is 1: use Unreferenced and let the "system" decide when to release the lock for the dead client.
2: Don't specify a lease period and the "application" decides when to release the lock.
SCJP, SCJD, SCWCD<br />"Meekness is not weakness, but power under control"
Several DataService implementations can share the same Data and LockManager instances. Each newly created Data instance has a corresponding LockManager instance tied to it within the DataService implementation.
Okay, I'll come back to what I think are two design options after doing some reading up, or if someone jumps in and kindly volunteers to agree/disagree.
It could be the wording again.
All DataService implementations (client connections) WILL share the same Data but each client connection has it's own LockManager instance but shares the HashSet or whatever it is you store your unique client identifier in.
Just semantics, but the two could be implemented very differently.
SCJP, SCJD, SCWCD<br />"Meekness is not weakness, but power under control"
unreferenced
This thread shows you are OK with having both a daemon thread and using unreferenced to handle dead client locks as long as you have given a good reason (i.e. understand the mechanics behind it).
I hope they'll accept my reasoning that this is a system requirement and not an application requirement. By system I mean the RMI distributed garbage collection sub-system.
SCJP, SCJD, SCWCD<br />"Meekness is not weakness, but power under control"
When the server is started up, if 3 database file names are specified on the command-line then 3 LockManagers will be created to correspond with the 3 Data instances.
but more apples and oranges.what you call tOmato , I call tomAtoe
Thanks for the feel-good support on leaning towards handling of dead client locks being a system requirement. There is now a third option to be considered , do nothing about dead client locks .
This is a new slant on the use of the LockManager class.
If you search for threads on connection on this forum , you'll find lots of discussions supporting the following :
Each client creates it's own Connection object, with a connect(table name) method and it's own LockManager object with a reference to a shared HashMap/WeakHashMap for storing the unique client identifiers.
I suspect it's semantics again, and what you call LockManager , I call HashMap/WeakHashMap i.e the Collection class for storing the identifiers.
Not quite
Assigning responsibilities in the right place?
Starting the server, should just start the server registry. The Client Connection class is responsible for connecting to the data , the LockManager is responsible for acquiring and releasing locks on the data and uses a HashMap/WeakHashMap to achieve this.
Looking at your code snippet , I don't think you should have data.getInstances and LockManager.getInstances in your code.
SCJP, SCJD, SCWCD<br />"Meekness is not weakness, but power under control"
That's right.I think the main difference between your implementation and mine is where and when the Data and LockManager instances are created
I don't see why the client of the application should be concerned with the fact the back-end system was unable to connect to the database when the client has not specified the name of a database to connect to.
I am confused why you are creating Data and LockManager instances in advance. Is it for Connection pooling , which I think I am right in saying is outside the requirements ?
SCJP, SCJD, SCWCD<br />"Meekness is not weakness, but power under control"
That's wrong. How else will the user know why his application failed?
How are you handling the error message, i.e. how does creating data and lock manager instances in advance help in this case ?
SCJP, SCJD, SCWCD<br />"Meekness is not weakness, but power under control"
I guess I could have delayed the creation of the LockManager instances until the later on, but I still think the creation of the Data instances is not entirely wrong.
Ok, not if you see your Data instance as a database being available 24-7.
But if you are connecting to a table/view , you may want to think about lazy initialising your Data instances , also.
Similarly, if you are handling multiple databases , the database schemas, will also be encapsulated in the Connection object as parameters. A standard solution repeated in many database packages.....
SCJP, SCJD, SCWCD<br />"Meekness is not weakness, but power under control"
I see what you mean. Thanks for the clarification and perseverance .
posted January 04, 2003 05:45 AM
--------------------------------------------------------------------------------
quote:
--------------------------------------------------------------------------------
Originally posted by HS Thomas:
I'm still trying to absorb this . So the first option would allow more than one database schema in a single JVM or many JVMs?
--------------------------------------------------------------------------------
Let me rephrase. There are broadly two approaches you can take with your ConnectionFactory (or whatever you call it)
Each ConnectionFactory corresponds to exactly one Data instance, hence one table. You gain access to a table by looking it up in the RMI registry and getting a connection to it.
The ConnectionFactory.connect() method takes a table name. Each ConnectionFactory encapsulates an arbitrary number of Data instances; the factory can be said to correspond to a database schema. You would gain access to a table by looking up the schema in the RMI registry, and requesting a connection to one of the tables in the schema. The schemas in the RMI registry can live in one or more JVMs.
Both alternatives satisfies the assignment requirements; you should do whatever is easiest and/or comes most naturally to your design.
In either case, you shouldn't go out of your way to limit the number of ConnectionFactory instances by enforcing a singleton pattern unless it significantly simplifies your design (which I don't think it will).
- Peter
--------------------
As far as I understand it, the user specifies the name and location of the datafile in 'local' mode and specifies only the hostname/ip and port number in 'remote' mode.
SCJP, SCJD, SCWCD<br />"Meekness is not weakness, but power under control"
The ConnectionFactory.connect() method takes a table name.
I’m tired of walking, and will rest for a minute and grow some wheels. This is the promise of this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|