gora-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Roland von Herget <roland.von.her...@gmail.com>
Subject Re: Gora–174 notes
Date Fri, 08 Mar 2013 11:47:34 GMT
Hi Alfonso,

On Fri, Mar 8, 2013 at 12:38 PM, Alfonso Nishikawa
<alfonso.nishikawa@gmail.com> wrote:
>> I'm reverting this... after reading java docs and googling around:
>> I think that will be wrong, because it locks the whole class (it will
>> take a lock on java.lang.Class's object). But we have to lock the
>> mutator. So if someone's using more than one CassandraClient instance
>> (or we add another mutator to CassandraClient in the future), there
>> will be unnecessary locks.
>> I think: whoever creates the mutator (which is CassandraClient here)
>> must lock it.
>>
>> --Roland
>
> Ouch! True! :P I didn't read "static" xD
> If I am not wrong, it is taking the lock on HectorUtils.class.
>
> Just use this (this surely-hopefuly will work :):
>
>   public static<K> void insertSubColumn(Mutator<K> mutator, K key,
> String columnFamily, String superColumnName, ByteBuffer columnName,
> ByteBuffer columnValue) {
>
>   synchronized(mutator){
>     mutator.insert(key, columnFamily,
> createSuperColumn(superColumnName, columnName, columnValue));
>   }
>
> }

Why not just do exactly this, but inside CassandraClient (as in my
patch in GORA-211) ?
That's the point the mutator is coming from. And everybody who touches
this in the future will recognize it needs sync.

> Is this right?
You really ask me? ;)

--Roland

Mime
View raw message