[hibernate-dev] Voldemort maven module for Hibernate OGM
emmanuel at hibernate.org
Tue Feb 28 14:47:47 EST 2012
On 28 févr. 2012, at 19:41, Seiya Kawashima wrote:
> Thank you for your response.
> Unfortunately I'm not quite sure the reason that the Voldemort project doesn't push it to the maven repository. There are questions and discussions about the usage of the repository on the Internet, but it seems to me that there is no clear answer for the reason. Or I just have not noticed the existence.
> I have several questions about hibernate ogm core. These parts are that particularly I would like you to take a look at. The implementations might be awkward or incorrect.
> To implement datastore providers for hibernate ogm, there are two code styles. One is from MapBasedDatastoreProvider and the other is from Infinispan and EhCache datastore providers. When we add other datastore providers, which style should we follow ? I've been referencing MapBasedDatastoreProvider from the beginning of my experiment on Hibernate OGM, the implementation followed MapBasedDatastoreProvider.
By style you mean architectural approach or code style (tab vs space)? If the former, then the MapBasedDatastoreProvider is a toy useful for us to abstract Hibernate OGM engine from a specific provider. You should use Infinispan as your example. But remember that Infinispan is full transactional and which makes the dialect somewhat easier to implement.
> To implement VoldemortDatastoreProvider.setNextValue() method, I was confused a little bit. I originally referenced other datastore
> and implemented it, but on VoldemortDialectTest.testIsThreadSafe() which tests concurrency on the method, my original implementation ran poorly because it required an exclusive lock and datastore access every time the method is called. And then I modified the method and got the current implementation in VoldemortDatastoreProvider. However, it doesn't quite reduce the number of accesses to the underlying datastore as I wanted, but allows concurrency. As a result, I put a flag to store the next value on the datastore or not. I'm not quite sure if this is the right implementation or not.
Some NoSQL stores have very efficient next value operations and this method is for them. You should try and make as efficient as possible but make sure it's safe. Your flag does not look like safe but I have not had time to investigate yet.
And don't worry too much about performance. Properly set, Hibernate OGM will only call this method every 50 or so id generation required as we use a hi/lo algorithm by default to generate sequential ids.
> To implement GridDialect.getLockingStrategy() method, the returned object whose type is LockingStratey represents locks on underlying datatore according to the javadoc. How should we implement this method when the underlying datastore doesn't explicitly expose locks as objects ? Looks like that Infinispan exposes some lock objects, so they are instantiated and returned from the method. Voldemort has the concept of optimistic lock exposing a method called voldemort.client.StoreClient.applyUpdate and Redis also has the concept exposing a method called watch and the description . I use Jedis 2.0.0 as Redis client.
Now that's clearly the hardest part to map and we will have to chat on IRC about that. Hibernate has the notion of optimistic locking with this definition: if somebody applies a change before a change I am applying, then I lose. To do that it uses version number comparison and update where style operations.
Now applyUpdate seems to be slightly different in the sense that they try and reapply a set of operations until they are not stale. That looks closer to a transaction than the Hibernate optimistic locking. But I need to have a chat with you to understand how people use it.
Watch seems more akeen to pessimistic locking which you have to implement as well in LockingStrategy. But again, we will need to have a discussion about how people use that. Pessimistic locking in Hibernate means that I am guaranteed that noone will be able to do anything on my entry until I release the lock (usually by committing the transaction.
Form this discussion it also seems that we might need to have datastores and dialect implement the Hibernate transaction object so that the datastore can properly demarcate when isolation starts and when it ends. But that's clearly not abstracted yet in Hibernate OGM.
More information about the hibernate-dev