You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2016/11/30 14:42:17 UTC

[1/7] ignite git commit: IGNITE-4299: Fixes for examples.

Repository: ignite
Updated Branches:
  refs/heads/ignite-4285 ed32c839e -> 5e56c3b6b


IGNITE-4299: Fixes for examples.


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

Branch: refs/heads/ignite-4285
Commit: 3e2ccfd30427ba0552eea8667c0129ae5ace9c0b
Parents: 56998e7
Author: Igor Sapego <is...@gridgain.com>
Authored: Fri Nov 25 14:26:54 2016 +0300
Committer: Igor Sapego <is...@gridgain.com>
Committed: Fri Nov 25 14:26:54 2016 +0300

----------------------------------------------------------------------
 .../platforms/cpp/examples/putget-example/src/putget_example.cpp   | 2 +-
 modules/platforms/cpp/examples/query-example/src/query_example.cpp | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/3e2ccfd3/modules/platforms/cpp/examples/putget-example/src/putget_example.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/examples/putget-example/src/putget_example.cpp b/modules/platforms/cpp/examples/putget-example/src/putget_example.cpp
index 0b57886..8bf9c8c 100644
--- a/modules/platforms/cpp/examples/putget-example/src/putget_example.cpp
+++ b/modules/platforms/cpp/examples/putget-example/src/putget_example.cpp
@@ -117,7 +117,7 @@ int main()
     }
 
     std::cout << std::endl;
-    std::cout << ">>> Example finished, press any key to exit ..." << std::endl;
+    std::cout << ">>> Example finished, press 'Enter' to exit ..." << std::endl;
     std::cout << std::endl;
 
     std::cin.get();

http://git-wip-us.apache.org/repos/asf/ignite/blob/3e2ccfd3/modules/platforms/cpp/examples/query-example/src/query_example.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/examples/query-example/src/query_example.cpp b/modules/platforms/cpp/examples/query-example/src/query_example.cpp
index 9bf3e52..8c2ca0c 100644
--- a/modules/platforms/cpp/examples/query-example/src/query_example.cpp
+++ b/modules/platforms/cpp/examples/query-example/src/query_example.cpp
@@ -450,7 +450,7 @@ int main()
     }
 
     std::cout << std::endl;
-    std::cout << ">>> Example finished, press any key to exit ..." << std::endl;
+    std::cout << ">>> Example finished, press 'Enter' to exit ..." << std::endl;
     std::cout << std::endl;
 
     std::cin.get();


[5/7] ignite git commit: ignite-4285

Posted by sb...@apache.org.
ignite-4285


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

Branch: refs/heads/ignite-4285
Commit: 5ead6d9c5b51dfb645fe2bcb19a81e042a511835
Parents: ed32c83
Author: sboikov <sb...@gridgain.com>
Authored: Wed Nov 30 15:03:45 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed Nov 30 16:55:12 2016 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheMapEntry.java     |  99 ++++++-
 .../distributed/GridDistributedCacheEntry.java  |  82 +-----
 .../cache/local/GridLocalCacheEntry.java        | 105 ++-----
 .../CacheSerializableTransactionsTest.java      | 288 ++++++++++++++++++-
 .../loadtests/hashmap/GridHashMapLoadTest.java  |   5 +
 5 files changed, 390 insertions(+), 189 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/5ead6d9c/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 0c30174..31baeda 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
@@ -79,9 +79,11 @@ import org.apache.ignite.lang.IgniteUuid;
 import org.jetbrains.annotations.Nullable;
 
 import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_EXPIRED;
+import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_LOCKED;
 import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_PUT;
 import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_READ;
 import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_REMOVED;
+import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_UNLOCKED;
 import static org.apache.ignite.internal.processors.cache.GridCacheOperation.DELETE;
 import static org.apache.ignite.internal.processors.dr.GridDrType.DR_NONE;
 
@@ -4316,7 +4318,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
     }
 
     /** {@inheritDoc} */
