Repository: ignite Updated Branches: refs/heads/ignite-5267 c7a7e6423 -> 7e45010b4
http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePersistentStoreDataStructuresTest.java ---------------------------------------------------------------------- diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePersistentStoreDataStructuresTest.java b/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePersistentStoreDataStructuresTest.java new file mode 100644 index 0000000..0183779 --- /dev/null +++ b/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePersistentStoreDataStructuresTest.java @@ -0,0 +1,205 @@ +/* + * 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.cache.database; + +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteAtomicLong; +import org.apache.ignite.IgniteAtomicSequence; +import org.apache.ignite.IgniteQueue; +import org.apache.ignite.IgniteSet; +import org.apache.ignite.configuration.CollectionConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.configuration.MemoryConfiguration; +import org.apache.ignite.configuration.MemoryPolicyConfiguration; +import org.apache.ignite.configuration.PersistentStoreConfiguration; +import org.apache.ignite.internal.processors.cache.database.wal.FileWriteAheadLogManager; +import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; +import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; +import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.GridTestUtils; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; + +/** + * + */ +public class IgnitePersistentStoreDataStructuresTest extends GridCommonAbstractTest { + /** */ + private static final TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); + + ((TcpDiscoverySpi)cfg.getDiscoverySpi()).setIpFinder(ipFinder); + + MemoryConfiguration dbCfg = new MemoryConfiguration(); + + MemoryPolicyConfiguration memPlcCfg = new MemoryPolicyConfiguration(); + + memPlcCfg.setName("dfltMemPlc"); + memPlcCfg.setInitialSize(200 * 1024 * 1024); + memPlcCfg.setMaxSize(200 * 1024 * 1024); + + dbCfg.setMemoryPolicies(memPlcCfg); + dbCfg.setDefaultMemoryPolicyName("dfltMemPlc"); + + cfg.setMemoryConfiguration(dbCfg); + + cfg.setPersistentStoreConfiguration(new PersistentStoreConfiguration()); + + cfg.setActiveOnStart(false); + + return cfg; + } + + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + super.beforeTestsStarted(); + + System.setProperty(FileWriteAheadLogManager.IGNITE_PDS_WAL_MODE, "LOG_ONLY"); + } + + /** {@inheritDoc} */ + @Override protected void afterTestsStopped() throws Exception { + System.clearProperty(FileWriteAheadLogManager.IGNITE_PDS_WAL_MODE); + + GridTestUtils.deleteDbFiles(); + } + + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + super.beforeTest(); + + GridTestUtils.deleteDbFiles(); + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + super.afterTest(); + + stopAllGrids(); + } + + /** + * @throws Exception If failed. + */ + public void testQueue() throws Exception { + Ignite ignite = startGrids(4); + + ignite.active(true); + + IgniteQueue<Object> queue = ignite.queue("testQueue", 100, new CollectionConfiguration()); + + for (int i = 0; i < 100; i++) + queue.offer(i); + + stopAllGrids(); + + ignite = startGrids(4); + + ignite.active(true); + + queue = ignite.queue("testQueue", 0, null); + + for (int i = 0; i < 100; i++) + assertEquals(i, queue.poll()); + } + + /** + * @throws Exception If failed. + */ + public void testAtomic() throws Exception { + Ignite ignite = startGrids(4); + + ignite.active(true); + + IgniteAtomicLong atomicLong = ignite.atomicLong("testLong", 0, true); + + for (int i = 0; i < 100; i++) + atomicLong.incrementAndGet(); + + stopAllGrids(); + + ignite = startGrids(4); + + ignite.active(true); + + atomicLong = ignite.atomicLong("testLong", 0, false); + + for (int i = 100; i != 0; ) + assertEquals(i--, atomicLong.getAndDecrement()); + } + + /** + * @throws Exception If failed. + */ + public void testSequence() throws Exception { + Ignite ignite = startGrids(4); + + ignite.active(true); + + IgniteAtomicSequence sequence = ignite.atomicSequence("testSequence", 0, true); + + int i = 0; + + while (i < 1000) { + sequence.incrementAndGet(); + + i++; + } + + stopAllGrids(); + + ignite = startGrids(4); + + ignite.active(true); + + sequence = ignite.atomicSequence("testSequence", 0, false); + + assertTrue(sequence.incrementAndGet() > i); + } + + /** + * @throws Exception If failed. + */ + public void testSet() throws Exception { + Ignite ignite = startGrids(4); + + ignite.active(true); + + IgniteSet<Object> set = ignite.set("testSet", new CollectionConfiguration()); + + for (int i = 0; i < 100; i++) + set.add(i); + + stopAllGrids(); + + ignite = startGrids(4); + + ignite.active(true); + + set = ignite.set("testSet", null); + + assertFalse(set.add(99)); + + for (int i = 0; i < 100; i++) + assertTrue(set.contains(i)); + + assertEquals(100, set.size()); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePersistentStoreMultiNodePutGetRestartSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePersistentStoreMultiNodePutGetRestartSelfTest.java b/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePersistentStoreMultiNodePutGetRestartSelfTest.java index 46ac5d2..a2eb3d4 100644 --- a/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePersistentStoreMultiNodePutGetRestartSelfTest.java +++ b/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePersistentStoreMultiNodePutGetRestartSelfTest.java @@ -132,8 +132,6 @@ public class IgnitePersistentStoreMultiNodePutGetRestartSelfTest extends GridCom * @throws Exception if failed. */ public void testPutGetSimple() throws Exception { - - info(">>> Will use path: " + allocPath); startGrids(GRID_CNT); http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePersistentStoreSingleNodeWithIndexingAndGroupPutGetPersistenceSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePersistentStoreSingleNodeWithIndexingAndGroupPutGetPersistenceSelfTest.java b/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePersistentStoreSingleNodeWithIndexingAndGroupPutGetPersistenceSelfTest.java new file mode 100644 index 0000000..665b9af --- /dev/null +++ b/modules/pds/src/test/java/org/apache/ignite/cache/database/IgnitePersistentStoreSingleNodeWithIndexingAndGroupPutGetPersistenceSelfTest.java @@ -0,0 +1,42 @@ +/* + * 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.cache.database; + +import org.apache.ignite.cache.affinity.AffinityFunction; +import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; + +/** + * + */ +public class IgnitePersistentStoreSingleNodeWithIndexingAndGroupPutGetPersistenceSelfTest + extends IgnitePersistentStoreSingleNodeWithIndexingPutGetPersistenceSelfTest { + /** {@inheritDoc} */ + @Override protected void configure(IgniteConfiguration cfg) { + super.configure(cfg); + + for (CacheConfiguration ccfg : cfg.getCacheConfiguration()) { + AffinityFunction aff = ccfg.getAffinity(); + + int parts = aff != null ? aff.partitions() : RendezvousAffinityFunction.DFLT_PARTITION_COUNT; + + ccfg.setGroupName("testGroup-parts" + parts); + } + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/NoOpPageStoreManager.java ---------------------------------------------------------------------- diff --git a/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/NoOpPageStoreManager.java b/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/NoOpPageStoreManager.java index 9d5fe69..783faf8 100644 --- a/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/NoOpPageStoreManager.java +++ b/modules/pds/src/test/java/org/apache/ignite/cache/database/pagemem/NoOpPageStoreManager.java @@ -19,7 +19,7 @@ package org.apache.ignite.cache.database.pagemem; import java.nio.ByteBuffer; import java.util.Collections; -import java.util.Set; +import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.atomic.AtomicInteger; @@ -29,7 +29,8 @@ import org.apache.ignite.internal.GridKernalContext; import org.apache.ignite.internal.pagemem.FullPageId; import org.apache.ignite.internal.pagemem.PageIdUtils; import org.apache.ignite.internal.pagemem.store.IgnitePageStoreManager; -import org.apache.ignite.internal.processors.cache.GridCacheContext; +import org.apache.ignite.internal.processors.cache.CacheGroupContext; +import org.apache.ignite.internal.processors.cache.CacheGroupDescriptor; import org.apache.ignite.internal.processors.cache.GridCacheSharedContext; import org.apache.ignite.internal.util.typedef.F; import org.apache.ignite.lang.IgniteFuture; @@ -52,17 +53,17 @@ public class NoOpPageStoreManager implements IgnitePageStoreManager { } /** {@inheritDoc} */ - @Override public void initializeForCache(CacheConfiguration ccfg) throws IgniteCheckedException { + @Override public void initializeForCache(CacheGroupDescriptor grpDesc, CacheConfiguration ccfg) throws IgniteCheckedException { // No-op. } /** {@inheritDoc} */ - @Override public void shutdownForCache(GridCacheContext cacheCtx, boolean destroy) throws IgniteCheckedException { + @Override public void shutdownForCacheGroup(CacheGroupContext grp, boolean destroy) throws IgniteCheckedException { // No-op. } /** {@inheritDoc} */ - @Override public void onPartitionCreated(int cacheId, int partId) throws IgniteCheckedException { + @Override public void onPartitionCreated(int grpId, int partId) throws IgniteCheckedException { // No-op. } @@ -170,17 +171,12 @@ public class NoOpPageStoreManager implements IgnitePageStoreManager { } /** {@inheritDoc} */ - @Override public Set<String> savedCacheNames() { - return Collections.emptySet(); + @Override public Map<String, CacheConfiguration> readCacheConfigurations() throws IgniteCheckedException { + return Collections.emptyMap(); } /** {@inheritDoc} */ - @Override public CacheConfiguration readConfiguration(String cacheName) { - return null; - } - - /** {@inheritDoc} */ - @Override public boolean hasIndexStore(int cacheId) { + @Override public boolean hasIndexStore(int grpId) { return false; } http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/pds/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite.java ---------------------------------------------------------------------- diff --git a/modules/pds/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite.java b/modules/pds/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite.java index c3e5a70..d38d403 100644 --- a/modules/pds/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite.java +++ b/modules/pds/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite.java @@ -18,9 +18,11 @@ package org.apache.ignite.testsuites; import junit.framework.TestSuite; +import org.apache.ignite.cache.database.IgnitePersistentStoreCacheGroupsTest; import org.apache.ignite.cache.database.IgnitePersistentStoreClientNearCachePutGetWithPersistenceSelfTest; import org.apache.ignite.cache.database.IgnitePersistentStoreDynamicCacheTest; import org.apache.ignite.cache.database.IgnitePersistentStoreSingleNodePutGetPersistenceSelfTest; +import org.apache.ignite.cache.database.IgnitePersistentStoreSingleNodeWithIndexingAndGroupPutGetPersistenceSelfTest; import org.apache.ignite.cache.database.IgnitePersistentStoreSingleNodeWithIndexingPutGetPersistenceSelfTest; import org.apache.ignite.cache.database.db.IgniteDbMultiNodePutGetRestartSelfTest; import org.apache.ignite.cache.database.db.IgniteDbPageEvictionSelfTest; @@ -80,11 +82,14 @@ public class IgnitePdsTestSuite extends TestSuite { suite.addTestSuite(IgniteDbMultiNodePutGetRestartSelfTest.class); suite.addTestSuite(IgnitePersistentStoreSingleNodePutGetPersistenceSelfTest.class); suite.addTestSuite(IgnitePersistentStoreSingleNodeWithIndexingPutGetPersistenceSelfTest.class); + suite.addTestSuite(IgnitePersistentStoreSingleNodeWithIndexingAndGroupPutGetPersistenceSelfTest.class); suite.addTestSuite(IgniteDbPageEvictionSelfTest.class); suite.addTestSuite(IgnitePersistentStoreDynamicCacheTest.class); suite.addTestSuite(IgniteWalDirectoriesConfigurationTest.class); suite.addTestSuite(IgnitePersistentStoreClientNearCachePutGetWithPersistenceSelfTest.class); + suite.addTestSuite(IgnitePersistentStoreCacheGroupsTest.class); + return suite; } } http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/pds/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite2.java ---------------------------------------------------------------------- diff --git a/modules/pds/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite2.java b/modules/pds/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite2.java index 223c3cb..2db7ff7 100644 --- a/modules/pds/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite2.java +++ b/modules/pds/src/test/java/org/apache/ignite/testsuites/IgnitePdsTestSuite2.java @@ -19,10 +19,11 @@ package org.apache.ignite.testsuites; import junit.framework.TestSuite; import org.apache.ignite.cache.database.IgnitePersistentStoreAtomicCacheRebalancingTest; -import org.apache.ignite.cache.database.IgnitePersistentStoreTxCacheRebalancingTest; import org.apache.ignite.cache.database.IgnitePersistentStoreContinuousRestartSelfTest; +import org.apache.ignite.cache.database.IgnitePersistentStoreDataStructuresTest; import org.apache.ignite.cache.database.IgnitePersistentStorePageSizesTest; import org.apache.ignite.cache.database.IgnitePersistentStoreRecoveryAfterFileCorruptionTest; +import org.apache.ignite.cache.database.IgnitePersistentStoreTxCacheRebalancingTest; import org.apache.ignite.cache.database.db.DbPageEvictionDuringPartitionClearSelfTest; import org.apache.ignite.cache.database.db.IgniteDbWholeClusterRestartSelfTest; import org.apache.ignite.cache.database.db.RebalancingOnNotStableTopologyTest; @@ -70,6 +71,8 @@ public class IgnitePdsTestSuite2 extends TestSuite { suite.addTestSuite(IgnitePersistentStoreContinuousRestartSelfTest.class); + suite.addTestSuite(IgnitePersistentStoreDataStructuresTest.class); + return suite; } } http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/yardstick/pom.xml ---------------------------------------------------------------------- diff --git a/modules/yardstick/pom.xml b/modules/yardstick/pom.xml index f496e02..6e8bf9b 100644 --- a/modules/yardstick/pom.xml +++ b/modules/yardstick/pom.xml @@ -62,6 +62,12 @@ <dependency> <groupId>org.apache.ignite</groupId> + <artifactId>ignite-pds</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>org.apache.ignite</groupId> <artifactId>ignite-log4j</artifactId> <version>${project.version}</version> </dependency> http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/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 11f9472..602b227 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 @@ -20,12 +20,15 @@ package org.apache.ignite.yardstick; import com.beust.jcommander.Parameter; import org.apache.ignite.cache.CacheWriteSynchronizationMode; import org.apache.ignite.configuration.MemoryConfiguration; +import org.apache.ignite.configuration.PersistentStoreConfiguration; import org.apache.ignite.internal.util.tostring.GridToStringBuilder; +import org.apache.ignite.internal.util.tostring.GridToStringInclude; import org.apache.ignite.transactions.TransactionConcurrency; import org.apache.ignite.transactions.TransactionIsolation; import java.util.ArrayList; import java.util.List; +import org.jetbrains.annotations.Nullable; /** * Input arguments for Ignite benchmarks. @@ -82,7 +85,8 @@ public class IgniteBenchmarkArguments { /** */ @Parameter(names = {"-r", "--range"}, description = "Key range") - public int range = 1_000_000; + @GridToStringInclude + private int range = 1_000_000; /** */ @Parameter(names = {"-sf", "--scaleFactor"}, description = "Scale factor") @@ -194,6 +198,25 @@ public class IgniteBenchmarkArguments { @Parameter(names = {"-ps", "--pageSize"}, description = "Page size") private int pageSize = MemoryConfiguration.DFLT_PAGE_SIZE; + /** */ + @Parameter(names = {"-cg", "--cacheGrp"}, description = "Cache group for caches") + private String cacheGrp; + + /** */ + @Parameter(names = {"-cc", "--cachesCnt"}, description = "Number of caches to create") + private int cachesCnt = 1; + + /** */ + @Parameter(names = {"-pds", "--persistentStore"}, description = "Persistent store flag") + private boolean persistentStoreEnabled; + + /** + * @return {@code True} if need set {@link PersistentStoreConfiguration}. + */ + public boolean persistentStoreEnabled() { + return persistentStoreEnabled; + } + /** * @return List of enabled load test operations. */ @@ -475,6 +498,20 @@ public class IgniteBenchmarkArguments { } /** + * @return Name of cache group to be set for caches. + */ + @Nullable public String cacheGroup() { + return cacheGrp; + } + + /** + * @return Number of caches to create. + */ + public int cachesCount() { + return cachesCnt; + } + + /** * @return Description. */ public String description() { http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/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 6e25fc4..35fa949 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 @@ -25,11 +25,13 @@ import org.apache.ignite.IgniteCheckedException; import org.apache.ignite.IgniteSpring; import org.apache.ignite.Ignition; import org.apache.ignite.cache.eviction.lru.LruEvictionPolicy; +import org.apache.ignite.configuration.BinaryConfiguration; import org.apache.ignite.configuration.CacheConfiguration; import org.apache.ignite.configuration.ConnectorConfiguration; import org.apache.ignite.configuration.MemoryConfiguration; import org.apache.ignite.configuration.IgniteConfiguration; import org.apache.ignite.configuration.NearCacheConfiguration; +import org.apache.ignite.configuration.PersistentStoreConfiguration; import org.apache.ignite.configuration.TransactionConfiguration; import org.apache.ignite.internal.util.IgniteUtils; import org.apache.ignite.internal.util.typedef.internal.U; @@ -112,6 +114,9 @@ public class IgniteNode implements BenchmarkServer { cc.setNearConfiguration(nearCfg); } + if (args.cacheGroup() != null) + cc.setGroupName(args.cacheGroup()); + cc.setWriteSynchronizationMode(args.syncMode()); cc.setBackups(args.backups()); @@ -152,15 +157,23 @@ public class IgniteNode implements BenchmarkServer { c.setCommunicationSpi(commSpi); if (args.getPageSize() != MemoryConfiguration.DFLT_PAGE_SIZE) { - MemoryConfiguration dbCfg = c.getMemoryConfiguration(); + MemoryConfiguration memCfg = c.getMemoryConfiguration(); - if (dbCfg == null) { - dbCfg = new MemoryConfiguration(); + if (memCfg == null) { + memCfg = new MemoryConfiguration(); - c.setMemoryConfiguration(dbCfg); + c.setMemoryConfiguration(memCfg); } - dbCfg.setPageSize(args.getPageSize()); + memCfg.setPageSize(args.getPageSize()); + } + + if (args.persistentStoreEnabled()) { + PersistentStoreConfiguration pcCfg = new PersistentStoreConfiguration(); + + c.setBinaryConfiguration(new BinaryConfiguration().setCompactFooter(false)); + + c.setPersistentStoreConfiguration(pcCfg); } ignite = IgniteSpring.start(c, appCtx); http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/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 da5cb1d..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 @@ -19,21 +19,30 @@ package org.apache.ignite.yardstick.cache; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +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; 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.cache.model.SampleValue; import org.yardstickframework.BenchmarkConfiguration; import org.yardstickframework.BenchmarkUtils; +import static org.yardstickframework.BenchmarkUtils.println; + /** * Abstract class for Ignite benchmarks which use cache. */ @@ -42,21 +51,96 @@ public abstract class IgniteCacheAbstractBenchmark<K, V> extends IgniteAbstractB protected IgniteCache<K, V> cache; /** */ + protected List<IgniteCache> testCaches; + + /** */ private ThreadLocal<ThreadRange> threadRange = new ThreadLocal<>(); /** */ private AtomicInteger threadIdx = new AtomicInteger(); + /** */ + private int caches; + + /** */ + private final AtomicInteger opCacheIdx = new AtomicInteger(); + + /** */ + private final ThreadLocal<IgniteCache<K, V>> opCache = new ThreadLocal<>(); + + /** + * @return Cache for benchmark operation. + */ + protected final IgniteCache<K, V> cacheForOperation() { + return cacheForOperation(false); + } + + /** + * @param perThread If {@code true} then cache is selected once and set in thread local. + * @return Cache for benchmark operation. + */ + protected final IgniteCache<K, V> cacheForOperation(boolean perThread) { + if (caches > 1) { + if (perThread) { + IgniteCache<K, V> cache = opCache.get(); + + if (cache == null) { + cache = testCaches.get(opCacheIdx.getAndIncrement() % caches); + + opCache.set(cache); + + BenchmarkUtils.println(cfg, "Initialized cache for thread [cache=" + cache.getName() + ']'); + } + + return cache; + } + else + return testCaches.get(ThreadLocalRandom.current().nextInt(caches)); + } + + return cache; + } + /** {@inheritDoc} */ @Override public void setUp(BenchmarkConfiguration cfg) throws Exception { super.setUp(cfg); cache = cache(); + CacheConfiguration<?, ?> ccfg = cache.getConfiguration(CacheConfiguration.class); + + String grpName = ccfg.getGroupName(); + BenchmarkUtils.println(cfg, "Benchmark setUp [name=" + getClass().getSimpleName() + ", cacheName="+ cache.getName() + + ", cacheGroup="+ grpName + ", cacheCfg=" + cache.getConfiguration(CacheConfiguration.class) + ']'); + caches = args.cachesCount(); + + if (caches > 1) { + List<CacheConfiguration> toCreate = new ArrayList<>(); + + 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); + + toCreate.add(ccfg0); + } + + Collection<IgniteCache> caches = ignite().getOrCreateCaches(toCreate); + + testCaches = new ArrayList<>(caches); + + testCaches.add(cache); + + BenchmarkUtils.println(cfg, "Created additional caches [caches=" + testCaches.size() + + ", grp=" + grpName + ']'); + } + if (args.printPartitionStatistics()) { Map<ClusterNode, T2<List<Integer>, List<Integer>>> parts = new HashMap<>(); @@ -104,6 +188,80 @@ public abstract class IgniteCacheAbstractBenchmark<K, V> extends IgniteAbstractB } /** + * @throws Exception If failed. + */ + protected final void loadCachesData() throws Exception { + List<IgniteCache> caches = testCaches != null ? testCaches : Collections.<IgniteCache>singletonList(cache); + + if (caches.size() > 1) { + ExecutorService executor = Executors.newFixedThreadPool(10); + + try { + List<Future<?>> futs = new ArrayList<>(); + + for (final IgniteCache cache : caches) { + futs.add(executor.submit(new Runnable() { + @Override public void run() { + loadCacheData0(cache.getName()); + } + })); + } + + for (Future<?> fut : futs) + fut.get(); + } + finally { + executor.shutdown(); + } + } + else + loadCacheData(caches.get(0).getName()); + } + + /** + * @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); + + long start = System.nanoTime(); + + loadCacheData(cacheName); + + long time = ((System.nanoTime() - start) / 1_000_000); + + println(cfg, "Finished populating data [cache=" + cacheName + ", time=" + time + "ms]"); + } + + /** + * @param cacheName Cache name. + */ + protected void loadCacheData(String cacheName) { + throw new IllegalStateException("Not implemented for " + getClass().getSimpleName()); + } + + /** * @return Range. */ protected final ThreadRange threadRange() { http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetAllBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetAllBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetAllBenchmark.java index 2f76b7c..f563ec8 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetAllBenchmark.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetAllBenchmark.java @@ -19,6 +19,7 @@ package org.apache.ignite.yardstick.cache; import java.util.Map; import java.util.Set; +import org.apache.ignite.IgniteCache; import org.apache.ignite.internal.util.typedef.internal.U; /** @@ -35,6 +36,8 @@ public class IgniteGetAllBenchmark extends IgniteGetBenchmark { keys.add(key); } + IgniteCache<Integer, Object> cache = cacheForOperation(); + cache.getAll(keys); return true; http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetAllPutAllTxBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetAllPutAllTxBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetAllPutAllTxBenchmark.java index a8f6d7b..d984e64 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetAllPutAllTxBenchmark.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetAllPutAllTxBenchmark.java @@ -55,6 +55,8 @@ public class IgniteGetAllPutAllTxBenchmark extends IgniteCacheAbstractBenchmark< vals.put(key, key); } + IgniteCache<Integer, Integer> cache = cacheForOperation(); + cache.getAll(vals.keySet()); cache.putAll(vals); http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetAndPutBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetAndPutBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetAndPutBenchmark.java index 8d15e5e..f943f16 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetAndPutBenchmark.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetAndPutBenchmark.java @@ -29,6 +29,8 @@ public class IgniteGetAndPutBenchmark extends IgniteCacheAbstractBenchmark<Integ @Override public boolean test(Map<Object, Object> ctx) throws Exception { int key = nextRandom(args.range()); + IgniteCache<Integer, Object> cache = cacheForOperation(); + cache.getAndPut(key, new SampleValue(key)); return true; http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetAndPutTxBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetAndPutTxBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetAndPutTxBenchmark.java index 0a3794c..4a1af43 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetAndPutTxBenchmark.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetAndPutTxBenchmark.java @@ -49,6 +49,8 @@ public class IgniteGetAndPutTxBenchmark extends IgniteCacheAbstractBenchmark<Int @Override public Void call() throws Exception { int key = nextRandom(args.range()); + IgniteCache<Integer, Object> cache = cacheForOperation(); + cache.getAndPut(key, new SampleValue(key)); return null; http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/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 6154ba4..96a99ff 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,19 +19,12 @@ 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. */ public class IgniteGetBenchmark extends IgniteCacheAbstractBenchmark<Integer, Object> { - /** */ - private static final String CACHE_NAME = "atomic"; - /** {@inheritDoc} */ @Override public void setUp(BenchmarkConfiguration cfg) throws Exception { super.setUp(cfg); @@ -40,32 +33,20 @@ public class IgniteGetBenchmark extends IgniteCacheAbstractBenchmark<Integer, Ob throw new IllegalArgumentException("Preloading amount (\"-pa\", \"--preloadAmount\") " + "must by less then the range (\"-r\", \"--range\")."); - String cacheName = cache().getName(); - - println(cfg, "Loading data for cache: " + cacheName); - - long start = System.nanoTime(); - - 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); - } - } - } + loadCachesData(); + } - println(cfg, "Finished populating query data in " + ((System.nanoTime() - start) / 1_000_000) + " ms."); + /** {@inheritDoc} */ + @Override protected void loadCacheData(String cacheName) { + loadSampleValues(cacheName, args.preloadAmount()); } /** {@inheritDoc} */ @Override public boolean test(Map<Object, Object> ctx) throws Exception { int key = nextRandom(args.range()); + IgniteCache<Integer, Object> cache = cacheForOperation(); + cache.get(key); return true; @@ -73,6 +54,6 @@ public class IgniteGetBenchmark extends IgniteCacheAbstractBenchmark<Integer, Ob /** {@inheritDoc} */ @Override protected IgniteCache<Integer, Object> cache() { - return ignite().cache(CACHE_NAME); + return ignite().cache("atomic"); } } http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetEntriesPutAllTxBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetEntriesPutAllTxBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetEntriesPutAllTxBenchmark.java index 501e12d..fd61d5f 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetEntriesPutAllTxBenchmark.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetEntriesPutAllTxBenchmark.java @@ -47,6 +47,8 @@ public class IgniteGetEntriesPutAllTxBenchmark extends IgniteCacheAbstractBenchm doInTransaction(txs, args.txConcurrency(), args.txIsolation(), new Callable<Void>() { @Override public Void call() throws Exception { + IgniteCache<Integer, Integer> cache = cacheForOperation(); + SortedMap<Integer, Integer> vals = new TreeMap<>(); for (int i = 0; i < args.batch(); i++) { http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteInvokeBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteInvokeBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteInvokeBenchmark.java index a1e80f0..fa29cc4 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteInvokeBenchmark.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteInvokeBenchmark.java @@ -31,6 +31,8 @@ public class IgniteInvokeBenchmark extends IgniteCacheAbstractBenchmark<Integer, @Override public boolean test(Map<Object, Object> ctx) throws Exception { int key = nextRandom(args.range()); + IgniteCache<Integer, Object> cache = cacheForOperation(); + cache.invoke(key, new SetValueEntryProcessor(new SampleValue(key))); return true; http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteInvokeTxBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteInvokeTxBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteInvokeTxBenchmark.java index 64dc6b8..c30ff29 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteInvokeTxBenchmark.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteInvokeTxBenchmark.java @@ -49,6 +49,8 @@ public class IgniteInvokeTxBenchmark extends IgniteInvokeBenchmark { @Override public Void call() throws Exception { int key = nextRandom(args.range()); + IgniteCache<Integer, Object> cache = cacheForOperation(); + cache.invoke(key, new SetValueEntryProcessor(new SampleValue(key))); return null; http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteInvokeWithInjectionBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteInvokeWithInjectionBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteInvokeWithInjectionBenchmark.java index ef9d17b..93704cc 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteInvokeWithInjectionBenchmark.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteInvokeWithInjectionBenchmark.java @@ -34,6 +34,8 @@ public class IgniteInvokeWithInjectionBenchmark extends IgniteCacheAbstractBench @Override public boolean test(Map<Object, Object> ctx) throws Exception { int key = nextRandom(args.range()); + IgniteCache<Integer, Object> cache = cacheForOperation(); + cache.invoke(key, new SetValueEntryProcessor(new SampleValue(key))); return true; http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutAllBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutAllBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutAllBenchmark.java index 33aa205..dc21029 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutAllBenchmark.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutAllBenchmark.java @@ -131,6 +131,8 @@ public class IgnitePutAllBenchmark extends IgniteCacheAbstractBenchmark<Integer, } } + IgniteCache<Integer, Object> cache = cacheForOperation(); + cache.putAll(vals); return true; http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutAllSerializableTxBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutAllSerializableTxBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutAllSerializableTxBenchmark.java index 200400e..089ee7a 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutAllSerializableTxBenchmark.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutAllSerializableTxBenchmark.java @@ -54,6 +54,8 @@ public class IgnitePutAllSerializableTxBenchmark extends IgniteCacheAbstractBenc vals.put(key, key); } + IgniteCache<Integer, Object> cache = cacheForOperation(); + while (true) { try (Transaction tx = txs.txStart(OPTIMISTIC, SERIALIZABLE)) { cache.putAll(vals); http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutBenchmark.java index 69db87f..ebee87c 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutBenchmark.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutBenchmark.java @@ -29,6 +29,8 @@ public class IgnitePutBenchmark extends IgniteCacheAbstractBenchmark<Integer, Ob @Override public boolean test(Map<Object, Object> ctx) throws Exception { int key = nextRandom(args.range()); + IgniteCache<Integer, Object> cache = cacheForOperation(); + cache.put(key, new SampleValue(key)); return true; http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetBatchBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetBatchBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetBatchBenchmark.java index a9f59d4..9526896 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetBatchBenchmark.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetBatchBenchmark.java @@ -30,6 +30,8 @@ import org.apache.ignite.yardstick.cache.model.SampleValue; public class IgnitePutGetBatchBenchmark extends IgniteCacheAbstractBenchmark<Integer, Object> { /** {@inheritDoc} */ @Override public boolean test(Map<Object, Object> ctx) throws Exception { + IgniteCache<Integer, Object> cache = cacheForOperation(); + Set<Integer> keys = new TreeSet<>(); while (keys.size() < args.batch()) http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetBenchmark.java index 42f308c..cc29e47 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetBenchmark.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetBenchmark.java @@ -29,6 +29,8 @@ public class IgnitePutGetBenchmark extends IgniteCacheAbstractBenchmark<Integer, @Override public boolean test(Map<Object, Object> ctx) throws Exception { int key = nextRandom(args.range()); + IgniteCache<Integer, Object> cache = cacheForOperation(); + Object val = cache.get(key); if (val != null) http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetEntryBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetEntryBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetEntryBenchmark.java index 1289fa1..eb49b57 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetEntryBenchmark.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetEntryBenchmark.java @@ -28,6 +28,8 @@ import org.apache.ignite.yardstick.cache.model.SampleValue; public class IgnitePutGetEntryBenchmark extends IgniteCacheAbstractBenchmark<Integer, Object> { /** {@inheritDoc} */ @Override public boolean test(Map<Object, Object> ctx) throws Exception { + IgniteCache<Integer, Object> cache = cacheForOperation(); + int key = nextRandom(args.range()); CacheEntry<Integer, Object> val = cache.getEntry(key); http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetEntryTxBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetEntryTxBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetEntryTxBenchmark.java index 6e58b41..5b35009 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetEntryTxBenchmark.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetEntryTxBenchmark.java @@ -45,6 +45,8 @@ public class IgnitePutGetEntryTxBenchmark extends IgniteCacheAbstractBenchmark<I clo = new Callable<Void>() { @Override public Void call() throws Exception { + IgniteCache<Integer, Object> cache = cacheForOperation(); + int key = nextRandom(0, args.range() / 2); CacheEntry<Integer, Object> val = cache.getEntry(key); http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetTxBatchBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetTxBatchBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetTxBatchBenchmark.java index 7ac8180..954f93f 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetTxBatchBenchmark.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetTxBatchBenchmark.java @@ -47,6 +47,8 @@ public class IgnitePutGetTxBatchBenchmark extends IgniteCacheAbstractBenchmark<I clo = new Callable<Void>() { @Override public Void call() throws Exception { + IgniteCache<Integer, Object> cache = cacheForOperation(); + Set<Integer> keys = new TreeSet<>(); while (keys.size() < args.batch()) http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetTxBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetTxBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetTxBenchmark.java index 3235721..6b11ef8 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetTxBenchmark.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutGetTxBenchmark.java @@ -44,6 +44,8 @@ public class IgnitePutGetTxBenchmark extends IgniteCacheAbstractBenchmark<Intege clo = new Callable<Void>() { @Override public Void call() throws Exception { + IgniteCache<Integer, Object> cache = cacheForOperation(); + int key = nextRandom(0, args.range() / 2); Object val = cache.get(key); http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutIfAbsentIndexedValue1Benchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutIfAbsentIndexedValue1Benchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutIfAbsentIndexedValue1Benchmark.java index aea909a..8430b12 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutIfAbsentIndexedValue1Benchmark.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutIfAbsentIndexedValue1Benchmark.java @@ -31,6 +31,8 @@ public class IgnitePutIfAbsentIndexedValue1Benchmark extends IgniteCacheAbstract /** {@inheritDoc} */ @Override public boolean test(Map<Object, Object> ctx) throws Exception { + IgniteCache<Integer, Object> cache = cacheForOperation(); + int key = insCnt.getAndIncrement(); cache.putIfAbsent(key, new Person1(key)); http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutIndexedValue1Benchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutIndexedValue1Benchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutIndexedValue1Benchmark.java index 6f06015..af206fe 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutIndexedValue1Benchmark.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutIndexedValue1Benchmark.java @@ -27,6 +27,8 @@ import org.apache.ignite.yardstick.cache.model.Person1; public class IgnitePutIndexedValue1Benchmark extends IgniteCacheAbstractBenchmark<Integer, Object> { /** {@inheritDoc} */ @Override public boolean test(Map<Object, Object> ctx) throws Exception { + IgniteCache<Integer, Object> cache = cacheForOperation(); + int key = nextRandom(args.range()); cache.put(key, new Person1(key)); http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutIndexedValue2Benchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutIndexedValue2Benchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutIndexedValue2Benchmark.java index 0112163..7c62714 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutIndexedValue2Benchmark.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutIndexedValue2Benchmark.java @@ -27,6 +27,8 @@ import org.apache.ignite.yardstick.cache.model.Person2; public class IgnitePutIndexedValue2Benchmark extends IgniteCacheAbstractBenchmark<Integer, Object> { /** {@inheritDoc} */ @Override public boolean test(Map<Object, Object> ctx) throws Exception { + IgniteCache<Integer, Object> cache = cacheForOperation(); + int key = nextRandom(args.range()); cache.put(key, new Person2(key)); http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutIndexedValue8Benchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutIndexedValue8Benchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutIndexedValue8Benchmark.java index dae32b4..a34e386 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutIndexedValue8Benchmark.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutIndexedValue8Benchmark.java @@ -27,6 +27,8 @@ import org.apache.ignite.yardstick.cache.model.Person8; public class IgnitePutIndexedValue8Benchmark extends IgniteCacheAbstractBenchmark<Integer, Object> { /** {@inheritDoc} */ @Override public boolean test(Map<Object, Object> ctx) throws Exception { + IgniteCache<Integer, Object> cache = cacheForOperation(); + int key = nextRandom(args.range()); cache.put(key, new Person8(key)); http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutRandomValueSizeBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutRandomValueSizeBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutRandomValueSizeBenchmark.java index 180b50e..db631aba 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutRandomValueSizeBenchmark.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutRandomValueSizeBenchmark.java @@ -26,6 +26,8 @@ import org.apache.ignite.IgniteCache; public class IgnitePutRandomValueSizeBenchmark extends IgniteCacheAbstractBenchmark<Integer, Object> { /** {@inheritDoc} */ @Override public boolean test(Map<Object, Object> ctx) throws Exception { + IgniteCache<Integer, Object> cache = cacheForOperation(); + int key = nextRandom(args.range()); int size = 64 + nextRandom(64); http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutRemoveBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutRemoveBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutRemoveBenchmark.java index 7ea3d91..564bff5 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutRemoveBenchmark.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutRemoveBenchmark.java @@ -27,6 +27,8 @@ import org.apache.ignite.yardstick.cache.model.SampleValue; public class IgnitePutRemoveBenchmark extends IgniteCacheAbstractBenchmark<Integer, Object> { /** {@inheritDoc} */ @Override public boolean test(Map<Object, Object> ctx) throws Exception { + IgniteCache<Integer, Object> cache = cacheForOperation(); + int key = nextRandom(args.range()); cache.put(key, new SampleValue(key)); http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutTxBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutTxBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutTxBenchmark.java index 15b7cd6..0a8a470 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutTxBenchmark.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutTxBenchmark.java @@ -47,6 +47,8 @@ public class IgnitePutTxBenchmark extends IgniteCacheAbstractBenchmark<Integer, clo = new Callable<Void>() { @Override public Void call() throws Exception { + IgniteCache<Integer, Object> cache = cacheForOperation(); + int key = nextRandom(args.range()); cache.put(key, new SampleValue(key)); http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutTxImplicitBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutTxImplicitBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutTxImplicitBenchmark.java index 89d87a8..d1070fb 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutTxImplicitBenchmark.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutTxImplicitBenchmark.java @@ -37,6 +37,8 @@ public class IgnitePutTxImplicitBenchmark extends IgniteCacheAbstractBenchmark<I /** {@inheritDoc} */ @Override public boolean test(Map<Object, Object> ctx) throws Exception { + IgniteCache<Integer, Object> cache = cacheForOperation(); + int key = nextRandom(args.range()); // Implicit transaction is used. http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutTxPrimaryOnlyBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutTxPrimaryOnlyBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutTxPrimaryOnlyBenchmark.java index 21275eb..5e79acd 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutTxPrimaryOnlyBenchmark.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutTxPrimaryOnlyBenchmark.java @@ -39,6 +39,8 @@ public class IgnitePutTxPrimaryOnlyBenchmark extends IgniteCacheAbstractBenchmar /** {@inheritDoc} */ @Override public boolean test(Map<Object, Object> ctx) throws Exception { + IgniteCache<Integer, Object> cache = cacheForOperation(); + int key; Affinity<Object> aff = ignite().affinity("tx"); http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutTxSkipLocalBackupBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutTxSkipLocalBackupBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutTxSkipLocalBackupBenchmark.java index 63934e6..29d565a 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutTxSkipLocalBackupBenchmark.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutTxSkipLocalBackupBenchmark.java @@ -39,6 +39,8 @@ public class IgnitePutTxSkipLocalBackupBenchmark extends IgniteCacheAbstractBenc /** {@inheritDoc} */ @Override public boolean test(Map<Object, Object> ctx) throws Exception { + IgniteCache<Integer, Object> cache = cacheForOperation(); + int key; Affinity<Object> aff = ignite().affinity("tx"); http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutValue8Benchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutValue8Benchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutValue8Benchmark.java index 6a3d492..e4ac2e2 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutValue8Benchmark.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutValue8Benchmark.java @@ -28,6 +28,8 @@ import java.util.Map; public class IgnitePutValue8Benchmark extends IgniteCacheAbstractBenchmark<Integer, Object> { /** {@inheritDoc} */ @Override public boolean test(Map<Object, Object> ctx) throws Exception { + IgniteCache<Integer, Object> cache = cacheForOperation(); + int key = nextRandom(args.range()); cache.put(key, new Person8(key)); http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteReplaceIndexedValue1Benchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteReplaceIndexedValue1Benchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteReplaceIndexedValue1Benchmark.java index cc50c84..70b94ab 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteReplaceIndexedValue1Benchmark.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteReplaceIndexedValue1Benchmark.java @@ -66,6 +66,8 @@ public class IgniteReplaceIndexedValue1Benchmark extends IgniteCacheAbstractBenc @Override public boolean test(Map<Object, Object> ctx) throws Exception { ThreadLocalRandom rnd = ThreadLocalRandom.current(); + IgniteCache<Integer, Object> cache = cacheForOperation(); + cache.replace(rnd.nextInt(args.range()), new Person1(rnd.nextInt(args.range()))); return true; http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/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); + } + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryBenchmark.java index 8e31455..732cb71 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryBenchmark.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryBenchmark.java @@ -37,20 +37,22 @@ public class IgniteSqlQueryBenchmark extends IgniteCacheAbstractBenchmark<Intege @Override public void setUp(BenchmarkConfiguration cfg) throws Exception { super.setUp(cfg); - println(cfg, "Populating query data..."); + loadCachesData(); + } - long start = System.nanoTime(); + /** {@inheritDoc} */ + @Override protected void loadCacheData(String cacheName) { + try (IgniteDataStreamer<Integer, Person> dataLdr = ignite().dataStreamer(cacheName)) { + for (int i = 0; i < args.range(); i++) { + if (i % 100 == 0 && Thread.currentThread().isInterrupted()) + break; - try (IgniteDataStreamer<Integer, Person> dataLdr = ignite().dataStreamer(cache.getName())) { - for (int i = 0; i < args.range() && !Thread.currentThread().isInterrupted(); i++) { dataLdr.addData(i, new Person(i, "firstName" + i, "lastName" + i, i * 1000)); if (i % 100000 == 0) println(cfg, "Populated persons: " + i); } } - - println(cfg, "Finished populating query data in " + ((System.nanoTime() - start) / 1_000_000) + " ms."); } /** {@inheritDoc} */ @@ -79,6 +81,8 @@ public class IgniteSqlQueryBenchmark extends IgniteCacheAbstractBenchmark<Intege * @throws Exception If failed. */ private Collection<Cache.Entry<Integer, Object>> executeQuery(double minSalary, double maxSalary) throws Exception { + IgniteCache<Integer, Object> cache = cacheForOperation(true); + SqlQuery qry = new SqlQuery(Person.class, "salary >= ? and salary <= ?"); qry.setArgs(minSalary, maxSalary); http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryDistributedJoinBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryDistributedJoinBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryDistributedJoinBenchmark.java index c5fdeb2..8f4829d 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryDistributedJoinBenchmark.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryDistributedJoinBenchmark.java @@ -47,14 +47,23 @@ public class IgniteSqlQueryDistributedJoinBenchmark extends IgniteCacheAbstractB println(cfg, "Populating query data..."); - long start = System.nanoTime(); - range = args.range(); if (range <= 0) throw new IllegalArgumentException(); - try (IgniteDataStreamer<Object, Object> dataLdr = ignite().dataStreamer(cache.getName())) { + println(cfg, "Populating join query data [orgCnt=" + range + + ", personCnt=" + range + + ", broadcastJoin=" + broadcast + "]"); + + loadCachesData(); + + executeQueryJoin(0, broadcast, true); + } + + /** {@inheritDoc} */ + @Override protected void loadCacheData(String cacheName) { + try (IgniteDataStreamer<Object, Object> dataLdr = ignite().dataStreamer(cacheName)) { for (int orgId = 0; orgId < range; orgId++) { dataLdr.addData(orgId, new Organization(orgId, "org" + orgId)); @@ -73,13 +82,6 @@ public class IgniteSqlQueryDistributedJoinBenchmark extends IgniteCacheAbstractB dataLdr.close(); } - - println(cfg, "Finished populating join query [orgCnt=" + range + - ", personCnt=" + range + - ", broadcastJoin=" + broadcast + - ", time=" + ((System.nanoTime() - start) / 1_000_000) + "ms]"); - - executeQueryJoin(0, broadcast, true); } /** @@ -141,6 +143,8 @@ public class IgniteSqlQueryDistributedJoinBenchmark extends IgniteCacheAbstractB qry.setDistributedJoins(true); qry.setArgs(orgId); + IgniteCache<Integer, Object> cache = cacheForOperation(true); + if (planOnly) { String plan = (String)cache.query(qry).getAll().get(0).get(0); http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryJoinBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryJoinBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryJoinBenchmark.java index 1f8006d..1160803 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryJoinBenchmark.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryJoinBenchmark.java @@ -40,9 +40,15 @@ public class IgniteSqlQueryJoinBenchmark extends IgniteCacheAbstractBenchmark<In println(cfg, "Populating query data..."); - long start = System.nanoTime(); + loadCachesData(); + } + + /** {@inheritDoc} */ + @Override protected void loadCacheData(String cacheName) { + if (args.range() < 100) + throw new IllegalArgumentException("Invalid range: " + args.range()); - try (IgniteDataStreamer<Object, Object> dataLdr = ignite().dataStreamer(cache.getName())) { + try (IgniteDataStreamer<Object, Object> dataLdr = ignite().dataStreamer(cacheName)) { final int orgRange = args.range() / 10; // Populate organizations. @@ -61,8 +67,6 @@ public class IgniteSqlQueryJoinBenchmark extends IgniteCacheAbstractBenchmark<In println(cfg, "Populated persons: " + i); } } - - println(cfg, "Finished populating join query data in " + ((System.nanoTime() - start) / 1_000_000) + " ms."); } /** {@inheritDoc} */ @@ -100,6 +104,8 @@ public class IgniteSqlQueryJoinBenchmark extends IgniteCacheAbstractBenchmark<In * @throws Exception If failed. */ private Collection<List<?>> executeQueryJoin(double minSalary, double maxSalary) throws Exception { + IgniteCache<Integer, Object> cache = cacheForOperation(true); + SqlFieldsQuery qry = new SqlFieldsQuery( "select p.id, p.orgId, p.firstName, p.lastName, p.salary, o.name " + "from Person p " + http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryPutBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryPutBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryPutBenchmark.java index dfa4cbc..a67f0dc 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryPutBenchmark.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryPutBenchmark.java @@ -25,7 +25,6 @@ import javax.cache.Cache; import org.apache.ignite.IgniteCache; import org.apache.ignite.cache.query.SqlQuery; import org.apache.ignite.yardstick.cache.model.Person; -import org.yardstickframework.BenchmarkConfiguration; import static org.yardstickframework.BenchmarkUtils.println; @@ -40,14 +39,11 @@ public class IgniteSqlQueryPutBenchmark extends IgniteCacheAbstractBenchmark<Int private AtomicInteger qryCnt = new AtomicInteger(); /** {@inheritDoc} */ - @Override public void setUp(BenchmarkConfiguration cfg) throws Exception { - super.setUp(cfg); - } - - /** {@inheritDoc} */ @Override public boolean test(Map<Object, Object> ctx) throws Exception { ThreadLocalRandom rnd = ThreadLocalRandom.current(); + IgniteCache<Integer, Object> cache = cacheForOperation(true); + if (rnd.nextBoolean()) { double salary = rnd.nextDouble() * args.range() * 1000; http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryPutSeparatedBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryPutSeparatedBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryPutSeparatedBenchmark.java index b74978e..2ba06cf 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryPutSeparatedBenchmark.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteSqlQueryPutSeparatedBenchmark.java @@ -55,6 +55,8 @@ public class IgniteSqlQueryPutSeparatedBenchmark extends IgniteCacheAbstractBenc } } else { + IgniteCache<Integer, Object> cache = cacheForOperation(true); + int i = rnd.nextInt(args.range()); cache.put(i, new Person(i, "firstName" + i, "lastName" + i, i * 1000)); @@ -70,6 +72,8 @@ public class IgniteSqlQueryPutSeparatedBenchmark extends IgniteCacheAbstractBenc * @throws Exception If failed. */ private Collection<Cache.Entry<Integer, Object>> executeQuery(double minSalary, double maxSalary) throws Exception { + IgniteCache<Integer, Object> cache = cacheForOperation(true); + SqlQuery qry = new SqlQuery(Person.class, "salary >= ? and salary <= ?"); qry.setArgs(minSalary, maxSalary); http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/jdbc/JdbcPutGetBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/jdbc/JdbcPutGetBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/jdbc/JdbcPutGetBenchmark.java index 8ee7679..a68b2b2 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/jdbc/JdbcPutGetBenchmark.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/jdbc/JdbcPutGetBenchmark.java @@ -28,8 +28,8 @@ import static org.apache.ignite.yardstick.cache.jdbc.JdbcPutBenchmark.createUpse public class JdbcPutGetBenchmark extends JdbcAbstractBenchmark { /** {@inheritDoc} */ @Override public boolean test(Map<Object, Object> ctx) throws Exception { - int newKey = nextRandom(args.range); - int newVal = nextRandom(args.range); + int newKey = nextRandom(args.range()); + int newVal = nextRandom(args.range()); try (PreparedStatement stmt = createUpsertStatement(conn.get(), newKey, newVal)) { if (stmt.executeUpdate() <= 0) http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/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 4010f5e..681ba34 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 @@ -31,6 +31,9 @@ import java.util.TreeMap; import java.util.TreeSet; import java.util.UUID; import java.util.concurrent.Callable; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.atomic.AtomicLong; import javax.cache.CacheException; @@ -267,7 +270,7 @@ public class IgniteCacheRandomOperationBenchmark extends IgniteAbstractBenchmark keys.add(keyCls); else throw new IgniteException("Class is unknown for the load test. Make sure you " + - "specified its full name [clsName=" + queryEntity.getKeyType() + ']'); + "specified its full name [cache=" + cacheName + ", clsName=" + queryEntity.getKeyType() + ']'); } if (queryEntity.getValueType() != null) { @@ -277,7 +280,7 @@ public class IgniteCacheRandomOperationBenchmark extends IgniteAbstractBenchmark values.add(valCls); else throw new IgniteException("Class is unknown for the load test. Make sure you " + - "specified its full name [clsName=" + queryEntity.getKeyType() + ']'); + "specified its full name [cache=" + cacheName + ", clsName=" + queryEntity.getValueType() + ']'); configureCacheSqlDescriptor(cacheName, queryEntity, valCls); } @@ -448,25 +451,36 @@ public class IgniteCacheRandomOperationBenchmark extends IgniteAbstractBenchmark startPreloadLogging(args.preloadLogsInterval()); - Thread[] threads = new Thread[availableCaches.size()]; + ExecutorService executor = Executors.newFixedThreadPool(10); - for (int i = 0; i < availableCaches.size(); i++) { - final String cacheName = availableCaches.get(i).getName(); + try { + List<Future<?>> futs = new ArrayList<>(); + + final Thread thread = Thread.currentThread(); + + for (int i = 0; i < availableCaches.size(); i++) { + final String cacheName = availableCaches.get(i).getName(); - threads[i] = new Thread() { - @Override public void run() { - try (IgniteDataStreamer<Object, Object> dataLdr = ignite().dataStreamer(cacheName)) { - for (int i = 0; i < args.preloadAmount() && !isInterrupted(); i++) - dataLdr.addData(createRandomKey(i, cacheName), createRandomValue(i, cacheName)); + futs.add(executor.submit(new Runnable() { + @Override public void run() { + try (IgniteDataStreamer<Object, Object> dataLdr = ignite().dataStreamer(cacheName)) { + for (int i = 0; i < args.preloadAmount(); i++) { + if (i % 100 == 0 && thread.isInterrupted()) + break; + + dataLdr.addData(createRandomKey(i, cacheName), createRandomValue(i, cacheName)); + } + } } - } - }; + })); + } - threads[i].start(); + for (Future<?> fut : futs) + fut.get(); + } + finally { + executor.shutdown(); } - - for (Thread thread : threads) - thread.join(); stopPreloadLogging(); } http://git-wip-us.apache.org/repos/asf/ignite/blob/7e45010b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/model/ModelUtil.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/model/ModelUtil.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/model/ModelUtil.java index 9268cdd..667e8c9 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/model/ModelUtil.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/model/ModelUtil.java @@ -38,6 +38,7 @@ public class ModelUtil { * Classes of keys. */ private static Class[] keyClasses = { + Integer.class, Double.class, Identifier.class, Mark.class, @@ -104,7 +105,7 @@ public class ModelUtil { * @return object from model */ public static Object create(Class c, int id) { - Object res = null; + Object res; switch (c.getSimpleName()) { case "Double": @@ -150,6 +151,9 @@ public class ModelUtil { break; case "String": res = String.valueOf(id); + break; + default: + throw new IllegalArgumentException("Unsupported class: " + c.getSimpleName()); } return res;
