Hi Roland,

2013/3/8 Roland von Herget <[email protected]>:
> Hi again,
>
> On Fri, Mar 8, 2013 at 10:10 AM, Roland von Herget
> <[email protected]> wrote:
>>> The real fix is:
>>>
>>> * Modify HectorUtils.java:
>>> - change all "public static<K> void insertSubColumn..." to "public
>>> syncronized static<K>..." (3 changes)
>>> - change "public static<K> void deleteSubColumn" to " public
>>> syncronized static<K> void deleteSubColumn" (1 change)
>>>
>>> And then you are just synchronizing the calls to the mutator.
>>
>> Yes, now I think this, too.
>
> 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));
  }

}

etc :)

Is this right?

Regards,

Alfonso Nishikawa

-- 
"Drinking bloody marys all night will make you feel like a corpse in
the morning."

Reply via email to