ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject ignite git commit: ignite-4656 Added dynamic cache start for IgniteCacheRandomOperationBenchmark.
Date Thu, 16 Feb 2017 13:51:13 GMT
Repository: ignite
Updated Branches:
  refs/heads/master d4efbf342 -> d3ccaf6d9


ignite-4656 Added dynamic cache start for IgniteCacheRandomOperationBenchmark.


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

Branch: refs/heads/master
Commit: d3ccaf6d911ebf88b0abfc5e2495d1d1fe24fc55
Parents: d4efbf3
Author: oleg-ostanin <oostanin@gridgain.com>
Authored: Thu Feb 16 16:51:08 2017 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Thu Feb 16 16:51:08 2017 +0300

----------------------------------------------------------------------
 .../yardstick/IgniteBenchmarkArguments.java     | 28 +++++++++--
 .../org/apache/ignite/yardstick/IgniteNode.java |  2 +-
 .../IgniteCacheRandomOperationBenchmark.java    | 49 ++++++++++++++++++++
 3 files changed, 75 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/d3ccaf6d/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 2d2da5a..6ccd04c 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
@@ -153,6 +153,14 @@ public class IgniteBenchmarkArguments {
     private boolean keysPerThread;
 
     /** */
+    @Parameter(names = {"-ac", "--additionalCachesNumber"}, description = "Number of additional
caches")
+    private int additionalCachesNum;
+
+    /** */
+    @Parameter(names = {"-acn", "--additionalCachesName"}, description = "Template cache
name for additional caches")
+    private String additionalCachesName;
+
+    /** */
     @Parameter(names = {"-pp", "--printPartitionStats"}, description = "Print partition statistics")
     private boolean printPartStats;
 
@@ -296,9 +304,9 @@ public class IgniteBenchmarkArguments {
     /**
      * @return Preload log printing interval in seconds.
      */
-     public long preloadLogsInterval() {
-         return preloadLogsInterval;
-     }
+    public long preloadLogsInterval() {
+        return preloadLogsInterval;
+    }
 
     /**
      * @return Configuration file.
@@ -392,6 +400,20 @@ public class IgniteBenchmarkArguments {
     }
 
     /**
+     * @return Number of additional caches.
+     */
+    public int additionalCachesNumber() {
+        return additionalCachesNum;
+    }
+
+    /**
+     * @return Name of cache which will be taken as base for additional caches.
+     */
+    public String additionalCachesName() {
+        return additionalCachesName;
+    }
+
+    /**
      * @return Description.
      */
     public String description() {

http://git-wip-us.apache.org/repos/asf/ignite/blob/d3ccaf6d/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteNode.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteNode.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteNode.java
index a261b98..404bd68 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteNode.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteNode.java
@@ -168,7 +168,7 @@ public class IgniteNode implements BenchmarkServer {
      * @return Tuple with grid configuration and Spring application context.
      * @throws Exception If failed.
      */
-    private static IgniteBiTuple<IgniteConfiguration, ? extends ApplicationContext>
loadConfiguration(String springCfgPath)
+    public static IgniteBiTuple<IgniteConfiguration, ? extends ApplicationContext>
loadConfiguration(String springCfgPath)
         throws Exception {
         URL url;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/d3ccaf6d/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/IgniteCacheRandomOperationBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/IgniteCacheRandomOperationBenchmark.java
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/IgniteCacheRandomOperationBenchmark.java
index 590b64f..c85595d 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/IgniteCacheRandomOperationBenchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/IgniteCacheRandomOperationBenchmark.java
@@ -33,6 +33,7 @@ import java.util.UUID;
 import java.util.concurrent.Callable;
 import java.util.concurrent.ThreadLocalRandom;
 import java.util.concurrent.atomic.AtomicLong;
+import javax.cache.CacheException;
 import javax.cache.configuration.FactoryBuilder;
 import javax.cache.event.CacheEntryEvent;
 import javax.cache.event.CacheEntryListenerException;
@@ -69,8 +70,10 @@ import org.apache.ignite.transactions.TransactionConcurrency;
 import org.apache.ignite.transactions.TransactionIsolation;
 import org.apache.ignite.yardstick.IgniteAbstractBenchmark;
 import org.apache.ignite.yardstick.IgniteBenchmarkUtils;
+import org.apache.ignite.yardstick.IgniteNode;
 import org.apache.ignite.yardstick.cache.load.model.ModelUtil;
 import org.jetbrains.annotations.NotNull;
+import org.springframework.beans.BeansException;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.StringUtils;
 import org.yardstickframework.BenchmarkConfiguration;
@@ -135,14 +138,60 @@ public class IgniteCacheRandomOperationBenchmark extends IgniteAbstractBenchmark
     @Override public void setUp(BenchmarkConfiguration cfg) throws Exception {
         super.setUp(cfg);
 
+        if (args.additionalCachesNumber() > 0)
+            createAdditionalCaches();
+
         searchCache();
 
         preLoading();
     }
 
+    /**
+     * Creates additional caches.
+     *
+     * @throws Exception If failed.
+     */
+    private void createAdditionalCaches() throws Exception {
+        Map<String, CacheConfiguration> cfgMap;
+
+        try {
+            // Loading spring application context and getting all of the caches configurations
in the map.
+            cfgMap = IgniteNode.loadConfiguration(args.configuration()).get2().getBeansOfType(CacheConfiguration.class);
+        }
+        catch (BeansException e) {
+            throw new Exception("Failed to instantiate bean [type=" + CacheConfiguration.class
+ ", err=" +
+                e.getMessage() + ']', e);
+        }
+
+        if (cfgMap == null || cfgMap.isEmpty())
+            throw new Exception("Failed to find cache configurations in: " + args.configuration());
+
+        // Getting cache configuration from the map using name specified in property file.
+        CacheConfiguration<Object, Object> ccfg = cfgMap.get(args.additionalCachesName());
+
+        if (ccfg == null)
+            throw new Exception("Failed to find cache configuration [cache=" + args.additionalCachesName()
+
+                ", cfg=" + args.configuration() + ']');
+
+        for (int i = 0; i < args.additionalCachesNumber(); i++) {
+            CacheConfiguration<Object, Object> newCfg = new CacheConfiguration<>(ccfg);
+
+            newCfg.setName("additional_" + args.additionalCachesName() + "_cache_" + i);
+
+            try {
+                ignite().createCache(newCfg);
+            }
+            catch (CacheException e) {
+                BenchmarkUtils.error("Failed to create additional cache [ name = " + args.additionalCachesName()
+
+                    ", err" + e.getMessage() + ']', e);
+            }
+        }
+    }
+
     /** {@inheritDoc} */
     @Override public void onException(Throwable e) {
         BenchmarkUtils.error("The benchmark of random operation failed.", e);
+
         super.onException(e);
     }
 


Mime
View raw message