-
1. Re: Atomic Numbers
alexgad Feb 1, 2013 11:12 AM (in response to paradigmza)Were you able to find a solution to the above? I an currently investigating Infinispan for a project and distributed atomic increment/decrement is an important requirement. Thanks.
-
2. Re: Atomic Numbers
an1310 Feb 4, 2013 1:11 PM (in response to paradigmza)Hi Sean,
While ISPN doesn't offer this as part of the API, I've implemented something similar in my application. It's actually pretty easy and very performant if you use the distributed executor framework. Here are some rough guidelines:
- You assuredly will either need a lock/increment/release pattern to get counter values. However, if you execute a task on the data owner, you're acquiring local locks.
- You will need to look at the cache configuration options for eager locks.
- You may want to consider allocating "chunks" of possible counter values for your clients to use locally. This will reduce contention on the cache, while guaranteeing uniqueness.
- (Don't forget about overflow conditions)
Erik
-
3. Re: Atomic Numbers
paolodt Feb 13, 2013 4:08 PM (in response to alexgad)It's pretty easy to implement using an distributed map.
Keep the last value in a map. When you need the next value, get the last value from the map, increment it, and save the new value using the ConcurrentMap#replace method.
If replace fails, continue to incremente the next value . .
Cheers,
Paolo
-
4. Re: Atomic Numbers
mircea.markus Feb 25, 2013 11:54 AM (in response to paolodt)Both suggeestions should work.
We do plan to add native support for atomic operations in future, please see/vore for https://issues.jboss.org/browse/ISPN-924.