# ignite-32 Add tx benchmark for store.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/fe7c2afc Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/fe7c2afc Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/fe7c2afc Branch: refs/heads/ignite-188 Commit: fe7c2afc0872d19e54f6a0e08a764b5cc7f3de0c Parents: 26e252f Author: anovikov <anovi...@gridgain.com> Authored: Fri Feb 6 09:49:06 2015 +0700 Committer: anovikov <anovi...@gridgain.com> Committed: Fri Feb 6 09:49:06 2015 +0700 ---------------------------------------------------------------------- .../yardstick/config/benchmark-store.properties | 35 ++++---- .../yardstick/config/ignite-store-config.xml | 7 +- .../jdbc/IgniteJdbcStoreAbstractBenchmark.java | 84 ++++++++++++++++++-- .../store/jdbc/IgniteJdbcStoreGetBenchmark.java | 10 +-- .../jdbc/IgniteJdbcStoreGetTxBenchmark.java | 47 +++++++++++ .../store/jdbc/IgniteJdbcStorePutBenchmark.java | 5 ++ .../jdbc/IgniteJdbcStorePutGetBenchmark.java | 5 ++ .../jdbc/IgniteJdbcStorePutGetTxBenchmark.java | 52 ++++++++++++ .../jdbc/IgniteJdbcStorePutTxBenchmark.java | 47 +++++++++++ 9 files changed, 260 insertions(+), 32 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/fe7c2afc/modules/yardstick/config/benchmark-store.properties ---------------------------------------------------------------------- diff --git a/modules/yardstick/config/benchmark-store.properties b/modules/yardstick/config/benchmark-store.properties index fcf3eb7..4a88724 100644 --- a/modules/yardstick/config/benchmark-store.properties +++ b/modules/yardstick/config/benchmark-store.properties @@ -19,32 +19,36 @@ # Contains all benchmarks for: # - ATOMIC cache # - TRANSACTIONAL cache -# - SQL queries # # JVM options. JVM_OPTS=${JVM_OPTS}" -DGRIDGAIN_QUIET=false" # Uncomment to enable concurrent garbage collection (GC) if you encounter long GC pauses. -# JVM_OPTS=${JVM_OPTS}" \ -# -XX:+UseParNewGC \ -# -XX:+UseConcMarkSweepGC \ -# -XX:+UseTLAB \ -# -XX:NewSize=128m \ -# -XX:MaxNewSize=128m \ -# -XX:MaxTenuringThreshold=0 \ -# -XX:SurvivorRatio=1024 \ -# -XX:+UseCMSInitiatingOccupancyOnly \ -# -XX:CMSInitiatingOccupancyFraction=60 \ -#" +JVM_OPTS=${JVM_OPTS}" \ + -Xloggc:./gc.log \ + -XX:+PrintGCDetails \ + -verbose:gc \ + -XX:+UseParNewGC \ + -XX:+UseConcMarkSweepGC \ + -XX:+UseTLAB \ + -XX:NewSize=128m \ + -XX:MaxNewSize=128m \ + -XX:MaxTenuringThreshold=0 \ + -XX:SurvivorRatio=1024 \ + -XX:+UseCMSInitiatingOccupancyOnly \ + -XX:CMSInitiatingOccupancyFraction=60 \ +" # List of default probes. # Add DStatProbe or VmStatProbe if your OS supports it (e.g. if running on Linux). -BENCHMARK_DEFAULT_PROBES=ThroughputLatencyProbe,PercentileProbe +BENCHMARK_DEFAULT_PROBES=ThroughputLatencyProbe,PercentileProbe,DStatProbe # Packages where the specified benchmark is searched by reflection mechanism. BENCHMARK_PACKAGES=org.yardstickframework,org.apache.ignite.yardstick +RESTART_SERVERS=true + # Probe point writer class name. # BENCHMARK_WRITER= @@ -64,6 +68,9 @@ nodesNum=$((`echo ${SERVER_HOSTS} | tr ',' '\n' | wc -l` + `echo ${DRIVER_HOSTS} # Note that each benchmark is set to run for 300 seconds (5 mins) with warm-up set to 60 seconds (1 minute). CONFIGS="\ -cfg ${SCRIPT_DIR}/../config/ignite-store-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgniteJdbcStoreGetBenchmark -sn IgniteNode -ds atomic-get,\ +-cfg ${SCRIPT_DIR}/../config/ignite-store-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgniteJdbcStoreGetTxBenchmark -sn IgniteNode -ds tx-get,\ -cfg ${SCRIPT_DIR}/../config/ignite-store-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgniteJdbcStorePutBenchmark -sn IgniteNode -ds atomic-put,\ --cfg ${SCRIPT_DIR}/../config/ignite-store-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgniteJdbcStorePutGetBenchmark -sn IgniteNode -ds atomic-put-get\ +-cfg ${SCRIPT_DIR}/../config/ignite-store-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgniteJdbcStorePutTxBenchmark -sn IgniteNode -ds tx-put,\ +-cfg ${SCRIPT_DIR}/../config/ignite-store-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgniteJdbcStorePutGetBenchmark -sn IgniteNode -ds atomic-put-get,\ +-cfg ${SCRIPT_DIR}/../config/ignite-store-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgniteJdbcStorePutGetTxBenchmark -sn IgniteNode -ds tx-put-get\ " http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/fe7c2afc/modules/yardstick/config/ignite-store-config.xml ---------------------------------------------------------------------- diff --git a/modules/yardstick/config/ignite-store-config.xml b/modules/yardstick/config/ignite-store-config.xml index ee6515a..6570c9e 100644 --- a/modules/yardstick/config/ignite-store-config.xml +++ b/modules/yardstick/config/ignite-store-config.xml @@ -26,7 +26,6 @@ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> <bean id="sampleTypeMetadata" class="org.apache.ignite.cache.CacheTypeMetadata"> - <property name="databaseSchema" value="PUBLIC"/> <property name="databaseTable" value="SAMPLE"/> <property name="keyType" value="org.apache.ignite.yardstick.cache.model.SampleKey"/> <property name="valueType" value="org.apache.ignite.yardstick.cache.model.SampleValue"/> @@ -43,7 +42,7 @@ <property name="valueFields"> <list> <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata"> - <property name="databaseName" value="ID"/> + <property name="databaseName" value="VALUE"/> <property name="databaseType" value="4"/> <property name="javaName" value="id"/> <property name="javaType" value="java.lang.Integer"/> @@ -98,7 +97,7 @@ <bean class="org.apache.ignite.cache.store.jdbc.JdbcPojoCacheStore"> <property name="dataSource"> <bean class="org.h2.jdbcx.JdbcConnectionPool" factory-method="create"> - <constructor-arg value="jdbc:h2:tcp://localhost//Users/nva/work/h2-test"/> + <constructor-arg value="jdbc:h2:tcp://localhost/store-benchmark/h2-benchmark"/> <constructor-arg value="sa"/> <constructor-arg value=""/> </bean> @@ -138,7 +137,7 @@ <bean class="org.apache.ignite.cache.store.jdbc.JdbcPojoCacheStore"> <property name="dataSource"> <bean class="org.h2.jdbcx.JdbcConnectionPool" factory-method="create"> - <constructor-arg value="jdbc:h2:tcp://localhost//Users/nva/work/h2-test"/> + <constructor-arg value="jdbc:h2:tcp://localhost/store-benchmark/h2-benchmark"/> <constructor-arg value="sa"/> <constructor-arg value=""/> </bean> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/fe7c2afc/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/store/jdbc/IgniteJdbcStoreAbstractBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/store/jdbc/IgniteJdbcStoreAbstractBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/store/jdbc/IgniteJdbcStoreAbstractBenchmark.java index 5719dd7..46c7262 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/store/jdbc/IgniteJdbcStoreAbstractBenchmark.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/store/jdbc/IgniteJdbcStoreAbstractBenchmark.java @@ -18,9 +18,14 @@ package org.apache.ignite.yardstick.cache.store.jdbc; import org.apache.ignite.*; +import org.apache.ignite.cache.*; +import org.apache.ignite.cache.store.jdbc.*; +import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.yardstick.*; import org.yardstickframework.*; +import java.sql.*; + /** * Abstract class for Ignite benchmarks which use cache. */ @@ -28,17 +33,84 @@ public abstract class IgniteJdbcStoreAbstractBenchmark extends IgniteAbstractBen /** Cache. */ protected IgniteCache<Object, Object> cache; + /** + * Each benchmark must determine which cache will be used. + * + * @return GridCache Cache to use. + */ + protected abstract IgniteCache<Object, Object> cache(); + + /** + * Each benchmark must determine key range (from {@code 0} to this number) for fill. + * + * @return GridCache Cache to use. + */ + protected abstract int fillRange(); + /** {@inheritDoc} */ @Override public void setUp(BenchmarkConfiguration cfg) throws Exception { super.setUp(cfg); cache = cache(); + + CacheConfiguration cc = cache.getConfiguration(CacheConfiguration.class); + + JdbcCacheStore store = (JdbcCacheStore)cc.getCacheStoreFactory().create(); + + try (Connection conn = store.getDataSource().getConnection()) { + conn.setAutoCommit(false); + + Statement stmt = conn.createStatement(); + + try { + stmt.executeUpdate("delete from SAMPLE"); + } + catch (SQLException ignore) { + // No-op. + } + + stmt.executeUpdate("CREATE TABLE IF NOT EXISTS SAMPLE (id integer not null, value integer, PRIMARY KEY(id))"); + + conn.commit(); + + U.closeQuiet(stmt); + + PreparedStatement orgStmt = conn.prepareStatement("INSERT INTO SAMPLE(id, value) VALUES (?, ?)"); + + for (int i = 0; i < fillRange(); i++) { + orgStmt.setInt(1, i); + orgStmt.setInt(2, i); + + orgStmt.addBatch(); + } + + orgStmt.executeBatch(); + + conn.commit(); + + U.closeQuiet(stmt); + } } - /** - * Each benchmark must determine which cache will be used. - * - * @return GridCache Cache to use. - */ - protected abstract IgniteCache<Object, Object> cache(); + /** {@inheritDoc} */ + @Override public void tearDown() throws Exception { + CacheConfiguration cc = cache.getConfiguration(CacheConfiguration.class); + + JdbcCacheStore store = (JdbcCacheStore)cc.getCacheStoreFactory().create(); + + try (Connection conn = store.getDataSource().getConnection()) { + conn.setAutoCommit(true); + + Statement stmt = conn.createStatement(); + + try { + stmt.executeUpdate("delete from SAMPLE"); + } + catch (SQLException ignore) { + // No-op. + } + + U.closeQuiet(stmt); + } + } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/fe7c2afc/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/store/jdbc/IgniteJdbcStoreGetBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/store/jdbc/IgniteJdbcStoreGetBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/store/jdbc/IgniteJdbcStoreGetBenchmark.java index 3ff3079..e426332 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/store/jdbc/IgniteJdbcStoreGetBenchmark.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/store/jdbc/IgniteJdbcStoreGetBenchmark.java @@ -19,7 +19,6 @@ package org.apache.ignite.yardstick.cache.store.jdbc; import org.apache.ignite.*; import org.apache.ignite.yardstick.cache.model.*; -import org.yardstickframework.*; import java.util.*; @@ -27,14 +26,9 @@ import java.util.*; * Ignite JDBC cache store benchmark that performs get operations. */ public class IgniteJdbcStoreGetBenchmark extends IgniteJdbcStoreAbstractBenchmark { - /** Cache. */ - protected IgniteCache<Object, Object> cache; - /** {@inheritDoc} */ - @Override public void setUp(BenchmarkConfiguration cfg) throws Exception { - super.setUp(cfg); - - cache = cache(); + @Override protected int fillRange() { + return args.range(); } /** {@inheritDoc} */ http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/fe7c2afc/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/store/jdbc/IgniteJdbcStoreGetTxBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/store/jdbc/IgniteJdbcStoreGetTxBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/store/jdbc/IgniteJdbcStoreGetTxBenchmark.java new file mode 100644 index 0000000..947ec1e --- /dev/null +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/store/jdbc/IgniteJdbcStoreGetTxBenchmark.java @@ -0,0 +1,47 @@ +/* + * 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.store.jdbc; + +import org.apache.ignite.*; +import org.apache.ignite.yardstick.cache.model.*; + +import java.util.*; + +/** + * Ignite JDBC cache store benchmark that performs get operations. + */ +public class IgniteJdbcStoreGetTxBenchmark extends IgniteJdbcStoreAbstractBenchmark { + /** {@inheritDoc} */ + @Override protected int fillRange() { + return args.range(); + } + + /** {@inheritDoc} */ + @Override public boolean test(Map<Object, Object> ctx) throws Exception { + int id = nextRandom(args.range()); + + cache().get(new SampleKey(id)); + + return true; + } + + /** {@inheritDoc} */ + @Override protected IgniteCache<Object, Object> cache() { + return ignite().jcache("tx"); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/fe7c2afc/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/store/jdbc/IgniteJdbcStorePutBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/store/jdbc/IgniteJdbcStorePutBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/store/jdbc/IgniteJdbcStorePutBenchmark.java index baac812..4b70eeb 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/store/jdbc/IgniteJdbcStorePutBenchmark.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/store/jdbc/IgniteJdbcStorePutBenchmark.java @@ -27,6 +27,11 @@ import java.util.*; */ public class IgniteJdbcStorePutBenchmark extends IgniteJdbcStoreAbstractBenchmark { /** {@inheritDoc} */ + @Override protected int fillRange() { + return args.range() / 2; + } + + /** {@inheritDoc} */ @Override public boolean test(Map<Object, Object> ctx) throws Exception { int id = nextRandom(args.range()); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/fe7c2afc/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/store/jdbc/IgniteJdbcStorePutGetBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/store/jdbc/IgniteJdbcStorePutGetBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/store/jdbc/IgniteJdbcStorePutGetBenchmark.java index dfcf2da..330f09c 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/store/jdbc/IgniteJdbcStorePutGetBenchmark.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/store/jdbc/IgniteJdbcStorePutGetBenchmark.java @@ -27,6 +27,11 @@ import java.util.*; */ public class IgniteJdbcStorePutGetBenchmark extends IgniteJdbcStoreAbstractBenchmark { /** {@inheritDoc} */ + @Override protected int fillRange() { + return 0; + } + + /** {@inheritDoc} */ @Override public boolean test(Map<Object, Object> ctx) throws Exception { int id = nextRandom(args.range()); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/fe7c2afc/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/store/jdbc/IgniteJdbcStorePutGetTxBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/store/jdbc/IgniteJdbcStorePutGetTxBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/store/jdbc/IgniteJdbcStorePutGetTxBenchmark.java new file mode 100644 index 0000000..81b1637 --- /dev/null +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/store/jdbc/IgniteJdbcStorePutGetTxBenchmark.java @@ -0,0 +1,52 @@ +/* + * 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.store.jdbc; + +import org.apache.ignite.*; +import org.apache.ignite.yardstick.cache.model.*; + +import java.util.*; + +/** + * Ignite benchmark that performs put and get operations. + */ +public class IgniteJdbcStorePutGetTxBenchmark extends IgniteJdbcStoreAbstractBenchmark { + /** {@inheritDoc} */ + @Override protected int fillRange() { + return 0; + } + + /** {@inheritDoc} */ + @Override public boolean test(Map<Object, Object> ctx) throws Exception { + int id = nextRandom(args.range()); + + Object val = cache.get(new SampleKey(id)); + + if (val != null) + id = nextRandom(args.range()); + + cache.put(new SampleKey(id), new SampleValue(id)); + + return true; + } + + /** {@inheritDoc} */ + @Override protected IgniteCache<Object, Object> cache() { + return ignite().jcache("tx"); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/fe7c2afc/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/store/jdbc/IgniteJdbcStorePutTxBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/store/jdbc/IgniteJdbcStorePutTxBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/store/jdbc/IgniteJdbcStorePutTxBenchmark.java new file mode 100644 index 0000000..f470265 --- /dev/null +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/store/jdbc/IgniteJdbcStorePutTxBenchmark.java @@ -0,0 +1,47 @@ +/* + * 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.store.jdbc; + +import org.apache.ignite.*; +import org.apache.ignite.yardstick.cache.model.*; + +import java.util.*; + +/** + * Ignite benchmark that performs put operations. + */ +public class IgniteJdbcStorePutTxBenchmark extends IgniteJdbcStoreAbstractBenchmark { + /** {@inheritDoc} */ + @Override protected int fillRange() { + return args.range() / 2; + } + + /** {@inheritDoc} */ + @Override public boolean test(Map<Object, Object> ctx) throws Exception { + int id = nextRandom(args.range()); + + cache.put(new SampleKey(id), new SampleValue(id)); + + return true; + } + + /** {@inheritDoc} */ + @Override protected IgniteCache<Object, Object> cache() { + return ignite().jcache("tx"); + } +}