# IGNITE-59 Support lock, lockAll. Fix javadoc problems.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/afe86664 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/afe86664 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/afe86664 Branch: refs/heads/ignite-59 Commit: afe86664c948cf90bcf16246beefdc42a5478792 Parents: 2c76212 Author: sevdokimov <sevdoki...@gridgain.com> Authored: Mon Jan 19 17:35:01 2015 +0300 Committer: sevdokimov <sevdoki...@gridgain.com> Committed: Mon Jan 19 17:35:01 2015 +0300 ---------------------------------------------------------------------- .../src/main/java/org/apache/ignite/CacheLock.java | 15 +++++++-------- .../main/java/org/apache/ignite/IgniteCache.java | 16 ++++++++++++++++ 2 files changed, 23 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/afe86664/modules/core/src/main/java/org/apache/ignite/CacheLock.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/CacheLock.java b/modules/core/src/main/java/org/apache/ignite/CacheLock.java index 50fc5d2..9be14e0 100644 --- a/modules/core/src/main/java/org/apache/ignite/CacheLock.java +++ b/modules/core/src/main/java/org/apache/ignite/CacheLock.java @@ -29,7 +29,7 @@ import java.util.concurrent.locks.*; */ public interface CacheLock extends Lock { /** - * Checks if any node owns a lock for the keys associated this lock. + * Checks if any node holds lock on at least one key associated with this {@code CacheLock}. * <p> * This is a local in-VM operation and does not involve any network trips * or access to persistent storage in any way. @@ -40,7 +40,7 @@ public interface CacheLock extends Lock { public boolean isLocked(); /** - * Checks if current thread owns a lock the keys associated this lock. + * Checks if current thread holds lock on at least one key associated with this {@code CacheLock}. * <p> * This is a local in-VM operation and does not involve any network trips * or access to persistent storage in any way. @@ -51,7 +51,7 @@ public interface CacheLock extends Lock { public boolean isLockedByThread(); /** - * Asynchronously acquires lock on a cached object with given keys associated this lock. + * Asynchronously acquires lock on a cached object with keys associated with this {@code CacheLock}. * <h2 class="header">Transactions</h2> * Locks are not transactional and should not be used from within transactions. If you do * need explicit locking within transaction, then you should use @@ -66,7 +66,7 @@ public interface CacheLock extends Lock { public IgniteFuture<Boolean> lockAsync(); /** - * Asynchronously acquires lock on a cached object with given keys associated this lock. + * Asynchronously acquires lock on a cached object with given keys associated with this {@code CacheLock}. * <h2 class="header">Transactions</h2> * Locks are not transactional and should not be used from within transactions. If you do * need explicit locking within transaction, then you should use @@ -76,10 +76,9 @@ public interface CacheLock extends Lock { * This method is not available if any of the following flags are set on projection: * {@link GridCacheFlag#LOCAL}, {@link GridCacheFlag#READ}. * - * @param timeout 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). - * @param unit the time unit of the {@code timeout} argument. + * @param timeout The maximum time to wait for the lock. If the time is less than or equal to zero, the method will + * not wait at all. + * @param unit The time unit of the {@code timeout} argument. * @return Future for the lock operation. The future will return {@code true} whenever locks are acquired before * timeout is expired, {@code false} otherwise. */ http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/afe86664/modules/core/src/main/java/org/apache/ignite/IgniteCache.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java index d900c12..884e665 100644 --- a/modules/core/src/main/java/org/apache/ignite/IgniteCache.java +++ b/modules/core/src/main/java/org/apache/ignite/IgniteCache.java @@ -180,8 +180,24 @@ public interface IgniteCache<K, V> extends javax.cache.Cache<K, V>, IgniteAsyncS */ public void removeAll(IgnitePredicate<Entry<K, V>> filter) throws CacheException; + /** + * Return a {@link CacheLock} instance associated with passed key. + * This method does not acquire lock immediately, you have to call something like {@link CacheLock#lock()} on + * returned instance. + * + * @param key Key for lock. + * @return New lock instance associated with passed key. + */ public CacheLock lock(K key); + /** + * Return a {@link CacheLock} instance associated with passed keys. + * This method does not acquire lock immediately, you have to call something like {@link CacheLock#lock()} on + * returned instance. + * + * @param keys Keys for lock. + * @return New lock instance associated with passed key. + */ public CacheLock lockAll(Collection<? extends K> keys); /**