[ 
https://issues.apache.org/jira/browse/IGNITE-28727?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18092319#comment-18092319
 ] 

Kirill Tkalenko commented on IGNITE-28727:
------------------------------------------

Looks good.

> Create internal API method to lock cache entry with specific version
> --------------------------------------------------------------------
>
>                 Key: IGNITE-28727
>                 URL: https://issues.apache.org/jira/browse/IGNITE-28727
>             Project: Ignite
>          Issue Type: Improvement
>            Reporter: Vladislav Pyatkov
>            Assignee: Vladislav Pyatkov
>            Priority: Major
>              Labels: ignite-2
>          Time Spent: 5.5h
>  Remaining Estimate: 0h
>
> h3. Motivation
> In some cases we want to have a guarantee that no other operation splits 
> between a read and an update. This case is rather more interesting for SQL 
> than the cache API, where the key is always known.
> Proposed API:
> {code:java|title=IgniteInternalCache.java}
> /**
>  * Acquires transactional lock for a cached object represented by the given 
> entry only if a current entry version
>  * is equal to the entry version. This method works only in {@link 
> TransactionConcurrency#PESSIMISTIC} transaction.
>  *
>  * @param entry Entry whose key, value and version should be used.
>  * @param waitTimeout Timeout in milliseconds to wait for lock to be acquired
>  *      ({@code '0'} for no expiration), {@code -1} for immediate failure if
>  *      lock cannot be acquired immediately).
>  * @return {@code True} if lock was acquired with the same entry version.
>  * @throws IgniteCheckedException If lock acquisition resulted in an error.
>  */
> public boolean lockTxEntry(CacheEntry<K, V> entry, long waitTimeout) throws 
> IgniteCheckedException;
> /**
>  * Acquires transactional locks for cached objects represented by the given 
> entries only if current entry versions
>  * are equal to entry versions. This method works only in {@link 
> TransactionConcurrency#PESSIMISTIC} transaction.
>  *
>  * @param entries Entries whose keys, values and versions should be used.
>  * @param waitTimeout Timeout in milliseconds to wait for locks to be acquired
>  *      ({@code '0'} for no expiration), {@code -1} for immediate failure if
>  *      locks cannot be acquired immediately).
>  * @return {@code True} if all locks were acquired with the same entry 
> versions.
>  * @throws IgniteCheckedException If lock acquisition resulted in an error.
>  */
> public boolean lockTxEntries(Collection<CacheEntry<K, V>> entries, long 
> waitTimeout) throws IgniteCheckedException;
> /**
>  * Asynchronously transactional lock for a cached object represented by the 
> given entry only if a current entry
>  * version is equal to the entry version. This method works only in
>  * {@link TransactionConcurrency#PESSIMISTIC} transaction.
>  *
>  * @param entry Entry whose key, value and version should be used.
>  * @param waitTimeout Timeout in milliseconds to wait for lock to be acquired
>  *      ({@code '0'} for no expiration), {@code -1} for immediate failure if
>  *      lock cannot be acquired immediately).
>  * @return {@code True} if lock was acquired with the same entry version.
>  * @throws IgniteCheckedException If lock acquisition resulted in an error.
>  */
> public IgniteInternalFuture<Boolean> lockTxEntryAsync(CacheEntry<K, V> entry, 
> long waitTimeout);
> /**
>  * Asynchronously acquires transactional locks for cached objects represented 
> by the given entries only if current
>  * entry versions are equal to entry versions. This method works only in
>  * {@link TransactionConcurrency#PESSIMISTIC} transaction.
>  *
>  * @param entries Entries whose keys, values and versions should be used.
>  * @param waitTimeout Timeout in milliseconds to wait for locks to be acquired
>  *      ({@code '0'} for no expiration), {@code -1} for immediate failure if
>  *      locks cannot be acquired immediately).
>  * @return {@code True} if all locks were acquired with the same entry 
> versions.
>  * @throws IgniteCheckedException If lock acquisition resulted in an error.
>  */
> public IgniteInternalFuture<Boolean> 
> lockTxEntriesAsync(Collection<CacheEntry<K, V>> entries, long 
> waitTimeout);{code}
> h3. Definition of done
> The method is added
> All guarantees are satisfied and confirmed by a bunch of tests.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to