ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [11/27] ignite git commit: Added print partition stats.
Date Wed, 02 Mar 2016 18:26:39 GMT
Added print partition stats.


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

Branch: refs/heads/ignite-2407
Commit: 071498f10ab1857759bc3c180199b6c7efbce81a
Parents: 62c26d5
Author: nikolay_tikhonov <ntikhonov@gridgain.com>
Authored: Mon Feb 29 22:20:15 2016 +0300
Committer: nikolay_tikhonov <ntikhonov@gridgain.com>
Committed: Mon Feb 29 22:20:15 2016 +0300

----------------------------------------------------------------------
 .../yardstick/IgniteBenchmarkArguments.java     | 11 +++++
 .../cache/IgniteCacheAbstractBenchmark.java     | 52 ++++++++++++++++++++
 2 files changed, 63 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/071498f1/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteBenchmarkArguments.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteBenchmarkArguments.java
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteBenchmarkArguments.java
index 1ecfa0f..36551cc 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteBenchmarkArguments.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteBenchmarkArguments.java
@@ -136,6 +136,17 @@ public class IgniteBenchmarkArguments {
     @Parameter(names = {"-kpt", "--keysPerThread"}, description = "Use not intersecting keys
in putAll benchmark")
     private boolean keysPerThread;
 
+    /** */
+    @Parameter(names = {"-pp", "--printPartitionStats"}, description = "Print partition statistics")
+    private boolean printPartStats;
+
+    /**
+     * @return If {@code true} when need to print partition statistics.
+     */
+    public boolean printPartitionStatistics() {
+        return printPartStats;
+    }
+
     /**
      * @return JDBC url.
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/071498f1/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteCacheAbstractBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteCacheAbstractBenchmark.java
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteCacheAbstractBenchmark.java
index 3efa4a5..c9a4b9c 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteCacheAbstractBenchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteCacheAbstractBenchmark.java
@@ -17,9 +17,18 @@
 
 package org.apache.ignite.yardstick.cache;
 
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 import java.util.concurrent.ThreadLocalRandom;
 import java.util.concurrent.atomic.AtomicInteger;
 import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.affinity.Affinity;
+import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.internal.util.typedef.T2;
+import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.yardstick.IgniteAbstractBenchmark;
 import org.yardstickframework.BenchmarkConfiguration;
 import org.yardstickframework.BenchmarkUtils;
@@ -42,6 +51,49 @@ public abstract class IgniteCacheAbstractBenchmark<K, V> extends
IgniteAbstractB
         super.setUp(cfg);
 
         cache = cache();
+
+        if (args.printPartitionStatistics()) {
+            Map<ClusterNode, T2<List<Integer>, List<Integer>>> parts
= new HashMap<>();
+
+            for (ClusterNode node : ignite().cluster().nodes())
+                parts.put(node,
+                    new T2<List<Integer>, List<Integer>>(new ArrayList<Integer>(),
new ArrayList<Integer>()));
+
+            U.sleep(5000);
+
+            Affinity<Object> aff = ignite().affinity(cache.getName());
+
+            for (int p = 0; p < aff.partitions(); p++) {
+                Collection<ClusterNode> nodes = aff.mapPartitionToPrimaryAndBackups(p);
+
+                boolean primary = true;
+
+                for (ClusterNode node : nodes) {
+                    if (primary) {
+                        parts.get(node).get1().add(p);
+
+                        primary = false;
+                    }
+                    else
+                        parts.get(node).get2().add(p);
+                }
+            }
+
+            BenchmarkUtils.println(cfg, "Partition stats. [cacheName: "+ cache.getName()
+", topVer: "
+                + ignite().cluster().topologyVersion() + "]");
+            BenchmarkUtils.println(cfg, "(Node id,  Number of Primary, Percent, Number of
Backup, Percent, Total, Percent)");
+
+            for (Map.Entry<ClusterNode, T2<List<Integer>, List<Integer>>>
e : parts.entrySet()) {
+                List<Integer> primary = e.getValue().get1();
+                List<Integer> backup = e.getValue().get2();
+
+                BenchmarkUtils.println(cfg, e.getKey().id() + " " + primary.size() + " "
+ primary.size() * 1. /
+                    aff.partitions() + " " + backup.size() + " "
+                    + backup.size() * 1. / (aff.partitions() * args.backups() == 0 ? 1 :
args.backups())
+                    + (primary.size() + backup.size() * 1.) / (aff.partitions() * args.backups()
+ aff.partitions())
+                );
+            }
+        }
     }
 
     /**


Mime
View raw message