ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yzhda...@apache.org
Subject [4/4] incubator-ignite git commit: ignite-96 minor
Date Sun, 08 Feb 2015 08:38:12 GMT
ignite-96 minor


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

Branch: refs/heads/ignite-96
Commit: ac548723cc3e608addf8a9ae5b7a563e0b83d799
Parents: 3b76b52
Author: Yakov Zhdanov <yzhdanov@gridgain.com>
Authored: Sun Feb 8 11:38:00 2015 +0300
Committer: Yakov Zhdanov <yzhdanov@gridgain.com>
Committed: Sun Feb 8 11:38:00 2015 +0300

----------------------------------------------------------------------
 .../processors/cache/CacheEntryImpl.java        | 19 ------
 .../cache/CacheVersionedEntryImpl.java          | 62 ++++++++++++++++++++
 .../processors/cache/GridCacheContext.java      |  7 ++-
 .../processors/cache/GridCacheEntryEx.java      |  8 ++-
 .../cache/GridCacheEvictionManager.java         |  4 +-
 .../processors/cache/GridCacheMapEntry.java     | 15 ++---
 .../transactions/IgniteTxLocalAdapter.java      | 10 ++--
 .../processors/cache/GridCacheTestEntryEx.java  |  7 ++-
 8 files changed, 94 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ac548723/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryImpl.java
index e5a084e..d6feefc 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryImpl.java
@@ -17,8 +17,6 @@
 
 package org.apache.ignite.internal.processors.cache;
 
-import org.jetbrains.annotations.*;
-
 import javax.cache.*;
 
 /**
@@ -31,9 +29,6 @@ public class CacheEntryImpl<K, V> implements Cache.Entry<K, V>
{
     /** */
     private final V val;
 
