Re: Accessing internal variables in DataNode and synchronization.

2009-09-11 Thread Erik Holstad
Hi Mahadev!

Sounds good that you want getters and setters, it makes most things easier
to reason about,
even though it might add a couple of extra lines of code.

The reason that I'm bringing up the synchronization is that some of the
methods in the DataNode
are synchronized, which I like if it means that you can get more concurrency
on the Object. But now
it feels like there is a mix of both approaches which is bit confusing to
me.

I think that more and more people are going to start pushing ZooKeeper
towards it's limits and then
it might be reasonable to change the current synchronization schema from the
node to the individual
variables and maybe even get fancy and use Volatile in some places.

Erik


Re: Accessing internal variables in DataNode and synchronization.

2009-09-11 Thread Mahadev Konar
Hi Erik,
  There is no such reason for accessing variable without acess and getters.
We should not be doing that. Its good to have getters and setters.

The synchronization on DataNode is a safe lock that would prevent developers
being concerned about finer locks and maintaining them. In our performance
experiments we havent ever seen any problems with these. So, we did not want
to make it more complex with finer granularity locks,

Thanks
mahadev

On 9/11/09 2:14 PM, "Erik Holstad"  wrote:

> In most places in the server side code, internal variables are accessed
> directly via something like, node.parent... instead of making the variable
> private and using getters and setters, what is the purpose of this?
> 
> Another question is why the synchronization on for example the DataNode is
> done on the node itself and not on the variables access, it seems reasonable
> to me that 2 different threads would be allowed to modify for example the
> data and the children at the same time, or is there something that I'm
> missing here, watchers?
> 
> Erik