You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2015/11/18 09:08:29 UTC
[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 <as...@gridgain.com>
Authored: Wed Nov 11 18:35:02 2015 +0300
Committer: ashutak <as...@gridgain.com>
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> T doInTransaction(IgniteTransactions igniteTx, TransactionConcurrency txConcurrency,
+ TransactionIsolation txIsolation, Callable<T> 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<Object, Object> ctx) throws Exception {
Set<Integer> 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<Integer, Account> 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<Object, Object> ctx) throws Exception {
Set<Integer> 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<Integer, Account> 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<Integer, Integer> {
+ /** */
+ private IgniteTransactions txs;
+
+ /** {@inheritDoc} */
+ @Override public void setUp(BenchmarkConfiguration cfg) throws Exception {
+ super.setUp(cfg);
+
+ txs = ignite().transactions();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean test(Map<Object, Object> ctx) throws Exception {
+ final ThreadRange r = threadRange();
+
+ doInTransaction(txs, args.txConcurrency(), args.txIsolation(), new Callable<Void>() {
+ @Override public Void call() throws Exception {
+ SortedMap<Integer, Integer> 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<Integer, Integer> 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<Boolean>() {
+ return doInTransaction(ignite().transactions(), PESSIMISTIC, REPEATABLE_READ, new Callable<Boolean>() {
@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> T doInTransaction(Ignite ignite, Callable<T> 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<Boolean>() {
+ return doInTransaction(ignite().transactions(), PESSIMISTIC, REPEATABLE_READ, new Callable<Boolean>() {
@Override public Boolean call() throws Exception {
Map<String, Long> 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> T doInTransaction(Ignite ignite, Callable<T> 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";