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 D84E618581 for ; Wed, 18 Nov 2015 08:08:11 +0000 (UTC) Received: (qmail 99937 invoked by uid 500); 18 Nov 2015 08:08:11 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 99577 invoked by uid 500); 18 Nov 2015 08:08:11 -0000 Mailing-List: contact commits-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list commits@ignite.apache.org Received: (qmail 99021 invoked by uid 99); 18 Nov 2015 08:08:11 -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; Wed, 18 Nov 2015 08:08:11 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 18533E04C2; Wed, 18 Nov 2015 08:08:11 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: vozerov@apache.org To: commits@ignite.apache.org Date: Wed, 18 Nov 2015 08:08:29 -0000 Message-Id: <46f8434d3dad4780ad80361d5f11e377@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [20/50] [abbrv] ignite git commit: Added tx-getAll PutAll benchmarks Added tx-getAll PutAll benchmarks Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/847b616f Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/847b616f Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/847b616f Branch: refs/heads/ignite-1816 Commit: 847b616f1a15756db8876fc8f88b0629318f14c3 Parents: 967cfcb Author: ashutak Authored: Wed Nov 11 18:35:02 2015 +0300 Committer: ashutak Committed: Wed Nov 11 18:35:02 2015 +0300 ---------------------------------------------------------------------- .../config/benchmark-multicast.properties | 5 +- .../ignite/yardstick/IgniteBenchmarkUtils.java | 75 ++++++++++++++++++++ .../IgniteAccountSerializableTxBenchmark.java | 11 ++- .../cache/IgniteAccountTxBenchmark.java | 11 ++- .../cache/IgniteGetAllPutAllTxBenchmark.java | 73 +++++++++++++++++++ ...IgniteTransactionalWriteInvokeBenchmark.java | 41 +---------- .../IgniteTransactionalWriteReadBenchmark.java | 41 +---------- 7 files changed, 166 insertions(+), 91 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/847b616f/modules/yardstick/config/benchmark-multicast.properties ---------------------------------------------------------------------- diff --git a/modules/yardstick/config/benchmark-multicast.properties b/modules/yardstick/config/benchmark-multicast.properties index 536ccf4..577d611 100644 --- a/modules/yardstick/config/benchmark-multicast.properties +++ b/modules/yardstick/config/benchmark-multicast.properties @@ -110,5 +110,8 @@ CONFIGS="\ -cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -dn IgniteSqlQueryPutOffHeapBenchmark -sn IgniteNode -ds ${ver}sql-query-put-offheap-1-backup,\ -cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -bs 100 -dn IgnitePutAllBenchmark -sn IgniteNode -ds ${ver}atomic-putAll-1-backup,\ -cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -bs 100 -dn IgnitePutAllTxBenchmark -sn IgniteNode -ds ${ver}tx-putAll-1-backup,\ --cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -bs 100 -dn IgnitePutAllSerializableTxBenchmark -sn IgniteNode -ds ${ver}tx-putAllSerializable-1-backup\ +-cfg ${SCRIPT_DIR}/../config/ignite-multicast-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -bs 100 -dn IgnitePutAllSerializableTxBenchmark -sn IgniteNode -ds ${ver}tx-putAllSerializable-1-backup,\ +-cfg ${SCRIPT_DIR}/../config/ignite-localhost-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -bs 10 -txc OPTIMISTIC -dn IgniteGetAllPutAllTxBenchmark -sn IgniteNode -ds tx-optimistic-getAllPutAll-1-backup,\ +-cfg ${SCRIPT_DIR}/../config/ignite-localhost-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -bs 10 -txc PESSIMISTIC -dn IgniteGetAllPutAllTxBenchmark -sn IgniteNode -ds tx-pessimistic-getAllPutAll-1-backup,\ +-cfg ${SCRIPT_DIR}/../config/ignite-localhost-config.xml -nn ${nodesNum} -b ${b} -w ${w} -d ${d} -t ${t} -sm ${sm} -bs 10 -txc OPTIMISTIC -txi SERIALIZABLE -dn IgniteGetAllPutAllTxBenchmark -sn IgniteNode -ds tx-opt-serializable-getAllPutAll-1-backup,\ " http://git-wip-us.apache.org/repos/asf/ignite/blob/847b616f/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteBenchmarkUtils.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteBenchmarkUtils.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteBenchmarkUtils.java new file mode 100644 index 0000000..0b7568b --- /dev/null +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteBenchmarkUtils.java @@ -0,0 +1,75 @@ +/* + * 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; + +import java.util.concurrent.Callable; +import javax.cache.CacheException; +import org.apache.ignite.IgniteTransactions; +import org.apache.ignite.cluster.ClusterTopologyException; +import org.apache.ignite.transactions.Transaction; +import org.apache.ignite.transactions.TransactionConcurrency; +import org.apache.ignite.transactions.TransactionIsolation; +import org.apache.ignite.transactions.TransactionOptimisticException; +import org.apache.ignite.transactions.TransactionRollbackException; + +/** + * Utils. + */ +public class IgniteBenchmarkUtils { + /** + * Utility class constructor. + */ + private IgniteBenchmarkUtils() { + // No-op. + } + + /** + * @param igniteTx Ignite transaction. + * @param txConcurrency Transaction concurrency. + * @param clo Closure. + * @return Result of closure execution. + * @throws Exception + */ + public static T doInTransaction(IgniteTransactions igniteTx, TransactionConcurrency txConcurrency, + TransactionIsolation txIsolation, Callable clo) throws Exception { + while (true) { + try (Transaction tx = igniteTx.txStart(txConcurrency, txIsolation)) { + T res = clo.call(); + + tx.commit(); + + return res; + } + catch (CacheException e) { + if (e.getCause() instanceof ClusterTopologyException) { + ClusterTopologyException topEx = (ClusterTopologyException)e.getCause(); + + topEx.retryReadyFuture().get(); + } + else + throw e; + } + catch (ClusterTopologyException e) { + e.retryReadyFuture().get(); + } + catch (TransactionRollbackException | TransactionOptimisticException ignore) { + // Safe to retry right away. + } + } + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/847b616f/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteAccountSerializableTxBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteAccountSerializableTxBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteAccountSerializableTxBenchmark.java index 32e7653..ecb6727 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteAccountSerializableTxBenchmark.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteAccountSerializableTxBenchmark.java @@ -31,21 +31,20 @@ import static org.apache.ignite.transactions.TransactionIsolation.SERIALIZABLE; * */ public class IgniteAccountSerializableTxBenchmark extends IgniteAccountTxAbstractBenchmark { - /** */ - private static final int ACCOUNT_NUMBER = 3; - /** {@inheritDoc} */ @Override public boolean test(Map ctx) throws Exception { Set accountIds = new HashSet<>(); - while (accountIds.size() < ACCOUNT_NUMBER) + int accNum = args.batch(); + + while (accountIds.size() < accNum) accountIds.add(nextRandom(args.range())); while (true) { try (Transaction tx = txs.txStart(OPTIMISTIC, SERIALIZABLE)) { Map accounts = (Map)cache.getAll(accountIds); - if (accounts.size() != ACCOUNT_NUMBER) + if (accounts.size() != accNum) throw new Exception("Failed to find accounts: " + accountIds); Integer fromId = accountIds.iterator().next(); @@ -78,4 +77,4 @@ public class IgniteAccountSerializableTxBenchmark extends IgniteAccountTxAbstrac return true; } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/ignite/blob/847b616f/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteAccountTxBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteAccountTxBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteAccountTxBenchmark.java index 78e675e..de332c1 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteAccountTxBenchmark.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteAccountTxBenchmark.java @@ -30,21 +30,20 @@ import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_REA * */ public class IgniteAccountTxBenchmark extends IgniteAccountTxAbstractBenchmark { - /** */ - private static final int ACCOUNT_NUMBER = 3; - /** {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public boolean test(Map ctx) throws Exception { Set accountIds = new TreeSet<>(); - while (accountIds.size() < ACCOUNT_NUMBER) + int accNum = args.batch(); + + while (accountIds.size() < accNum) accountIds.add(nextRandom(args.range())); try (Transaction tx = txs.txStart(PESSIMISTIC, REPEATABLE_READ)) { Map accounts = (Map)cache.getAll(accountIds); - if (accounts.size() != ACCOUNT_NUMBER) + if (accounts.size() != accNum) throw new Exception("Failed to find accounts: " + accountIds); Integer fromId = accountIds.iterator().next(); @@ -71,4 +70,4 @@ public class IgniteAccountTxBenchmark extends IgniteAccountTxAbstractBenchmark { return true; } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/ignite/blob/847b616f/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 new file mode 100644 index 0000000..a8f6d7b --- /dev/null +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteGetAllPutAllTxBenchmark.java @@ -0,0 +1,73 @@ +/* + * 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.Map; +import java.util.SortedMap; +import java.util.TreeMap; +import java.util.concurrent.Callable; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteTransactions; +import org.yardstickframework.BenchmarkConfiguration; + +import static org.apache.ignite.yardstick.IgniteBenchmarkUtils.doInTransaction; + +/** + * Ignite benchmark that performs transactional putAll operations. + */ +public class IgniteGetAllPutAllTxBenchmark extends IgniteCacheAbstractBenchmark { + /** */ + private IgniteTransactions txs; + + /** {@inheritDoc} */ + @Override public void setUp(BenchmarkConfiguration cfg) throws Exception { + super.setUp(cfg); + + txs = ignite().transactions(); + } + + /** {@inheritDoc} */ + @Override public boolean test(Map ctx) throws Exception { + final ThreadRange r = threadRange(); + + doInTransaction(txs, args.txConcurrency(), args.txIsolation(), new Callable() { + @Override public Void call() throws Exception { + SortedMap vals = new TreeMap<>(); + + for (int i = 0; i < args.batch(); i++) { + int key = r.nextRandom(); + + vals.put(key, key); + } + + cache.getAll(vals.keySet()); + + cache.putAll(vals); + + return null; + } + }); + + return true; + } + + /** {@inheritDoc} */ + @Override protected IgniteCache cache() { + return ignite().cache("tx"); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/847b616f/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalWriteInvokeBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalWriteInvokeBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalWriteInvokeBenchmark.java index 1a8ee14..2c4050b 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalWriteInvokeBenchmark.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalWriteInvokeBenchmark.java @@ -22,17 +22,13 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.concurrent.Callable; -import javax.cache.CacheException; import javax.cache.processor.EntryProcessorException; import javax.cache.processor.MutableEntry; -import org.apache.ignite.Ignite; import org.apache.ignite.cache.CacheEntryProcessor; -import org.apache.ignite.cluster.ClusterTopologyException; -import org.apache.ignite.transactions.Transaction; -import org.apache.ignite.transactions.TransactionRollbackException; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ; +import static org.apache.ignite.yardstick.IgniteBenchmarkUtils.doInTransaction; import static org.yardstickframework.BenchmarkUtils.println; /** @@ -63,7 +59,7 @@ public class IgniteTransactionalWriteInvokeBenchmark extends IgniteFailoverAbstr final int scenario = nextRandom(2); - return doInTransaction(ignite(), new Callable() { + return doInTransaction(ignite().transactions(), PESSIMISTIC, REPEATABLE_READ, new Callable() { @Override public Boolean call() throws Exception { final int timeout = args.cacheOperationTimeoutMillis(); @@ -127,39 +123,6 @@ public class IgniteTransactionalWriteInvokeBenchmark extends IgniteFailoverAbstr }); } - /** - * @param ignite Ignite instance. - * @param clo Closure. - * @return Result of closure execution. - * @throws Exception - */ - public static T doInTransaction(Ignite ignite, Callable clo) throws Exception { - while (true) { - try (Transaction tx = ignite.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { - T res = clo.call(); - - tx.commit(); - - return res; - } - catch (CacheException e) { - if (e.getCause() instanceof ClusterTopologyException) { - ClusterTopologyException topEx = (ClusterTopologyException)e.getCause(); - - topEx.retryReadyFuture().get(); - } - else - throw e; - } - catch (ClusterTopologyException e) { - e.retryReadyFuture().get(); - } - catch (TransactionRollbackException ignore) { - // Safe to retry right away. - } - } - } - /** {@inheritDoc} */ @Override protected String cacheName() { return "tx-write-invoke"; http://git-wip-us.apache.org/repos/asf/ignite/blob/847b616f/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalWriteReadBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalWriteReadBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalWriteReadBenchmark.java index c962749..f278e8a 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalWriteReadBenchmark.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/failover/IgniteTransactionalWriteReadBenchmark.java @@ -22,14 +22,10 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.concurrent.Callable; -import javax.cache.CacheException; -import org.apache.ignite.Ignite; -import org.apache.ignite.cluster.ClusterTopologyException; -import org.apache.ignite.transactions.Transaction; -import org.apache.ignite.transactions.TransactionRollbackException; import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC; import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ; +import static org.apache.ignite.yardstick.IgniteBenchmarkUtils.doInTransaction; import static org.yardstickframework.BenchmarkUtils.println; /** @@ -51,7 +47,7 @@ public class IgniteTransactionalWriteReadBenchmark extends IgniteFailoverAbstrac for (int i = 0; i < keys.length; i++) keys[i] = "key-" + k + "-" + i; - return doInTransaction(ignite(), new Callable() { + return doInTransaction(ignite().transactions(), PESSIMISTIC, REPEATABLE_READ, new Callable() { @Override public Boolean call() throws Exception { Map map = new HashMap<>(); @@ -101,39 +97,6 @@ public class IgniteTransactionalWriteReadBenchmark extends IgniteFailoverAbstrac }); } - /** - * @param ignite Ignite instance. - * @param clo Closure. - * @return Result of closure execution. - * @throws Exception - */ - public static T doInTransaction(Ignite ignite, Callable clo) throws Exception { - while (true) { - try (Transaction tx = ignite.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { - T res = clo.call(); - - tx.commit(); - - return res; - } - catch (CacheException e) { - if (e.getCause() instanceof ClusterTopologyException) { - ClusterTopologyException topEx = (ClusterTopologyException)e.getCause(); - - topEx.retryReadyFuture().get(); - } - else - throw e; - } - catch (ClusterTopologyException e) { - e.retryReadyFuture().get(); - } - catch (TransactionRollbackException ignore) { - // Safe to retry right away. - } - } - } - /** {@inheritDoc} */ @Override protected String cacheName() { return "tx-write-read";