ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [22/48] incubator-ignite git commit: # sprint-2 added localRemoveAll for SpringCache
Date Thu, 19 Feb 2015 18:43:44 GMT
# sprint-2 added localRemoveAll for SpringCache


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

Branch: refs/heads/ignite-292
Commit: 29852495e6ebeceb2321197843c2afd6df872007
Parents: 28584e7
Author: sboikov <sboikov@gridgain.com>
Authored: Thu Feb 19 09:48:49 2015 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Thu Feb 19 09:48:49 2015 +0300

----------------------------------------------------------------------
 .../processors/cache/CacheProjection.java       |  5 ++++
 .../processors/cache/GridCacheAdapter.java      | 25 ++++++++++++++++++++
 .../cache/GridCacheProjectionImpl.java          |  5 ++++
 .../processors/cache/GridCacheProxyImpl.java    | 12 ++++++++++
 .../dht/atomic/GridDhtAtomicCache.java          | 10 ++++++++
 .../distributed/near/GridNearAtomicCache.java   | 10 ++++++++
 .../apache/ignite/cache/spring/SpringCache.java |  2 +-
 7 files changed, 68 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/29852495/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 950043b..74dfebd 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
@@ -1626,6 +1626,11 @@ public interface CacheProjection<K, V> extends Iterable<Cache.Entry<K,
V>> {
     public IgniteInternalFuture<?> removeAllAsync();
 
     /**
+     * @throws IgniteCheckedException If failed.
+     */
+    public void localRemoveAll() throws IgniteCheckedException;
+
+    /**
      * Synchronously acquires lock on a cached object with given
      * key only if the passed in filter (if any) passes. This method
      * together with filter check will be executed as one atomic operation.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/29852495/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 1e3105a..808c62f 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
@@ -3636,6 +3636,31 @@ public abstract class GridCacheAdapter<K, V> implements GridCache<K,
V>,
         return fut;
     }
 
+    /**
+     * @param filter Filter.
+     * @return Future.
+     */
+    public IgniteInternalFuture<?> localRemoveAll(final IgnitePredicate<Cache.Entry<K,
V>> filter) {
+        ctx.denyOnLocalRead();
+
+        final Set<? extends K> keys = filter != null ? keySet(filter) : keySet();
+
+        return asyncOp(new AsyncInOp(keys) {
+            @Override public IgniteInternalFuture<?> inOp(IgniteTxLocalAdapter<K,
V> tx) {
+                return tx.removeAllAsync(ctx, keys, null, false, null);
+            }
+
+            @Override public String toString() {
+                return "removeAllAsync [filter=" + filter + ']';
+            }
+        });
+    }
+
+    /** {@inheritDoc} */
+    @Override public void localRemoveAll() throws IgniteCheckedException {
+        localRemoveAll(null);
+    }
+
     /** {@inheritDoc} */
     @Override public CacheMetrics metrics() {
         return new CacheMetricsSnapshot(metrics);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/29852495/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 f759b12..aa47d48 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
@@ -1227,6 +1227,11 @@ public class GridCacheProjectionImpl<K, V> implements GridCacheProjectionEx<K,
V
     }
 
     /** {@inheritDoc} */
+    @Override public void localRemoveAll() throws IgniteCheckedException {
+        cache.localRemoveAll(predicate());
+    }
+
+    /** {@inheritDoc} */
     @Override public boolean lock(K key, long timeout,
         @Nullable IgnitePredicate<Cache.Entry<K, V>>... filter) throws IgniteCheckedException
{
         return cache.lock(key, timeout, and(filter, false));

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/29852495/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 429bfde..55a9daf 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
@@ -1640,6 +1640,18 @@ public class GridCacheProxyImpl<K, V> implements GridCacheProxy<K,
V>, Externali
     }
 
     /** {@inheritDoc} */
+    @Override public void localRemoveAll() throws IgniteCheckedException {
+        GridCacheProjectionImpl<K, V> prev = gate.enter(prj);
+
+        try {
+            delegate.localRemoveAll();
+        }
+        finally {
+            gate.leave(prev);
+        }
+    }
+
+    /** {@inheritDoc} */
     @Override public boolean lock(K key, long timeout, @Nullable IgnitePredicate<Cache.Entry<K,
V>>[] filter)
         throws IgniteCheckedException {
         GridCacheProjectionImpl<K, V> prev = gate.enter(prj);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/29852495/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
index d422411..c408394 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java
@@ -545,6 +545,16 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K,
V> {
     }
 
     /** {@inheritDoc} */
+    @Override public void localRemoveAll() throws IgniteCheckedException {
+        removeAll(keySet());
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteInternalFuture<?> localRemoveAll(IgnitePredicate<Cache.Entry<K,
V>> filter) {
+        return removeAllAsync(keySet(filter), null);
+    }
+
+    /** {@inheritDoc} */
     @Override public void removeAllConflict(Map<? extends K, GridCacheVersion> conflictMap)
         throws IgniteCheckedException {
         removeAllConflictAsync(conflictMap).get();

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/29852495/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java
index ee31c38..2b608f4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java
@@ -640,6 +640,16 @@ public class GridNearAtomicCache<K, V> extends GridNearCacheAdapter<K,
V> {
     }
 
     /** {@inheritDoc} */
+    @Override public void localRemoveAll() throws IgniteCheckedException {
+        dht.localRemoveAll();
+    }
+
+    /** {@inheritDoc} */
+    @Override public IgniteInternalFuture<?> localRemoveAll(IgnitePredicate<Cache.Entry<K,
V>> filter) {
+        return dht.localRemoveAll(filter);
+    }
+
+    /** {@inheritDoc} */
     @Override public void removeAllConflict(Map<? extends K, GridCacheVersion> drMap)
throws IgniteCheckedException {
         dht.removeAllConflict(drMap);
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/29852495/modules/spring/src/main/java/org/apache/ignite/cache/spring/SpringCache.java
----------------------------------------------------------------------
diff --git a/modules/spring/src/main/java/org/apache/ignite/cache/spring/SpringCache.java
b/modules/spring/src/main/java/org/apache/ignite/cache/spring/SpringCache.java
index 6719069..07e38a1 100644
--- a/modules/spring/src/main/java/org/apache/ignite/cache/spring/SpringCache.java
+++ b/modules/spring/src/main/java/org/apache/ignite/cache/spring/SpringCache.java
@@ -172,7 +172,7 @@ class SpringCache implements Cache, Serializable {
 
         /** {@inheritDoc} */
         @Override public void applyx() throws IgniteCheckedException {
-            cache.removeAll();
+            cache.localRemoveAll();
         }
 
         /** {@inheritDoc} */


Mime
View raw message