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 C108018611 for ; Tue, 28 Apr 2015 09:32:55 +0000 (UTC) Received: (qmail 44735 invoked by uid 500); 28 Apr 2015 09:32:55 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 44706 invoked by uid 500); 28 Apr 2015 09:32:55 -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 44697 invoked by uid 99); 28 Apr 2015 09:32:55 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Apr 2015 09:32:55 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [54.164.171.186] (HELO mx1-us-east.apache.org) (54.164.171.186) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Apr 2015 09:32:51 +0000 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 D78E543CCE for ; Tue, 28 Apr 2015 09:32:30 +0000 (UTC) Received: (qmail 43034 invoked by uid 99); 28 Apr 2015 09:32:30 -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; Tue, 28 Apr 2015 09:32:30 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 3338DE054B; Tue, 28 Apr 2015 09:32:30 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: akuznetsov@apache.org To: commits@ignite.incubator.apache.org Date: Tue, 28 Apr 2015 09:32:30 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [1/3] incubator-ignite git commit: Added metric for indexes memory size for later implementation. X-Virus-Checked: Checked by ClamAV on apache.org Repository: incubator-ignite Updated Branches: refs/heads/ignite-sprint-4 073c9f365 -> 7ff09b9d0 Added metric for indexes memory size for later implementation. Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/f6e2ef71 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/f6e2ef71 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/f6e2ef71 Branch: refs/heads/ignite-sprint-4 Commit: f6e2ef716085a827e32e283fd33f069042528bc6 Parents: 19bd611 Author: AKuznetsov Authored: Tue Apr 28 16:00:32 2015 +0700 Committer: AKuznetsov Committed: Tue Apr 28 16:00:32 2015 +0700 ---------------------------------------------------------------------- .../ignite/internal/visor/cache/VisorCache.java | 92 +++++++++++--------- .../visor/node/VisorNodeDataCollectorJob.java | 2 +- 2 files changed, 54 insertions(+), 40 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f6e2ef71/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCache.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCache.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCache.java index 8c880a7..bd24ecf 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCache.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/cache/VisorCache.java @@ -57,6 +57,9 @@ public class VisorCache implements Serializable { /** Cache size in bytes. */ private long memorySize; + /** Cache size in bytes. */ + private long indexesSize; + /** Number of all entries in cache. */ private int size; @@ -103,7 +106,7 @@ public class VisorCache implements Serializable { * @return Data transfer object for given cache. * @throws IgniteCheckedException If failed to create data transfer object. */ - public static VisorCache from(IgniteEx ignite, String cacheName, int sample) throws IgniteCheckedException { + public VisorCache from(IgniteEx ignite, String cacheName, int sample) throws IgniteCheckedException { assert ignite != null; GridCacheAdapter ca = ignite.context().cache().internalCache(cacheName); @@ -112,8 +115,7 @@ public class VisorCache implements Serializable { if (ca == null || !ca.context().started()) return null; - long swapSize; - long swapKeys; + name = cacheName; try { swapSize = ca.swapSize(); @@ -124,13 +126,12 @@ public class VisorCache implements Serializable { swapKeys = -1; } - Collection> pps = Collections.emptyList(); - Collection> bps = Collections.emptyList(); - GridDhtPartitionMap partsMap = null; + primaryPartitions = Collections.emptyList(); + backupPartitions = Collections.emptyList(); CacheConfiguration cfg = ca.configuration(); - CacheMode mode = cfg.getCacheMode(); + mode = cfg.getCacheMode(); boolean partitioned = (mode == CacheMode.PARTITIONED || mode == CacheMode.REPLICATED) && ca.context().affinityNode(); @@ -147,22 +148,23 @@ public class VisorCache implements Serializable { GridDhtPartitionTopology top = dca.topology(); if (cfg.getCacheMode() != CacheMode.LOCAL && cfg.getBackups() > 0) - partsMap = top.localPartitionMap(); + partitionsMap = top.localPartitionMap(); List parts = top.localPartitions(); - pps = new ArrayList<>(parts.size()); - bps = new ArrayList<>(parts.size()); + primaryPartitions = new ArrayList<>(parts.size()); + backupPartitions = new ArrayList<>(parts.size()); for (GridDhtLocalPartition part : parts) { int p = part.id(); int sz = part.size(); - if (part.primary(AffinityTopologyVersion.NONE)) // Pass -1 as topology version in order not to wait for topology version. - pps.add(new IgnitePair<>(p, sz)); + // Pass -1 as topology version in order not to wait for topology version. + if (part.primary(AffinityTopologyVersion.NONE)) + primaryPartitions.add(new IgnitePair<>(p, sz)); else - bps.add(new IgnitePair<>(p, sz)); + backupPartitions.add(new IgnitePair<>(p, sz)); } } else { @@ -171,28 +173,52 @@ public class VisorCache implements Serializable { int[] pp = ca.affinity().primaryPartitions(node); - pps = new ArrayList<>(pp.length); + primaryPartitions= new ArrayList<>(pp.length); for (int p : pp) { Set set = ca.entrySet(p); - pps.add(new IgnitePair<>(p, set != null ? set.size() : 0)); + primaryPartitions.add(new IgnitePair<>(p, set != null ? set.size() : 0)); } int[] bp = ca.affinity().backupPartitions(node); - bps = new ArrayList<>(bp.length); + backupPartitions = new ArrayList<>(bp.length); for (int p : bp) { Set set = ca.entrySet(p); - bps.add(new IgnitePair<>(p, set != null ? set.size() : 0)); + backupPartitions.add(new IgnitePair<>(p, set != null ? set.size() : 0)); } } } + size = ca.size(); + nearSize = ca.nearSize(); + + dynamicDeploymentId = ca.context().dynamicDeploymentId(); + dhtSize = size - nearSize; + primarySize = ca.primarySize(); + offHeapAllocatedSize = ca.offHeapAllocatedSize(); + offHeapEntriesCnt = ca.offHeapEntriesCount(); + partitions = ca.affinity().partitions(); + metrics = VisorCacheMetrics.from(ignite, ca); + + estimateMemorySize(ignite, ca, sample); + + return this; + } + + /** + * Estimate memory size used by cache. + * + * @param ignite Ignite. + * @param ca Cache adapter. + * @param sample Sample size. + * @throws IgniteCheckedException If estimation failed. + */ + protected void estimateMemorySize(IgniteEx ignite, GridCacheAdapter ca, int sample) throws IgniteCheckedException { int size = ca.size(); - int near = ca.nearSize(); Set set = ca.map().entries0(); @@ -213,27 +239,7 @@ public class VisorCache implements Serializable { if (cnt > 0) memSz = (long)((double)memSz / cnt * size); - VisorCache cache = new VisorCache(); - - cache.name = cacheName; - cache.dynamicDeploymentId = ca.context().dynamicDeploymentId(); - cache.mode = mode; - cache.memorySize = memSz; - cache.size = size; - cache.nearSize = near; - cache.dhtSize = size - near; - cache.primarySize = ca.primarySize(); - cache.offHeapAllocatedSize = ca.offHeapAllocatedSize(); - cache.offHeapEntriesCnt = ca.offHeapEntriesCount(); - cache.swapSize = swapSize; - cache.swapKeys = swapKeys; - cache.partitions = ca.affinity().partitions(); - cache.primaryPartitions = pps; - cache.backupPartitions = bps; - cache.metrics = VisorCacheMetrics.from(ignite, ca); - cache.partitionsMap = partsMap; - - return cache; + memorySize = memSz; } /** @@ -245,6 +251,7 @@ public class VisorCache implements Serializable { c.name = name; c.mode = mode; c.memorySize = memorySize; + c.indexesSize = indexesSize; c.size = size; c.nearSize = nearSize; c.dhtSize = dhtSize; @@ -290,6 +297,13 @@ public class VisorCache implements Serializable { } /** + * @return Indexes size in bytes. + */ + public long indexesSize() { + return indexesSize; + } + + /** * @return Number of all entries in cache. */ public int size() { http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f6e2ef71/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorJob.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorJob.java b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorJob.java index 1f58563..c850ab0 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorJob.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/visor/node/VisorNodeDataCollectorJob.java @@ -125,7 +125,7 @@ public class VisorNodeDataCollectorJob extends VisorJob