ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [07/15] incubator-ignite git commit: #ignite-683: Remove filter from GridCacheProjection.putAsync.
Date Wed, 08 Apr 2015 13:31:10 GMT
#ignite-683: Remove filter from GridCacheProjection.putAsync.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/acb6afc1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/acb6afc1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/acb6afc1

Branch: refs/heads/ignite-683
Commit: acb6afc1f231094915f790417b8f38410fe4401b
Parents: ac488d3
Author: ivasilinets <ivasilinets@gridgain.com>
Authored: Tue Apr 7 01:27:21 2015 +0300
Committer: ivasilinets <ivasilinets@gridgain.com>
Committed: Tue Apr 7 01:27:21 2015 +0300

----------------------------------------------------------------------
 .../processors/cache/CacheProjection.java       |  8 +--
 .../processors/cache/GridCacheAdapter.java      | 66 +++++++++++++++++++-
 .../cache/GridCacheProjectionImpl.java          | 22 +++----
 .../processors/cache/GridCacheProxyImpl.java    | 10 ++-
 4 files changed, 80 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/acb6afc1/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheProjection.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheProjection.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheProjection.java
index 5312ccc..2e959d6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheProjection.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheProjection.java
@@ -493,12 +493,10 @@ public interface CacheProjection<K, V> extends Iterable<Cache.Entry<K,
V>> {
      *
      * @param key Key to store in cache.
      * @param val Value to be associated with the given key.
-     * @param filter Optional filter to check prior to putting value in cache. Note
-     *      that filter check is atomic with put operation.
      * @return Future for the put operation.
      * @throws NullPointerException If either key or value are {@code null}.
      */
-    public IgniteInternalFuture<V> putAsync(K key, V val, @Nullable CacheEntryPredicate...
filter);
+    public IgniteInternalFuture<V> putAsync(K key, V val);
 
     /**
      * Stores given key-value pair in cache. If filters are provided, then entries will
@@ -545,14 +543,12 @@ public interface CacheProjection<K, V> extends Iterable<Cache.Entry<K,
V>> {
      *
      * @param key Key to store in cache.
      * @param val Value to be associated with the given key.
-     * @param filter Optional filter to check prior to putting value in cache. Note
-     *      that filter check is atomic with put operation.
      * @return Future for the put operation. Future will return {@code true} if optional
filter
      *      passed and value was stored in cache, {@code false} otherwise. Note that future
will
      *      return {@code true} if filter is not specified.
      * @throws NullPointerException If either key or value are {@code null}.
      */
-    public IgniteInternalFuture<Boolean> putxAsync(K key, V val, @Nullable CacheEntryPredicate...
filter);
+    public IgniteInternalFuture<Boolean> putxAsync(K key, V val);
 
     /**
      * Stores given key-value pair in cache only if cache had no previous mapping for it.
If cache

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/acb6afc1/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
index 6316175..0481f7b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
@@ -2076,7 +2076,40 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K,
V>,
     }
 
     /** {@inheritDoc} */
-    @Override public IgniteInternalFuture<V> putAsync(K key, V val,
+    @Override public IgniteInternalFuture<V> putAsync(K key, V val) {
+        return putAsync(key, val, null);
+    }
+
+    /**
+     * Asynchronously stores given key-value pair in cache. If filters are provided, then
entries will
+     * be stored in cache only if they pass the filter. Note that filter check is atomic,
+     * so value stored in cache is guaranteed to be consistent with the filters. If cache
+     * previously contained value for the given key, then this value is returned. Otherwise,
+     * in case of {@link CacheMode#REPLICATED} caches, the value will be loaded from swap
+     * and, if it's not there, and read-through is allowed, from the underlying
+     * {@link org.apache.ignite.cache.store.CacheStore} storage. In case of {@link CacheMode#PARTITIONED}
caches,
+     * the value will be loaded from the primary node, which in its turn may load the value
+     * from the swap storage, and consecutively, if it's not in swap and read-through is
allowed,
+     * from the underlying persistent storage. If value has to be loaded from persistent
+     * storage,  <code>CacheStore#load(Transaction, Object)</code> method will
be used.
+     * <p>
+     * If the returned value is not needed, method <code>#putx(Object, Object, org.apache.ignite.lang.IgnitePredicate[])</code>
should
+     * always be used instead of this one to avoid the overhead associated with returning
of the previous value.
+     * <p>
+     * If write-through is enabled, the stored value will be persisted to {@link org.apache.ignite.cache.store.CacheStore}
+     * via <code>CacheStore#put(Transaction, Object, Object)</code> method.
+     * <h2 class="header">Transactions</h2>
+     * This method is transactional and will enlist the entry into ongoing transaction
+     * if there is one.
+     *
+     * @param key Key to store in cache.
+     * @param val Value to be associated with the given key.
+     * @param filter Optional filter to check prior to putting value in cache. Note
+     *      that filter check is atomic with put operation.
+     * @return Future for the put operation.
+     * @throws NullPointerException If either key or value are {@code null}.
+     */
+    public IgniteInternalFuture<V> putAsync(K key, V val,
         @Nullable CacheEntryPredicate[] filter) {
         final boolean statsEnabled = ctx.config().isStatisticsEnabled();
 
@@ -2411,7 +2444,36 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K,
V>,
     }
 
     /** {@inheritDoc} */
-    @Override public IgniteInternalFuture<Boolean> putxAsync(K key, V val,
+    @Override public IgniteInternalFuture<Boolean> putxAsync(K key, V val) {
+        return putxAsync(key, val, null);
+    }
+
+    /**
+     * Stores given key-value pair in cache. If filters are provided, then entries will
+     * be stored in cache only if they pass the filter. Note that filter check is atomic,
+     * so value stored in cache is guaranteed to be consistent with the filters.
+     * <p>
+     * This method will return {@code true} if value is stored in cache and {@code false}
otherwise.
+     * Unlike <code>#put(Object, Object, org.apache.ignite.lang.IgnitePredicate[])</code>
method, it does not return previous
+     * value and, therefore, does not have any overhead associated with returning of a value.
It
+     * should always be used whenever return value is not required.
+     * <p>
+     * If write-through is enabled, the stored value will be persisted to {@link org.apache.ignite.cache.store.CacheStore}
+     * via <code>CacheStore#put(Transaction, Object, Object)</code> method.
+     * <h2 class="header">Transactions</h2>
+     * This method is transactional and will enlist the entry into ongoing transaction
+     * if there is one.
+     *
+     * @param key Key to store in cache.
+     * @param val Value to be associated with the given key.
+     * @param filter Optional filter to check prior to putting value in cache. Note
+     *      that filter check is atomic with put operation.
+     * @return Future for the put operation. Future will return {@code true} if optional
filter
+     *      passed and value was stored in cache, {@code false} otherwise. Note that future
will
+     *      return {@code true} if filter is not specified.
+     * @throws NullPointerException If either key or value are {@code null}.
+     */
+    public IgniteInternalFuture<Boolean> putxAsync(K key, V val,
         @Nullable CacheEntryPredicate... filter) {
         final boolean statsEnabled = ctx.config().isStatisticsEnabled();
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/acb6afc1/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java
index 7bf3515..26cb783 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProjectionImpl.java
@@ -351,7 +351,7 @@ public class GridCacheProjectionImpl<K, V> implements GridCacheProjectionEx<K,
V
     /** {@inheritDoc} */
     @Override public V put(K key, V val, @Nullable CacheEntryPredicate[] filter)
         throws IgniteCheckedException {
-        return putAsync(key, val, filter).get();
+        return putAsync(key, val, null, filter).get();
     }
 
     /** {@inheritDoc} */
@@ -361,9 +361,8 @@ public class GridCacheProjectionImpl<K, V> implements GridCacheProjectionEx<K,
V
     }
 
     /** {@inheritDoc} */
-    @Override public IgniteInternalFuture<V> putAsync(K key, V val,
-        @Nullable CacheEntryPredicate[] filter) {
-        return putAsync(key, val, null, filter);
+    @Override public IgniteInternalFuture<V> putAsync(K key, V val) {
+        return putAsync(key, val, null, null);
     }
 
     /** {@inheritDoc} */
@@ -382,7 +381,7 @@ public class GridCacheProjectionImpl<K, V> implements GridCacheProjectionEx<K,
V
 
     /** {@inheritDoc} */
     @Override public boolean putx(K key, V val) throws IgniteCheckedException {
-        return putxAsync(key, val, null).get();
+        return putxAsync(key, val).get();
     }
 
     /** {@inheritDoc} */
@@ -438,9 +437,8 @@ public class GridCacheProjectionImpl<K, V> implements GridCacheProjectionEx<K,
V
     }
 
     /** {@inheritDoc} */
-    @Override public IgniteInternalFuture<Boolean> putxAsync(K key, V val,
-        @Nullable CacheEntryPredicate[] filter) {
-        return putxAsync(key, val, null, filter);
+    @Override public IgniteInternalFuture<Boolean> putxAsync(K key, V val) {
+        return putxAsync(key, val, null, null);
     }
 
     /** {@inheritDoc} */
@@ -458,7 +456,7 @@ public class GridCacheProjectionImpl<K, V> implements GridCacheProjectionEx<K,
V
 
     /** {@inheritDoc} */
     @Override public IgniteInternalFuture<V> putIfAbsentAsync(K key, V val) {
-        return putAsync(key, val, cctx.noValArray());
+        return cache.putAsync(key, val, null, cctx.noValArray());
     }
 
     /** {@inheritDoc} */
@@ -468,7 +466,7 @@ public class GridCacheProjectionImpl<K, V> implements GridCacheProjectionEx<K,
V
 
     /** {@inheritDoc} */
     @Override public IgniteInternalFuture<Boolean> putxIfAbsentAsync(K key, V val)
{
-        return putxAsync(key, val, cctx.noValArray());
+        return cache.putxAsync(key, val, null, cctx.noValArray());
     }
 
     /** {@inheritDoc} */
@@ -478,7 +476,7 @@ public class GridCacheProjectionImpl<K, V> implements GridCacheProjectionEx<K,
V
 
     /** {@inheritDoc} */
     @Override public IgniteInternalFuture<V> replaceAsync(K key, V val) {
-        return putAsync(key, val, cctx.hasValArray());
+        return cache.putAsync(key, val, null, cctx.hasValArray());
     }
 
     /** {@inheritDoc} */
@@ -488,7 +486,7 @@ public class GridCacheProjectionImpl<K, V> implements GridCacheProjectionEx<K,
V
 
     /** {@inheritDoc} */
     @Override public IgniteInternalFuture<Boolean> replacexAsync(K key, V val) {
-        return putxAsync(key, val, cctx.hasValArray());
+        return cache.putxAsync(key, val, null, cctx.hasValArray());
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/acb6afc1/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
index b7719b0..b7665a3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java
@@ -604,12 +604,11 @@ public class GridCacheProxyImpl<K, V> implements GridCacheProxy<K,
V>, Externali
     }
 
     /** {@inheritDoc} */
-    @Override public IgniteInternalFuture<V> putAsync(K key, V val,
-        @Nullable CacheEntryPredicate[] filter) {
+    @Override public IgniteInternalFuture<V> putAsync(K key, V val) {
         GridCacheProjectionImpl<K, V> prev = gate.enter(prj);
 
         try {
-            return delegate.putAsync(key, val, filter);
+            return delegate.putAsync(key, val);
         }
         finally {
             gate.leave(prev);
@@ -766,12 +765,11 @@ public class GridCacheProxyImpl<K, V> implements GridCacheProxy<K,
V>, Externali
     }
 
     /** {@inheritDoc} */
-    @Override public IgniteInternalFuture<Boolean> putxAsync(K key, V val,
-        @Nullable CacheEntryPredicate[] filter) {
+    @Override public IgniteInternalFuture<Boolean> putxAsync(K key, V val) {
         GridCacheProjectionImpl<K, V> prev = gate.enter(prj);
 
         try {
-            return delegate.putxAsync(key, val, filter);
+            return delegate.putxAsync(key, val);
         }
         finally {
             gate.leave(prev);


Mime
View raw message