Return-Path: X-Original-To: apmail-ignite-commits-archive@minotaur.apache.org Delivered-To: apmail-ignite-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id F38C618C20 for ; Wed, 13 May 2015 09:52:10 +0000 (UTC) Received: (qmail 90944 invoked by uid 500); 13 May 2015 09:52:10 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 90912 invoked by uid 500); 13 May 2015 09:52:10 -0000 Mailing-List: contact commits-help@ignite.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.incubator.apache.org Delivered-To: mailing list commits@ignite.incubator.apache.org Received: (qmail 90903 invoked by uid 99); 13 May 2015 09:52:10 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 May 2015 09:52:10 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 6FBD1182369 for ; Wed, 13 May 2015 09:52:10 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.771 X-Spam-Level: * X-Spam-Status: No, score=1.771 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, T_RP_MATCHES_RCVD=-0.01, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id a42IRco-10PH for ; Wed, 13 May 2015 09:52:08 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with SMTP id B944343DB7 for ; Wed, 13 May 2015 09:52:07 +0000 (UTC) Received: (qmail 90899 invoked by uid 99); 13 May 2015 09:52:07 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 May 2015 09:52:07 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 2E656E0329; Wed, 13 May 2015 09:52:07 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sboikov@apache.org To: commits@ignite.incubator.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: incubator-ignite git commit: # ignite-876 Date: Wed, 13 May 2015 09:52:07 +0000 (UTC) Repository: incubator-ignite Updated Branches: refs/heads/ignite-876 [created] b16fd589c # ignite-876 Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/b16fd589 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/b16fd589 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/b16fd589 Branch: refs/heads/ignite-876 Commit: b16fd589c7ab493f60ffb77a9fa2930fbedaabd5 Parents: bbc21a6 Author: sboikov Authored: Wed May 13 12:51:34 2015 +0300 Committer: sboikov Committed: Wed May 13 12:51:34 2015 +0300 ---------------------------------------------------------------------- .../processors/cache/GridCacheMapEntry.java | 149 ++++++++++++------- 1 file changed, 96 insertions(+), 53 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b16fd589/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 71858d1..bfff2d6 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 @@ -488,34 +488,34 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { if (cctx.isSwapOrOffheapEnabled() && !deletedUnlocked() && hasValueUnlocked() && !detached()) { assert Thread.holdsLock(this); - long expireTime = expireTimeExtras(); - - if (expireTime > 0 && U.currentTimeMillis() >= expireTime) { // Don't swap entry if it's expired. - // Entry might have been updated. - if (cctx.offheapTiered()) { - cctx.swap().removeOffheap(key); + if (cctx.offheapTiered()) { + if (val == null && valPtr != 0) { + if (log.isDebugEnabled()) + log.debug("Value did not change, skip write swap entry: " + this); - valPtr = 0; + if (cctx.swap().offheapEvictionEnabled()) + cctx.swap().enableOffheapEviction(key()); } return; } - if (val == null && cctx.offheapTiered() && valPtr != 0) { - if (log.isDebugEnabled()) - log.debug("Value did not change, skip write swap entry: " + this); - - if (cctx.swap().offheapEvictionEnabled()) - cctx.swap().enableOffheapEviction(key()); + long expireTime = expireTimeExtras(); + if (expireTime > 0 && U.currentTimeMillis() >= expireTime) // Don't swap entry if it's expired. return; - } IgniteUuid valClsLdrId = null; + IgniteUuid keyClsLdrId = null; - if (val != null) { - valClsLdrId = cctx.deploy().getClassLoaderId( - val.value(cctx.cacheObjectContext(), false).getClass().getClassLoader()); + if (cctx.kernalContext().config().isPeerClassLoadingEnabled()) { + if (val != null) { + valClsLdrId = cctx.deploy().getClassLoaderId( + U.detectObjectClassLoader(val.value(cctx.cacheObjectContext(), false))); + } + + keyClsLdrId = cctx.deploy().getClassLoaderId( + U.detectObjectClassLoader(key.value(cctx.cacheObjectContext(), false))); } IgniteBiTuple valBytes = valueBytes0(); @@ -526,7 +526,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { ver, ttlExtras(), expireTime, - cctx.deploy().getClassLoaderId(U.detectObjectClassLoader(key.value(cctx.cacheObjectContext(), false))), + keyClsLdrId, valClsLdrId); if (log.isDebugEnabled()) @@ -816,13 +816,10 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { // Update indexes before actual write to entry. updateIndex(ret, expTime, nextVer, prevVal); - boolean hadValPtr = valPtr != 0; - // Don't change version for read-through. update(ret, expTime, ttl, nextVer); - if (hadValPtr && cctx.offheapTiered()) - cctx.swap().removeOffheap(key); + updateOffheap(ret, expTime, ttl); if (cctx.deferredDelete() && deletedUnlocked() && !isInternal() && !detached()) deletedUnlocked(false); @@ -903,6 +900,8 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { update(ret, expTime, ttl, nextVer); + updateOffheap(ret, expTime, ttl); + touch = true; // If value was set - return, otherwise try again. @@ -1037,6 +1036,8 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { update(val, expireTime, ttl, newVer); + updateOffheap(val, expireTime, ttl); + drReplicate(drType, val, newVer); recordNodeId(affNodeId, topVer); @@ -1164,15 +1165,10 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { // can be updated without actually holding entry lock. clearIndex(old); - boolean hadValPtr = valPtr != 0; - update(null, 0, 0, newVer); - if (cctx.offheapTiered() && hadValPtr) { - boolean rmv = cctx.swap().removeOffheap(key); - - assert rmv; - } + if (cctx.offheapTiered()) + cctx.swap().removeOffheap(key); if (cctx.deferredDelete() && !detached() && !isInternal()) { if (!deletedUnlocked()) { @@ -1351,6 +1347,8 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { clearIndex(null); update(old, expireTime, ttl, ver); + + updateOffheap(old, expireTime, ttl); } // Apply metrics. @@ -1495,6 +1493,8 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { update(updated, expireTime, ttl, ver); + updateOffheap(updated, expireTime, ttl); + if (evt) { CacheObject evtOld = null; @@ -1521,19 +1521,14 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { // Must persist inside synchronization in non-tx mode. cctx.store().remove(null, keyValue(false)); - boolean hasValPtr = valPtr != 0; - // Update index inside synchronization since it can be updated // in load methods without actually holding entry lock. clearIndex(old); update(null, CU.TTL_ETERNAL, CU.EXPIRE_TIME_ETERNAL, ver); - if (cctx.offheapTiered() && hasValPtr) { - boolean rmv = cctx.swap().removeOffheap(key); - - assert rmv; - } + if (cctx.offheapTiered()) + cctx.swap().removeOffheap(key); if (evt) { CacheObject evtOld = null; @@ -1841,6 +1836,8 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { update(oldVal, initExpireTime, initTtl, ver); + updateOffheap(oldVal, initExpireTime, initTtl); + if (deletedUnlocked() && oldVal != null && !isInternal()) deletedUnlocked(false); } @@ -2052,6 +2049,8 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { update(updated, newExpireTime, newTtl, newVer); + updateOffheap(updated, newExpireTime, newTtl); + drReplicate(drType, updated, newVer); recordNodeId(affNodeId, topVer); @@ -2122,19 +2121,14 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { enqueueVer = newVer; - boolean hasValPtr = valPtr != 0; - // Clear value on backup. Entry will be removed from cache when it got evicted from queue. update(null, CU.TTL_ETERNAL, CU.EXPIRE_TIME_ETERNAL, newVer); assert newSysTtl == CU.TTL_NOT_CHANGED; assert newSysExpireTime == CU.EXPIRE_TIME_CALCULATE; - if (cctx.offheapTiered() && hasValPtr) { - boolean rmv = cctx.swap().removeOffheap(key); - - assert rmv; - } + if (cctx.offheapTiered()) + cctx.swap().removeOffheap(key); clearReaders(); @@ -2989,6 +2983,8 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { // Version does not change for load ops. update(val, expTime, ttl, ver); + updateOffheap(val, expTime, ttl); + boolean skipQryNtf = false; if (val == null) { @@ -3036,11 +3032,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { val = cctx.kernalContext().cacheObjects().prepareForCache(val, cctx); // Version does not change for load ops. - update(val, - unswapped.expireTime(), - unswapped.ttl(), - unswapped.version() - ); + update(val, unswapped.expireTime(), unswapped.ttl(), unswapped.version()); return true; } @@ -3093,6 +3085,8 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { // Version does not change for load ops. update(val, expTime, ttl, newVer); + + updateOffheap(val, expTime, ttl); } return true; @@ -3647,6 +3641,8 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { return true; } + else if (cctx.offheapTiered()) + cctx.swap().removeOffheap(key); } } else { @@ -3690,8 +3686,12 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { return true; } - else + else { + if (cctx.offheapTiered()) + cctx.swap().removeOffheap(key); + return false; + } } } } @@ -3722,10 +3722,17 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { if (!hasReaders() && markObsolete0(obsoleteVer, false)) { if (!isStartVersion() && hasValueUnlocked()) { IgniteUuid valClsLdrId = null; + IgniteUuid keyClsLdrId = null; - if (val != null) - valClsLdrId = cctx.deploy().getClassLoaderId( - U.detectObjectClassLoader(val.value(cctx.cacheObjectContext(), false))); + if (cctx.kernalContext().config().isPeerClassLoadingEnabled()) { + if (val != null) { + valClsLdrId = cctx.deploy().getClassLoaderId( + U.detectObjectClassLoader(val.value(cctx.cacheObjectContext(), false))); + } + + keyClsLdrId = cctx.deploy().getClassLoaderId( + U.detectObjectClassLoader(key.value(cctx.cacheObjectContext(), false))); + } IgniteBiTuple valBytes = valueBytes0(); @@ -3736,7 +3743,7 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { ver, ttlExtras(), expireTimeExtras(), - cctx.deploy().getClassLoaderId(U.detectObjectClassLoader(key.value(cctx.cacheObjectContext(), false))), + keyClsLdrId, valClsLdrId); } @@ -4108,6 +4115,42 @@ public abstract class GridCacheMapEntry implements GridCacheEntryEx { return extras != null ? extras.size() : 0; } + /** + * @param val Value. + * @param expireTime Expire time. + * @param ttl TTL. + * @throws IgniteCheckedException If failed. + */ + private void updateOffheap(@Nullable CacheObject val, long expireTime, long ttl) throws IgniteCheckedException { + if (cctx.offheapTiered() && val != null) { + IgniteUuid valClsLdrId; + IgniteUuid keyClsLdrId; + + if (cctx.kernalContext().config().isPeerClassLoadingEnabled()) { + valClsLdrId = cctx.deploy().getClassLoaderId( + U.detectObjectClassLoader(val.value(cctx.cacheObjectContext(), false))); + + keyClsLdrId = cctx.deploy().getClassLoaderId( + U.detectObjectClassLoader(key.value(cctx.cacheObjectContext(), false))); + } + else { + valClsLdrId = null; + keyClsLdrId = null; + } + + byte[] valBytes = val.valueBytes(cctx.cacheObjectContext()); + + cctx.swap().write(key(), + ByteBuffer.wrap(valBytes), + val.type(), + ver, + ttl, + expireTime, + keyClsLdrId, + valClsLdrId); + } + } + /** {@inheritDoc} */ @Override public boolean equals(Object o) { // Identity comparison left on purpose.