ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agoncha...@apache.org
Subject [15/35] incubator-ignite git commit: ignite-946: fixed review notes
Date Sat, 15 Aug 2015 01:49:02 GMT
ignite-946: fixed review notes


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

Branch: refs/heads/ignite-264
Commit: 911ffbb5de261d662a915677b99cae4a160407eb
Parents: 9f16eb1
Author: Denis Magda <dmagda@gridgain.com>
Authored: Mon Aug 10 11:39:44 2015 +0300
Committer: Denis Magda <dmagda@gridgain.com>
Committed: Mon Aug 10 11:39:44 2015 +0300

----------------------------------------------------------------------
 .../ignite/cache/version/VersionedEntry.java    |  2 +-
 .../processors/cache/CacheEntryImpl0.java       |  4 +-
 .../processors/cache/GridCacheMapEntry.java     |  2 +-
 .../processors/cache/GridCacheSwapManager.java  | 88 ++++++++++++--------
 .../cache/transactions/IgniteTxAdapter.java     |  2 +
 .../cache/transactions/IgniteTxEntry.java       |  2 +-
 .../transactions/IgniteTxLocalAdapter.java      |  8 ++
 .../cache/version/GridCacheVersionAware.java    | 30 +++++++
 .../cache/version/GridVersionedMapEntry.java    | 33 --------
 .../CacheVersionedEntryAbstractTest.java        |  2 +-
 10 files changed, 99 insertions(+), 74 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/911ffbb5/modules/core/src/main/java/org/apache/ignite/cache/version/VersionedEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/version/VersionedEntry.java