-    /** Version. */
-    private Object ver;
-
     /**
      * @param key Key.
      * @param val Value.
@@ -53,20 +48,6 @@ public class CacheEntryImpl<K, V> implements Cache.Entry<K, V>
{
         return val;
     }
 
-    /**
-     * @return Version.
-     */
-    @Nullable public Object version() {
-        return ver;
-    }
-
-    /**
-     * @param ver Version.
-     */
-    public void version(Object ver) {
-        this.ver = ver;
-    }
-
     /** {@inheritDoc} */
     @SuppressWarnings("unchecked")
     @Override public <T> T unwrap(Class<T> cls) {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ac548723/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheVersionedEntryImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheVersionedEntryImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheVersionedEntryImpl.java
new file mode 100644
index 0000000..a31c7e2
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheVersionedEntryImpl.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import org.jetbrains.annotations.*;
+
+/**
+ *
+ */
+public class CacheVersionedEntryImpl<K, V> extends CacheEntryImpl<K, V> {
+    /** Version. */
+    private final Object ver;
+
+    /**
+     * @param key Key.
+     * @param val Value (always null).
+     * @param ver Version.
+     */
+    public CacheVersionedEntryImpl(K key, V val, Object ver) {
+        super(key, val);
+
+        assert val == null;
+
+        this.ver = ver;
+    }
+
+    /**
+     * @return Version.
+     */
+    @Nullable public Object version() {
+        return ver;
+    }
+
+    /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
+    @Override public <T> T unwrap(Class<T> cls) {
+        if (!cls.equals(getClass()))
+            throw new IllegalArgumentException("Unwrapping to class is not supported: " +
cls);
+
+        return (T)this;
+    }
+
+    /** {@inheritDoc} */
+    public String toString() {
+        return "VersionedEntry [key=" + getKey() + ", val=" + getValue() + ", ver=" + ver
+ ']';
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ac548723/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
index ed4480f..e8192b9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheContext.java
@@ -1000,9 +1000,10 @@ public class GridCacheContext<K, V> implements Externalizable
{
      * @return {@code True} if predicates passed.
      * @throws IgniteCheckedException If failed.
      */
-    @SuppressWarnings({"ErrorNotRethrown"})
-    public <K1, V1> boolean isAll(GridCacheEntryEx<K1, V1> e,
-        @Nullable IgnitePredicate<Cache.Entry<K1, V1>>[] p) throws IgniteCheckedException
{
+    public <K1, V1> boolean isAll(
+        GridCacheEntryEx<K1, V1> e,
+        @Nullable IgnitePredicate<Cache.Entry<K1, V1>>[] p
+    ) throws IgniteCheckedException {
         return F.isEmpty(p) || isAll(e.wrap(), p);
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ac548723/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
index ca2273d..dff1b9d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEntryEx.java
@@ -151,7 +151,13 @@ public interface GridCacheEntryEx<K, V> {
     /**
      * @return Entry which is safe to pass into eviction policy.
      */
-    public EvictableEntry<K, V> evictWrap();
+    public EvictableEntry<K, V> wrapEviction();
+
+    /**
+     * @return Entry which holds key and version (no value, since entry
+     *      is intended to be used in sync evictions checks).
+     */
+    public CacheVersionedEntryImpl<K, V> wrapVersioned();
 
     /**
      * @return Not-null version if entry is obsolete.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ac548723/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
index 8019002..b3ef296 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheEvictionManager.java
@@ -1239,7 +1239,7 @@ public class GridCacheEvictionManager<K, V> extends GridCacheManagerAdapter<K,
V
         // then we should not evict entry.
         return cctx.vararg(new P1<Cache.Entry<K, V>>() {
             @Override public boolean apply(Cache.Entry<K, V> e) {
-                GridCacheVersion ver = (GridCacheVersion)((CacheEntryImpl)e).version();
+                GridCacheVersion ver = (GridCacheVersion)((CacheVersionedEntryImpl)e).version();
 
                 return info.version().equals(ver) && F.isAll(info.filter());
             }
@@ -1318,7 +1318,7 @@ public class GridCacheEvictionManager<K, V> extends GridCacheManagerAdapter<K,
V
             log.debug("Notifying eviction policy with entry: " + e);
 
         if (filter == null || filter.evictAllowed(e.wrap()))
-            plc.onEntryAccessed(e.obsoleteOrDeleted(), e.evictWrap());
+            plc.onEntryAccessed(e.obsoleteOrDeleted(), e.wrapEviction());
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ac548723/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
index 2312764..9fe352d 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
@@ -3708,11 +3708,7 @@ public abstract class GridCacheMapEntry<K, V> implements GridCacheEntryEx<K,
V>
             else
                 val = rawGetOrUnmarshal(false);
 
-            CacheEntryImpl<K, V> entry = new CacheEntryImpl<>(key, val);
-
-            entry.version(ver);
-
-            return entry;
+            return new CacheEntryImpl<>(key, val);
         }
         catch (GridCacheFilterFailedException ignored) {
             throw new IgniteException("Should never happen.");
@@ -3728,11 +3724,16 @@ public abstract class GridCacheMapEntry<K, V> implements GridCacheEntryEx<K,
V>
     }
 
     /** {@inheritDoc} */
-    @Override public EvictableEntry<K, V> evictWrap() {
+    @Override public EvictableEntry<K, V> wrapEviction() {
         return new GridCacheEvictionEntry<>(this);
     }
 
     /** {@inheritDoc} */
+    @Override public synchronized CacheVersionedEntryImpl<K, V> wrapVersioned() {
+        return new CacheVersionedEntryImpl<>(key, null, ver);
+    }
+
+    /** {@inheritDoc} */
     @Override public boolean evictInternal(boolean swap, GridCacheVersion obsoleteVer,
         @Nullable IgnitePredicate<Cache.Entry<K, V>>[] filter) throws IgniteCheckedException
{
         boolean marked = false;
@@ -3775,7 +3776,7 @@ public abstract class GridCacheMapEntry<K, V> implements GridCacheEntryEx<K,
V>
                         v = ver;
                     }
 
-                    if (!cctx.isAll(this, filter))
+                    if (!cctx.isAll(/*version needed for sync evicts*/wrapVersioned(), filter))
                         return false;
 
                     synchronized (this) {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ac548723/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
index b3d5beb..d1e26de 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxLocalAdapter.java
@@ -571,7 +571,7 @@ public abstract class IgniteTxLocalAdapter<K, V> extends IgniteTxAdapter<K,
V>
                             }
 
                             if (rmvCol == null)
-                                rmvCol = new LinkedList<>();
+                                rmvCol = new ArrayList<>();
 
                             rmvCol.add(key);
 
@@ -1741,7 +1741,7 @@ public abstract class IgniteTxLocalAdapter<K, V> extends IgniteTxAdapter<K,
V>
             else {
                 assert optimistic() || readCommitted() || groupLock();
 
-                final Collection<K> redos = new LinkedList<>();
+                final Collection<K> redos = new ArrayList<>();
 
                 if (!missed.isEmpty()) {
                     if (!readCommitted())
@@ -2577,7 +2577,7 @@ public abstract class IgniteTxLocalAdapter<K, V> extends IgniteTxAdapter<K,
V>
         try {
             Set<? extends K> keySet = map0 != null ? map0.keySet() : invokeMap0.keySet();
 
-            Collection<K> enlisted = new LinkedList<>();
+            Collection<K> enlisted = new ArrayList<>();
 
             GridCacheProjectionImpl<K, V> prj = cacheCtx.projectionPerCall();
 
@@ -2775,7 +2775,7 @@ public abstract class IgniteTxLocalAdapter<K, V> extends IgniteTxAdapter<K,
V>
         init();
 
         try {
-            Collection<K> enlisted = new LinkedList<>();
+            Collection<K> enlisted = new ArrayList<>();
 
             ExpiryPolicy plc;
 
@@ -2954,7 +2954,7 @@ public abstract class IgniteTxLocalAdapter<K, V> extends IgniteTxAdapter<K,
V>
 
             GridCacheReturn<V> ret = new GridCacheReturn<>(false);
 
-            Collection<K> enlisted = new LinkedList<>();
+            Collection<K> enlisted = new ArrayList<>();
 
             Set<K> skipped = enlistWrite(
                 cacheCtx,

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ac548723/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
index 3cbe044..670958c 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheTestEntryEx.java
@@ -117,7 +117,7 @@ public class GridCacheTestEntryEx<K, V> extends GridMetadataAwareAdapter
impleme
     }
 
     /** {@inheritDoc} */
-    @Nullable @Override public EvictableEntry<K, V> evictWrap() {
+    @Nullable @Override public EvictableEntry<K, V> wrapEviction() {
         return null;
     }
 
@@ -343,6 +343,11 @@ public class GridCacheTestEntryEx<K, V> extends GridMetadataAwareAdapter
impleme
     }
 
     /** {@inheritDoc} */
+    @Override public CacheVersionedEntryImpl<K, V> wrapVersioned() {
+        assert false; return null;
+    }
+
+    /** {@inheritDoc} */
     @Override public Cache.Entry<K, V> wrapFilterLocked() throws IgniteCheckedException
{
         assert false; return null;
     }


Mime
View raw message