This section from the RMI spec: A method dispatched by the RMI runtime to a remote object implementation may or may not execute in a separate thread. The RMI runtime makes no guarantees with respect to mapping remote object invocations to threads. [...] Although not everyone seems to agree on the interpretation of these two sentences, for me the core consists of the words "no guarantees". Make no assumptions whatsoever about which thread executes what when.Originally posted by Boris Milojkovic:
[...] If this is true, what prevent us from using threadID as clentID?
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
Originally posted by Boris Milojkovic:
Hi all, (my first post)
Eny client has its own thread of exec. When rmi call happens, that thread is
mapped to rmi thread (on "server side"). If that thread is blocked, it can not
be reused (by rmi rt)??? If this is true, what prevent us from using threadID as clentID?
There is no guarantee that, even as Peter is speaking to Juliet, that Mark will not call her and ask her to do something that would upset Peter. If Peter and Mark want to ask Juliet to not accept calls from a second person when she's already talking to someone, then they need to make those arrangements beforehand.
I'm probably a bit thick, Max, but can you point out explicitly where the material you linked to supports thisOriginally posted by Max Habibi:
Peter, I think there's a little confusion about the way the distributed garbage collector works: Internally, it relies on the local garbage collector.
It should be clear from the above that this is just plain wrong. Unreferenced does not involve the server-side garbage collector at all. Using a WeakHashMap rather than the Unreferenced callback completely unnecessarily adds the server-side garbage collector into the mix.The 'simplicity' that you're talking about is illusionary: You're simply going the long way around the block, for the sake of going the long way around the block.
This is an interesting contention, and I would like to see supported, which it is not below. Again, I think there is some confusion in the premise, and the content on your argument.
It is not a non-sequitur,1. To be brief, your first contention is that a mapping of locks to clients should be modeled as a map: While this is true, it is a non-sequalar, since you have not (yet) established that this is the appropriate path to take.
Have you read the argument you're trying to refute? No such assumption was made. In fact it stated in as many words that "Removing a lock can be done by client and is O(1)." It's the locking that kills you. Significantly, you don't say a word about that.2. Your second argument, that locking based on record id produces faster searches, is also flawed. First, you're assuming that the unlock mechanism would first check the locked status of the record, when in reality it would actually check the locked status of the
client.
An obvious fact. Its relevance escapes me for the moment, unfortunately. I don't care in the least what exactly you're searching for; searching the value collection of a Map is an O(n) operation.Second, you're forgetting that structure would be searched not by record index, but by the Integer that represents that record. And searching for an Object that happens to be an Integer is no faster then searching for an Object that happens to be String.
And as much is stated at the end of my reply. Nice thing is, inverting the map doesn't actually make the code anyHowever, even if you were correct, this is also a non starter, since performance is not a motivation for the design of this project. [...]
No, this is not strictly required, as stated with as many words at the end of my argument. That doesn't render it insignificant.3. Your third perspective [is] not a part of the requirements, nor is it implied by information supplied by their usage [...] this is also a non starter.
This piece of rhetoric is not what I'd expect of you, Max. By all means, discount aesthetics and elegance as purely subjective. That leaves the core of the argument in my fourth perspective, which was all about clarity, robustness and expressiveness. All of these are objective and measurable (even if measuring them isn't necessarily easy), and deliver real business benefits (or the lack thereof).4. Your final perspective is that you like your own design better. [...]
Where to start?However, let's consider the balance of the objective evidence.
A. Using the Distributed garbage collector is not more 'simple', or 'elegant' then simply using the garbage collector.
This is true, and at no point did I dispute this. That does not make such a restriction desirable. Please see the last bit of my previous response. It also fails to address the other three perspectives on the lock map issue.B. There is no requirement that clients be allowed to lock a more then a single record at a time.
Beside the point and not true.It seems to me that your design has a lot of everything (call backs, unnecessary requirement implementation, DGC, etc.,), that can be removed.
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
Originally posted by Peter den Haan:
I'd like to add to this that you may choose to implement the java.rmi.server.Unreferenced interface as an alternative way to achieve the same thing, with the added advantage that you wouldn't have to wait for the server-side garbage collector to kick in. Opinions differ on which way is simpler.
The main reason I followed up on this is that the suggested Map would be the wrong way around.
elegant simplicity comes when you have removed everything that you can.
I'm probably a bit thick, Max, but can you point out explicitly where the material you linked to supports this statement? With "local garbage collector", I'll assume you mean the server-side one, as that's what I was explicitly referring to above.Originally posted by Max Habibi:
Peter, I think there's a little confusion about the way the distributed garbage collector works: Internally, it relies on the local garbage collector.
It should be clear from the above that this is just plain wrong. Unreferenced does not involve the server-side garbage collector at all. Using a WeakHashMap rather than the Unreferenced callback completely unnecessarily adds the server-side garbage collector into the mix.The 'simplicity' that you're talking about is illusionary: You're simply going the long way around the block, for the sake of going the long way around the block.
This is an interesting contention, and I would like to see supported, which it is not below. Again, I think there is some confusion in the premise, and the content on your argument.
It is not a non-sequitur, as I did not set out to prove that a Map is the best implementation. No such proof exists for any nontrivial programming problem, as you well know. I set out to prove that a Map from records to clients is superior than a Map the other way around, and this is exactly what my conclusion states. This does follow from the argument. If you think it doesn't, show why. Don't just assert.1. To be brief, your first contention is that a mapping of locks to clients should be modeled as a map: While this is true, it is a non-sequalar, since you have not (yet) established that this is the appropriate path to take.
Have you read the argument you're trying to refute? No such assumption was made. In fact it stated in as many words that "Removing a lock can be done by client and is O(1)." It's the locking that kills you. Significantly, you don't say a word about that.2. Your second argument, that locking based on record id produces faster searches, is also flawed. First, you're assuming that the unlock mechanism would first check the locked status of the record, when in reality it would actually check the locked status of the client.
An obvious fact. Its relevance escapes me for the moment, unfortunately. I don't care in the least what exactly you're searching for; searching the value collection of a Map is an O(n) operation.Second, you're forgetting that structure would be searched not by record index, but by the Integer that represents that record. And searching for an Object that happens to be an Integer is no faster then searching for an Object that happens to be String.
And as much is stated at the end of my reply. Nice thing is, inverting the map doesn't actually make the code any more complex. That makes the issue really simple, doesn't it?However, even if you were correct, this is also a non starter, since performance is not a motivation for the design of this project. [...]
No, this is not strictly required, as stated with as many words at the end of my argument. That doesn't render it insignificant.3. Your third perspective [is] not a part of the requirements, nor is it implied by information supplied by their usage [...] this is also a non starter.
This piece of rhetoric is not what I'd expect of you, Max. By all means, discount aesthetics and elegance as purely subjective. That leaves the core of the argument in my fourth perspective, which was all about clarity, robustness and expressiveness. All of these are objective and measurable (even if measuring them isn't necessarily easy), and deliver real business benefits (or the lack thereof).4. Your final perspective is that you like your own design better. [...]
Where to start?However, let's consider the balance of the objective evidence.
A. Using the Distributed garbage collector is not more 'simple', or 'elegant' then simply using the garbage collector.
This is true, and at no point did I dispute this. That does not make such a restriction desirable. Please see the last bit of my previous response. It also fails to address the other three perspectives on the lock map issue.B. There is no requirement that clients be allowed to lock a more then a single record at a time.
Beside the point and not true.It seems to me that your design has a lot of everything (call backs, unnecessary requirement implementation, DGC, etc.,), that can be removed.
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
As always, thanks for the discussion, Max. We really disagree here, and unfortunately it seems you didn't address any of the points I raised. Maybe I didn't express myself quite clearly enough, in which case, accept my apologies and I hope the above will act as a clarification. I am looking forward to seeing a solid, rational argument establishing why I'm wrong.
True; however, as the ability to acquire multiple locks would improve reusability of your server classes I would at least classify this ability as a "nice-to-have".Originally posted by Max Habibi:
Assumption 3: Clients are not required to be able to lock more then a single record at a time.
Agreed, provided that the keys in the WeakHashMap are the Connection objects. We still have this other unresolved question whether using the Thread to give the client identity is a good idea or not. It is probably best to keep the discussion clean and ignore this issue.Assumption 4: Both the WeakHashMap approach, and the Unreferenced approach, will work, as far as the goal of cleaning up 'lost' locks is concerned.
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
Peter wrote:
We still have this other unresolved question whether using the Thread to give the client identity is a good idea or not.
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
True; however, as the ability to acquire multiple locks would improve reusability of your server classes I would at least classify this ability as a "nice-to-have".
Agreed, provided that the keys in the WeakHashMap are the Connection objects. We still have this other unresolved question whether using the Thread to give the client identity is a good idea or not. It is probably best to keep the discussion clean and ignore this issue.
Well, to be honest, no. Data is a completely generic, perfectly business-agnostic class. The requirements strongly steer us in the direction of building an equally business-agnostic generic database server. Business-driven restrictions on the number of locks, in contrast, are purely application-specific and should therefore be no consideration in our server design (complexity might be though).Originally posted by Max Habibi:
I don't agree that [multiple locks are] "nice to have", because we don't really know enough about the business: Maybe it hurts business to have agents lock more then a single client at a time: we, as developers, just don't know. [...] There are, I think, reasonable arguments of both sides, but neither side overwhelmingly convincing. Do you agree?
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
Originally posted by Peter den Haan:
Well, to be honest, no. Data is a completely generic, perfectly business-agnostic class.
The requirements strongly steer us in the direction of building an equally business-agnostic generic database server.
Business-driven restrictions on the number of locks of the kind that you are discussing here, on the other hand, are purely application-specific.
By restricting clients to one lock only we certainly are restricting applications and thereby the reusability of the class.
Enabling multiple locks per client does not restricting application-level functionality in any way;
any constraints can be enforced by the application where it belongs. I find it very hard to see how one could argue with the "nice-to-have-ness" of this feature.
Quite apart from the fact that the supplied javadoc, which is the most precise specification for this feature that we have, does not even hint at any restrictions in the number of locks held.
Even so, I would be happy to let the matter rest if it weren't for the fact that it is a symptom of the underlying, much more serious problem that the inversion of the Map makes turns an excellent and faithful representation of the problem domain into a very poor one.
That is the underlying cause which gives rise to this restriction; you're trying to shoehorn a square problem
I did, and it had a much stronger emphasis on re-use than the current one (to the point of explicitly stating that the database stuff was going to be re-used in the future), which might colour my thinking. But regardless of that: (1) Data is fully generic. (2) The Data API is the API of a fully generic database. (3) You are strongly steered towards exposing your database server using the Data API.Originally posted by Max Habibi:
I'm surprised that you would think that [the requirements strongly steer us in the direction of building an equally business-agnostic generic database server]: maybe you had a different version of the test then the most recent version.
This is rather a distortion of the point I'm trying to make.There are no 'applications': only a single application. Writing code for non existing applications increases complexity, which is the exact opposite of the directive the students are given here. [...] You're not a consultant who's creating a shrink wrapped product that you can then turn around and sell to another client.
Very funny, or silly, depending on how you look at it. To my memory, the assignment supplies no javadoc for either pink elephants or interfaces for the deaf. There is, however, a javadoc specification for the lock() and unlock() functions, and it provides essential instructions for the assignment (e.g. the whole client ID issue). If you do not think that this same javadoc should clearly document restrictions on the number of locks that can be held, I will never want to use or maintain your software!The javadoc does not even hint at pink elephants dancing around the border, or an interface for the deaf. However, a good developer will choose to exclude those also, because they do not serve a business function, per the specifications
They have never been answered; you have followed up on them, which is something entirely different. Core problem domain constraints like "you can give a record lock only to one client at a time", "the locked records form a Set", "there is no a priori reason why a client cannot hold more than one lock" are fully expressed with the map in one direction and not at all with the map in the other direction. Fact. This mismatch between problem and solution expresses itself in a number of ways, ranging from restrictions via code readability to performance. See earlier threads for all the gory details.Saying that the inverted map is an 'excellent' and 'faithful' representation of the problem does not make it so, as I'm sure that someone with your skill in discussion is aware. You have presented arguments about why you feel that it is an excellent reason: they have been answered.
You haven't proven item 2) either -- and won't ever be able to, since it doesn't require more work. It's a pity that we aren't able to post code here because it would help make things pretty obvious. Regarding 1), well, no good developer needs encouragement when it becomes clear that an implementation can be made more generic with no extra effort. Often, the more generic version turns out to be simpler to understand and maintain as well, simply because the code is a better fit for the problem.[...] this generic nature is 1) unspecified in the requirements, and 2) requires more work, and 3) complicates locking (which assertion I have not proven yet)
I was looking for an analogy to describe the mismatch between problem and solution if you do the map the wrong way around; I'm not conscious of ascribing specific motivations to you. However, if this offended, then please accept my apologies."That is the underlying cause which gives rise to this restriction; you're trying to shoehorn a square problem"
Peter, I expect better from you. I specfically restarted this thread, because I wanted us to focus on the merits of the arguments, and not on the suspected motivations of the fellow we're discussing this topic with. As the moderator of this forum, I'm making this a ground rule. Thus, no more 'you are trying to', etc.
I'm not trying to argue that "locking multiple locks per clients is the only reasonable choice" in isolation. As I said, it is merely one symptom of a deeper issue: how do I model my problem using a Map? I have demonstrated why, quite extensively, as I remember. For example, I even dragged set theory into it to show that the problem fits the map in one way only. There has been nothing to refute it.Demonstrate, and argue on the merits. If you can prove that locking multiple locks per clients is the only reasonable choice, then please do so.
Peter den Haan | peterdenhaan.com | quantum computing specialist, Objectivity Ltd
I did, and it had a much stronger emphasis on re-use than the current one (to the point of explicitly stating that the database stuff was going to be re-used in the future), which might colour my thinking.
But regardless of that: (1) Data is fully generic.
(2) The Data API is the API of a fully generic database.
(3) You are strongly steered towards exposing your database server using the Data API.
Now if the stuff you're writing is just for the FBN client, the design you're being forced into makes no good sense whatsoever.
That, together with the evident genericity and reusability of the Data class itself, seems highly significant.
quote:
--------------------------------------------------------------------------------
There are no 'applications': only a single application. Writing code for non existing applications increases complexity, which is the exact opposite of the directive the students are given here. [...] You're not a consultant who's creating a shrink wrapped product that you can then turn around and sell to another client.
--------------------------------------------------------------------------------
This is rather a distortion of the point I'm trying to make.
I'm still totally stumped how you can possibly argue that better reusability is not a nice-to-have. It is always a nice to have; even when you decide that the extra effort isn't worth it, that it's not quite nice enough to justify the price, that doesn't make it any less of a nice-to-have.
Specifically, if introducing an (in this context) unimportant restriction greatly simplifies matters, go for it ...In this case, it has none of these. To the contrary.
quote:
--------------------------------------------------------------------------------
The javadoc does not even hint at pink elephants dancing around the border, or an interface for the deaf. However, a good developer will choose to exclude those also, because they do not serve a business function, per the specifications
--------------------------------------------------------------------------------
Very funny, or silly,depending on how you look at it.
To my memory, the assignment supplies no javadoc for either pink elephants or interfaces for the deaf. There is, however, a javadoc specification for the lock() and unlock() functions, and it provides essential instructions for the assignment (e.g. the whole client ID issue). If you do not think that this same javadoc should clearly document restrictions on the number of locks that can be held, I will never want to use or maintain your software!
If, on the other hand, you think that modifying the supplied contract in the interest of simplicity is OK,
Your position is just not consistent, Max, and in the light of that,
turning what I'm saying into idiocy with elephants isn't the most convincing of responses.
Please give a clear answer: is it OK to modify the supplied contract (as described by the javadoc) if the modifications work for FBN and it makes things lots simpler, or isn't it? If it is, then why not remove the whole client-ID business? If it isn't, then what's this number-of-locks-restriction business about?
quote:
--------------------------------------------------------------------------------
Saying that the inverted map is an 'excellent' and 'faithful' representation of the problem does not make it so, as I'm sure that someone with your skill in discussion is aware. You have presented arguments about why you feel that it is an excellent reason: they have been answered.
--------------------------------------------------------------------------------
They have never been answered;
...Core problem domain constraints like "you can give a record lock only to one client at a time", "the locked records form a Set", "there is no a priori reason why a client cannot hold more than one lock" are fully expressed with the map in one direction and not at all with the map in the other direction. Fact.
--------------------------------------------------------------------------------
[...] this generic nature is 1) unspecified in the requirements, and 2) requires more work, and 3) complicates locking (which assertion I have not proven yet)
--------------------------------------------------------------------------------
You haven't proven item 2) either -- and won't ever be able to, since it doesn't require more work.
It's a pity that we aren't able to post code here because it would help make things pretty obvious.
Regarding 1), well, no good developer needs encouragement when it becomes clear that an implementation can be made more generic with no extra effort.
--------------------------------------------------------------------------------
"That is the underlying cause which gives rise to this restriction; you're trying to shoehorn a square problem"
Peter, I expect better from you. I specfically restarted this thread, because I wanted us to focus on the merits of the arguments, and not on the suspected motivations of the fellow we're discussing this topic with. As the moderator of this forum, I'm making this a ground rule. Thus, no more 'you are trying to', etc.
--------------------------------------------------------------------------------
I was looking for an analogy to describe the mismatch between problem and solution if you do the map the wrong way around;
I'm not conscious of ascribing specific motivations to you. However, if this offended, then please accept my apologies.
I'm not trying to argue that "locking multiple locks per clients is the only reasonable choice" in isolation. As I said, it is merely one symptom of a deeper issue: how do I model my problem using a Map? I have demonstrated why, quite extensively, as I remember. For example, I even dragged set theory into it to show that the problem fits the map in one way only. There has been nothing to refute it.
- Peter
I'm sure glad that he's gone. Now I can read this tiny ad in peace!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
|