Repository: ignite Updated Branches: refs/heads/master 958909305 -> 409f6e5d0
Added RDBMS benchmarks Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/409f6e5d Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/409f6e5d Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/409f6e5d Branch: refs/heads/master Commit: 409f6e5d049dd095f2f496dc3bc00717c1e03bba Parents: 9589093 Author: oleg-ostanin <[email protected]> Authored: Thu Jun 1 15:46:03 2017 +0300 Committer: oleg-ostanin <[email protected]> Committed: Thu Jun 1 15:49:36 2017 +0300 ---------------------------------------------------------------------- .../yardstick/config/ignite-db-base-config.xml | 118 ++++++++++ .../config/ignite-db-localhost-config.xml | 53 +++++ .../yardstick/config/ignite-rdbms-config.xml | 70 ++++++ .../config/sql/benchmark-jdbc-ignite.properties | 64 ++++++ .../sql/benchmark-mysql-ignite.properties | 66 ++++++ .../config/sql/benchmark-native.properties | 62 ++++++ .../sql/benchmark-pgsql-ignite.properties | 66 ++++++ modules/yardstick/config/sql/db-h2-queries.sql | 9 + .../yardstick/config/sql/db-mysql-queries.sql | 14 ++ .../yardstick/config/sql/db-pgsql-queries.sql | 14 ++ .../yardstick/config/sql/h2-insert-query.sql | 1 + .../yardstick/config/sql/rdbms-mysql-schema.sql | 5 + .../yardstick/config/sql/rdbms-pgsql-schema.sql | 10 + .../yardstick/IgniteBenchmarkArguments.java | 46 +++- .../cache/jdbc/IgniteNativeTxBenchmark.java | 169 ++++++++++++++ .../cache/jdbc/JdbcAbstractBenchmark.java | 51 ++++- .../yardstick/cache/jdbc/JdbcPutBenchmark.java | 3 - .../yardstick/cache/jdbc/RdbmsBenchmark.java | 220 +++++++++++++++++++ .../ignite/yardstick/cache/model/Accounts.java | 62 ++++++ .../ignite/yardstick/cache/model/Branches.java | 62 ++++++ .../ignite/yardstick/cache/model/History.java | 69 ++++++ .../ignite/yardstick/cache/model/Tellers.java | 62 ++++++ 22 files changed, 1285 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/409f6e5d/modules/yardstick/config/ignite-db-base-config.xml ---------------------------------------------------------------------- diff --git a/modules/yardstick/config/ignite-db-base-config.xml b/modules/yardstick/config/ignite-db-base-config.xml new file mode 100644 index 0000000..690edac --- /dev/null +++ b/modules/yardstick/config/ignite-db-base-config.xml @@ -0,0 +1,118 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + 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. +--> + +<!-- + Ignite Spring configuration file to startup grid. +--> +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation=" + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> + <bean id="base-ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration" abstract="true"> + <property name="peerClassLoadingEnabled" value="false"/> + + <property name="metricsLogFrequency" value="5000"/> + + <property name="memoryConfiguration"> + <bean class="org.apache.ignite.configuration.MemoryConfiguration"> + <property name="pageCacheSize" value="#{400L * 1024L * 1024L}"/> + </bean> + </property> + + <property name="binaryConfiguration"> + <bean class="org.apache.ignite.configuration.BinaryConfiguration"> + <property name="compactFooter" value="false"/> + </bean> + </property> + + <property name="cacheConfiguration"> + <list> + <bean class="org.apache.ignite.configuration.CacheConfiguration"> + <property name="name" value="Accounts"/> + + <property name="cacheMode" value="PARTITIONED"/> + + <property name="atomicityMode" value="TRANSACTIONAL"/> + + <property name="indexedTypes"> + <list> + <value>java.lang.Long</value> + <value>org.apache.ignite.yardstick.cache.model.Accounts</value> + </list> + </property> + </bean> + + <bean class="org.apache.ignite.configuration.CacheConfiguration"> + <property name="name" value="Tellers"/> + + <property name="cacheMode" value="PARTITIONED"/> + + <property name="atomicityMode" value="TRANSACTIONAL"/> + + <property name="indexedTypes"> + <list> + <value>java.lang.Long</value> + <value>org.apache.ignite.yardstick.cache.model.Tellers</value> + </list> + </property> + </bean> + + <bean class="org.apache.ignite.configuration.CacheConfiguration"> + <property name="name" value="Branches"/> + + <property name="cacheMode" value="PARTITIONED"/> + + <property name="atomicityMode" value="TRANSACTIONAL"/> + + <property name="indexedTypes"> + <list> + <value>java.lang.Long</value> + <value>org.apache.ignite.yardstick.cache.model.Branches</value> + </list> + </property> + </bean> + + <bean class="org.apache.ignite.configuration.CacheConfiguration"> + <property name="name" value="History"/> + + <property name="cacheMode" value="PARTITIONED"/> + + <property name="atomicityMode" value="TRANSACTIONAL"/> + + <property name="indexedTypes"> + <list> + <value>java.lang.Long</value> + <value>org.apache.ignite.yardstick.cache.model.History</value> + </list> + </property> + </bean> + </list> + </property> + + <property name="includeEventTypes"> + <list/> + </property> + + <property name="loadBalancingSpi"> + <bean class="org.apache.ignite.spi.loadbalancing.roundrobin.RoundRobinLoadBalancingSpi"> + <property name="perTask" value="false"/> + </bean> + </property> + </bean> +</beans> http://git-wip-us.apache.org/repos/asf/ignite/blob/409f6e5d/modules/yardstick/config/ignite-db-localhost-config.xml ---------------------------------------------------------------------- diff --git a/modules/yardstick/config/ignite-db-localhost-config.xml b/modules/yardstick/config/ignite-db-localhost-config.xml new file mode 100644 index 0000000..15811a6 --- /dev/null +++ b/modules/yardstick/config/ignite-db-localhost-config.xml @@ -0,0 +1,53 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + 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. +--> + +<!-- + Ignite Spring configuration file to startup grid. +--> +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation=" + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> + <import resource="ignite-db-base-config.xml"/> + + <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration" parent="base-ignite.cfg"> + <property name="localHost" value="127.0.0.1"/> + + <property name="discoverySpi"> + <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi"> + <property name="ipFinder"> + <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder"> + <property name="addresses"> + <list> + <value>127.0.0.1:47500..47549</value> + <value>127.0.0.1:47500..47549</value> + </list> + </property> + </bean> + </property> + </bean> + </property> + + <property name="communicationSpi"> + <bean class="org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi"> + <property name="sharedMemoryPort" value="-1"/> + </bean> + </property> + </bean> +</beans> http://git-wip-us.apache.org/repos/asf/ignite/blob/409f6e5d/modules/yardstick/config/ignite-rdbms-config.xml ---------------------------------------------------------------------- diff --git a/modules/yardstick/config/ignite-rdbms-config.xml b/modules/yardstick/config/ignite-rdbms-config.xml new file mode 100644 index 0000000..26e8016 --- /dev/null +++ b/modules/yardstick/config/ignite-rdbms-config.xml @@ -0,0 +1,70 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + 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. +--> + +<!-- + Ignite Spring configuration file. +--> +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation=" + http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans.xsd"> + <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration"> + <property name="clientMode" value="true"/> + + <property name="memoryConfiguration"> + <bean class="org.apache.ignite.configuration.MemoryConfiguration"> + + <!-- Set page memory size to 8 GB. --> + <property name="defaultMemoryPolicyName" value="default"/> + <property name="memoryPolicies"> + <list> + <bean class="org.apache.ignite.configuration.MemoryPolicyConfiguration"> + <property name="name" value="default"/> + <property name="initialSize" value="#{1L * 1024 * 1024 * 1024}"/> + <property name="maxSize" value="#{8L * 1024 * 1024 * 1024}"/> + </bean> + </list> + </property> + </bean> + </property> + + <property name="binaryConfiguration"> + <bean class="org.apache.ignite.configuration.BinaryConfiguration"> + <property name="compactFooter" value="false"/> + </bean> + </property> + + <property name="localHost" value="127.0.0.1"/> <!-- remove this line for remote running --> + + <property name="discoverySpi"> + <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi"> + <property name="ipFinder"> + <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder"> + <property name="addresses"> + <list> + <value>127.0.0.1:47500..47549</value> <!-- change IP for actual host IP for remote running --> + </list> + </property> + </bean> + </property> + </bean> + </property> + </bean> +</beans> http://git-wip-us.apache.org/repos/asf/ignite/blob/409f6e5d/modules/yardstick/config/sql/benchmark-jdbc-ignite.properties ---------------------------------------------------------------------- diff --git a/modules/yardstick/config/sql/benchmark-jdbc-ignite.properties b/modules/yardstick/config/sql/benchmark-jdbc-ignite.properties new file mode 100644 index 0000000..11e9108 --- /dev/null +++ b/modules/yardstick/config/sql/benchmark-jdbc-ignite.properties @@ -0,0 +1,64 @@ +# 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. + +# +# Contains benchmarks for SQL queries. +# + +# Uncomment to enable concurrent garbage collection (GC) if you encounter long GC pauses. +JVM_OPTS=${JVM_OPTS}" -DIGNITE_QUIET=false \ +-Xms6g \ +-Xmx6g \ +-XX:+PrintGCDetails \ +-verbose:gc \ +-XX:+UseParNewGC \ +-XX:+UseConcMarkSweepGC \ +" + +IGNITE_PARAMS="-jdbcDrv org.apache.ignite.IgniteJdbcDriver -jdbc jdbc:ignite:cfg://cache=Accounts@${SCRIPT_DIR}/../config/ignite-rdbms-config.xml -ltqf ${SCRIPT_DIR}/../config/sql/db-h2-queries.sql" + +# List of default probes. +# Add DStatProbe or VmStatProbe if your OS supports it (e.g. if running on Linux). +BENCHMARK_DEFAULT_PROBES=ThroughputLatencyProbe,PercentileProbe + +# Packages where the specified benchmark is searched by reflection mechanism. +BENCHMARK_PACKAGES=org.yardstickframework,org.apache.ignite.yardstick + +# Comma-separated list of the hosts to run BenchmarkServers on. 2 nodes on local host are enabled by default. +SERVER_HOSTS=localhost + +# Comma-separated list of the hosts to run BenchmarkDrivers on. 1 node on local host is enabled by default. +DRIVER_HOSTS=localhost + +# Backups count. +b=1 + +# Warmup. +w=60 + +# Duration. +d=300 + +# Threads count. +t=64 + +# Scale factor +sf=10 + +# Run configuration. +# 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-db-localhost-config.xml -b ${b} -w ${w} -d ${d} -t ${t} -sf ${sf} -plfreq 5000 ${IGNITE_PARAMS} -dn RdbmsBenchmark -sn IgniteNode -ds jdbc-ignite-put,\ +" \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/409f6e5d/modules/yardstick/config/sql/benchmark-mysql-ignite.properties ---------------------------------------------------------------------- diff --git a/modules/yardstick/config/sql/benchmark-mysql-ignite.properties b/modules/yardstick/config/sql/benchmark-mysql-ignite.properties new file mode 100644 index 0000000..fcf1ae2 --- /dev/null +++ b/modules/yardstick/config/sql/benchmark-mysql-ignite.properties @@ -0,0 +1,66 @@ +# 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. + +# +# Contains benchmarks for SQL queries. +# + +# Uncomment to enable concurrent garbage collection (GC) if you encounter long GC pauses. +JVM_OPTS=${JVM_OPTS}" -DIGNITE_QUIET=false \ +-Xms6g \ +-Xmx6g \ +-XX:+PrintGCDetails \ +-verbose:gc \ +-XX:+UseParNewGC \ +-XX:+UseConcMarkSweepGC \ +" + +# List of default probes. +# Add DStatProbe or VmStatProbe if your OS supports it (e.g. if running on Linux). +BENCHMARK_DEFAULT_PROBES=ThroughputLatencyProbe,PercentileProbe + +# Packages where the specified benchmark is searched by reflection mechanism. +BENCHMARK_PACKAGES=org.yardstickframework,org.apache.ignite.yardstick + +# Comma-separated list of the hosts to run BenchmarkServers on. 2 nodes on local host are enabled by default. +SERVER_HOSTS=localhost + +# Comma-separated list of the hosts to run BenchmarkDrivers on. 1 node on local host is enabled by default. +DRIVER_HOSTS=localhost + +# For running this benchmark on the remote host you need to add "\" in the URL like this: ignite\&password=pass\&useSSL=false +MYSQL_PARAMS="-jdbcDrv com.mysql.jdbc.Driver -jdbc jdbc:mysql://${SERVER_HOSTS}/?user=ignite&password=pass&useSSL=false -tempDb -ltqf ${SCRIPT_DIR}/../config/sql/db-mysql-queries.sql -sch ${SCRIPT_DIR}/../config/sql/rdbms-mysql-schema.sql" + + +# Backups count. +b=1 + +# Warmup. +w=60 + +# Duration. +d=300 + +# Threads count. +t=64 + +# Scale factor +sf=10 + +# Run configuration. +# 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-localhost-config.xml -b ${b} -w ${w} -d ${d} -t ${t} -sf ${sf} ${MYSQL_PARAMS} -dn RdbmsBenchmark -sn IgniteNode -ds jdbc-mysql-commit,\ +" \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/409f6e5d/modules/yardstick/config/sql/benchmark-native.properties ---------------------------------------------------------------------- diff --git a/modules/yardstick/config/sql/benchmark-native.properties b/modules/yardstick/config/sql/benchmark-native.properties new file mode 100644 index 0000000..bc025b8 --- /dev/null +++ b/modules/yardstick/config/sql/benchmark-native.properties @@ -0,0 +1,62 @@ +# 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. + +# +# Contains benchmarks for SQL queries. +# + +# Uncomment to enable concurrent garbage collection (GC) if you encounter long GC pauses. +JVM_OPTS=${JVM_OPTS}" -DIGNITE_QUIET=false \ +-Xms6g \ +-Xmx6g \ +-XX:+PrintGCDetails \ +-verbose:gc \ +-XX:+UseParNewGC \ +-XX:+UseConcMarkSweepGC \ +" + +# List of default probes. +# Add DStatProbe or VmStatProbe if your OS supports it (e.g. if running on Linux). +BENCHMARK_DEFAULT_PROBES=ThroughputLatencyProbe,PercentileProbe + +# Packages where the specified benchmark is searched by reflection mechanism. +BENCHMARK_PACKAGES=org.yardstickframework,org.apache.ignite.yardstick + +# Comma-separated list of the hosts to run BenchmarkServers on. 2 nodes on local host are enabled by default. +SERVER_HOSTS=localhost + +# Comma-separated list of the hosts to run BenchmarkDrivers on. 1 node on local host is enabled by default. +DRIVER_HOSTS=localhost + +# Backups count. +b=1 + +# Warmup. +w=60 + +# Duration. +d=300 + +# Threads count. +t=64 + +# Scale factor +sf=10 + +# Run configuration. +# 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-db-localhost-config.xml -b ${b} -w ${w} -d ${d} -t ${t} -sf ${sf} -txc PESSIMISTIC -dn IgniteNativeTxBenchmark -sn IgniteNode -ds jdbc-ignite-put,\ +" \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/409f6e5d/modules/yardstick/config/sql/benchmark-pgsql-ignite.properties ---------------------------------------------------------------------- diff --git a/modules/yardstick/config/sql/benchmark-pgsql-ignite.properties b/modules/yardstick/config/sql/benchmark-pgsql-ignite.properties new file mode 100644 index 0000000..e3bc216 --- /dev/null +++ b/modules/yardstick/config/sql/benchmark-pgsql-ignite.properties @@ -0,0 +1,66 @@ +# 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. + +# +# Contains benchmarks for SQL queries. +# + +# Uncomment to enable concurrent garbage collection (GC) if you encounter long GC pauses. +JVM_OPTS=${JVM_OPTS}" -DIGNITE_QUIET=false \ +-Xms6g \ +-Xmx6g \ +-XX:+PrintGCDetails \ +-verbose:gc \ +-XX:+UseParNewGC \ +-XX:+UseConcMarkSweepGC \ +" + +# List of default probes. +# Add DStatProbe or VmStatProbe if your OS supports it (e.g. if running on Linux). +BENCHMARK_DEFAULT_PROBES=ThroughputLatencyProbe,PercentileProbe + +# Packages where the specified benchmark is searched by reflection mechanism. +BENCHMARK_PACKAGES=org.yardstickframework,org.apache.ignite.yardstick + +# Comma-separated list of the hosts to run BenchmarkServers on. 2 nodes on local host are enabled by default. +SERVER_HOSTS=localhost + +# Comma-separated list of the hosts to run BenchmarkDrivers on. 1 node on local host is enabled by default. +DRIVER_HOSTS=localhost + +# Warning: database must be created and specified in URL explicitly, and there's no other way around as long as driver does not support changing DB in runtime +# For running this benchmark on the remote host you need to add "\" in the URL like this: ignite\&password=pass +PGSQL_PARAMS="-jdbcDrv org.postgresql.Driver -jdbc jdbc:postgresql://${SERVER_HOSTS}/pgbenchmark?user=ignite&password=pass -ltqf ${SCRIPT_DIR}/../config/sql/db-mysql-queries.sql -sch ${SCRIPT_DIR}/../config/sql/rdbms-pgsql-schema.sql" + +# Backups count. +b=1 + +# Warmup. +w=60 + +# Duration. +d=300 + +# Threads count. +t=64 + +# Scale factor +sf=10 + +# Run configuration. +# 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-localhost-config.xml -b ${b} -w ${w} -d ${d} -t ${t} -sf ${sf} ${PGSQL_PARAMS} -dn RdbmsBenchmark -sn IgniteNode -ds jdbc-pgsql-commit,\ +" \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/409f6e5d/modules/yardstick/config/sql/db-h2-queries.sql ---------------------------------------------------------------------- diff --git a/modules/yardstick/config/sql/db-h2-queries.sql b/modules/yardstick/config/sql/db-h2-queries.sql new file mode 100644 index 0000000..9ce66a4 --- /dev/null +++ b/modules/yardstick/config/sql/db-h2-queries.sql @@ -0,0 +1,9 @@ +UPDATE "Accounts".Accounts SET val = val + :delta WHERE _key = :aid; + +SELECT val FROM "Accounts".Accounts WHERE _key = :aid; + +UPDATE "Tellers".Tellers SET val = val + :delta WHERE _key = :tid; + +UPDATE "Branches".Branches SET val = val + :delta WHERE _key = :bid; + +INSERT INTO "History".History (_key, tid, bid, aid, delta) VALUES (?, ?, ?, ? ,?); http://git-wip-us.apache.org/repos/asf/ignite/blob/409f6e5d/modules/yardstick/config/sql/db-mysql-queries.sql ---------------------------------------------------------------------- diff --git a/modules/yardstick/config/sql/db-mysql-queries.sql b/modules/yardstick/config/sql/db-mysql-queries.sql new file mode 100644 index 0000000..2d11ad49 --- /dev/null +++ b/modules/yardstick/config/sql/db-mysql-queries.sql @@ -0,0 +1,14 @@ +BEGIN + +UPDATE Accounts SET val = val + :delta WHERE id = :aid; + +SELECT val FROM Accounts WHERE id = :aid; + +UPDATE Tellers SET val = val + :delta WHERE id = :tid; + +UPDATE Branches SET val = val + :delta WHERE id = :bid; + +INSERT INTO History (tid, bid, aid, delta) VALUES (:tid, :bid, :aid, :delta); + +COMMIT + http://git-wip-us.apache.org/repos/asf/ignite/blob/409f6e5d/modules/yardstick/config/sql/db-pgsql-queries.sql ---------------------------------------------------------------------- diff --git a/modules/yardstick/config/sql/db-pgsql-queries.sql b/modules/yardstick/config/sql/db-pgsql-queries.sql new file mode 100644 index 0000000..582daf6 --- /dev/null +++ b/modules/yardstick/config/sql/db-pgsql-queries.sql @@ -0,0 +1,14 @@ +BEGIN + +UPDATE Accounts SET val = val + :delta WHERE id = :aid; + +SELECT val FROM Accounts WHERE id = :aid; + +UPDATE Tellers SET val = val + :delta WHERE id = :tid; + +UPDATE Branches SET val = val + :delta WHERE id = :bid; + +INSERT INTO History (id, tid, bid, aid, delta) VALUES (:id, :tid, :bid, :aid, :delta); + +COMMIT + http://git-wip-us.apache.org/repos/asf/ignite/blob/409f6e5d/modules/yardstick/config/sql/h2-insert-query.sql ---------------------------------------------------------------------- diff --git a/modules/yardstick/config/sql/h2-insert-query.sql b/modules/yardstick/config/sql/h2-insert-query.sql new file mode 100644 index 0000000..c160a16 --- /dev/null +++ b/modules/yardstick/config/sql/h2-insert-query.sql @@ -0,0 +1 @@ +INSERT INTO "History".History (_key, tid, bid, aid, delta) VALUES (?, ?, ?, ? ,?); http://git-wip-us.apache.org/repos/asf/ignite/blob/409f6e5d/modules/yardstick/config/sql/rdbms-mysql-schema.sql ---------------------------------------------------------------------- diff --git a/modules/yardstick/config/sql/rdbms-mysql-schema.sql b/modules/yardstick/config/sql/rdbms-mysql-schema.sql new file mode 100644 index 0000000..552852b --- /dev/null +++ b/modules/yardstick/config/sql/rdbms-mysql-schema.sql @@ -0,0 +1,5 @@ +create table if not exists Accounts (`id` BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, val BIGINT); +create table if not exists Tellers (`id` BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, val BIGINT); +create table if not exists Branches (`id` BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, val BIGINT); +create table if not exists History (`id` BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY, aid BIGINT, tid BIGINT, bid BIGINT, delta BIGINT); +create index v8_2 using btree on Accounts(`id`); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/409f6e5d/modules/yardstick/config/sql/rdbms-pgsql-schema.sql ---------------------------------------------------------------------- diff --git a/modules/yardstick/config/sql/rdbms-pgsql-schema.sql b/modules/yardstick/config/sql/rdbms-pgsql-schema.sql new file mode 100644 index 0000000..d73204d --- /dev/null +++ b/modules/yardstick/config/sql/rdbms-pgsql-schema.sql @@ -0,0 +1,10 @@ +DROP TABLE if exists Accounts; +DROP TABLE if exists Tellers; +DROP TABLE if exists Branches; +DROP TABLE if exists History; +create table if not exists Accounts (id BIGINT NOT NULL PRIMARY KEY, val BIGINT); +create table if not exists Tellers (id BIGINT NOT NULL PRIMARY KEY, val BIGINT); +create table if not exists Branches (id BIGINT NOT NULL PRIMARY KEY, val BIGINT); +create table if not exists History (id BIGINT NOT NULL PRIMARY KEY, aid BIGINT, tid BIGINT, bid BIGINT, delta BIGINT); +drop index if exists H_1; +create index H_1 on History using btree (aid, tid, bid, delta); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/409f6e5d/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 74413f5..11f9472 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 @@ -85,12 +85,20 @@ public class IgniteBenchmarkArguments { public int range = 1_000_000; /** */ + @Parameter(names = {"-sf", "--scaleFactor"}, description = "Scale factor") + private int scaleFactor = 1; + + /** */ + @Parameter(names = {"-ntv", "--native"}, description = "Native benchmarking flag") + private boolean ntv = false; + + /** */ @Parameter(names = {"-pa", "--preloadAmount"}, description = "Data pre-loading amount for load tests") - public int preloadAmount = 500_000; + private int preloadAmount = 500_000; /** */ @Parameter(names = {"-plfreq", "--preloadLogFrequency"}, description = "Interval between printing logs") - public long preloadLogsInterval = 30_000; + private long preloadLogsInterval = 30_000; /** */ @Parameter(names = {"-j", "--jobs"}, description = "Number of jobs for compute benchmarks") @@ -139,6 +147,10 @@ public class IgniteBenchmarkArguments { private boolean createTempDatabase = false; /** */ + @Parameter(names = {"-dbn", "--databaseName"}, description = "Name of database") + private String dbn = null; + + /** */ @Parameter(names = {"-rd", "--restartdelay"}, description = "Restart delay in seconds") private int restartDelay = 20; @@ -203,19 +215,35 @@ public class IgniteBenchmarkArguments { return jdbcUrl; } + /** + * @return JDBC driver. + */ public String jdbcDriver() { return jdbcDriver; } + /** + * @return schema definition. + */ public String schemaDefinition() { return schemaDefinition; } + /** + * @return flag for creation temporary database. + */ public boolean createTempDatabase() { return createTempDatabase; } /** + * @return existing database name defined in property file. + */ + public String dbn() { + return dbn; + } + + /** * @return Transaction concurrency. */ public TransactionConcurrency txConcurrency() { @@ -279,6 +307,13 @@ public class IgniteBenchmarkArguments { } /** + * @return {@code True} if flag for native benchmarking is set. + */ + public boolean isNative(){ + return ntv; + } + + /** * @return Nodes. */ public int nodes() { @@ -293,6 +328,13 @@ public class IgniteBenchmarkArguments { } /** + * @return Scale factor. + */ + public int scaleFactor() { + return scaleFactor; + } + + /** * @return Preload key range, from {@code 0} to this number. */ public int preloadAmount() { http://git-wip-us.apache.org/repos/asf/ignite/blob/409f6e5d/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/jdbc/IgniteNativeTxBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/jdbc/IgniteNativeTxBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/jdbc/IgniteNativeTxBenchmark.java new file mode 100644 index 0000000..b331d6a --- /dev/null +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/jdbc/IgniteNativeTxBenchmark.java @@ -0,0 +1,169 @@ +/* + * 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.jdbc; + +import java.util.Map; +import java.util.concurrent.ThreadLocalRandom; +import java.util.concurrent.atomic.AtomicLong; +import javax.cache.processor.EntryProcessor; +import javax.cache.processor.EntryProcessorException; +import javax.cache.processor.MutableEntry; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteDataStreamer; +import org.apache.ignite.IgniteTransactions; +import org.apache.ignite.transactions.Transaction; +import org.apache.ignite.yardstick.IgniteAbstractBenchmark; +import org.apache.ignite.yardstick.cache.model.Accounts; +import org.apache.ignite.yardstick.cache.model.Branches; +import org.apache.ignite.yardstick.cache.model.History; +import org.apache.ignite.yardstick.cache.model.Tellers; +import org.yardstickframework.BenchmarkConfiguration; + +/** JDBC benchmark that performs raw SQL insert */ +public class IgniteNativeTxBenchmark extends IgniteAbstractBenchmark { + /** Default number of rows in Accounts table. */ + private long accRows; + + /** Default number of rows in Tellers table. */ + private long tellRows; + + /** Default number of rows in Branches table. */ + private long branchRows; + + /** Cache for Accounts table. */ + private IgniteCache<Long, Accounts> accounts; + + /** Cache for Tellers table. */ + private IgniteCache<Long, Tellers> tellers; + + /** Cache for Branches table. */ + private IgniteCache<Long, Branches> branches; + + /** Cache for History table. */ + private IgniteCache<Long, History> hist; + + /** Id for History table */ + private AtomicLong cnt; + + /** {@inheritDoc} */ + @Override public void setUp(BenchmarkConfiguration cfg) throws Exception { + super.setUp(cfg); + + cnt = new AtomicLong(); + + accRows = 1000L * args.scaleFactor(); + tellRows = 10L * args.scaleFactor(); + branchRows = 5L * args.scaleFactor(); + + accounts = ignite().cache("Accounts"); + tellers = ignite().cache("Tellers"); + branches = ignite().cache("Branches"); + hist = ignite().cache("History"); + + clearCaches(); + + fillTables(); + } + + /** {@inheritDoc} */ + @SuppressWarnings("SimplifiableIfStatement") + @Override public boolean test(Map<Object, Object> ctx) throws Exception { + long aid = ThreadLocalRandom.current().nextLong(accRows); + long bid = ThreadLocalRandom.current().nextLong(branchRows); + long tid = ThreadLocalRandom.current().nextLong(tellRows); + + final long delta = ThreadLocalRandom.current().nextLong(1000); + + IgniteTransactions transactions = ignite().transactions(); + + try (Transaction tx = transactions.txStart(args.txConcurrency(), args.txIsolation())) { + accounts.invoke(aid, new EntryProcessor<Long, Accounts, Object>() { + @Override public Long process(MutableEntry<Long, Accounts> entry, Object... objects) + throws EntryProcessorException { + long newVal = entry.getValue().getVal() + delta; + + entry.setValue(entry.getValue().setVal(newVal)); + + return newVal; + } + }); + + tellers.invoke(tid, new EntryProcessor<Long, Tellers, Object>() { + @Override public Long process(MutableEntry<Long, Tellers> entry, Object... objects) + throws EntryProcessorException { + long newVal = entry.getValue().getVal() + delta; + + entry.setValue(entry.getValue().setVal(newVal)); + + return null; + } + }); + + branches.invoke(bid, new EntryProcessor<Long, Branches, Object>() { + @Override public Long process(MutableEntry<Long, Branches> entry, + Object... objects) throws EntryProcessorException { + long newVal = entry.getValue().getVal() + delta; + + entry.setValue(entry.getValue().setVal(newVal)); + + return null; + } + }); + + hist.put(cnt.getAndIncrement(), new History(tid, bid, aid, delta)); + + tx.commit(); + } + + return true; + } + + /** + * Fill tables using native Ignite API. + */ + private void fillTables() throws Exception { + startPreloadLogging(args.preloadLogsInterval()); + + try (IgniteDataStreamer<Long, Accounts> dataLdr = ignite().dataStreamer(accounts.getName())) { + for (long i = 0; i < accRows; i++) + dataLdr.addData(i, new Accounts(nextRandom(args.range()))); + } + + try (IgniteDataStreamer<Long, Branches> dataLdr = ignite().dataStreamer(branches.getName())) { + for (long i = 0; i < branchRows; i++) + dataLdr.addData(i, new Branches(nextRandom(args.range()))); + } + + try (IgniteDataStreamer<Long, Tellers> dataLdr = ignite().dataStreamer(tellers.getName())) { + for (long i = 0; i < tellRows; i++) + dataLdr.addData(i, new Tellers(nextRandom(args.range()))); + } + + stopPreloadLogging(); + } + + /** + * Clear caches. + */ + private void clearCaches() { + ignite().cache("Accounts").clear(); + ignite().cache("Tellers").clear(); + ignite().cache("Branches").clear(); + ignite().cache("History").clear(); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/409f6e5d/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/jdbc/JdbcAbstractBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/jdbc/JdbcAbstractBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/jdbc/JdbcAbstractBenchmark.java index e9a6b1d..87c2cab 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/jdbc/JdbcAbstractBenchmark.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/jdbc/JdbcAbstractBenchmark.java @@ -30,27 +30,30 @@ import java.util.List; import java.util.UUID; import org.apache.ignite.IgniteException; import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.yardstick.IgniteAbstractBenchmark; import org.apache.ignite.yardstick.IgniteBenchmarkArguments; import org.yardstickframework.BenchmarkConfiguration; -import org.yardstickframework.BenchmarkDriverAdapter; import static org.yardstickframework.BenchmarkUtils.jcommander; /** Base class for benchmarks that measure raw performance of JDBC databases */ -public abstract class JdbcAbstractBenchmark extends BenchmarkDriverAdapter { +public abstract class JdbcAbstractBenchmark extends IgniteAbstractBenchmark { /** Arguments. */ protected final IgniteBenchmarkArguments args = new IgniteBenchmarkArguments(); /** All {@link Connection}s associated with threads. */ private final List<Connection> threadConnections = new ArrayList<>(); + /** List of queries. */ + private final List<String> dbqueries = new ArrayList<>(); + /** Each connection is also a transaction, so we better pin them to threads. */ ThreadLocal<Connection> conn = new ThreadLocal<Connection>() { @Override protected Connection initialValue() { Connection conn; try { conn = connection(); - if (args.createTempDatabase()) { + if (args.createTempDatabase() || args.dbn() != null) { assert dbName != null; conn.setCatalog(dbName); } @@ -76,12 +79,18 @@ public abstract class JdbcAbstractBenchmark extends BenchmarkDriverAdapter { Class.forName(args.jdbcDriver()); if (args.createTempDatabase()) createTestDatabase(); + else + dbName = (args.dbn() == null) ? null : args.dbn(); try (Connection conn = connection()) { if (args.createTempDatabase()) conn.setCatalog(dbName); + populateTestDatabase(conn); } + + if (args.loadTestQueriesFile() != null) + setQueries(); } /** {@inheritDoc} */ @@ -89,10 +98,13 @@ public abstract class JdbcAbstractBenchmark extends BenchmarkDriverAdapter { synchronized (threadConnections) { for (Connection conn : threadConnections) U.closeQuiet(conn); + threadConnections.clear(); } + if (args.createTempDatabase()) dropTestDatabase(); + super.tearDown(); } @@ -111,7 +123,8 @@ public abstract class JdbcAbstractBenchmark extends BenchmarkDriverAdapter { private void dropTestDatabase() throws SQLException { try (Connection conn = connection()) { try (Statement stmt = conn.createStatement()) { - stmt.executeUpdate("drop database " + dbName); + if (!conn.getMetaData().getDatabaseProductName().equals("Ignite Cache")) + stmt.executeUpdate("drop database " + dbName); } } } @@ -141,14 +154,39 @@ public abstract class JdbcAbstractBenchmark extends BenchmarkDriverAdapter { } } + /** Set list of queries defined in file */ + private void setQueries() throws IOException, SQLException { + if (args.loadTestQueriesFile() != null) { + try (FileReader fr = new FileReader(args.loadTestQueriesFile())) { + try (BufferedReader br = new BufferedReader(fr)) { + String line; + + while ((line = br.readLine()) != null) { + if (line.trim().isEmpty()) + continue; + + dbqueries.add(line.trim()); + } + } + } + } + } + /** Create new {@link Connection} from {@link #args}. Intended for use by {@link #setUp} and {@link #tearDown} */ - private Connection connection() throws SQLException { + public Connection connection() throws SQLException { Connection conn = DriverManager.getConnection(args.jdbcUrl()); conn.setAutoCommit(true); return conn; } /** + * @return List of queries. + */ + public List<String> getDbqueries(){ + return dbqueries; + } + + /** * Delete all data from the table specified * @param tblName target table * @throws SQLException if failed @@ -156,7 +194,8 @@ public abstract class JdbcAbstractBenchmark extends BenchmarkDriverAdapter { void clearTable(String tblName) throws SQLException { try (Connection conn = connection()) { try (PreparedStatement stmt = conn.prepareStatement("drop table " + tblName)) { - stmt.executeUpdate(); + if (!conn.getMetaData().getDatabaseProductName().equals("Ignite Cache")) + stmt.executeUpdate(); } } } http://git-wip-us.apache.org/repos/asf/ignite/blob/409f6e5d/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/jdbc/JdbcPutBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/jdbc/JdbcPutBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/jdbc/JdbcPutBenchmark.java index 1b10088..47e4150 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/jdbc/JdbcPutBenchmark.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/jdbc/JdbcPutBenchmark.java @@ -21,11 +21,8 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; import java.util.Map; - import org.apache.ignite.IgniteException; -import static org.apache.ignite.yardstick.IgniteAbstractBenchmark.nextRandom; - /** JDBC benchmark that performs raw SQL insert */ public class JdbcPutBenchmark extends JdbcAbstractBenchmark { /** {@inheritDoc} */ http://git-wip-us.apache.org/repos/asf/ignite/blob/409f6e5d/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/jdbc/RdbmsBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/jdbc/RdbmsBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/jdbc/RdbmsBenchmark.java new file mode 100644 index 0000000..341e5a7 --- /dev/null +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/jdbc/RdbmsBenchmark.java @@ -0,0 +1,220 @@ +/* + * 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.jdbc; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.util.Map; +import java.util.concurrent.ThreadLocalRandom; +import java.util.concurrent.atomic.AtomicLong; +import org.apache.ignite.IgniteException; +import org.yardstickframework.BenchmarkConfiguration; +import org.yardstickframework.BenchmarkUtils; + +/** JDBC benchmark that performs raw SQL insert */ +public class RdbmsBenchmark extends JdbcAbstractBenchmark { + /** Default number of rows in Accounts table. */ + private long accRows; + + /** Default number of rows in Tellers table. */ + private long tellRows; + + /** Default number of rows in Branches table. */ + private long branchRows; + + /** Id for History table */ + private AtomicLong cnt; + + /** Flag for working with Ignite jdbc. */ + private boolean isIgnite; + + /** {@inheritDoc} */ + @Override public void setUp(BenchmarkConfiguration cfg) throws Exception { + super.setUp(cfg); + + isIgnite = conn.get().getMetaData().getDatabaseProductName().equals("Ignite Cache"); + + if (isIgnite) + clearCaches(); + else { + conn.get().createStatement().execute("DROP TABLE if exists History;"); + conn.get().createStatement().execute("CREATE TABLE if not exists History (id BIGINT, aid BIGINT, tid BIGINT, bid BIGINT, delta BIGINT);"); + } + cnt = new AtomicLong(); + + accRows = 1000L * args.scaleFactor(); + + tellRows = 10L * args.scaleFactor(); + + branchRows = 5L * args.scaleFactor(); + + fillTable("Accounts", accRows); + + fillTable("Tellers", tellRows); + + fillTable("Branches", branchRows); + } + + /** {@inheritDoc} */ + @SuppressWarnings("SimplifiableIfStatement") + @Override public boolean test(Map<Object, Object> ctx) throws Exception { + long aid = ThreadLocalRandom.current().nextLong(accRows); + long bid = ThreadLocalRandom.current().nextLong(branchRows); + long tid = ThreadLocalRandom.current().nextLong(tellRows); + + long delta = ThreadLocalRandom.current().nextLong(1000); + + for (String query : getDbqueries()) { + boolean done = false; + + query = query.replaceAll(":aid", Long.toString(aid)); + query = query.replaceAll(":bid", Long.toString(bid)); + query = query.replaceAll(":tid", Long.toString(tid)); + query = query.replaceAll(":delta", Long.toString(delta)); + if (query.contains(":id")) + query = query.replaceAll(":id", Long.toString(cnt.getAndIncrement())); + + try (PreparedStatement stmt = conn.get().prepareStatement(query)) { + if (isIgnite && query.startsWith("INSERT")) { + stmt.setLong(1, cnt.getAndIncrement()); + stmt.setLong(2, tid); + stmt.setLong(3, bid); + stmt.setLong(4, aid); + stmt.setLong(5, delta); + } + while (!done) { + stmt.execute(); + done = true; + } + } + catch (Exception ignored) { + BenchmarkUtils.println("Failed to execute query " + query); + } + } + return true; + } + + /** + * Create upsert statement depending on the type of database + * + * @param conn {@link Connection} to get metadata from to determine storage type + * @param tblName Target table name. + * @return upsert statement with params set + * @throws SQLException if failed + */ + + private static PreparedStatement createUpsertStatement(Connection conn, String tblName) throws SQLException { + switch (conn.getMetaData().getDatabaseProductName()) { + case "H2": + return conn.prepareStatement("merge into " + tblName + " (id, val) values(?, ?)"); + + case "Ignite Cache": + return conn.prepareStatement("merge into " + '"' + tblName + '"' + '.' + tblName + " (_key, val) values(?, ?)"); + + case "MySQL": + return conn.prepareStatement("insert into " + tblName + " (id, val) values(?, ?) on duplicate key " + + "update val = ?"); + + case "PostgreSQL": + return conn.prepareStatement("insert into " + tblName + " (id, val) values(?, ?) on conflict(id) do " + + "update set val = ?"); + + default: + throw new IgniteException("Unexpected database type [databaseProductName=" + + conn.getMetaData().getDatabaseProductName() + ']'); + } + } + + /** + * Set args to prepared upsert statement. + * + * @param stmt Statement. + * @param newKey Key. + * @param newVal Value. + * @throws SQLException if failed. + */ + private static void setUpsertStatementArgs(PreparedStatement stmt, long newKey, long newVal) + throws SQLException { + switch (stmt.getConnection().getMetaData().getDatabaseProductName()) { + case "H2": + // No-op. + break; + + case "Ignite Cache": + // No-op. + break; + + case "MySQL": + case "PostgreSQL": + stmt.setLong(3, newVal); + + break; + + default: + throw new IgniteException("Unexpected database type [databaseProductName=" + + stmt.getConnection().getMetaData().getDatabaseProductName() + ']'); + } + stmt.setLong(1, newKey); + stmt.setLong(2, newVal); + } + + /** + * Fill tables with random data. + * + * @param tblName name of the table to fill + * @param rows number of rows in the table + * @throws Exception if failed. + */ + private void fillTable(String tblName, long rows) throws Exception { + if (!isIgnite && args.schemaDefinition() == null) + return; + + if (isIgnite) + startPreloadLogging(args.preloadLogsInterval()); + + try (PreparedStatement stmt = createUpsertStatement(conn.get(), tblName)) { + for (long i = 0; i < rows; i++) { + int newVal = nextRandom(args.range()); + + setUpsertStatementArgs(stmt, i, newVal); + + stmt.execute(); + + if(i % 1000 == 0) + BenchmarkUtils.println("Inserting " + i + "th value into " + tblName); + } + } + stopPreloadLogging(); + } + + /** {@inheritDoc} */ + @Override public void tearDown() throws Exception { + super.tearDown(); + } + + /** + * Clear caches. + */ + private void clearCaches() { + ignite().cache("Accounts").clear(); + ignite().cache("Tellers").clear(); + ignite().cache("Branches").clear(); + ignite().cache("History").clear(); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/409f6e5d/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/model/Accounts.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/model/Accounts.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/model/Accounts.java new file mode 100644 index 0000000..7cc26cf --- /dev/null +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/model/Accounts.java @@ -0,0 +1,62 @@ +/* + * 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.model; + +import org.apache.ignite.cache.query.annotations.QuerySqlField; + +/** + * Entity class for benchmark. + */ +public class Accounts { + /** */ + @QuerySqlField + private long val; + + /** */ + public Accounts() { + // No-op. + } + + /** + * @param val Id. + */ + public Accounts(long val) { + this.val = val; + } + + /** + * @param val Val. + */ + public Accounts setVal(long val) { + this.val = val; + + return this; + } + + /** + * @return Val. + */ + public long getVal() { + return val; + } + + /** {@inheritDoc} */ + @Override public String toString() { + return "Accounts [val=" + val + ']'; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/409f6e5d/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/model/Branches.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/model/Branches.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/model/Branches.java new file mode 100644 index 0000000..ab7cf64 --- /dev/null +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/model/Branches.java @@ -0,0 +1,62 @@ +/* + * 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.model; + +import org.apache.ignite.cache.query.annotations.QuerySqlField; + +/** + * Entity class for benchmark. + */ +public class Branches { + /** */ + @QuerySqlField + private long val; + + /** */ + public Branches() { + // No-op. + } + + /** + * @param val Id. + */ + public Branches(long val) { + this.val = val; + } + + /** + * @param val Val. + */ + public Branches setVal(long val) { + this.val = val; + + return this; + } + + /** + * @return Val. + */ + public long getVal() { + return val; + } + + /** {@inheritDoc} */ + @Override public String toString() { + return "Branches [val=" + val + ']'; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/409f6e5d/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/model/History.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/model/History.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/model/History.java new file mode 100644 index 0000000..751594e --- /dev/null +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/model/History.java @@ -0,0 +1,69 @@ +/* + * 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.model; + +import org.apache.ignite.cache.query.annotations.QuerySqlField; + +/** + * Value used for indexed put test. + */ +public class History { + /** Value 1. */ + @QuerySqlField(index = true) + private long tid; + + /** Value 2. */ + @QuerySqlField(index = true) + private long bid; + + /** Value 3. */ + @QuerySqlField(index = true) + private long aid; + + /** Value 4. */ + @QuerySqlField(index = true) + private long delta; + + /** + * Constructs. + * + * @param tid Indexed value. + */ + public History(long tid, long bid, long aid, long delta) { + this.tid = tid; + this.bid = bid; + this.aid = aid; + this.delta = delta; + } + + /** {@inheritDoc} */ + @Override public int hashCode() { + Long result = tid; + + result = 31 * result + bid; + result = 31 * result + aid; + result = 31 * result + delta; + + return result.intValue(); + } + + /** {@inheritDoc} */ + @Override public String toString() { + return "History [tid=" + tid + ", bid=" + bid + ", aid=" + aid + ", delta=" + delta +']'; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/409f6e5d/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/model/Tellers.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/model/Tellers.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/model/Tellers.java new file mode 100644 index 0000000..f953b76 --- /dev/null +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/model/Tellers.java @@ -0,0 +1,62 @@ +/* + * 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.model; + +import org.apache.ignite.cache.query.annotations.QuerySqlField; + +/** + * Entity class for benchmark. + */ +public class Tellers { + /** */ + @QuerySqlField + private long val; + + /** */ + public Tellers() { + // No-op. + } + + /** + * @param val Id. + */ + public Tellers(long val) { + this.val = val; + } + + /** + * @param val Val. + */ + public Tellers setVal(long val) { + this.val = val; + + return this; + } + + /** + * @return Val. + */ + public long getVal() { + return val; + } + + /** {@inheritDoc} */ + @Override public String toString() { + return "Tellers [val=" + val + ']'; + } +} \ No newline at end of file
