Fixed race in IgniteTransactionalWriteInvokeBenchmark test.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/3a340034 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/3a340034 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/3a340034 Branch: refs/heads/ignite-843-rc2 Commit: 3a340034056f5da0ca00ed88e128b59cc28381d2 Parents: efe632b Author: ashutak <ashu...@gridgain.com> Authored: Tue Dec 8 16:02:36 2015 +0300 Committer: ashutak <ashu...@gridgain.com> Committed: Tue Dec 8 16:02:36 2015 +0300 ---------------------------------------------------------------------- .../config/benchmark-failover.properties | 2 +- ...IgniteTransactionalWriteInvokeBenchmark.java | 42 +++++++++++++++----- 2 files changed, 33 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/3a340034/modules/yardstick/config/benchmark-failover.properties ---------------------------------------------------------------------- diff --git a/modules/yardstick/config/benchmark-failover.properties b/modules/yardstick/config/benchmark-failover.properties index 7ed464c..352e2d4 100644 --- a/modules/yardstick/config/benchmark-failover.properties +++ b/modules/yardstick/config/benchmark-failover.properties @@ -60,7 +60,7 @@ RESTART_SERVERS=true SERVER_HOSTS=localhost,localhost # Comma-separated list of the hosts to run BenchmarkDrivers on. -DRIVER_HOSTS=localhost +DRIVER_HOSTS=localhost,localhost # Remote username. # REMOTE_USER= http://git-wip-us.apache.org/repos/asf/ignite/blob/3a340034/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 35befad..67044a1 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 @@ -25,9 +25,11 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.concurrent.Callable; +import java.util.concurrent.TimeUnit; import javax.cache.processor.EntryProcessorException; import javax.cache.processor.MutableEntry; import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCountDownLatch; import org.apache.ignite.IgniteDataStreamer; import org.apache.ignite.cache.CacheEntryProcessor; import org.apache.ignite.cache.affinity.Affinity; @@ -58,29 +60,49 @@ public class IgniteTransactionalWriteInvokeBenchmark extends IgniteFailoverAbstr /** */ private static final Long INITIAL_VALUE = 1L; + /** */ + public static final int TIMEOUT_SEC = 20 * 60; + /** {@inheritDoc} */ @Override public void setUp(BenchmarkConfiguration cfg) throws Exception { super.setUp(cfg); assert args.keysCount() > 0 : "Count of keys: " + args.keysCount(); - println(cfg, "Populating data..."); + IgniteCountDownLatch latch = ignite().countDownLatch("DATA-POPULATED-LATCH-" + cacheName(), 1, true, true); + + if (cfg.memberId() == 0) { + println(cfg, "Populating data for cache: " + cacheName()); - long start = System.nanoTime(); + long start = System.nanoTime(); - try (IgniteDataStreamer<String, Long> dataLdr = ignite().dataStreamer(cacheName())) { - for (int k = 0; k < args.range() && !Thread.currentThread().isInterrupted(); k++) { - dataLdr.addData("key-" + k + "-master", INITIAL_VALUE); + try (IgniteDataStreamer<String, Long> dataLdr = ignite().dataStreamer(cacheName())) { + for (int k = 0; k < args.range() && !Thread.currentThread().isInterrupted(); k++) { + dataLdr.addData("key-" + k + "-master", INITIAL_VALUE); - for (int i = 0; i < args.keysCount(); i++) - dataLdr.addData("key-" + k + "-" + i, INITIAL_VALUE); + for (int i = 0; i < args.keysCount(); i++) + dataLdr.addData("key-" + k + "-" + i, INITIAL_VALUE); - if (k % 100000 == 0) - println(cfg, "Populated accounts: " + k); + if (k % 100000 == 0) + println(cfg, "Populated accounts: " + k); + } } + + println(cfg, "Finished populating data in " + ((System.nanoTime() - start) / 1_000_000) + + " ms. for cache: " + cacheName()); + + latch.countDown(); } + else { + println(cfg, "Waiting for populating data in cache by driver with id 0: " + cacheName()); + + boolean success = latch.await(TIMEOUT_SEC, TimeUnit.SECONDS); - println(cfg, "Finished populating data in " + ((System.nanoTime() - start) / 1_000_000) + " ms."); + if (!success) + throw new IllegalStateException("Failed to wait that data populating finish."); + + println(cfg, "Finished waiting for populating data in cache by driver with id 0: " + cacheName()); + } } /** {@inheritDoc} */