Can I lock non-existing key?
I need to create only 1 (singleton) object in distributed space and share this instance between apps. And for ex. I have 2 applications which are trying to get/put this object. The expected behavior is:
start transaction
map.lock(MyObjectType.class);
if(map.get(MyObjectType.class) == null) {
map.putAndUnlock(MyObjectType.class, new MyObjectType())
} else {
// init MyObjectType instance with getted value from map
}
commit transaction
But this code doesn't work. I found out this code in TransactionManager class:
// TODO GS-9310: design and implement a solution for locking non-existent keys.
map.put(key, EMPTY_LOCK_VALUE, tr, Integer.MAX_VALUE);
So, question is can I implement my behavior using GS 10.1.1-12280 version?
↧