b/modules/core/src/main/java/org/apache/ignite/cache/version/VersionedEntry.java
index e669f15..2c0879b 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/version/VersionedEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/version/VersionedEntry.java
@@ -56,7 +56,7 @@ public interface VersionedEntry<K, V> extends Cache.Entry<K, V>
{
     /**
      * Versions comparator.
      */
-    public static final Comparator<VersionedEntry> VERSIONS_COMPARATOR = new Comparator<VersionedEntry>()
{
+    public static final Comparator<VersionedEntry> VER_COMP = new Comparator<VersionedEntry>()
{
         @Override public int compare(VersionedEntry o1, VersionedEntry o2) {
             int res = Integer.compare(o1.topologyVersion(), o2.topologyVersion());
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/911ffbb5/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryImpl0.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryImpl0.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryImpl0.java
index a5e27d6..987fbd3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryImpl0.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheEntryImpl0.java
@@ -52,8 +52,8 @@ public class CacheEntryImpl0<K, V> implements Cache.Entry<K, V>
{
     @Override public <T> T unwrap(Class<T> cls) {
         if(cls.isAssignableFrom(getClass()))
             return cls.cast(this);
-        else if (cls.isAssignableFrom(VersionedEntry.class) && e instanceof GridVersionedMapEntry)
-            return (T)new CacheVersionedEntryImpl<>(e.getKey(), e.getValue(), ((GridVersionedMapEntry)e).version());
+        else if (cls.isAssignableFrom(VersionedEntry.class) && e instanceof GridCacheVersionAware)
+            return (T)new CacheVersionedEntryImpl<>(e.getKey(), e.getValue(), ((GridCacheVersionAware)e).version());
 
         throw new IllegalArgumentException("Unwrapping to class is not supported: " + cls);
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/911ffbb5/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 43cf2fe..298f7a6 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
@@ -1385,7 +1385,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter
impleme
 
                 assert entryProcessor != null;
 
-                CacheInvokeEntry<Object, Object> entry = new CacheInvokeEntry<>(cctx,
key, old, this.ver);
+                CacheInvokeEntry<Object, Object> entry = new CacheInvokeEntry<>(cctx,
key, old, version());
 
                 try {
                     Object computed = entryProcessor.process(entry, invokeArgs);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/911ffbb5/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
index ffe6169..ea9b0fd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheSwapManager.java
@@ -1513,41 +1513,7 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter {
             @Override protected Map.Entry<K, V> onNext() {
                 final Map.Entry<byte[], byte[]> cur0 = it.next();
 
-                cur = new GridVersionedMapEntry<K, V>() {
-                    @Override public K getKey() {
-                        try {
-                            KeyCacheObject key = cctx.toCacheKeyObject(cur0.getKey());
-
-                            return key.value(cctx.cacheObjectContext(), false);
-                        }
-                        catch (IgniteCheckedException e) {
-                            throw new IgniteException(e);
-                        }
-                    }
-
-                    @Override public V getValue() {
-                        try {
-                            GridCacheSwapEntry e = unmarshalSwapEntry(cur0.getValue());
-
-                            swapEntry(e);
-
-                            return e.value().value(cctx.cacheObjectContext(), false);
-                        }
-                        catch (IgniteCheckedException ex) {
-                            throw new IgniteException(ex);
-                        }
-                    }
-
-                    @Override public GridCacheVersion version() {
-                        GridCacheSwapEntry e = unmarshalSwapEntry(cur0.getValue());
-
-                        return e.version();
-                    }
-
-                    @Override public V setValue(V val) {
-                        throw new UnsupportedOperationException();
-                    }
-                };
+                cur = new GridVersionedMapEntry<K, V>(cur0);
 
                 return cur;
             }
@@ -2330,4 +2296,56 @@ public class GridCacheSwapManager extends GridCacheManagerAdapter {
          */
         abstract protected GridCloseableIterator<T1> partitionIterator(int part) throws
IgniteCheckedException;
     }
+
+    private class GridVersionedMapEntry<K,V> implements Map.Entry<K,V>, GridCacheVersionAware
{
+        /** */
+        private Map.Entry<byte[], byte[]> entry;
+
+        /**
+         * Constructor.
+         *
+         * @param entry Entry.
+         */
+        public GridVersionedMapEntry(Map.Entry<byte[], byte[]> entry) {
+            this.entry = entry;
+        }
+
+        /** {@inheritDoc} */
+        @Override public K getKey() {
+            try {
+                KeyCacheObject key = cctx.toCacheKeyObject(entry.getKey());
+
+                return key.value(cctx.cacheObjectContext(), false);
+            }
+            catch (IgniteCheckedException e) {
+                throw new IgniteException(e);
+            }
+        }
+
+        /** {@inheritDoc} */
+        @Override public V getValue() {
+            try {
+                GridCacheSwapEntry e = unmarshalSwapEntry(entry.getValue());
+
+                swapEntry(e);
+
+                return e.value().value(cctx.cacheObjectContext(), false);
+            }
+            catch (IgniteCheckedException ex) {
+                throw new IgniteException(ex);
+            }
+        }
+
+        /** {@inheritDoc} */
+        @Override public GridCacheVersion version() {
+            GridCacheSwapEntry e = unmarshalSwapEntry(entry.getValue());
+
+            return e.version();
+        }
+
+        /** {@inheritDoc} */
+        @Override public V setValue(V val) {
+            throw new UnsupportedOperationException();
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/911ffbb5/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
index 797f75e..e9fdd22 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxAdapter.java
@@ -1234,6 +1234,8 @@ public abstract class IgniteTxAdapter extends GridMetadataAwareAdapter
                     ver = txEntry.cached().version();
                 }
                 catch (GridCacheEntryRemovedException e) {
+                    assert optimistic() : txEntry;
+
                     if (log.isDebugEnabled())
                         log.debug("Failed to get entry version: [msg=" + e.getMessage() +
']');
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/911ffbb5/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
index 73b9975..3c792f6 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
@@ -577,7 +577,7 @@ public class IgniteTxEntry implements GridPeerDeployAware, Message {
             ver = entry.version();
         }
         catch (GridCacheEntryRemovedException e) {
-            assert tx.optimistic() : tx;
+            assert tx == null || tx.optimistic() : tx;
 
             ver = null;
         }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/911ffbb5/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 a209780..b354fed 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
@@ -2236,6 +2236,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
                                                 ver = entry.version();
                                             }
                                             catch (GridCacheEntryRemovedException ex) {
+                                                assert optimistic() : txEntry;
+
                                                 if (log.isDebugEnabled())
                                                     log.debug("Failed to get entry version
" +
                                                         "[err=" + ex.getMessage() + ']');
@@ -2311,6 +2313,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
                                 ver = entry.version();
                             }
                             catch (GridCacheEntryRemovedException e) {
+                                assert optimistic() : txEntry;
+
                                 if (log.isDebugEnabled())
                                     log.debug("Failed to get entry version: [msg=" + e.getMessage()
+ ']');
 
@@ -2362,6 +2366,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
                                 ver = e.cached().version();
                             }
                             catch (GridCacheEntryRemovedException ex) {
+                                assert optimistic() : e;
+
                                 if (log.isDebugEnabled())
                                     log.debug("Failed to get entry version: [msg=" + ex.getMessage()
+ ']');
 
@@ -2489,6 +2495,8 @@ public abstract class IgniteTxLocalAdapter extends IgniteTxAdapter
                                     ver = cached.version();
                                 }
                                 catch (GridCacheEntryRemovedException e) {
+                                    assert optimistic() : txEntry;
+
                                     if (log.isDebugEnabled())
                                         log.debug("Failed to get entry version: [msg=" +
e.getMessage() + ']');
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/911ffbb5/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionAware.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionAware.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionAware.java
new file mode 100644
index 0000000..0c0a270
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridCacheVersionAware.java
@@ -0,0 +1,30 @@
+/*
+ * 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.version;
+
+/**
+ * Interface implemented by classes that holds version related information.
+ */
+public interface GridCacheVersionAware {
+    /**
+     * Gets version.
+     *
+     * @return Cache entry version.
+     */
+    public GridCacheVersion version();
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/911ffbb5/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridVersionedMapEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridVersionedMapEntry.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridVersionedMapEntry.java
deleted file mode 100644
index f653fac..0000000
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/version/GridVersionedMapEntry.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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.version;
-
-import java.util.*;
-
-/**
- * This interface extends {@link java.util.Map.Entry} by adding the method that returns entry's
- * {@link GridCacheVersion}.
- */
-public interface GridVersionedMapEntry<K, V> extends Map.Entry<K, V> {
-    /**
-     * Gets entry version.
-     *
-     * @return Entry version.
-     */
-    public GridCacheVersion version();
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/911ffbb5/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryAbstractTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryAbstractTest.java
index 25a2a42..b121995 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/version/CacheVersionedEntryAbstractTest.java
@@ -152,7 +152,7 @@ public abstract class CacheVersionedEntryAbstractTest extends GridCacheAbstractS
                     }
             });
 
-        assert VersionedEntry.VERSIONS_COMPARATOR.compare(ver1, ver2) < 0;
+        assert VersionedEntry.VER_COMP.compare(ver1, ver2) < 0;
     }
 
     /**


Mime
View raw message