Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 7931B200C61 for ; Mon, 10 Apr 2017 17:55:11 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 77D94160BB4; Mon, 10 Apr 2017 15:55:11 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 01F67160BB2 for ; Mon, 10 Apr 2017 17:55:09 +0200 (CEST) Received: (qmail 46975 invoked by uid 500); 10 Apr 2017 15:55:09 -0000 Mailing-List: contact commits-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list commits@ignite.apache.org Received: (qmail 46426 invoked by uid 99); 10 Apr 2017 15:55:08 -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; Mon, 10 Apr 2017 15:55:08 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 929A0F49E8; Mon, 10 Apr 2017 15:55:08 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: agoncharuk@apache.org To: commits@ignite.apache.org Date: Mon, 10 Apr 2017 15:55:24 -0000 Message-Id: In-Reply-To: <6249ec11a1c540ac927d10c6995c825f@git.apache.org> References: <6249ec11a1c540ac927d10c6995c825f@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [17/53] [abbrv] ignite git commit: ignite-4535 : GridDhtLocalPartition - replaced delegation to map with inheritance. archived-at: Mon, 10 Apr 2017 15:55:11 -0000 ignite-4535 : GridDhtLocalPartition - replaced delegation to map with inheritance. Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/f2df0a7c Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/f2df0a7c Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/f2df0a7c Branch: refs/heads/ignite-3477-master Commit: f2df0a7c7c11426bc83839cc903f10da18a0d677 Parents: 7d7b283 Author: Ilya Lantukh Authored: Fri Mar 31 16:50:06 2017 +0300 Committer: Ilya Lantukh Committed: Fri Mar 31 16:50:06 2017 +0300 ---------------------------------------------------------------------- .../distributed/dht/GridDhtLocalPartition.java | 98 ++------------------ 1 file changed, 10 insertions(+), 88 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/f2df0a7c/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java index 9389afd..46b2bf8 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtLocalPartition.java @@ -78,7 +78,7 @@ import static org.apache.ignite.internal.processors.cache.distributed.dht.GridDh /** * Key partition. */ -public class GridDhtLocalPartition implements Comparable, GridReservable, GridCacheConcurrentMap { +public class GridDhtLocalPartition extends GridCacheConcurrentMapImpl implements Comparable, GridReservable { /** Maximum size for delete queue. */ public static final int MAX_DELETE_QUEUE_SIZE = Integer.getInteger(IGNITE_ATOMIC_CACHE_DELETE_HISTORY_SIZE, 200_000); @@ -109,9 +109,6 @@ public class GridDhtLocalPartition implements Comparable, @GridToStringExclude private final GridFutureAdapter rent; - /** Entries map. */ - private final GridCacheConcurrentMap map; - /** Context. */ private final GridCacheContext cctx; @@ -151,7 +148,7 @@ public class GridDhtLocalPartition implements Comparable, */ @SuppressWarnings("ExternalizableWithoutPublicNoArgConstructor") GridDhtLocalPartition(GridCacheContext cctx, int id, GridCacheMapEntryFactory entryFactory) { - assert cctx != null; + super(cctx, entryFactory, cctx.config().getStartSize() / cctx.affinity().partitions()); this.id = id; this.cctx = cctx; @@ -160,12 +157,10 @@ public class GridDhtLocalPartition implements Comparable, rent = new GridFutureAdapter() { @Override public String toString() { - return "PartitionRentFuture [part=" + GridDhtLocalPartition.this + ", map=" + map + ']'; + return "PartitionRentFuture [part=" + GridDhtLocalPartition.this + ']'; } }; - map = new GridCacheConcurrentMapImpl(cctx, entryFactory, cctx.config().getStartSize() / cctx.affinity().partitions()); - int delQueueSize = CU.isSystemCache(cctx.name()) ? 100 : Math.max(MAX_DELETE_QUEUE_SIZE / cctx.affinity().partitions(), 20); @@ -240,20 +235,13 @@ public class GridDhtLocalPartition implements Comparable, } /** - * @return Keys belonging to partition. - */ - public Set keySet() { - return map.keySet(); - } - - /** * @return {@code True} if partition is empty. */ public boolean isEmpty() { if (cctx.allowFastEviction()) - return map.size() == 0; + return size() == 0; - return store.size() == 0 && map.size() == 0; + return store.size() == 0 && size() == 0; } /** @@ -294,26 +282,6 @@ public class GridDhtLocalPartition implements Comparable, } } - /** {@inheritDoc} */ - @Override public int size() { - return map.size(); - } - - /** {@inheritDoc} */ - @Override public int publicSize() { - return map.publicSize(); - } - - /** {@inheritDoc} */ - @Override public void incrementPublicSize(GridCacheEntryEx e) { - map.incrementPublicSize(e); - } - - /** {@inheritDoc} */ - @Override public void decrementPublicSize(GridCacheEntryEx e) { - map.decrementPublicSize(e); - } - /** * @return If partition is moving or owning or renting. */ @@ -323,52 +291,6 @@ public class GridDhtLocalPartition implements Comparable, return state == MOVING || state == OWNING || state == RENTING; } - /** {@inheritDoc} */ - @Override @Nullable public GridCacheMapEntry getEntry(KeyCacheObject key) { - return map.getEntry(key); - } - - /** {@inheritDoc} */ - @Override public boolean removeEntry(GridCacheEntryEx entry) { - return map.removeEntry(entry); - } - - /** {@inheritDoc} */ - @Override public Iterable entries( - CacheEntryPredicate... filter) { - return map.entries(filter); - } - - /** {@inheritDoc} */ - @Override public Iterable allEntries(CacheEntryPredicate... filter) { - return map.allEntries(filter); - } - - /** {@inheritDoc} */ - @Override public Set entrySet(CacheEntryPredicate... filter) { - return map.entrySet(filter); - } - - /** {@inheritDoc} */ - @Override @Nullable public GridCacheMapEntry randomEntry() { - return map.randomEntry(); - } - - /** {@inheritDoc} */ - @Override public GridCacheMapEntry putEntryIfObsoleteOrAbsent( - AffinityTopologyVersion topVer, - KeyCacheObject key, - @Nullable CacheObject val, - boolean create, - boolean touch) { - return map.putEntryIfObsoleteOrAbsent(topVer, key, val, create, touch); - } - - /** {@inheritDoc} */ - @Override public Set keySet(CacheEntryPredicate... filter) { - return map.keySet(filter); - } - /** * @param entry Entry to remove. */ @@ -376,7 +298,7 @@ public class GridDhtLocalPartition implements Comparable, assert entry.obsolete() : entry; // Make sure to remove exactly this entry. - map.removeEntry(entry); + removeEntry(entry); // Attempt to evict. try { @@ -895,20 +817,20 @@ public class GridDhtLocalPartition implements Comparable, boolean rec = cctx.events().isRecordable(EVT_CACHE_REBALANCE_OBJECT_UNLOADED); - Iterator it = (Iterator)map.allEntries().iterator(); + Iterator it = allEntries().iterator(); GridCacheObsoleteEntryExtras extras = new GridCacheObsoleteEntryExtras(clearVer); while (it.hasNext()) { - GridDhtCacheEntry cached = null; + GridCacheMapEntry cached = null; cctx.shared().database().checkpointReadLock(); try { cached = it.next(); - if (cached.clearInternal(clearVer, extras)) { - map.removeEntry(cached); + if (cached instanceof GridDhtCacheEntry && ((GridDhtCacheEntry)cached).clearInternal(clearVer, extras)) { + removeEntry(cached); if (!cached.isInternal()) { if (rec) {