There isn't anything provided by the Geode project but it is fairly easy to
implement. Having experimented with it internally some time ago it really
came down to utilizing the check and set map operations.
Consider AtomicInteger.comparAndSet():
public boolean compareAndSet(final Integer expect, final Integer update) {
return region.replace(name, expect, update);
}
Then all other operations are something like this:
public final Integer getAndIncrement() {
for (;;) {
final Integer current = get();
if (compareAndSet(current, increment(current)))
return current;
}
}
Keep in mind that with any compare and set type operation the more
contention for the same resource the more often it will fail meaning that
atomic inc/dec operations may loop frequently. Many round trips back to the
server could make this very expensive.
An alternative would be to pair client side AtomicInteger with a function
on the server such that the inc/dec/set operations are sent to the server
to be resolved and the final result sent back to the client. I have not
experimented with this solution myself.
-Jake
On Sun, Jul 16, 2017 at 8:16 AM Amit Pandey <[email protected]>
wrote:
> Hi Guys,
>
> We had a hazelcast app we want to port to geode. There are some usages of
> AtomicLOng of hazelcast which we need to port, is there a best
> practice/alternative to achieve the same in Apache Geode?
>
> regards
>