api - Apache Ignite Locks for synchronizing arbitrary computation across the grid -
i have simple question can't find definitive answer in apache ignite docs.
i see there api in apache ignite create explicit lock. understand these locks used writing cache entries , done implicitly.
however, can (should i) able explicitly create lock in grid synchronizing computation arbitrary code. here's i'm thinking of doing:
- request comes api.
- i try enter lock on ignite cache
- if can enter lock calculation (which should done on 1 of api instances @ given time)
- if can't enter lock, return 409 error code (duplicate request)
- i exit lock
are there potential caveats doing this? should watch out potential pitfalls?
yes, can use cache locks entering critical section in distributed manner. here can find how: https://apacheignite.readme.io/docs/distributed-locks
here can find more documentation on ignite locks: https://www.gridgain.com/sdk/pe/latest/javadoc/org/apache/ignite/ignitelock.html
ignite cache locks implement mutual exclusion, can rely on no 2 threads or processes holding 1 lock @ same time. should make sure nodes use replicas of same cache acquire locks (cache not local, etc) , cache transactional.
usually locks used perform complex operations on cache atomically. if want use locking without changing cache, may symptom of don't need lock, or should use synchronization mechanism of resource trying utilize inside of critical section. depends on computations trying perform.
Comments
Post a Comment