Return-Path: X-Original-To: apmail-ignite-commits-archive@minotaur.apache.org Delivered-To: apmail-ignite-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4455A1899D for ; Tue, 4 Aug 2015 14:51:19 +0000 (UTC) Received: (qmail 92321 invoked by uid 500); 4 Aug 2015 14:51:19 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 92291 invoked by uid 500); 4 Aug 2015 14:51:19 -0000 Mailing-List: contact commits-help@ignite.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.incubator.apache.org Delivered-To: mailing list commits@ignite.incubator.apache.org Received: (qmail 92282 invoked by uid 99); 4 Aug 2015 14:51:19 -0000 Received: from Unknown (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Aug 2015 14:51:19 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id AF15EDA48A for ; Tue, 4 Aug 2015 14:51:18 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.632 X-Spam-Level: * X-Spam-Status: No, score=1.632 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.149, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id gZ6v30zxEAeD for ; Tue, 4 Aug 2015 14:51:17 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with SMTP id 6447450685 for ; Tue, 4 Aug 2015 14:51:17 +0000 (UTC) Received: (qmail 92215 invoked by uid 99); 4 Aug 2015 14:51:17 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Aug 2015 14:51:17 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id E1FBEE17ED; Tue, 4 Aug 2015 14:51:16 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ntikhonov@apache.org To: commits@ignite.incubator.apache.org Message-Id: <65fd8389fffc46f28ddb65c09ddce064@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: incubator-ignite git commit: Added benchmarks for jdbc. Date: Tue, 4 Aug 2015 14:51:16 +0000 (UTC) Repository: incubator-ignite Updated Branches: refs/heads/master b056a739e -> 52c1dfa32 Added benchmarks for jdbc. Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/52c1dfa3 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/52c1dfa3 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/52c1dfa3 Branch: refs/heads/master Commit: 52c1dfa32d86183c07c82bb3c34a03316d6fd7b5 Parents: b056a73 Author: nikolay_tikhonov Authored: Tue Aug 4 17:51:05 2015 +0300 Committer: nikolay_tikhonov Committed: Tue Aug 4 17:51:05 2015 +0300 ---------------------------------------------------------------------- .../yardstick/config/benchmark-query.properties | 3 +- modules/yardstick/config/ignite-base-config.xml | 2 - .../yardstick/IgniteBenchmarkArguments.java | 11 ++ .../cache/IgniteJdbcSqlQueryBenchmark.java | 134 +++++++++++++++++++ 4 files changed, 147 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/52c1dfa3/modules/yardstick/config/benchmark-query.properties ---------------------------------------------------------------------- diff --git a/modules/yardstick/config/benchmark-query.properties b/modules/yardstick/config/benchmark-query.properties index d6a8b9e..1a75926 100644 --- a/modules/yardstick/config/benchmark-query.properties +++ b/modules/yardstick/config/benchmark-query.properties @@ -63,5 +63,6 @@ CONFIGS="\ -cfg ${SCRIPT_DIR}/../config/ignite-localhost-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgniteSqlQueryJoinBenchmark -sn IgniteNode -ds sql-query-join-1-backup,\ -cfg ${SCRIPT_DIR}/../config/ignite-localhost-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgniteSqlQueryJoinOffHeapBenchmark -sn IgniteNode -ds sql-query-join-offheap-1-backup,\ -cfg ${SCRIPT_DIR}/../config/ignite-localhost-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgniteSqlQueryPutBenchmark -sn IgniteNode -ds sql-query-put-1-backup,\ --cfg ${SCRIPT_DIR}/../config/ignite-localhost-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgniteSqlQueryPutOffHeapBenchmark -sn IgniteNode -ds sql-query-put-offheap-1-backup\ +-cfg ${SCRIPT_DIR}/../config/ignite-localhost-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgniteSqlQueryPutOffHeapBenchmark -sn IgniteNode -ds sql-query-put-offheap-1-backup,\ +-cfg ${SCRIPT_DIR}/../config/ignite-localhost-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -jdbc jdbc:ignite://127.0.0.1/query -t 64 -sm PRIMARY_SYNC -dn IgniteJdbcSqlQueryBenchmark -sn IgniteNode -ds sql-query-jdbc-1-backup\ " http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/52c1dfa3/modules/yardstick/config/ignite-base-config.xml ---------------------------------------------------------------------- diff --git a/modules/yardstick/config/ignite-base-config.xml b/modules/yardstick/config/ignite-base-config.xml index b2c976a..c77cc9a 100644 --- a/modules/yardstick/config/ignite-base-config.xml +++ b/modules/yardstick/config/ignite-base-config.xml @@ -180,8 +180,6 @@ - - http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/52c1dfa3/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 1562b26..5eb7060 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 @@ -106,6 +106,17 @@ public class IgniteBenchmarkArguments { @Parameter(names = {"-col", "--collocated"}, description = "Collocated") private boolean collocated; + /** */ + @Parameter(names = {"-jdbc", "--jdbcUrl"}, description = "JDBC url") + private String jdbcUrl; + + /** + * @return JDBC url. + */ + public String jdbcUrl() { + return jdbcUrl; + } + /** * @return Transaction concurrency. */ http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/52c1dfa3/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteJdbcSqlQueryBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteJdbcSqlQueryBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteJdbcSqlQueryBenchmark.java new file mode 100644 index 0000000..0ded2bd --- /dev/null +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteJdbcSqlQueryBenchmark.java @@ -0,0 +1,134 @@ +/* + * 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 org.apache.ignite.*; +import org.apache.ignite.yardstick.cache.model.Person; +import org.yardstickframework.BenchmarkConfiguration; + +import javax.cache.Cache; +import java.sql.*; +import java.util.*; +import java.util.concurrent.ConcurrentLinkedQueue; +import java.util.concurrent.ThreadLocalRandom; + +import static org.yardstickframework.BenchmarkUtils.println; + +/** + * Ignite benchmark that performs query operations. + */ +public class IgniteJdbcSqlQueryBenchmark extends IgniteCacheAbstractBenchmark { + /** Statements for closing. */ + Set stms = Collections.synchronizedSet(new HashSet()); + + /** {@inheritDoc} */ + @Override public void setUp(BenchmarkConfiguration cfg) throws Exception { + super.setUp(cfg); + + println(cfg, "Populating query data..."); + + long start = System.nanoTime(); + + try (IgniteDataStreamer 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} */ + @Override public boolean test(Map ctx) throws Exception { + PreparedStatement stm = (PreparedStatement)ctx.get(0); + + if (stm == null) { + stm = createStatement(); + + stms.add(stm); + + ctx.put(0, stm); + } + + double salary = ThreadLocalRandom.current().nextDouble() * args.range() * 1000; + + double maxSalary = salary + 1000; + + stm.clearParameters(); + + stm.setDouble(1, salary); + stm.setDouble(2, maxSalary); + + ResultSet rs = stm.executeQuery(); + + while (rs.next()) { + double sal = rs.getDouble("salary"); + + if (sal < salary || sal > maxSalary) + throw new Exception("Invalid person retrieved [min=" + salary + ", max=" + maxSalary + ']'); + } + + return true; + } + + /** {@inheritDoc} */ + @Override public void tearDown() throws Exception { + for (PreparedStatement stm : stms) { + try { + stm.getConnection().close(); + + stm.close(); + } + catch (Exception ignore) { + println("Failed to close connection." + stm); + } + } + + super.tearDown(); + } + + /** + * @return Prepared statement. + * @throws Exception + */ + private PreparedStatement createStatement() throws Exception { + Class.forName("org.apache.ignite.IgniteJdbcDriver"); + + Connection conn = null; + + try { + conn = DriverManager.getConnection(args.jdbcUrl()); + + return conn.prepareStatement("select * from Person where salary >= ? and salary <= ?"); + } + catch (Exception e) { + if (conn != null) + conn.close(); + + throw new IgniteException("Failed to create prepare statement.", e); + } + } + + /** {@inheritDoc} */ + @Override protected IgniteCache cache() { + return ignite().cache("query"); + } +}