-    @Override public GridCacheBatchSwapEntry evictInBatchInternal(GridCacheVersion obsoleteVer)
+    @Override public final GridCacheBatchSwapEntry evictInBatchInternal(GridCacheVersion obsoleteVer)
         throws IgniteCheckedException {
         assert Thread.holdsLock(this);
         assert cctx.isSwapOrOffheapEnabled();
@@ -4383,7 +4385,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
      * @param filter Entry filter.
      * @return {@code True} if entry is visitable.
      */
-    public boolean visitable(CacheEntryPredicate[] filter) {
+    public final boolean visitable(CacheEntryPredicate[] filter) {
         boolean rmv = false;
 
         try {
@@ -4438,7 +4440,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
     }
 
     /** {@inheritDoc} */
-    @Override public boolean deleted() {
+    @Override public final boolean deleted() {
         if (!cctx.deferredDelete())
             return false;
 
@@ -4448,7 +4450,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
     }
 
     /** {@inheritDoc} */
-    @Override public synchronized boolean obsoleteOrDeleted() {
+    @Override public final synchronized boolean obsoleteOrDeleted() {
         return obsoleteVersionExtras() != null ||
             (cctx.deferredDelete() && (deletedUnlocked() || !hasValueUnlocked()));
     }
@@ -4457,7 +4459,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
      * @return {@code True} if deleted.
      */
     @SuppressWarnings("SimplifiableIfStatement")
-    protected boolean deletedUnlocked() {
+    protected final boolean deletedUnlocked() {
         assert Thread.holdsLock(this);
 
         if (!cctx.deferredDelete())
@@ -4469,7 +4471,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
     /**
      * @param deleted {@code True} if deleted.
      */
-    protected void deletedUnlocked(boolean deleted) {
+    protected final void deletedUnlocked(boolean deleted) {
         assert Thread.holdsLock(this);
         assert cctx.deferredDelete();
 
@@ -4506,7 +4508,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
     /**
      * @return MVCC.
      */
-    @Nullable protected GridCacheMvcc mvccExtras() {
+    @Nullable protected final GridCacheMvcc mvccExtras() {
         return extras != null ? extras.mvcc() : null;
     }
 
@@ -4514,7 +4516,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
      * @return All MVCC local and non near candidates.
      */
     @SuppressWarnings("ForLoopReplaceableByForEach")
-    @Nullable public synchronized List<GridCacheMvccCandidate> mvccAllLocal() {
+    @Nullable public final synchronized List<GridCacheMvccCandidate> mvccAllLocal() {
         GridCacheMvcc mvcc = extras != null ? extras.mvcc() : null;
 
         if (mvcc == null)
@@ -4540,21 +4542,22 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
     /**
      * @param mvcc MVCC.
      */
-    protected void mvccExtras(@Nullable GridCacheMvcc mvcc) {
+    protected final void mvccExtras(@Nullable GridCacheMvcc mvcc) {
         extras = (extras != null) ? extras.mvcc(mvcc) : mvcc != null ? new GridCacheMvccEntryExtras(mvcc) : null;
     }
 
     /**
      * @return Obsolete version.
      */
-    @Nullable protected GridCacheVersion obsoleteVersionExtras() {
+    @Nullable protected final GridCacheVersion obsoleteVersionExtras() {
         return extras != null ? extras.obsoleteVersion() : null;
     }
 
     /**
      * @param obsoleteVer Obsolete version.
+     * @param ext Extras.
      */
-    protected void obsoleteVersionExtras(@Nullable GridCacheVersion obsoleteVer, GridCacheObsoleteEntryExtras ext) {
+    private void obsoleteVersionExtras(@Nullable GridCacheVersion obsoleteVer, GridCacheObsoleteEntryExtras ext) {
         extras = (extras != null) ?
             extras.obsoleteVersion(obsoleteVer) :
             obsoleteVer != null ?
@@ -4563,6 +4566,80 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
     }
 
     /**
+     * @param prevOwners Previous owners.
+     * @param owners Current owners.
+     * @param val Entry value.
+     */
+    protected final void checkOwnerChanged(@Nullable CacheLockCandidates prevOwners,
+        @Nullable CacheLockCandidates owners,
+        CacheObject val) {
+        assert !Thread.holdsLock(this);
+
+        if (prevOwners != null && owners == null) {
+            cctx.mvcc().callback().onOwnerChanged(this, null);
+
+            if (cctx.events().isRecordable(EVT_CACHE_OBJECT_UNLOCKED)) {
+                boolean hasVal = hasValue();
+
+                GridCacheMvccCandidate cand = prevOwners.candidate(0);
+
+                cctx.events().addEvent(partition(),
+                    key,
+                    cand.nodeId(),
+                    cand,
+                    EVT_CACHE_OBJECT_UNLOCKED,
+                    val,
+                    hasVal,
+                    val,
+                    hasVal,
+                    null,
+                    null,
+                    null,
+                    true);
+            }
+        }
+
+        if (owners != null) {
+            for (int i = 0; i < owners.size(); i++) {
+                GridCacheMvccCandidate owner = owners.candidate(i);
+
+                boolean locked = prevOwners == null || !prevOwners.hasCandidate(owner.version());
+
+                if (locked) {
+                    cctx.mvcc().callback().onOwnerChanged(this, owner);
+
+                    if (owner.local())
+                        checkThreadChain(owner);
+
+                    if (cctx.events().isRecordable(EVT_CACHE_OBJECT_LOCKED)) {
+                        boolean hasVal = hasValue();
+
+                        // Event notification.
+                        cctx.events().addEvent(partition(),
+                            key,
+                            owner.nodeId(),
+                            owner,
+                            EVT_CACHE_OBJECT_LOCKED,
+                            val,
+                            hasVal,
+                            val,
+                            hasVal,
+                            null,
+                            null,
+                            null,
+                            true);
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * @param owner Starting candidate in the chain.
+     */
+    protected abstract void checkThreadChain(GridCacheMvccCandidate owner);
+
+    /**
      * Updates metrics.
      *
      * @param op Operation.

http://git-wip-us.apache.org/repos/asf/ignite/blob/5ead6d9c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheEntry.java
index 2a11c01..6f8d0b5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheEntry.java
@@ -688,86 +688,8 @@ public class GridDistributedCacheEntry extends GridCacheMapEntry {
         }
     }
 
-    /**
-     * @param prevOwners Previous owners.
-     * @param owners Current owners.
-     * @param val Entry value.
-     */
-    protected final void checkOwnerChanged(@Nullable CacheLockCandidates prevOwners,
-        @Nullable CacheLockCandidates owners,
-        CacheObject val) {
-        assert !Thread.holdsLock(this);
-
-        if (prevOwners != null) {
-            for (int i = 0; i < prevOwners.size(); i++) {
-                GridCacheMvccCandidate cand = prevOwners.candidate(i);
-
-                boolean unlocked = owners == null || !owners.hasCandidate(cand.version());
-
-                if (unlocked) {
-                    cctx.mvcc().callback().onOwnerChanged(this, null);
-
-                    if (cctx.events().isRecordable(EVT_CACHE_OBJECT_UNLOCKED)) {
-                        boolean hasVal = hasValue();
-
-                        cctx.events().addEvent(partition(),
-                            key,
-                            cand.nodeId(),
-                            cand,
-                            EVT_CACHE_OBJECT_UNLOCKED,
-                            val,
-                            hasVal,
-                            val, hasVal,
-                            null,
-                            null,
-                            null,
-                            true);
-                    }
-
-                    break;
-                }
-            }
-        }
-
-        if (owners != null) {
-            for (int i = 0; i < owners.size(); i++) {
-                GridCacheMvccCandidate owner = owners.candidate(i);
-
-                boolean locked = prevOwners == null || !prevOwners.hasCandidate(owner.version());
-
-                if (locked) {
-                    cctx.mvcc().callback().onOwnerChanged(this, owner);
-
-                    if (owner.local())
-                        checkThreadChain(owner);
-
-                    if (cctx.events().isRecordable(EVT_CACHE_OBJECT_LOCKED)) {
-                        boolean hasVal = hasValue();
-
-                        // Event notification.
-                        cctx.events().addEvent(partition(),
-                            key,
-                            owner.nodeId(),
-                            owner,
-                            EVT_CACHE_OBJECT_LOCKED,
-                            val,
-                            hasVal,
-                            val,
-                            hasVal,
-                            null,
-                            null,
-                            null,
-                            true);
-                    }
-                }
-            }
-        }
-    }
-
-    /**
-     * @param owner Starting candidate in the chain.
-     */
-    protected void checkThreadChain(GridCacheMvccCandidate owner) {
+    /** {@inheritDoc} */
+    @Override final protected void checkThreadChain(GridCacheMvccCandidate owner) {
         assert !Thread.holdsLock(this);
 
         assert owner != null;

http://git-wip-us.apache.org/repos/asf/ignite/blob/5ead6d9c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalCacheEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalCacheEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalCacheEntry.java
index 9d45084..b298819 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalCacheEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalCacheEntry.java
@@ -30,9 +30,6 @@ import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.jetbrains.annotations.Nullable;
 
-import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_LOCKED;
-import static org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_UNLOCKED;
-
 /**
  * Cache entry for local caches.
  */
@@ -89,6 +86,7 @@ public class GridLocalCacheEntry extends GridCacheMapEntry {
     ) throws GridCacheEntryRemovedException {
         assert serReadVer == null || serOrder != null;
 
+        CacheObject val;
         GridCacheMvccCandidate cand;
         CacheLockCandidates prev;
         CacheLockCandidates owner;
@@ -130,12 +128,14 @@ public class GridLocalCacheEntry extends GridCacheMapEntry {
 
             if (mvcc.isEmpty())
                 mvccExtras(null);
+
+            val = this.val;
         }
 
         if (cand != null && !cand.reentry())
             cctx.mvcc().addNext(cctx, cand);
 
-        checkOwnerChanged(prev, owner);
+        checkOwnerChanged(prev, owner, val);
 
         return cand;
     }
@@ -144,6 +144,7 @@ public class GridLocalCacheEntry extends GridCacheMapEntry {
      * @param cand Candidate.
      */
     void readyLocal(GridCacheMvccCandidate cand) {
+        CacheObject val;
         CacheLockCandidates prev = null;
         CacheLockCandidates owner = null;
 
@@ -158,9 +159,11 @@ public class GridLocalCacheEntry extends GridCacheMapEntry {
                 if (mvcc.isEmpty())
                     mvccExtras(null);
             }
+
+            val = this.val;
         }
 
-        checkOwnerChanged(prev, owner);
+        checkOwnerChanged(prev, owner, val);
     }
 
     /** {@inheritDoc} */
@@ -195,6 +198,7 @@ public class GridLocalCacheEntry extends GridCacheMapEntry {
      * Rechecks if lock should be reassigned.
      */
     public void recheck() {
+        CacheObject val;
         CacheLockCandidates prev = null;
         CacheLockCandidates owner = null;
 
@@ -209,88 +213,15 @@ public class GridLocalCacheEntry extends GridCacheMapEntry {
                 if (mvcc.isEmpty())
                     mvccExtras(null);
             }
-        }
-
-        checkOwnerChanged(prev, owner);
-    }
-
-    /**
-     * @param prevOwners Previous owners.
-     * @param owners Current owners.
-     */
-    private void checkOwnerChanged(@Nullable CacheLockCandidates prevOwners, @Nullable CacheLockCandidates owners) {
-        assert !Thread.holdsLock(this);
-
-        if (prevOwners != null) {
-            for (int i = 0; i < prevOwners.size(); i++) {
-                GridCacheMvccCandidate cand = prevOwners.candidate(i);
-
-                boolean unlocked = owners == null || !owners.hasCandidate(cand.version());
-
-                if (unlocked) {
-                    cctx.mvcc().callback().onOwnerChanged(this, null);
-
-                    if (cctx.events().isRecordable(EVT_CACHE_OBJECT_UNLOCKED)) {
-                        boolean hasVal = hasValue();
-
-                        cctx.events().addEvent(partition(),
-                            key,
-                            cand.nodeId(),
-                            cand,
-                            EVT_CACHE_OBJECT_UNLOCKED,
-                            val,
-                            hasVal,
-                            val,
-                            hasVal,
-                            null,
-                            null,
-                            null,
-                            true);
-                    }
 
-                    break;
-                }
-            }
+            val = this.val;
         }
 
-        if (owners != null) {
-            for (int i = 0; i < owners.size(); i++) {
-                GridCacheMvccCandidate owner = owners.candidate(i);
-
-                boolean locked = prevOwners == null || !prevOwners.hasCandidate(owner.version());
-
-                if (locked) {
-                    cctx.mvcc().callback().onOwnerChanged(this, owner);
-
-                    checkThreadChain(owner);
-
-                    if (cctx.events().isRecordable(EVT_CACHE_OBJECT_LOCKED)) {
-                        boolean hasVal = hasValue();
-
-                        // Event notification.
-                        cctx.events().addEvent(partition(),
-                            key,
-                            owner.nodeId(),
-                            owner,
-                            EVT_CACHE_OBJECT_LOCKED,
-                            val,
-                            hasVal,
-                            val,
-                            hasVal,
-                            null,
-                            null,
-                            null,
-                            true);
-                    }
-                }
-            }
-        }
+        checkOwnerChanged(prev, owner, val);
     }
 
-    /**
-     * @param owner Starting candidate in the chain.
-     */
-    private void checkThreadChain(GridCacheMvccCandidate owner) {
+    /** {@inheritDoc} */
+    @Override protected void checkThreadChain(GridCacheMvccCandidate owner) {
         assert !Thread.holdsLock(this);
 
         assert owner != null;
@@ -340,6 +271,7 @@ public class GridLocalCacheEntry extends GridCacheMapEntry {
      * @param threadId Thread ID.
      */
     private void releaseLocal(long threadId) {
+        CacheObject val;
         CacheLockCandidates prev = null;
         CacheLockCandidates owner = null;
 
@@ -356,6 +288,8 @@ public class GridLocalCacheEntry extends GridCacheMapEntry {
                 else
                     owner = mvcc.allOwners();
             }
+
+            val = this.val;
         }
 
         if (prev != null) {
@@ -366,11 +300,12 @@ public class GridLocalCacheEntry extends GridCacheMapEntry {
             }
         }
 
-        checkOwnerChanged(prev, owner);
+        checkOwnerChanged(prev, owner, val);
     }
 
     /** {@inheritDoc} */
     @Override public boolean removeLock(GridCacheVersion ver) throws GridCacheEntryRemovedException {
+        CacheObject val;
         CacheLockCandidates prev = null;
         CacheLockCandidates owner = null;
 
@@ -396,12 +331,14 @@ public class GridLocalCacheEntry extends GridCacheMapEntry {
                 else
                     owner = mvcc.allOwners();
             }
+
+            val = this.val;
         }
 
         if (doomed != null)
             checkThreadChain(doomed);
 
-        checkOwnerChanged(prev, owner);
+        checkOwnerChanged(prev, owner, val);
 
         return doomed != null;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/5ead6d9c/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheSerializableTransactionsTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheSerializableTransactionsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheSerializableTransactionsTest.java
index 4986c8a..91e069a 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheSerializableTransactionsTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheSerializableTransactionsTest.java
@@ -925,6 +925,71 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
     }
 
     /**
+     * @throws Exception If failed.
+     */
+    public void testTxConflictReadWrite3() throws Exception {
+        Ignite ignite0 = ignite(0);
+
+        final IgniteTransactions txs = ignite0.transactions();
+
+        for (CacheConfiguration<Integer, Integer> ccfg : cacheConfigurations()) {
+            logCacheInfo(ccfg);
+
+            IgniteCache<Integer, Integer> cache = ignite0.createCache(ccfg);
+
+            List<Integer> readKeys = new ArrayList<>();
+            List<Integer> writeKeys = new ArrayList<>();
+
+            readKeys.add(primaryKey(cache));
+            writeKeys.add(primaryKeys(cache, 1, 1000_0000).get(0));
+
+            if (ccfg.getBackups() > 0) {
+                readKeys.add(backupKey(cache));
+                writeKeys.add(backupKeys(cache, 1, 1000_0000).get(0));
+            }
+
+            if (ccfg.getCacheMode() == PARTITIONED) {
+                readKeys.add(nearKey(cache));
+                writeKeys.add(nearKeys(cache, 1, 1000_0000).get(0));
+            }
+
+            try {
+                for (Integer readKey : readKeys) {
+                    for (Integer writeKey : writeKeys) {
+                        try {
+                            try (Transaction tx = txs.txStart(OPTIMISTIC, SERIALIZABLE)) {
+                                cache.get(readKey);
+
+                                cache.put(writeKey, writeKey);
+
+                                updateKey(cache, readKey, 0);
+
+                                tx.commit();
+                            }
+
+                            fail();
+                        }
+                        catch (TransactionOptimisticException e) {
+                            // Expected exception.
+                        }
+
+                        try (Transaction tx = txs.txStart(OPTIMISTIC, SERIALIZABLE)) {
+                            cache.get(readKey);
+
+                            cache.put(writeKey, writeKey);
+
+                            tx.commit();
+                        }
+                    }
+                }
+            }
+            finally {
+                destroyCache(ccfg.getName());
+            }
+        }
+    }
+
+    /**
      * @throws Exception If failed
      */
     public void testTxConflictGetAndPut1() throws Exception {
@@ -2471,53 +2536,70 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
 
             ignite0.createCache(ccfg);
 
+            CacheConfiguration<Integer, Integer> readCacheCcfg = new CacheConfiguration<>(ccfg);
+
+            readCacheCcfg.setName(ccfg.getName() + "-read");
+
+            ignite0.createCache(readCacheCcfg);
+
             try {
-                checkNoReadLockConflict(ignite(0), ccfg.getName(), entry, putKey);
+                checkNoReadLockConflict(ignite(0), ccfg.getName(), ccfg.getName(), entry, putKey);
+
+                checkNoReadLockConflict(ignite(1), ccfg.getName(), ccfg.getName(), entry, putKey);
+
+                checkNoReadLockConflict(ignite(SRVS), ccfg.getName(), ccfg.getName(), entry, putKey);
+
+                checkNoReadLockConflict(ignite(0), readCacheCcfg.getName(), ccfg.getName(), entry, putKey);
 
-                checkNoReadLockConflict(ignite(1), ccfg.getName(), entry, putKey);
+                checkNoReadLockConflict(ignite(1), readCacheCcfg.getName(), ccfg.getName(), entry, putKey);
 
-                checkNoReadLockConflict(ignite(SRVS), ccfg.getName(), entry, putKey);
+                checkNoReadLockConflict(ignite(SRVS), readCacheCcfg.getName(), ccfg.getName(), entry, putKey);
             }
             finally {
                 destroyCache(ccfg.getName());
+
+                destroyCache(readCacheCcfg.getName());
             }
         }
     }
 
     /**
      * @param ignite Node.
-     * @param cacheName Cache name.
+     * @param readCacheName Cache name for get.
+     * @param writeCacheName Cache name for put.
      * @param entry If {@code true} then uses 'getEntry' to read value, otherwise uses 'get'.
      * @param putKey Write key counter.
      * @throws Exception If failed.
      */
     private void checkNoReadLockConflict(final Ignite ignite,
-        String cacheName,
+        String readCacheName,
+        String writeCacheName,
         final boolean entry,
         final AtomicInteger putKey) throws Exception
     {
         final int THREADS = 64;
 
-        final IgniteCache<Integer, Integer> cache = ignite.cache(cacheName);
+        final IgniteCache<Integer, Integer> readCache = ignite.cache(readCacheName);
+        final IgniteCache<Integer, Integer> writeCache = ignite.cache(writeCacheName);
 
-        List<Integer> readKeys = testKeys(cache);
+        List<Integer> readKeys = testKeys(readCache);
 
         for (final Integer readKey : readKeys) {
             final CyclicBarrier barrier = new CyclicBarrier(THREADS);
 
-            cache.put(readKey, Integer.MIN_VALUE);
+            readCache.put(readKey, Integer.MIN_VALUE);
 
             GridTestUtils.runMultiThreaded(new Callable<Void>() {
                 @Override public Void call() throws Exception {
                     try (Transaction tx = ignite.transactions().txStart(OPTIMISTIC, SERIALIZABLE)) {
                         if (entry)
-                            cache.get(readKey);
+                            readCache.get(readKey);
                         else
-                            cache.getEntry(readKey);
+                            readCache.getEntry(readKey);
 
                         barrier.await();
 
-                        cache.put(putKey.incrementAndGet(), 0);
+                        writeCache.put(putKey.incrementAndGet(), 0);
 
                         tx.commit();
                     }
@@ -2526,11 +2608,11 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
                 }
             }, THREADS, "test-thread");
 
-            assertEquals((Integer)Integer.MIN_VALUE, cache.get(readKey));
+            assertEquals((Integer)Integer.MIN_VALUE, readCache.get(readKey));
 
-            cache.put(readKey, readKey);
+            readCache.put(readKey, readKey);
 
-            assertEquals(readKey, cache.get(readKey));
+            assertEquals(readKey, readCache.get(readKey));
         }
     }
 
@@ -2774,6 +2856,184 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
     /**
      * @throws Exception If failed.
      */
+    public void testReadWriteAccountTx() throws Exception {
+        final CacheConfiguration<Integer, Integer> ccfg = cacheConfiguration(PARTITIONED,
+            FULL_SYNC,
+            1,
+            false,
+            false);
+
+        ignite(0).createCache(ccfg);
+
+        try {
+            final int ACCOUNTS = 50;
+            final int VAL_PER_ACCOUNT = 1000;
+
+            IgniteCache<Integer, Account> cache0 = ignite(0).cache(ccfg.getName());
+
+            final Set<Integer> keys = new HashSet<>();
+
+            for (int i = 0; i < ACCOUNTS; i++) {
+                cache0.put(i, new Account(VAL_PER_ACCOUNT));
+
+                keys.add(i);
+            }
+
+            final List<Ignite> clients = clients();
+
+            final AtomicBoolean stop = new AtomicBoolean();
+
+            final AtomicInteger idx = new AtomicInteger();
+
+            IgniteInternalFuture<?> readFut = GridTestUtils.runMultiThreadedAsync(new Callable<Void>() {
+                @Override public Void call() throws Exception {
+                    try {
+                        int threadIdx = idx.getAndIncrement();
+
+                        int nodeIdx = threadIdx % (SRVS + CLIENTS);
+
+                        Ignite node = ignite(nodeIdx);
+
+                        IgniteCache<Integer, Account> cache = node.cache(ccfg.getName());
+
+                        IgniteTransactions txs = node.transactions();
+
+                        Integer putKey = ACCOUNTS + threadIdx;
+
+                        while (!stop.get()) {
+                            int sum;
+
+                            while (true) {
+                                sum = 0;
+
+                                try (Transaction tx = txs.txStart(OPTIMISTIC, SERIALIZABLE)) {
+                                    Map<Integer, Account> data = cache.getAll(keys);
+
+                                    for (int i = 0; i < ACCOUNTS; i++) {
+                                        Account account = data.get(i);
+
+                                        assertNotNull(account);
+
+                                        sum += account.value();
+                                    }
+
+                                    cache.put(putKey, new Account(sum));
+
+                                    tx.commit();
+                                }
+                                catch (TransactionOptimisticException e) {
+                                    continue;
+                                }
+
+                                break;
+                            }
+
+                            assertEquals(ACCOUNTS * VAL_PER_ACCOUNT, sum);
+                        }
+
+                        return null;
+                    }
+                    catch (Throwable e) {
+                        stop.set(true);
+
+                        log.error("Unexpected error: " + e);
+
+                        throw e;
+                    }
+                }
+            }, (SRVS + CLIENTS) * 2, "update-thread");
+
+            IgniteInternalFuture<?> updateFut = GridTestUtils.runMultiThreadedAsync(new Callable<Void>() {
+                @Override public Void call() throws Exception {
+                    try {
+                        int nodeIdx = idx.getAndIncrement() % clients.size();
+
+                        Ignite node = clients.get(nodeIdx);
+
+                        IgniteCache<Integer, Account> cache = node.cache(ccfg.getName());
+
+                        IgniteTransactions txs = node.transactions();
+
+                        ThreadLocalRandom rnd = ThreadLocalRandom.current();
+
+                        while (!stop.get()) {
+                            int id1 = rnd.nextInt(ACCOUNTS);
+
+                            int id2 = rnd.nextInt(ACCOUNTS);
+
+                            while (id2 == id1)
+                                id2 = rnd.nextInt(ACCOUNTS);
+
+                            while (true) {
+                                try (Transaction tx = txs.txStart(OPTIMISTIC, SERIALIZABLE)) {
+                                    Account a1 = cache.get(id1);
+                                    Account a2 = cache.get(id2);
+
+                                    assertNotNull(a1);
+                                    assertNotNull(a2);
+
+                                    if (a1.value() > 0) {
+                                        a1 = new Account(a1.value() - 1);
+                                        a2 = new Account(a2.value() + 1);
+                                    }
+
+                                    cache.put(id1, a1);
+                                    cache.put(id2, a2);
+
+                                    tx.commit();
+                                }
+                                catch (TransactionOptimisticException e) {
+                                    continue;
+                                }
+
+                                break;
+                            }
+                        }
+
+                        return null;
+                    }
+                    catch (Throwable e) {
+                        stop.set(true);
+
+                        log.error("Unexpected error: " + e);
+
+                        throw e;
+                    }
+                }
+            }, 2, "update-thread");
+
+            try {
+                U.sleep(15_000);
+            }
+            finally {
+                stop.set(true);
+            }
+
+            readFut.get();
+            updateFut.get();
+            int sum = 0;
+
+            for (int i = 0; i < ACCOUNTS; i++) {
+                Account a = cache0.get(i);
+
+                assertNotNull(a);
+                assertTrue(a.value() >= 0);
+
+                log.info("Account: " + a.value());
+
+                sum += a.value();
+            }
+
+            assertEquals(ACCOUNTS * VAL_PER_ACCOUNT, sum);
+        }
+        finally {
+            ignite(0).destroyCache(ccfg.getName());
+        }
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
     public void testNearCacheReaderUpdate() throws Exception {
         Ignite ignite0 = ignite(0);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/5ead6d9c/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridHashMapLoadTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridHashMapLoadTest.java b/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridHashMapLoadTest.java
index 13f29fe..5c12f84 100644
--- a/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridHashMapLoadTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/loadtests/hashmap/GridHashMapLoadTest.java
@@ -21,6 +21,7 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 import org.apache.ignite.internal.processors.cache.GridCacheMapEntry;
+import org.apache.ignite.internal.processors.cache.GridCacheMvccCandidate;
 import org.apache.ignite.internal.processors.cache.transactions.IgniteInternalTx;
 import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
 import org.apache.ignite.testframework.junits.GridTestKernalContext;
@@ -90,6 +91,10 @@ public class GridHashMapLoadTest extends GridCommonAbstractTest {
                     return false;
                 }
 
+                @Override protected void checkThreadChain(GridCacheMvccCandidate owner) {
+                    // No-op.
+                }
+
                 @Override public void txUnlock(IgniteInternalTx tx) {
                     // No-op.
                 }


[4/7] ignite git commit: ignite-4332 Usage of cache.getEntry inside GridCacheQueryManager.runQuery causes to remote operations

Posted by sb...@apache.org.
ignite-4332 Usage of cache.getEntry inside GridCacheQueryManager.runQuery causes to remote operations


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

Branch: refs/heads/ignite-4285
Commit: c06e4017771603df7118974758d3d6b9cadc41b5
Parents: 1a2de51
Author: Eduard Shangareev <es...@gridgain.com>
Authored: Wed Nov 30 14:34:47 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed Nov 30 14:34:47 2016 +0300

----------------------------------------------------------------------
 .../cache/query/GridCacheQueryManager.java        | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/c06e4017/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
index ab8bd63..d4decb4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/GridCacheQueryManager.java
@@ -57,6 +57,7 @@ import org.apache.ignite.internal.IgniteInternalFuture;
 import org.apache.ignite.internal.IgniteKernal;
 import org.apache.ignite.internal.managers.eventstorage.GridLocalEventListener;
 import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
+import org.apache.ignite.internal.processors.cache.CacheEntryImpl;
 import org.apache.ignite.internal.processors.cache.CacheMetricsImpl;
 import org.apache.ignite.internal.processors.cache.CacheObject;
 import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
@@ -1560,9 +1561,12 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
                         metrics.addGetTimeNanos(System.nanoTime() - start);
                     }
 
+                    K key0 = null;
+                    V val0 = null;
+
                     if (readEvt) {
-                        K key0 = (K)cctx.unwrapBinaryIfNeeded(key, qry.keepBinary());
-                        V val0 = (V)cctx.unwrapBinaryIfNeeded(val, qry.keepBinary());
+                        key0 = (K)cctx.unwrapBinaryIfNeeded(key, qry.keepBinary());
+                        val0 = (V)cctx.unwrapBinaryIfNeeded(val, qry.keepBinary());
 
                         switch (type) {
                             case SQL:
@@ -1631,12 +1635,12 @@ public abstract class GridCacheQueryManager<K, V> extends GridCacheManagerAdapte
                     }
 
                     if (rdc != null || trans != null) {
-                        Cache.Entry<K, V> entry;
+                        if (key0 == null)
+                            key0 = (K)cctx.unwrapBinaryIfNeeded(key, qry.keepBinary());
+                        if (val0 == null)
+                            val0 = (V)cctx.unwrapBinaryIfNeeded(val, qry.keepBinary());
 
-                        if (qry.keepBinary())
-                            entry = cache.<K, V>keepBinary().getEntry(key);
-                        else
-                            entry = cache.<K, V>getEntry(key);
+                        Cache.Entry<K, V> entry = new CacheEntryImpl(key0, val0);
 
                         // Reduce.
                         if (rdc != null) {


[6/7] ignite git commit: Merge remote-tracking branch 'remotes/community/ignite-1.7.4' into ignite-4285

Posted by sb...@apache.org.
Merge remote-tracking branch 'remotes/community/ignite-1.7.4' into ignite-4285


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

Branch: refs/heads/ignite-4285
Commit: 7435d1d053e13819271ab77b49f0eee029523b53
Parents: 5ead6d9 c06e401
Author: sboikov <sb...@gridgain.com>
Authored: Wed Nov 30 16:57:02 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed Nov 30 16:57:02 2016 +0300

----------------------------------------------------------------------
 .../GridNearAtomicSingleUpdateInvokeRequest.java  |  5 ++++-
 .../cache/query/GridCacheQueryManager.java        | 18 +++++++++++-------
 .../putget-example/src/putget_example.cpp         |  2 +-
 .../examples/query-example/src/query_example.cpp  |  2 +-
 4 files changed, 17 insertions(+), 10 deletions(-)
----------------------------------------------------------------------



[3/7] ignite git commit: IGNITE-4305 marshalling fix

Posted by sb...@apache.org.
IGNITE-4305 marshalling fix


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

Branch: refs/heads/ignite-4285
Commit: 1a2de51f5807a91ce0d5dff28f24ed5bf7abebbc
Parents: 6fbaef4
Author: Konstantin Dudkov <kd...@ya.ru>
Authored: Mon Nov 28 12:59:02 2016 +0300
Committer: Konstantin Dudkov <kd...@ya.ru>
Committed: Tue Nov 29 11:53:07 2016 +0300

----------------------------------------------------------------------
 .../dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java       | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/1a2de51f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java
index 238db8b..df9e384 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java
@@ -203,7 +203,8 @@ public class GridNearAtomicSingleUpdateInvokeRequest extends GridNearAtomicSingl
             addDepInfo = true;
 
         if (entryProcessor != null && entryProcessorBytes == null) {
-            prepareObject(entryProcessor, cctx);
+            if (addDepInfo)
+                prepareObject(entryProcessor, cctx);
             entryProcessorBytes = CU.marshal(cctx, entryProcessor);
         }
 


[7/7] ignite git commit: ignite-4285

Posted by sb...@apache.org.
ignite-4285


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

Branch: refs/heads/ignite-4285
Commit: 5e56c3b6b022d50748b5c323fd9ca4c220a6f21c
Parents: 7435d1d
Author: sboikov <sb...@gridgain.com>
Authored: Wed Nov 30 17:41:58 2016 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed Nov 30 17:41:58 2016 +0300

----------------------------------------------------------------------
 .../internal/processors/cache/CacheLockCandidates.java | 11 +++++++++++
 .../processors/cache/CacheLockCandidatesList.java      |  4 +++-
 .../internal/processors/cache/GridCacheMvcc.java       | 13 +++++++++----
 .../cache/distributed/GridDistributedCacheEntry.java   |  6 +++---
 .../cache/distributed/near/GridNearCacheEntry.java     | 10 +++++-----
 .../distributed/near/GridNearTransactionalCache.java   |  4 +---
 .../processors/cache/local/GridLocalCacheEntry.java    | 11 +++++++----
 7 files changed, 39 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/5e56c3b6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLockCandidates.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLockCandidates.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLockCandidates.java
index d139262..9cf16f4 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLockCandidates.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLockCandidates.java
@@ -23,9 +23,20 @@ import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
  *
  */
 public interface CacheLockCandidates {
+    /**
+     * @param idx Candidate index.
+     * @return Candidate.
+     */
     public GridCacheMvccCandidate candidate(int idx);
 
+    /**
+     * @return Number of candidates.
+     */
     public int size();
 
+    /**
+     * @param ver Candidate version.
+     * @return {@code True} if contains candidate with given version.
+     */
     public boolean hasCandidate(GridCacheVersion ver);
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/5e56c3b6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLockCandidatesList.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLockCandidatesList.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLockCandidatesList.java
index f127d43..e026bce 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLockCandidatesList.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheLockCandidatesList.java
@@ -35,13 +35,15 @@ class CacheLockCandidatesList implements CacheLockCandidates {
      * @param cand Candidate to add.
      */
     void add(GridCacheMvccCandidate cand) {
-        assert !hasCandidate(cand.version());
+        assert !hasCandidate(cand.version()) : cand;
 
         list.add(cand);
     }
 
     /** {@inheritDoc} */
     @Override public GridCacheMvccCandidate candidate(int idx) {
+        assert idx < list.size() : idx;
+
         return list.get(idx);
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/5e56c3b6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvcc.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvcc.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvcc.java
index 0ef3f6f..498584c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvcc.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMvcc.java
@@ -150,6 +150,7 @@ public final class GridCacheMvcc {
     @Nullable public CacheLockCandidates localOwners() {
         if (locs != null) {
             assert !locs.isEmpty();
+
             CacheLockCandidates owners = null;
 
             GridCacheMvccCandidate first = locs.getFirst();
@@ -160,15 +161,19 @@ public final class GridCacheMvcc {
                         assert cand.read() : this;
 
                         if (owners != null) {
+                            CacheLockCandidatesList list;
+
                             if (owners.size() == 1) {
                                 GridCacheMvccCandidate owner = owners.candidate(0);
 
-                                owners = new CacheLockCandidatesList();
+                                owners = list = new CacheLockCandidatesList();
 
                                 ((CacheLockCandidatesList)owners).add(owner);
                             }
+                            else
+                                list = ((CacheLockCandidatesList)owners);
 
-                            ((CacheLockCandidatesList)owners).add(cand);
+                            list.add(cand);
                         }
                         else
                             owners = cand;
@@ -1062,9 +1067,9 @@ public final class GridCacheMvcc {
 
                         return;
                     }
-                }
 
-                first = false;
+                    first = false;
+                }
 
                 if (cand.owner())
                     return;

http://git-wip-us.apache.org/repos/asf/ignite/blob/5e56c3b6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheEntry.java
index 6f8d0b5..3d55f31 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/GridDistributedCacheEntry.java
@@ -67,7 +67,7 @@ public class GridDistributedCacheEntry extends GridCacheMapEntry {
     /**
      *
      */
-    protected void refreshRemotes() {
+    private void refreshRemotes() {
         GridCacheMvcc mvcc = mvccExtras();
 
         rmts = mvcc == null ? Collections.<GridCacheMvccCandidate>emptyList() : mvcc.remoteCandidates();
@@ -377,8 +377,6 @@ public class GridDistributedCacheEntry extends GridCacheMapEntry {
 
                 mvcc.remove(doomed.version());
 
-                owner = mvcc.allOwners();
-
                 boolean emptyAfter = mvcc.isEmpty();
 
                 if (!doomed.local())
@@ -388,6 +386,8 @@ public class GridDistributedCacheEntry extends GridCacheMapEntry {
 
                 if (emptyAfter)
                     mvccExtras(null);
+                else
+                    owner = mvcc.allOwners();
             }
 
             val = this.val;

http://git-wip-us.apache.org/repos/asf/ignite/blob/5e56c3b6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheEntry.java
index cad6f90..30fc213 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearCacheEntry.java
@@ -487,7 +487,7 @@ public class GridNearCacheEntry extends GridDistributedCacheEntry {
         boolean read)
         throws GridCacheEntryRemovedException {
         CacheLockCandidates prev;
-        CacheLockCandidates owner;
+        CacheLockCandidates owner = null;
         GridCacheMvccCandidate cand;
 
         CacheObject val;
@@ -531,8 +531,6 @@ public class GridNearCacheEntry extends GridDistributedCacheEntry {
 
             cand.topologyVersion(topVer);
 
-            owner = mvcc.allOwners();
-
             boolean emptyAfter = mvcc.isEmpty();
 
             checkCallbacks(emptyBefore, emptyAfter);
@@ -541,6 +539,8 @@ public class GridNearCacheEntry extends GridDistributedCacheEntry {
 
             if (emptyAfter)
                 mvccExtras(null);
+            else
+                owner = mvcc.allOwners();
         }
 
         // This call must be outside of synchronization.
@@ -652,7 +652,7 @@ public class GridNearCacheEntry extends GridDistributedCacheEntry {
     /**
      * @throws GridCacheEntryRemovedException If entry was removed.
      */
-    public synchronized void reserveEviction() throws GridCacheEntryRemovedException {
+    synchronized void reserveEviction() throws GridCacheEntryRemovedException {
         checkObsolete();
 
         evictReservations++;
@@ -661,7 +661,7 @@ public class GridNearCacheEntry extends GridDistributedCacheEntry {
     /**
      *
      */
-    public synchronized void releaseEviction() {
+    synchronized void releaseEviction() {
         assert evictReservations > 0 : this;
         assert !obsolete() : this;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/5e56c3b6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
index d61915b..7ac3295 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearTransactionalCache.java
@@ -576,9 +576,7 @@ public class GridNearTransactionalCache<K, V> extends GridNearCacheAdapter<K, V>
                                     if (!primary.isLocal()) {
                                         assert req != null;
 
-                                        req.addKey(
-                                            entry.key(),
-                                            ctx);
+                                        req.addKey(entry.key(), ctx);
                                     }
                                     else
                                         locKeys.add(cacheKey);

http://git-wip-us.apache.org/repos/asf/ignite/blob/5e56c3b6/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalCacheEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalCacheEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalCacheEntry.java
index b298819..bc61333 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalCacheEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/local/GridLocalCacheEntry.java
@@ -89,7 +89,7 @@ public class GridLocalCacheEntry extends GridCacheMapEntry {
         CacheObject val;
         GridCacheMvccCandidate cand;
         CacheLockCandidates prev;
-        CacheLockCandidates owner;
+        CacheLockCandidates owner = null;
 
         synchronized (this) {
             checkObsolete();
@@ -124,10 +124,10 @@ public class GridLocalCacheEntry extends GridCacheMapEntry {
                 read
             );
 
-            owner = mvcc.localOwners();
-
             if (mvcc.isEmpty())
                 mvccExtras(null);
+            else
+                owner = mvcc.localOwners();
 
             val = this.val;
         }
@@ -296,7 +296,10 @@ public class GridLocalCacheEntry extends GridCacheMapEntry {
             for (int i = 0; i < prev.size(); i++) {
                 GridCacheMvccCandidate cand = prev.candidate(i);
 
-                checkThreadChain(cand);
+                boolean unlocked = owner == null || !owner.hasCandidate(cand.version());
+
+                if (unlocked)
+                    checkThreadChain(cand);
             }
         }
 


[2/7] ignite git commit: IGNITE-4305 marshalling fix in GridNearAtomicSingleUpdateInvokeRequest

Posted by sb...@apache.org.
IGNITE-4305 marshalling fix in GridNearAtomicSingleUpdateInvokeRequest


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

Branch: refs/heads/ignite-4285
Commit: 6fbaef45af8f40062a95058df7ec0984c99035b9
Parents: 3e2ccfd
Author: Konstantin Dudkov <kd...@ya.ru>
Authored: Fri Nov 25 13:58:58 2016 +0300
Committer: Konstantin Dudkov <kd...@ya.ru>
Committed: Fri Nov 25 16:32:52 2016 +0300

----------------------------------------------------------------------
 .../dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java      | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/6fbaef45/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java
index 42b51d6..238db8b 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridNearAtomicSingleUpdateInvokeRequest.java
@@ -202,8 +202,10 @@ public class GridNearAtomicSingleUpdateInvokeRequest extends GridNearAtomicSingl
         if (!addDepInfo && ctx.deploymentEnabled())
             addDepInfo = true;
 
-        if (entryProcessor != null && entryProcessorBytes == null)
+        if (entryProcessor != null && entryProcessorBytes == null) {
+            prepareObject(entryProcessor, cctx);
             entryProcessorBytes = CU.marshal(cctx, entryProcessor);
+        }
 
         if (invokeArgsBytes == null)
             invokeArgsBytes = marshalInvokeArguments(invokeArgs, cctx);