Repository: ignite Updated Branches: refs/heads/ignite-5075 2549b9a44 -> fce685be1
ignite-5075 Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/fce685be Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/fce685be Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/fce685be Branch: refs/heads/ignite-5075 Commit: fce685be1efef0b57ebd0dbdf773508de2e69c54 Parents: 2549b9a Author: sboikov <[email protected]> Authored: Thu Jun 1 10:04:09 2017 +0300 Committer: sboikov <[email protected]> Committed: Thu Jun 1 10:04:09 2017 +0300 ---------------------------------------------------------------------- .../yardstick/IgniteBenchmarkArguments.java | 10 +- .../cache/IgniteCacheAbstractBenchmark.java | 36 +++--- .../cache/IgnitePutObjectKeyBenchmark.java | 125 ------------------- 3 files changed, 20 insertions(+), 151 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/fce685be/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 34d2de4..0827780 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 @@ -191,8 +191,8 @@ public class IgniteBenchmarkArguments { private String cacheGrp; /** */ - @Parameter(names = {"-cig", "--cachesInGrp"}, description = "Number of caches to create in configured group") - private int cachesInGrp = 1; + @Parameter(names = {"-cc", "--cachesCnt"}, description = "Number of caches to create") + private int cachesCnt = 1; /** * @return List of enabled load test operations. @@ -452,10 +452,10 @@ public class IgniteBenchmarkArguments { } /** - * @return Number of caches to create in configured group. + * @return Number of caches to create. */ - public int cachesInGroup() { - return cachesInGrp; + public int cachesCount() { + return cachesCnt; } /** http://git-wip-us.apache.org/repos/asf/ignite/blob/fce685be/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 9c0344d..986b410 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 @@ -50,7 +50,7 @@ public abstract class IgniteCacheAbstractBenchmark<K, V> extends IgniteAbstractB protected IgniteCache<K, V> cache; /** */ - protected List<IgniteCache> grpCaches; + protected List<IgniteCache> testCaches; /** */ private ThreadLocal<ThreadRange> threadRange = new ThreadLocal<>(); @@ -59,7 +59,7 @@ public abstract class IgniteCacheAbstractBenchmark<K, V> extends IgniteAbstractB private AtomicInteger threadIdx = new AtomicInteger(); /** */ - private int cachesInGrp; + private int caches; /** */ private final AtomicInteger opCacheIdx = new AtomicInteger(); @@ -79,12 +79,12 @@ public abstract class IgniteCacheAbstractBenchmark<K, V> extends IgniteAbstractB * @return Cache for benchmark operation. */ protected final IgniteCache<K, V> cacheForOperation(boolean perThread) { - if (cachesInGrp > 1) { + if (caches > 1) { if (perThread) { IgniteCache<K, V> cache = opCache.get(); if (cache == null) { - cache = grpCaches.get(opCacheIdx.getAndIncrement() % cachesInGrp); + cache = testCaches.get(opCacheIdx.getAndIncrement() % caches); opCache.set(cache); @@ -94,7 +94,7 @@ public abstract class IgniteCacheAbstractBenchmark<K, V> extends IgniteAbstractB return cache; } else - return grpCaches.get(ThreadLocalRandom.current().nextInt(cachesInGrp)); + return testCaches.get(ThreadLocalRandom.current().nextInt(caches)); } return cache; @@ -115,34 +115,28 @@ public abstract class IgniteCacheAbstractBenchmark<K, V> extends IgniteAbstractB ", cacheGroup="+ grpName + ", cacheCfg=" + cache.getConfiguration(CacheConfiguration.class) + ']'); - cachesInGrp = args.cachesInGroup(); - - if (cachesInGrp > 1) { - if (grpName == null) - throw new IllegalArgumentException("Group is not configured for cache: " + cache.getName()); - - JdkMarshaller marsh = new JdkMarshaller(); - - ccfg = marsh.unmarshal(marsh.marshal(ccfg), null); + caches = args.cachesCount(); + if (caches > 1) { List<CacheConfiguration> toCreate = new ArrayList<>(); - for (int i = 0; i < cachesInGrp - 1; i++) { - CacheConfiguration<?, ?> ccfg0 = new CacheConfiguration<>(ccfg); + for (int i = 0; i < caches - 1; i++) { + JdkMarshaller marsh = new JdkMarshaller(); + + CacheConfiguration ccfg0 = marsh.unmarshal(marsh.marshal(ccfg), null); ccfg0.setName(cache.getName() + "-" + i); - ccfg0.setGroupName(grpName); toCreate.add(ccfg0); } Collection<IgniteCache> caches = ignite().getOrCreateCaches(toCreate); - grpCaches = new ArrayList<>(caches); + testCaches = new ArrayList<>(caches); - grpCaches.add(cache); + testCaches.add(cache); - BenchmarkUtils.println(cfg, "Created additional caches for group [cachesInGrp=" + grpCaches.size() + + BenchmarkUtils.println(cfg, "Created additional caches [caches=" + testCaches.size() + ", grp=" + grpName + ']'); } @@ -196,7 +190,7 @@ public abstract class IgniteCacheAbstractBenchmark<K, V> extends IgniteAbstractB * @throws Exception If failed. */ protected final void loadCachesData() throws Exception { - List<IgniteCache> caches = grpCaches != null ? grpCaches : (List)Collections.singletonList(cache); + List<IgniteCache> caches = testCaches != null ? testCaches : Collections.<IgniteCache>singletonList(cache); if (caches.size() > 1) { ExecutorService executor = Executors.newFixedThreadPool(10); http://git-wip-us.apache.org/repos/asf/ignite/blob/fce685be/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutObjectKeyBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutObjectKeyBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutObjectKeyBenchmark.java deleted file mode 100644 index e8468cb..0000000 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutObjectKeyBenchmark.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * 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.io.Serializable; -import java.util.Map; -import org.apache.ignite.IgniteCache; -import org.apache.ignite.yardstick.cache.model.SampleValue; -import org.yardstickframework.BenchmarkConfiguration; - -/** - * - */ -public class IgnitePutObjectKeyBenchmark extends IgniteCacheAbstractBenchmark<Object, Object> { - /** {@inheritDoc} */ - @Override public void setUp(BenchmarkConfiguration cfg) throws Exception { - super.setUp(cfg); - } - - /** {@inheritDoc} */ - @Override public boolean test(Map<Object, Object> ctx) throws Exception { - int key = nextRandom(args.range()); - - IgniteCache<Object, Object> cache = cacheForOperation(); - - cache.put(grpCaches != null ? new Key1(key) : new Key2(key, key), new SampleValue(key)); - - return true; - } - - /** {@inheritDoc} */ - @Override protected IgniteCache<Object, Object> cache() { - return ignite().cache("atomic"); - } - - /** - * - */ - static class Key1 implements Serializable { - /** */ - private final int id; - - /** - * @param id ID. - */ - Key1(int id) { - this.id = id; - } - - /** {@inheritDoc} */ - @Override public boolean equals(Object o) { - if (this == o) - return true; - - if (o == null || getClass() != o.getClass()) - return false; - - Key1 key1 = (Key1)o; - - return id == key1.id; - } - - /** {@inheritDoc} */ - @Override public int hashCode() { - return id; - } - } - - /** - * - */ - static class Key2 implements Serializable { - /** */ - private final int id1; - - /** */ - private final int id2; - - /** - * @param id1 ID1. - * @param id2 ID2. - */ - Key2(int id1, int id2) { - this.id1 = id1; - this.id2 = id2; - } - - /** {@inheritDoc} */ - @Override public boolean equals(Object o) { - if (this == o) - return true; - - if (o == null || getClass() != o.getClass()) - return false; - - Key2 key2 = (Key2) o; - - return id1 == key2.id1 && id2 == key2.id2; - } - - /** {@inheritDoc} */ - @Override public int hashCode() { - int res = id1; - - res = 31 * res + id2; - - return res; - } - } -}
