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-5075
Date Thu, 01 Jun 2017 08:06:47 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-5075 fce685be1 -> 70fc1a019


ignite-5075


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

Branch: refs/heads/ignite-5075
Commit: 70fc1a01997dcb4ce1ce69b10f878e1fd56c2fc7
Parents: fce685b
Author: sboikov <sboikov@gridgain.com>
Authored: Thu Jun 1 11:06:38 2017 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Thu Jun 1 11:06:38 2017 +0300

----------------------------------------------------------------------
 .../cache/IgniteCacheAbstractBenchmark.java     | 24 +++++-
 .../yardstick/cache/IgniteGetBenchmark.java     | 17 +---
 .../cache/IgniteScanQueryBenchmark.java         | 88 ++++++++++++++++++++
 3 files changed, 112 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/70fc1a01/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 986b410..28aa5a2 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
@@ -29,6 +29,7 @@ import java.util.concurrent.Future;
 import java.util.concurrent.ThreadLocalRandom;
 import java.util.concurrent.atomic.AtomicInteger;
 import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteDataStreamer;
 import org.apache.ignite.cache.affinity.Affinity;
 import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.configuration.CacheConfiguration;
@@ -36,7 +37,7 @@ import org.apache.ignite.internal.util.typedef.T2;
 import org.apache.ignite.internal.util.typedef.internal.U;
 import org.apache.ignite.marshaller.jdk.JdkMarshaller;
 import org.apache.ignite.yardstick.IgniteAbstractBenchmark;
-import org.apache.ignite.yardstick.IgniteNode;
+import org.apache.ignite.yardstick.cache.model.SampleValue;
 import org.yardstickframework.BenchmarkConfiguration;
 import org.yardstickframework.BenchmarkUtils;
 
@@ -219,6 +220,27 @@ public abstract class IgniteCacheAbstractBenchmark<K, V> extends
IgniteAbstractB
 
     /**
      * @param cacheName Cache name.
+     * @param cnt Number of entries to load.
+     */
+    protected final void loadSampleValues(String cacheName, int cnt) {
+        try (IgniteDataStreamer<Object, Object> dataLdr = ignite().dataStreamer(cacheName))
{
+            for (int i = 0; i < cnt; i++) {
+                dataLdr.addData(i, new SampleValue(i));
+
+                if (i % 100000 == 0) {
+                    if (Thread.currentThread().isInterrupted())
+                        break;
+
+                    println("Loaded entries [cache=" + cacheName + ", cnt=" + i + ']');
+                }
+            }
+        }
+
+        println("Load entries done [cache=" + cacheName + ", cnt=" + cnt + ']');
+    }
+
+    /**
+     * @param cacheName Cache name.
      */
     private void loadCacheData0(String cacheName) {
         println(cfg, "Loading data for cache: " + cacheName);

http://git-wip-us.apache.org/repos/asf/ignite/blob/70fc1a01/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetBenchmark.java
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetBenchmark.java
index 8beb043..607be8a 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetBenchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetBenchmark.java
@@ -19,12 +19,8 @@ package org.apache.ignite.yardstick.cache;
 
 import java.util.Map;
 import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteDataStreamer;
-import org.apache.ignite.yardstick.cache.model.SampleValue;
 import org.yardstickframework.BenchmarkConfiguration;
 
-import static org.yardstickframework.BenchmarkUtils.println;
-
 /**
  * Ignite benchmark that performs get operations.
  */
@@ -42,18 +38,7 @@ public class IgniteGetBenchmark extends IgniteCacheAbstractBenchmark<Integer,
Ob
 
     /** {@inheritDoc} */
     @Override protected void loadCacheData(String cacheName) {
-        try (IgniteDataStreamer<Object, Object> dataLdr = ignite().dataStreamer(cacheName))
{
-            for (int i = 0; i < args.preloadAmount(); i++) {
-                dataLdr.addData(i, new SampleValue(i));
-
-                if (i % 100000 == 0) {
-                    if (Thread.currentThread().isInterrupted())
-                        break;
-
-                    println("Loaded entries: " + i);
-                }
-            }
-        }
+        loadSampleValues(cacheName, args.preloadAmount);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/70fc1a01/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteScanQueryBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteScanQueryBenchmark.java
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteScanQueryBenchmark.java
new file mode 100644
index 0000000..eda4ff6
--- /dev/null
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteScanQueryBenchmark.java
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.yardstick.cache;
+
+import java.util.List;
+import java.util.Map;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.query.ScanQuery;
+import org.apache.ignite.lang.IgniteBiPredicate;
+import org.yardstickframework.BenchmarkConfiguration;
+
+/**
+ *
+ */
+public class IgniteScanQueryBenchmark extends IgniteCacheAbstractBenchmark<Integer, Object>
{
+    /** {@inheritDoc} */
+    @Override public void setUp(BenchmarkConfiguration cfg) throws Exception {
+        super.setUp(cfg);
+
+        loadCachesData();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void loadCacheData(String cacheName) {
+        loadSampleValues(cacheName, args.range());
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean test(Map<Object, Object> ctx) throws Exception {
+        int key = nextRandom(args.range());
+
+        ScanQuery<Integer, Object> qry = new ScanQuery<>();
+
+        qry.setFilter(new KeyFilter(key));
+
+        IgniteCache<Integer, Object> cache = cacheForOperation().withKeepBinary();
+
+        List<IgniteCache.Entry<Integer, Object>> res = cache.query(qry).getAll();
+
+        if (res.size() != 1)
+            throw new Exception("Invalid result size: " + res.size());
+
+        if (res.get(0).getKey() != key)
+            throw new Exception("Invalid entry found [key=" + key + ", entryKey=" + res.get(0).getKey()
+ ']');
+
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected IgniteCache<Integer, Object> cache() {
+        return ignite().cache("atomic");
+    }
+
+    /**
+     *
+     */
+    static class KeyFilter implements IgniteBiPredicate<Integer, Object> {
+        /** */
+        private final Integer key;
+
+        /**
+         * @param key Key to find.
+         */
+        public KeyFilter(Integer key) {
+            this.key = key;
+        }
+
+        /** {@inheritDoc} */
+        @Override public boolean apply(Integer key, Object val) {
+            return this.key.equals(key);
+        }
+    }
+}


Mime
View raw message