http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e1d8f69b/modules/core/src/test/java/org/gridgain/loadtests/nio/GridNioBenchmarkClient.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/loadtests/nio/GridNioBenchmarkClient.java b/modules/core/src/test/java/org/gridgain/loadtests/nio/GridNioBenchmarkClient.java deleted file mode 100644 index 3feb586..0000000 --- a/modules/core/src/test/java/org/gridgain/loadtests/nio/GridNioBenchmarkClient.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * 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.gridgain.loadtests.nio; - -import org.apache.ignite.internal.util.typedef.*; - -import java.io.*; -import java.net.*; -import java.util.*; -import java.util.concurrent.*; - -/** - * - */ -public class GridNioBenchmarkClient { - /** */ - private static final int INITIAL_PACKET_SIZE = 65536; - - /** */ - private static final byte[] INITIAL_PACKET = new byte[INITIAL_PACKET_SIZE]; - - /** - * - */ - static { - Random r = new Random(); - - for (int i = 0; i < INITIAL_PACKET_SIZE; i++) - r.nextBytes(INITIAL_PACKET); - } - - /** */ - private final int connCnt; - - /** */ - private final String host; - - /** */ - private final int port; - - /** */ - private final ExecutorService exec; - - /** */ - private final byte[] buf = new byte[(int)(65536*1.5)]; - - /** - * @param connCnt Connections count. - * @param host Host. - * @param port Port. - */ - public GridNioBenchmarkClient(int connCnt, String host, int port) { - this.connCnt = connCnt; - this.host = host; - this.port = port; - - exec = Executors.newFixedThreadPool(connCnt); - } - - /** - * Runs single benchamark configuration. - * - * @throws IOException If connection failed. - * @throws InterruptedException If benchmark was interrupted. - */ - public void run() throws IOException, InterruptedException { - for (int i = 0; i < connCnt; i++) - exec.submit(new ClientThread()); - - Thread.sleep(5*60*1000); - - exec.shutdownNow(); - } - - /** - * Runs set of tests. - * - * @param args Command line arguments. - * @throws Exception If failed. - */ - public static void main(String[] args) throws Exception { - if (args.length != 3) { - X.println("Usage: " + GridNioBenchmarkClient.class.getSimpleName() + " <connections count> <host> <port>"); - - return; - } - - final int connCnt = Integer.parseInt(args[0]); - final String host = args[1]; - final int port = Integer.parseInt(args[2]); - - new GridNioBenchmarkClient(connCnt, host, port).run(); - } - - /** - * Test thread. - */ - private class ClientThread implements Runnable { - /** {@inheritDoc} */ - @Override public void run() { - Socket s = new Socket(); - - try { - s.connect(new InetSocketAddress(host, port)); - - InputStream in = s.getInputStream(); - OutputStream out = s.getOutputStream(); - - out.write(INITIAL_PACKET); - - for (int i = 0; i < 1000000; i++) - doIteration(in, out); - - long bytes = 0; - - long start = System.currentTimeMillis(); - - while (!Thread.interrupted()) - bytes += doIteration(in, out); - - long duration = System.currentTimeMillis() - start; - - long mb = bytes/1048576; - - X.println("Thread finished [MB=" + bytes/1048576 + ", MB/s=" + ((double)mb)*1000/duration + "]"); - } - catch (IOException e) { - e.printStackTrace(); - } - } - - /** - * Performs single test iterations. - * - * @param in Stream to read data. - * @param out Stream to write data. - * @return Echoed bytes count. - * @throws IOException If failed. - */ - @SuppressWarnings("CallToThreadYield") - private long doIteration(InputStream in, OutputStream out) throws IOException { - int read = in.read(buf, 0, in.available()); - - if (read == 0) - Thread.yield(); - - out.write(buf, 0, read); - - return read; - } - } -}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e1d8f69b/modules/core/src/test/java/org/gridgain/loadtests/nio/GridNioBenchmarkTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/loadtests/nio/GridNioBenchmarkTest.java b/modules/core/src/test/java/org/gridgain/loadtests/nio/GridNioBenchmarkTest.java deleted file mode 100644 index 712b213..0000000 --- a/modules/core/src/test/java/org/gridgain/loadtests/nio/GridNioBenchmarkTest.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * 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.gridgain.loadtests.nio; - -import org.apache.ignite.*; -import org.apache.ignite.internal.util.typedef.*; -import org.apache.ignite.internal.util.nio.*; -import org.apache.ignite.internal.util.typedef.internal.*; -import org.gridgain.testframework.junits.logger.*; -import org.jetbrains.annotations.*; - -import java.net.*; -import java.nio.*; - -/** - * - */ -public class GridNioBenchmarkTest { - /** */ - private final int port; - - /** */ - private final int selectorCnt; - - /** - * @param selectorCnt Selector count. - * @param port Port. - */ - public GridNioBenchmarkTest(int selectorCnt, int port) { - this.selectorCnt = selectorCnt; - this.port = port; - } - - /** - * Runs the benchmark. - * - * @throws UnknownHostException If can't connect to given hist, - * @throws IgniteCheckedException If NIO server initialisation failed. - */ - @SuppressWarnings("ConstantConditions") - public void run() throws UnknownHostException, IgniteCheckedException { - GridNioServerListener<ByteBuffer> lsnr = new GridNioServerListenerAdapter<ByteBuffer>() { - @Override public void onConnected(GridNioSession ses) { - X.print("New connection accepted."); - } - - @Override public void onDisconnected(GridNioSession ses, @Nullable Exception e) { - // No-op. - } - - @Override public void onMessage(GridNioSession ses, ByteBuffer msg) { - ByteBuffer buf = ByteBuffer.allocate(msg.remaining()).put(msg); - buf.position(0); - ses.send(buf); - } - - @Override public void onSessionWriteTimeout(GridNioSession ses) { - X.error("Session write timeout. Closing."); - } - - @Override public void onSessionIdleTimeout(GridNioSession ses) { - X.error("Session idle timeout. Closing."); - } - }; - - IgniteLogger log = new GridTestLog4jLogger(U.resolveGridGainUrl("config/gridgain-log4j.xml")); - - GridNioServer.<ByteBuffer>builder() - .address(InetAddress.getByName("localhost")) - .port(port) - .listener(lsnr) - .logger(log) - .selectorCount(selectorCnt) - .gridName("") - .tcpNoDelay(false) - .directBuffer(false) - .byteOrder(ByteOrder.nativeOrder()) - .socketSendBufferSize(0) - .socketReceiveBufferSize(0) - .sendQueueLimit(0) - .build() - .start(); - } - - /** - * Runs the benchmark. - * - * @param args Command line arguments. - * @throws UnknownHostException If can't connect to given hist, - * @throws IgniteCheckedException If NIO server initialisation failed. - */ - public static void main(String[] args) throws UnknownHostException, IgniteCheckedException { - if (args.length != 2) { - X.println("Usage: " + GridNioBenchmarkTest.class.getSimpleName() + " <threads> <port>"); - - return; - } - - final int threads = Integer.parseInt(args[0]); - final int port = Integer.parseInt(args[1]); - - new GridNioBenchmarkTest(threads, port).run(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e1d8f69b/modules/core/src/test/java/org/gridgain/loadtests/offheap/GridOffHeapMapPerformanceAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/loadtests/offheap/GridOffHeapMapPerformanceAbstractTest.java b/modules/core/src/test/java/org/gridgain/loadtests/offheap/GridOffHeapMapPerformanceAbstractTest.java deleted file mode 100644 index eaa4fe1..0000000 --- a/modules/core/src/test/java/org/gridgain/loadtests/offheap/GridOffHeapMapPerformanceAbstractTest.java +++ /dev/null @@ -1,290 +0,0 @@ -/* - * 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.gridgain.loadtests.offheap; - -import org.apache.ignite.internal.util.typedef.*; -import org.apache.ignite.internal.util.offheap.*; -import org.gridgain.testframework.junits.common.*; - -import java.util.*; - -/** - * Tests off-heap map. - */ -public abstract class GridOffHeapMapPerformanceAbstractTest extends GridCommonAbstractTest { - /** Random. */ - private static final Random RAND = new Random(); - - /** */ - protected static final int LOAD_CNT = 1024 * 1024; - - /** Sample map. */ - private static Map<String, T3<String, byte[], byte[]>> kvMap = - new HashMap<>(LOAD_CNT); - - /** Unsafe map. */ - private GridOffHeapMap<String> map; - - /** */ - protected float load = 0.75f; - - /** */ - protected int initCap = 1024 * 1024 * 1024; - - /** */ - protected int concurrency = 16; - - /** */ - protected short lruStripes = 16; - - /** */ - protected GridOffHeapEvictListener evictClo; - - /** */ - protected long mem = 12L * 1024L * 1024L * 1024L; - - /** */ - protected long dur = 60 * 1000;//2 * 60 * 60 * 1000; - - /** - * - */ - protected GridOffHeapMapPerformanceAbstractTest() { - super(false); - } - - /** {@inheritDoc} */ - @Override protected void beforeTest() throws Exception { - map = newMap(); - - if (kvMap.isEmpty()) - for (int i = 0; i < LOAD_CNT; i++) { - String k = string(); - String v = string(); - - kvMap.put(k, new T3<>(v, k.getBytes(), v.getBytes())); - } - } - - /** {@inheritDoc} */ - @Override protected void afterTest() throws Exception { - if (map != null) - map.destruct(); - } - - /** - * @return New map. - */ - protected abstract <K> GridOffHeapMap<K> newMap(); - - /** - * @param key Key. - * @return Hash. - */ - private int hash(Object key) { - return hash(key.hashCode()); - } - - /** - * @param h Hashcode. - * @return Hash. - */ - private int hash(int h) { - // Apply base step of MurmurHash; see http://code.google.com/p/smhasher/ - // Despite two multiplies, this is often faster than others - // with comparable bit-spread properties. - h ^= h >>> 16; - h *= 0x85ebca6b; - h ^= h >>> 13; - h *= 0xc2b2ae35; - - return (h >>> 16) ^ h; - } - - /** - * - * @return New Object. - */ - private String string() { - String key = ""; - - for (int i = 0; i < 3; i++) - key += RAND.nextLong(); - - return key; - } - - /** - * Test plain hash map. - */ - public void testHashMapPutRemove() { - Map<String, String> map = new HashMap<>(LOAD_CNT); - - info("Starting standard HashMap performance test..."); - - long cnt = 0; - - long start = System.currentTimeMillis(); - - boolean rmv = false; - - boolean done = false; - - while (!done) { - for (Map.Entry<String, T3<String, byte[], byte[]>> e : kvMap.entrySet()) { - String key = e.getKey(); - T3<String, byte[], byte[]> t = e.getValue(); - - try { - if (rmv) - map.remove(key); - else - map.put(key, t.get1()); - } - catch (GridOffHeapOutOfMemoryException ex) { - error("Map put failed for count: " + cnt, ex); - - throw ex; - } - - if (cnt > 0 && cnt % 10000000 == 0) { - long cur = System.currentTimeMillis(); - - long throughput = cnt * 1000 / (cur - start); - - X.println("Insert [cnt=" + cnt + ", ops/sec=" + throughput + ']'); - - if ((cur - start) > dur) { - done = true; - - break; - } - } - - cnt++; - } - - rmv = !rmv; - } - } - - /** - * - */ - public void testInsertRemoveLoad() { - info("Starting insert performance test..."); - - long cnt = 0; - - long start = System.currentTimeMillis(); - - boolean rmv = false; - - boolean done = false; - - while (!done) { - for (Map.Entry<String, T3<String, byte[], byte[]>> e : kvMap.entrySet()) { - String key = e.getKey(); - T3<String, byte[], byte[]> t = e.getValue(); - - try { - if (rmv) - map.remove(hash(key), t.get2()); - else - map.insert(hash(key), t.get2(), t.get3()); - } - catch (GridOffHeapOutOfMemoryException ex) { - error("Map put failed for count: " + cnt, ex); - - throw ex; - } - - if (cnt > 0 && cnt % 10000000 == 0) { - long cur = System.currentTimeMillis(); - - long throughput = cnt * 1000 / (cur - start); - - X.println("Insert [cnt=" + cnt + ", ops/sec=" + throughput + ']'); - - if ((cur - start) > dur) { - done = true; - - break; - } - } - - cnt++; - } - - rmv = !rmv; - } - } - - - /** - * - */ - public void testPutRemoveLoad() { - info("Starting put performance test..."); - - long cnt = 0; - - long start = System.currentTimeMillis(); - - boolean rmv = false; - - boolean done = false; - - while (!done) { - for (Map.Entry<String, T3<String, byte[], byte[]>> e : kvMap.entrySet()) { - String key = e.getKey(); - T3<String, byte[], byte[]> t = e.getValue(); - - try { - if (rmv) - map.remove(hash(key), t.get2()); - else - map.put(hash(key), t.get2(), t.get3()); - } - catch (GridOffHeapOutOfMemoryException ex) { - error("Map put failed for count: " + cnt, ex); - - throw ex; - } - - if (cnt > 0 && cnt % 10000000 == 0) { - long cur = System.currentTimeMillis(); - - long throughput = cnt * 1000 / (cur - start); - - X.println("Put [cnt=" + cnt + ", ops/sec=" + throughput + ']'); - - if ((cur - start) > dur) { - done = true; - - break; - } - } - - cnt++; - } - - rmv = cnt % 3 == 0; - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e1d8f69b/modules/core/src/test/java/org/gridgain/loadtests/offheap/GridOffHeapPartitionedMapPerformanceAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/loadtests/offheap/GridOffHeapPartitionedMapPerformanceAbstractTest.java b/modules/core/src/test/java/org/gridgain/loadtests/offheap/GridOffHeapPartitionedMapPerformanceAbstractTest.java deleted file mode 100644 index 38f8056..0000000 --- a/modules/core/src/test/java/org/gridgain/loadtests/offheap/GridOffHeapPartitionedMapPerformanceAbstractTest.java +++ /dev/null @@ -1,430 +0,0 @@ -/* - * 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.gridgain.loadtests.offheap; - -import org.apache.ignite.cache.affinity.*; -import org.apache.ignite.cache.affinity.consistenthash.*; -import org.apache.ignite.lang.*; -import org.apache.ignite.internal.util.typedef.*; -import org.apache.ignite.internal.util.typedef.internal.*; -import org.apache.ignite.internal.util.offheap.*; -import org.gridgain.testframework.junits.common.*; -import org.jdk8.backport.*; - -import java.util.*; -import java.util.concurrent.*; -import java.util.concurrent.atomic.*; - -/** - * Performance test for partitioned offheap hash map. - */ -@SuppressWarnings({"unchecked", "NonThreadSafeLazyInitialization"}) -public abstract class GridOffHeapPartitionedMapPerformanceAbstractTest extends GridCommonAbstractTest { - /** */ - protected static final int LOAD_CNT = 256; - - /** Sample keys. */ - private static T3<Integer, Integer, byte[]> keys[]; - - /** Wrapped keys. */ - private static GridByteArrayWrapper[] wrappers; - - /** Unsafe map. */ - private GridOffHeapPartitionedMap map; - - /** */ - protected float load = 0.75f; - - /** */ - protected int concurrency = 16; - - /** */ - protected short lruStripes = 16; - - /** */ - protected long mem = 2L * 1024L * 1024L * 1024L; - - /** */ - protected long dur = 120 * 1000; - - /** - * - */ - protected GridOffHeapPartitionedMapPerformanceAbstractTest() { - super(false); - } - - /** {@inheritDoc} */ - @Override protected void beforeTest() throws Exception { - map = newMap(); - - if (keys == null) { - keys = new T3[LOAD_CNT]; - wrappers = new GridByteArrayWrapper[LOAD_CNT]; - - GridCacheAffinityFunction aff = new GridCacheConsistentHashAffinityFunction(); - - Random rnd = new Random(); - - for (int i = 0; i < LOAD_CNT; i++) { - byte[] key = new byte[rnd.nextInt(511) + 1]; - - rnd.nextBytes(key); - - GridByteArrayWrapper wrap = new GridByteArrayWrapper(key); - - keys[i] = new T3<>(aff.partition(wrap), wrap.hashCode(), key); - wrappers[i] = wrap; - } - } - } - - /** {@inheritDoc} */ - @Override protected void afterTest() throws Exception { - if (map != null) - map.destruct(); - } - - /** - * @return New map. - */ - protected abstract GridOffHeapPartitionedMap newMap(); - - /** - * @throws Exception If failed. - */ - public void testPuts() throws Exception { - info("Warming up..."); - - checkPuts(1, 20000); - - info("Warm up finished."); - - checkPuts(Runtime.getRuntime().availableProcessors(), dur); - } - - /** - * @throws Exception If failed. - */ - public void testPutsConcurrentMap() throws Exception { - info("Warming up..."); - - checkPutsConcurrentMap(1, 20000); - - info("Warm up finished."); - - checkPutsConcurrentMap(Runtime.getRuntime().availableProcessors(), dur); - } - - /** - * @throws Exception If failed. - */ - public void testPutRemoves() throws Exception { - info("Warming up..."); - - checkPutRemoves(2, 20000); - - info("Warm up finished."); - - checkPutRemoves(Runtime.getRuntime().availableProcessors(), dur); - } - - /** - * @throws Exception If failed. - */ - public void testPutRemovesConcurrentMap() throws Exception { - info("Warming up..."); - - checkPutRemovesConcurrentMap(2, 20000); - - info("Warm up finished."); - - checkPutRemovesConcurrentMap(Runtime.getRuntime().availableProcessors(), dur); - } - - /** - * @throws Exception If failed. - */ - private void checkPuts(int threadCnt, long duration) throws Exception { - final AtomicLong opCnt = new AtomicLong(); - final AtomicLong totalOpCnt = new AtomicLong(); - - final AtomicBoolean done = new AtomicBoolean(); - - long start = System.currentTimeMillis(); - - IgniteFuture<?> fut = multithreadedAsync(new Callable<Object>() { - @Override public Object call() throws Exception { - Random rnd = new Random(); - - byte[] val = new byte[1024]; - - long locTotalOpCnt = 0; - - while (!done.get()) { - for (int i = 0; i < 500; i++) { - T3<Integer, Integer, byte[]> key = randomKey(rnd); - - map.put(key.get1(), key.get2(), key.get3(), val); - } - - locTotalOpCnt += 500; - opCnt.addAndGet(500); - } - - totalOpCnt.addAndGet(locTotalOpCnt); - - return null; - } - }, threadCnt); - - final int step = 2000; - - while (System.currentTimeMillis() - start < duration) { - U.sleep(step); - - long ops = opCnt.getAndSet(0); - - info("Putting " + (ops * 1000) / step + " ops/sec"); - } - - done.set(true); - - fut.get(); - - long end = System.currentTimeMillis(); - - info("Average put performance: " + (totalOpCnt.get() * 1000) / (end - start) + " ops/sec"); - } - - /** - * @throws Exception If failed. - */ - private void checkPutRemoves(int threadCnt, long duration) throws Exception { - final AtomicLong opCnt = new AtomicLong(); - final AtomicLong totalOpCnt = new AtomicLong(); - - final AtomicBoolean done = new AtomicBoolean(); - - long start = System.currentTimeMillis(); - - IgniteFuture<?> fut = multithreadedAsync(new Callable<Object>() { - @Override public Object call() throws Exception { - Random rnd = new Random(); - - byte[] val = new byte[1024]; - - long locTotalOpCnt = 0; - - while (!done.get()) { - for (int i = 0; i < 500; i++) { - T3<Integer, Integer, byte[]> key = randomKey(rnd); - - int op = rnd.nextInt(2); - - switch (op) { - case 0: - map.put(key.get1(), key.get2(), key.get3(), val); - - break; - - case 1: - map.remove(key.get1(), key.get2(), key.get3()); - - break; - - default: - assert false; - } - } - - locTotalOpCnt += 500; - opCnt.addAndGet(500); - } - - totalOpCnt.addAndGet(locTotalOpCnt); - - return null; - } - }, threadCnt); - - final int step = 2000; - - while (System.currentTimeMillis() - start < duration) { - U.sleep(step); - - long ops = opCnt.getAndSet(0); - - info("Putting " + (ops * 1000) / step + " ops/sec"); - } - - done.set(true); - - fut.get(); - - long end = System.currentTimeMillis(); - - info("Average random operation performance: " + (totalOpCnt.get() * 1000) / (end - start) + " ops/sec"); - } - /** - * @throws Exception If failed. - */ - private void checkPutsConcurrentMap(int threadCnt, long duration) throws Exception { - final Map<GridByteArrayWrapper, byte[]> map = new ConcurrentHashMap8<>(); - - final AtomicLong opCnt = new AtomicLong(); - final AtomicLong totalOpCnt = new AtomicLong(); - - final AtomicBoolean done = new AtomicBoolean(); - - long start = System.currentTimeMillis(); - - IgniteFuture<?> fut = multithreadedAsync(new Callable<Object>() { - @Override public Object call() throws Exception { - Random rnd = new Random(); - - long locTotalOpCnt = 0; - - while (!done.get()) { - for (int i = 0; i < 500; i++) { - GridByteArrayWrapper key = randomKeyWrapper(rnd); - - map.put(key, new byte[1024]); - } - - locTotalOpCnt += 500; - opCnt.addAndGet(500); - } - - totalOpCnt.addAndGet(locTotalOpCnt); - - return null; - } - }, threadCnt); - - final int step = 2000; - - while (System.currentTimeMillis() - start < duration) { - U.sleep(step); - - long ops = opCnt.getAndSet(0); - - info("Putting " + (ops * 1000) / step + " ops/sec"); - } - - done.set(true); - - fut.get(); - - long end = System.currentTimeMillis(); - - info("Average put performance: " + (totalOpCnt.get() * 1000) / (end - start) + " ops/sec"); - } - - /** - * @throws Exception If failed. - */ - private void checkPutRemovesConcurrentMap(int threadCnt, long duration) throws Exception { - final Map<GridByteArrayWrapper, byte[]> map = new ConcurrentHashMap8<>(); - - final AtomicLong opCnt = new AtomicLong(); - final AtomicLong totalOpCnt = new AtomicLong(); - - final AtomicBoolean done = new AtomicBoolean(); - - long start = System.currentTimeMillis(); - - IgniteFuture<?> fut = multithreadedAsync(new Callable<Object>() { - @Override public Object call() throws Exception { - Random rnd = new Random(); - - byte[] val = new byte[1024]; - - long locTotalOpCnt = 0; - - while (!done.get()) { - for (int i = 0; i < 500; i++) { - GridByteArrayWrapper key = randomKeyWrapper(rnd); - - int op = rnd.nextInt(2); - - switch (op) { - case 0: - map.put(key, val); - - break; - - case 1: - map.remove(key); - - break; - - default: - assert false; - } - } - - locTotalOpCnt += 500; - opCnt.addAndGet(500); - } - - totalOpCnt.addAndGet(locTotalOpCnt); - - return null; - } - }, threadCnt); - - final int step = 2000; - - while (System.currentTimeMillis() - start < duration) { - U.sleep(step); - - long ops = opCnt.getAndSet(0); - - info("Putting " + (ops * 1000) / step + " ops/sec"); - } - - done.set(true); - - fut.get(); - - long end = System.currentTimeMillis(); - - info("Average random operation performance: " + (totalOpCnt.get() * 1000) / (end - start) + " ops/sec"); - } - - /** - * Gets random key from pregenerated array. - * - * @param rnd Random to use. - * @return Tuple with key. - */ - private T3<Integer, Integer, byte[]> randomKey(Random rnd) { - return keys[rnd.nextInt(keys.length)]; - } - - /** - * Gets random key from pregenerated array. - * - * @param rnd Random to use. - * @return Tuple with key. - */ - private GridByteArrayWrapper randomKeyWrapper(Random rnd) { - return wrappers[rnd.nextInt(keys.length)]; - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e1d8f69b/modules/core/src/test/java/org/gridgain/loadtests/offheap/unsafe/GridUnsafeMapPerformanceTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/loadtests/offheap/unsafe/GridUnsafeMapPerformanceTest.java b/modules/core/src/test/java/org/gridgain/loadtests/offheap/unsafe/GridUnsafeMapPerformanceTest.java deleted file mode 100644 index a08c2a5..0000000 --- a/modules/core/src/test/java/org/gridgain/loadtests/offheap/unsafe/GridUnsafeMapPerformanceTest.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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.gridgain.loadtests.offheap.unsafe; - -import org.apache.ignite.internal.util.offheap.*; - -/** - * Unsafe map test. - */ -public class GridUnsafeMapPerformanceTest extends GridOffHeapMapPerformanceAbstractTest { - /** {@inheritDoc} */ - @Override protected <K> GridOffHeapMap<K> newMap() { - return GridOffHeapMapFactory.unsafeMap(concurrency, load, initCap, mem, lruStripes, evictClo); - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e1d8f69b/modules/core/src/test/java/org/gridgain/loadtests/offheap/unsafe/GridUnsafePartitionedMapPerformanceTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/loadtests/offheap/unsafe/GridUnsafePartitionedMapPerformanceTest.java b/modules/core/src/test/java/org/gridgain/loadtests/offheap/unsafe/GridUnsafePartitionedMapPerformanceTest.java deleted file mode 100644 index 0cad587..0000000 --- a/modules/core/src/test/java/org/gridgain/loadtests/offheap/unsafe/GridUnsafePartitionedMapPerformanceTest.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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.gridgain.loadtests.offheap.unsafe; - -import org.apache.ignite.cache.affinity.consistenthash.*; -import org.apache.ignite.internal.util.offheap.*; - -/** - * Unsafe partitioned map performance test. - */ -public class GridUnsafePartitionedMapPerformanceTest extends GridOffHeapPartitionedMapPerformanceAbstractTest { - /** {@inheritDoc} */ - @Override protected GridOffHeapPartitionedMap newMap() { - return GridOffHeapMapFactory.unsafePartitionedMap(GridCacheConsistentHashAffinityFunction.DFLT_PARTITION_COUNT, - Runtime.getRuntime().availableProcessors(), load, LOAD_CNT, mem, lruStripes, null); - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e1d8f69b/modules/core/src/test/java/org/gridgain/loadtests/streamer/EventClosure.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/loadtests/streamer/EventClosure.java b/modules/core/src/test/java/org/gridgain/loadtests/streamer/EventClosure.java deleted file mode 100644 index 65c2309..0000000 --- a/modules/core/src/test/java/org/gridgain/loadtests/streamer/EventClosure.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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.gridgain.loadtests.streamer; - -import org.apache.ignite.*; -import org.apache.ignite.lang.*; -import org.apache.ignite.internal.util.typedef.*; - -import java.util.*; - -/** - * Closure for events generation. - */ -class EventClosure implements IgniteInClosure<IgniteStreamer> { - /** Random range. */ - private int rndRange = 100; - - /** {@inheritDoc} */ - @Override public void apply(IgniteStreamer streamer) { - Random rnd = new Random(); - - while (!Thread.interrupted()) { - try { - streamer.addEvent(rnd.nextInt(rndRange)); - } - catch (IgniteCheckedException e) { - X.println("Failed to add streamer event: " + e); - } - } - } - - /** - * @return Random range. - */ - public int getRandomRange() { - return rndRange; - } - - /** - * @param rndRange Random range. - */ - public void setRandomRange(int rndRange) { - this.rndRange = rndRange; - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e1d8f69b/modules/core/src/test/java/org/gridgain/loadtests/streamer/GridStreamerBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/loadtests/streamer/GridStreamerBenchmark.java b/modules/core/src/test/java/org/gridgain/loadtests/streamer/GridStreamerBenchmark.java deleted file mode 100644 index 30f1b21..0000000 --- a/modules/core/src/test/java/org/gridgain/loadtests/streamer/GridStreamerBenchmark.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * 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.gridgain.loadtests.streamer; - -import org.apache.ignite.*; -import org.apache.ignite.lang.*; -import org.apache.ignite.internal.util.typedef.*; -import org.apache.ignite.internal.util.typedef.internal.*; -import org.springframework.beans.factory.xml.*; -import org.springframework.context.support.*; -import org.springframework.core.io.*; - -import java.io.*; -import java.net.*; -import java.util.*; - -/** - * Streamer benchmark. - */ -public class GridStreamerBenchmark { - - /** - * Entry point. Expects configuration URL to be provided. - * - * @param args Arguments. First argument is grid configuration. Second optional argument "-w" - stands for - * "worker", in this case no load will be generated on the node. - * @throws Exception In case of any error. - */ - public static void main(String[] args) throws Exception{ - if (args.length == 0) - throw new IllegalArgumentException("Configuration path is not provided."); - - String cfgPath = args.length > 0 ? args[0] : - "modules/core/src/test/config/streamer/average/spring-streamer-average-local.xml"; - - boolean worker = args.length > 1 && "-w".equalsIgnoreCase(args[1]); - - // Get load definitions. - Collection<GridStreamerLoad> loads = worker ? null : loads(cfgPath); - - // Start the grid. - Ignite ignite = G.start(cfgPath); - - // Start load threads. - Collection<Thread> loadThreads = new HashSet<>(); - - if (loads != null && !loads.isEmpty()) { - for (GridStreamerLoad load : loads) { - final IgniteStreamer streamer = ignite.streamer(load.getName()); - - if (streamer == null) - throw new Exception("Steamer is not found: " + load.getName()); - - List<IgniteInClosure<IgniteStreamer>> clos = load.getClosures(); - - if (clos != null && !clos.isEmpty()) { - for (final IgniteInClosure<IgniteStreamer> clo : clos) { - Thread t = new Thread(new Runnable() { - @Override public void run() { - try { - clo.apply(streamer); - } - catch (Exception e) { - X.println("Exception during execution of closure for streamer " + - "[streamer=" + streamer.name() + ", closure=" + clo + ", err=" + - e.getMessage() + ']'); - - e.printStackTrace(); - } - } - }); - - loadThreads.add(t); - - t.start(); - } - } - } - } - - // Once all loads are started, simply join them. - System.out.println("Press enter to stop running benchmark."); - - try (BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) { - in.readLine(); - } - - for (Thread t : loadThreads) - t.interrupt(); - - for (Thread t : loadThreads) - t.join(); - } - - /** - * Get loads from the Spring context. - * - * @param cfgPath Configuration path. - * @return Collection of loads, if any. - * @throws Exception If failed. - */ - private static Collection<GridStreamerLoad> loads(String cfgPath) throws Exception { - URL cfgUrl; - - try { - cfgUrl = new URL(cfgPath); - } - catch (MalformedURLException ignore) { - cfgUrl = U.resolveGridGainUrl(cfgPath); - } - - if (cfgUrl == null) - throw new Exception("Spring XML configuration path is invalid: " + cfgPath); - - GenericApplicationContext springCtx = new GenericApplicationContext(); - - new XmlBeanDefinitionReader(springCtx).loadBeanDefinitions(new UrlResource(cfgUrl)); - - springCtx.refresh(); - - Map<String, GridStreamerLoad> cfgMap = springCtx.getBeansOfType(GridStreamerLoad.class); - - return cfgMap.values(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e1d8f69b/modules/core/src/test/java/org/gridgain/loadtests/streamer/GridStreamerIndexLoadTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/loadtests/streamer/GridStreamerIndexLoadTest.java b/modules/core/src/test/java/org/gridgain/loadtests/streamer/GridStreamerIndexLoadTest.java deleted file mode 100644 index 11b7385..0000000 --- a/modules/core/src/test/java/org/gridgain/loadtests/streamer/GridStreamerIndexLoadTest.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * 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.gridgain.loadtests.streamer; - -import org.apache.ignite.*; -import org.apache.ignite.lang.*; -import org.apache.ignite.streamer.index.*; -import org.apache.ignite.streamer.index.hash.*; -import org.apache.ignite.streamer.index.tree.*; -import org.apache.ignite.streamer.window.*; -import org.apache.ignite.internal.util.typedef.*; -import org.apache.ignite.internal.util.typedef.internal.*; - -import java.util.*; -import java.util.concurrent.atomic.*; - -import static org.gridgain.loadtests.util.GridLoadTestArgs.*; -import static org.gridgain.testframework.GridTestUtils.*; - -/** - * Load test for streamer index. - */ -public class GridStreamerIndexLoadTest { - /** - * Window index configuration. - */ - private enum IndexConfiguration { - /** - * Tree index with non-unique elements and no event tracking. - */ - TREE_INDEX_NOT_UNIQUE { - /** {@inheritDoc} */ - @Override - StreamerIndexProvider<Integer, Integer, Long> indexProvider() { - StreamerTreeIndexProvider<Integer, Integer, Long> idx = new StreamerTreeIndexProvider<>(); - - idx.setUpdater(new IndexUpdater()); - idx.setUnique(false); - idx.setPolicy(StreamerIndexPolicy.EVENT_TRACKING_OFF); - - return idx; - } - }, - - /** - * Hash index with non-unique elements and no event tracking. - */ - HASH_INDEX_NOT_UNIQUE { - /** {@inheritDoc} */ - @Override - StreamerIndexProvider<Integer, Integer, Long> indexProvider() { - StreamerHashIndexProvider<Integer, Integer, Long> idx = new StreamerHashIndexProvider<>(); - - idx.setUpdater(new IndexUpdater()); - idx.setUnique(false); - idx.setPolicy(StreamerIndexPolicy.EVENT_TRACKING_OFF); - - return idx; - } - }; - - /** - * @return Index provider for this index configuration. - */ - abstract StreamerIndexProvider<Integer, Integer, Long> indexProvider(); - } - - /** - * @param args Command line arguments. - * @throws Exception If error occurs. - */ - public static void main(String[] args) throws Exception { - for (IndexConfiguration idxCfg : EnumSet.allOf(IndexConfiguration.class)) { - X.println(">>> Running benchmark for configuration: " + idxCfg); - - runBenchmark(idxCfg); - } - } - - /** - * Runs the benchmark for the specified index configuration. - * - * @param idxCfg Index configuration. - * @throws Exception If error occurs. - */ - public static void runBenchmark(IndexConfiguration idxCfg) throws Exception { - int thrCnt = getIntProperty(THREADS_CNT, 1); - int dur = getIntProperty(TEST_DUR_SEC, 60); - int winSize = getIntProperty("GG_WIN_SIZE", 5000); - - dumpProperties(System.out); - - final StreamerBoundedSizeWindow<Integer> win = new StreamerBoundedSizeWindow<>(); - - win.setMaximumSize(winSize); - win.setIndexes(idxCfg.indexProvider()); - - win.start(); - - final AtomicLong enqueueCntr = new AtomicLong(); - - IgniteFuture<Long> enqueueFut = runMultiThreadedAsync(new CAX() { - @Override public void applyx() throws IgniteCheckedException { - Random rnd = new Random(); - - while (!Thread.currentThread().isInterrupted()) { - win.enqueue(rnd.nextInt()); - - enqueueCntr.incrementAndGet(); - } - } - }, thrCnt, "generator"); - - final AtomicLong evictCntr = new AtomicLong(); - - IgniteFuture<Long> evictFut = runMultiThreadedAsync(new CAX() { - @Override public void applyx() throws IgniteCheckedException { - while (!Thread.currentThread().isInterrupted()) { - win.pollEvicted(); - - evictCntr.incrementAndGet(); - } - } - }, thrCnt, "evictor"); - - IgniteFuture<Long> collFut = runMultiThreadedAsync(new CAX() { - @Override public void applyx() { - int nSec = 0; - long prevEnqueue = enqueueCntr.get(); - long prevEvict = evictCntr.get(); - - try { - while (!Thread.currentThread().isInterrupted()) { - U.sleep(1000); - nSec++; - - long curEnqueue = enqueueCntr.get(); - long curEvict = evictCntr.get(); - - X.println("Stats [enqueuePerSec=" + (curEnqueue - prevEnqueue) + - ", evictPerSec=" + (curEvict - prevEvict) + ']'); - - prevEnqueue = curEnqueue; - prevEvict = curEvict; - } - } - catch (IgniteInterruptedException ignored) { - // No-op. - } - - X.println("Final results [enqueuePerSec=" + (enqueueCntr.get() / nSec) + - ", evictPerSec=" + (evictCntr.get() / nSec) + ']'); - } - }, 1, "collector"); - - U.sleep(dur * 1000); - - X.println("Finishing test."); - - collFut.cancel(); - enqueueFut.cancel(); - evictFut.cancel(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e1d8f69b/modules/core/src/test/java/org/gridgain/loadtests/streamer/GridStreamerLoad.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/loadtests/streamer/GridStreamerLoad.java b/modules/core/src/test/java/org/gridgain/loadtests/streamer/GridStreamerLoad.java deleted file mode 100644 index 3bdd63d..0000000 --- a/modules/core/src/test/java/org/gridgain/loadtests/streamer/GridStreamerLoad.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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.gridgain.loadtests.streamer; - -import org.apache.ignite.*; -import org.apache.ignite.lang.*; - -import java.util.*; - -/** - * Configurable streamer load. - */ -public class GridStreamerLoad { - /** Steamer name. */ - private String name; - - /** Load closures. */ - private List<IgniteInClosure<IgniteStreamer>> clos; - - /** - * @return Steamer name. - */ - public String getName() { - return name; - } - - /** - * @param name Steamer name. - */ - public void setName(String name) { - this.name = name; - } - - /** - * @return Query closure. - */ - public List<IgniteInClosure<IgniteStreamer>> getClosures() { - return clos; - } - - /** - * @param clos Query closure. - */ - public void setClosures(List<IgniteInClosure<IgniteStreamer>> clos) { - this.clos = clos; - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e1d8f69b/modules/core/src/test/java/org/gridgain/loadtests/streamer/IndexUpdater.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/loadtests/streamer/IndexUpdater.java b/modules/core/src/test/java/org/gridgain/loadtests/streamer/IndexUpdater.java deleted file mode 100644 index d01e904..0000000 --- a/modules/core/src/test/java/org/gridgain/loadtests/streamer/IndexUpdater.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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.gridgain.loadtests.streamer; - -import org.apache.ignite.streamer.index.*; -import org.jetbrains.annotations.*; - -/** - * Streamer benchmark window index updater. - */ -class IndexUpdater implements StreamerIndexUpdater<Integer, Integer, Long> { - /** {@inheritDoc} */ - @Override public Integer indexKey(Integer evt) { - return evt; - } - - /** {@inheritDoc} */ - @Nullable @Override public Long onAdded(StreamerIndexEntry<Integer, Integer, Long> entry, Integer evt) { - return entry.value() + 1; - } - - /** {@inheritDoc} */ - @Nullable @Override public Long onRemoved(StreamerIndexEntry<Integer, Integer, Long> entry, Integer evt) { - return entry.value() - 1 == 0 ? null : entry.value() - 1; - } - - /** {@inheritDoc} */ - @Override public Long initialValue(Integer evt, Integer key) { - return 1L; - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e1d8f69b/modules/core/src/test/java/org/gridgain/loadtests/streamer/QueryClosure.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/loadtests/streamer/QueryClosure.java b/modules/core/src/test/java/org/gridgain/loadtests/streamer/QueryClosure.java deleted file mode 100644 index 69c2169..0000000 --- a/modules/core/src/test/java/org/gridgain/loadtests/streamer/QueryClosure.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * 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.gridgain.loadtests.streamer; - -import org.apache.ignite.*; -import org.apache.ignite.lang.*; -import org.apache.ignite.internal.util.typedef.*; -import org.apache.ignite.internal.util.typedef.internal.*; - -/** - * Closure for events generation. - */ -class QueryClosure implements IgniteInClosure<IgniteStreamer> { - /** Sleep period (seconds). */ - private static final int SLEEP_PERIOD_SEC = 3; - - /** Random range. */ - private int rndRange = 100; - - /** Warmup time. */ - private long warmup = 60000; - - /** {@inheritDoc} */ - @Override public void apply(IgniteStreamer streamer) { - X.println("Pefromrming warmup: " + warmup + "ms..."); - - try { - U.sleep(warmup); - } - catch (IgniteInterruptedException ignore) { - return; - } - - long initTime = System.currentTimeMillis(); - long initExecs = streamer.metrics().stageTotalExecutionCount(); - - long prevExecs = initExecs; - - while (!Thread.interrupted()) { - try { - U.sleep(SLEEP_PERIOD_SEC * 1000); - } - catch (IgniteInterruptedException ignore) { - return; - } - - long curTime = System.currentTimeMillis(); - long curExecs = streamer.metrics().stageTotalExecutionCount(); - - long deltaExecs = curExecs - prevExecs; - long deltaThroughput = deltaExecs/SLEEP_PERIOD_SEC; - - long totalTimeSec = (curTime - initTime) / 1000; - long totalExecs = curExecs - initExecs; - long totalThroughput = totalExecs/totalTimeSec; - - X.println("Measurement: [throughput=" + deltaThroughput + " execs/sec, totalThroughput=" + - totalThroughput + " execs/sec]"); - - prevExecs = curExecs; - } - } - - /** - * @return Random range. - */ - public int getRandomRange() { - return rndRange; - } - - /** - * @param rndRange Random range. - */ - public void setRandomRange(int rndRange) { - this.rndRange = rndRange; - } - - /** - * @return Warmup time (milliseconds) - */ - public long getWarmup() { - return warmup; - } - - /** - * @param warmup Warmup time (milliseconds) - */ - public void setWarmup(long warmup) { - this.warmup = warmup; - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e1d8f69b/modules/core/src/test/java/org/gridgain/loadtests/streamer/average/TestAverage.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/loadtests/streamer/average/TestAverage.java b/modules/core/src/test/java/org/gridgain/loadtests/streamer/average/TestAverage.java deleted file mode 100644 index bfce365..0000000 --- a/modules/core/src/test/java/org/gridgain/loadtests/streamer/average/TestAverage.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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.gridgain.loadtests.streamer.average; - -/** - * Average helper class. - */ -class TestAverage { - /** */ - private int total; - - /** */ - private int cnt; - - /** - * @param avg Average. - */ - @SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter") - public void increment(TestAverage avg) { - int total; - int cnt; - - synchronized (avg) { - total = avg.total; - cnt = avg.cnt; - } - - increment(total, cnt); - } - - /** - * @param total Increment total. - * @param cnt Increment count. - */ - public synchronized void increment(int total, int cnt) { - this.total += total; - this.cnt += cnt; - } - - /** - * @param total Total. - * @param cnt Count. - */ - public synchronized void set(int total, int cnt) { - this.total = total; - this.cnt = cnt; - } - - /** - * @return Running average. - */ - public synchronized double average() { - return (double)total / cnt; - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e1d8f69b/modules/core/src/test/java/org/gridgain/loadtests/streamer/average/TestStage.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/loadtests/streamer/average/TestStage.java b/modules/core/src/test/java/org/gridgain/loadtests/streamer/average/TestStage.java deleted file mode 100644 index 204e879..0000000 --- a/modules/core/src/test/java/org/gridgain/loadtests/streamer/average/TestStage.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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.gridgain.loadtests.streamer.average; - -import org.apache.ignite.*; -import org.apache.ignite.streamer.*; -import org.apache.ignite.internal.util.typedef.*; - -import java.util.*; -import java.util.concurrent.*; - -/** - * Stage for average benchmark. - */ -class TestStage implements StreamerStage<Integer> { - /** {@inheritDoc} */ - @Override public String name() { - return "stage"; - } - - /** {@inheritDoc} */ - @Override public Map<String, Collection<?>> run(StreamerContext ctx, Collection<Integer> evts) - throws IgniteCheckedException { - ConcurrentMap<String, TestAverage> loc = ctx.localSpace(); - - TestAverage avg = loc.get("avg"); - - if (avg == null) - avg = F.addIfAbsent(loc, "avg", new TestAverage()); - - for (Integer e : evts) - avg.increment(e, 1); - - StreamerWindow<Integer> win = ctx.window(); - - win.enqueueAll(evts); - - while (true) { - Integer e = win.pollEvicted(); - - if (e == null) - break; - - // Subtract evicted events from running total. - avg.increment(-e, -1); - } - - return null; - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e1d8f69b/modules/core/src/test/java/org/gridgain/loadtests/swap/GridSwapEvictAllBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/loadtests/swap/GridSwapEvictAllBenchmark.java b/modules/core/src/test/java/org/gridgain/loadtests/swap/GridSwapEvictAllBenchmark.java deleted file mode 100644 index 225298b..0000000 --- a/modules/core/src/test/java/org/gridgain/loadtests/swap/GridSwapEvictAllBenchmark.java +++ /dev/null @@ -1,299 +0,0 @@ -/* - * 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.gridgain.loadtests.swap; - -import org.apache.ignite.*; -import org.apache.ignite.cache.*; -import org.apache.ignite.cache.eviction.fifo.*; -import org.apache.ignite.cache.store.*; -import org.apache.ignite.configuration.*; -import org.apache.ignite.lang.*; -import org.apache.ignite.spi.discovery.tcp.*; -import org.apache.ignite.spi.discovery.tcp.ipfinder.*; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*; -import org.apache.ignite.spi.swapspace.file.*; -import org.apache.ignite.internal.util.typedef.*; -import org.gridgain.loadtests.util.*; -import org.gridgain.testframework.*; -import org.jetbrains.annotations.*; - -import javax.cache.*; -import javax.cache.configuration.*; -import java.util.*; -import java.util.concurrent.atomic.*; - -/** - * Swap benchmark. - */ -@SuppressWarnings("BusyWait") -public class GridSwapEvictAllBenchmark { - /** Eviction policy size. */ - public static final int EVICT_PLC_SIZE = 3200000; - - /** Keys count. */ - public static final int KEYS_CNT = 3000000; - - /** Batch size. */ - private static final int BATCH_SIZE = 200; - - /** - * @param args Parameters. - * @throws Exception If failed. - */ - public static void main(String ... args) throws Exception { - GridFileLock fileLock = GridLoadTestUtils.fileLock(); - - fileLock.lock(); - - try { - String outputFileName = args.length > 0 ? args[0] : null; - - Ignite g = start(new CacheStoreAdapter<Long, String>() { - @Nullable @Override public String load(Long key) { - return null; - } - - @Override public void loadCache(final IgniteBiInClosure<Long, String> c, - @Nullable Object... args) { - for (int i = 0; i < KEYS_CNT; i++) - c.apply((long)i, String.valueOf(i)); - } - - @Override public void write(Cache.Entry<? extends Long, ? extends String> e) { - assert false; - } - - @Override public void delete(Object key) { - assert false; - } - }); - - try { - GridCache<Object, Object> cache = g.cache(null); - - assert cache != null; - - cache.loadCache(null, 0); - - X.println("Finished load cache."); - - // Warm-up. - runBenchmark(BATCH_SIZE, BATCH_SIZE, null); - - // Run. - runBenchmark(KEYS_CNT, BATCH_SIZE, outputFileName); - - assert g.configuration().getSwapSpaceSpi().count(null) == 0; - } - finally { - G.stopAll(false); - } - } - finally { - fileLock.close(); - } - } - - /** - * @param keysCnt Number of keys to swap and promote. - * @param batchSize Size of batch to swap/promote. - * @param outputFileName Output file name. - * @throws Exception If failed. - */ - private static void runBenchmark(final int keysCnt, int batchSize, @Nullable String outputFileName) - throws Exception { - assert keysCnt % batchSize == 0; - - final AtomicInteger evictedKeysCnt = new AtomicInteger(); - - final GridCumulativeAverage evictAvg = new GridCumulativeAverage(); - - Thread evictCollector = GridLoadTestUtils.startDaemon(new Runnable() { - @Override public void run() { - int curCnt = evictedKeysCnt.get(); - - try { - while (!Thread.currentThread().isInterrupted()) { - Thread.sleep(1000); - - int newCnt = evictedKeysCnt.get(); - - int entPerSec = newCnt - curCnt; - - X.println(">>> Evicting " + entPerSec + " entries/second"); - - evictAvg.update(entPerSec); - - curCnt = newCnt; - } - } - catch (InterruptedException ignored) { - Thread.currentThread().interrupt(); - } - finally { - X.println(">>> Average eviction speed: " + evictAvg + " entries/second"); - } - } - }); - - long start = System.currentTimeMillis(); - - GridCache<Object, Object> cache = G.ignite().cache(null); - - assert cache != null; - - Collection<Long> keys = new ArrayList<>(batchSize); - - for (long i = 0; i < keysCnt; i++) { - keys.add(i); - - if (keys.size() == batchSize) { - cache.evictAll(keys); - - evictedKeysCnt.addAndGet(batchSize); - - keys.clear(); - } - } - - assert keys.isEmpty(); - - long end = System.currentTimeMillis(); - - X.println("Done evicting in " + (end - start) + "ms"); - - evictCollector.interrupt(); - - final AtomicInteger unswappedKeys = new AtomicInteger(); - - final GridCumulativeAverage unswapAvg = new GridCumulativeAverage(); - - Thread unswapCollector = GridLoadTestUtils.startDaemon(new Runnable() { - @Override public void run() { - int curCnt = unswappedKeys.get(); - - try { - while (!Thread.currentThread().isInterrupted()) { - Thread.sleep(1000); - - int newCnt = unswappedKeys.get(); - - int entPerSec = newCnt - curCnt; - - X.println(">>> Unswapping " + entPerSec + " entries/second"); - - unswapAvg.update(entPerSec); - - curCnt = newCnt; - } - } - catch (InterruptedException ignored) { - Thread.currentThread().interrupt(); - } - finally { - X.println(">>> Average unswapping speed: " + unswapAvg + " entries/second"); - } - } - }); - - start = System.currentTimeMillis(); - - for (long i = 0; i < keysCnt; i++) { - keys.add(i); - - if (keys.size() == batchSize) { - cache.promoteAll(keys); - - unswappedKeys.addAndGet(batchSize); - - keys.clear(); - } - } - - assert keys.isEmpty(); - - end = System.currentTimeMillis(); - - X.println("Done promote in " + (end - start) + "ms"); - - unswapCollector.interrupt(); - - if (outputFileName != null) - GridLoadTestUtils.appendLineToFile( - outputFileName, - "%s,%d,%d", - GridLoadTestUtils.DATE_TIME_FORMAT.format(new Date()), - evictAvg.get(), - unswapAvg.get() - ); - } - - /** - * @param store Cache store. - * @return Started grid. - * @throws IgniteCheckedException If failed. - */ - @SuppressWarnings("unchecked") - private static Ignite start(CacheStore<Long, String> store) throws IgniteCheckedException { - IgniteConfiguration cfg = new IgniteConfiguration(); - - cfg.setLocalHost("127.0.0.1"); - - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - TcpDiscoveryIpFinder finder = new TcpDiscoveryVmIpFinder(true); - - disco.setIpFinder(finder); - - cfg.setDiscoverySpi(disco); - - CacheConfiguration ccfg = new CacheConfiguration(); - - ccfg.setSwapEnabled(true); - ccfg.setEvictSynchronized(false); - ccfg.setEvictionPolicy(new GridCacheFifoEvictionPolicy(EVICT_PLC_SIZE)); - - if (store != null) { - ccfg.setCacheStoreFactory(new FactoryBuilder.SingletonFactory(store)); - ccfg.setReadThrough(true); - ccfg.setWriteThrough(true); - ccfg.setLoadPreviousValue(true); - } - - FileSwapSpaceSpi swap = new FileSwapSpaceSpi(); - -// swap.setConcurrencyLevel(16); -// swap.setWriterThreadsCount(16); - -// swap.setLevelDbCacheSize(128 * 1024 * 1024); -// swap.setLevelDbWriteBufferSize(128 * 1024 * 1024); -// swap.setLevelDbBlockSize(1024 * 1024); -// swap.setLevelDbParanoidChecks(false); -// swap.setLevelDbVerifyChecksums(false); - - cfg.setSwapSpaceSpi(swap); - - ccfg.setCacheMode(GridCacheMode.LOCAL); - ccfg.setQueryIndexEnabled(false); - - cfg.setCacheConfiguration(ccfg); - - return G.start(cfg); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e1d8f69b/modules/core/src/test/java/org/gridgain/loadtests/util/GridCumulativeAverage.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/loadtests/util/GridCumulativeAverage.java b/modules/core/src/test/java/org/gridgain/loadtests/util/GridCumulativeAverage.java deleted file mode 100644 index ac98804..0000000 --- a/modules/core/src/test/java/org/gridgain/loadtests/util/GridCumulativeAverage.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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.gridgain.loadtests.util; - -/** - * Counts the cumulative average as new data arrives. - */ -public class GridCumulativeAverage { - /** Iteration number. */ - private int i; - - /** Current value. */ - private long cur; - - /** - * Updates the current average and the counter, taking into account - * the next coming value. - * - * @param nextVal The next value to recalculate the average with. - */ - public void update(long nextVal) { - cur = (nextVal + i * cur) / (i + 1); - - i++; - } - - /** - * @return The current average value. - */ - public long get() { - return cur; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return Long.toString(cur); - } - - /** {@inheritDoc} */ - @Override public int hashCode() { - return Long.valueOf(cur).hashCode(); - } - - /** {@inheritDoc} */ - @Override public boolean equals(Object obj) { - return Long.valueOf(cur).equals(obj); - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e1d8f69b/modules/core/src/test/java/org/gridgain/loadtests/util/GridLoadTestArgs.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/gridgain/loadtests/util/GridLoadTestArgs.java b/modules/core/src/test/java/org/gridgain/loadtests/util/GridLoadTestArgs.java deleted file mode 100644 index c55abbc..0000000 --- a/modules/core/src/test/java/org/gridgain/loadtests/util/GridLoadTestArgs.java +++ /dev/null @@ -1,283 +0,0 @@ -/* - * 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.gridgain.loadtests.util; - -import org.apache.ignite.*; -import org.apache.ignite.lang.*; -import org.jetbrains.annotations.*; - -import java.io.*; -import java.util.*; - -/** - * Contains constants and methods for working with - * command line arguments, JVM properties and environment - * variables. - */ -public class GridLoadTestArgs { - /** Cache name. */ - public static final String CACHE_NAME = "GG_CACHE_NAME"; - - /** Threads count. */ - public static final String THREADS_CNT = "GG_THREADS_COUNT"; - - /** Test duration in seconds. */ - public static final String TEST_DUR_SEC = "GG_TEST_DUR_SEC"; - - /** Value size. */ - public static final String VALUE_SIZE = "GG_VALUE_SIZE"; - - /** Properties map for dumping. */ - private static ThreadLocal<Map<String, String>> props = new ThreadLocal<Map<String, String>>() { - @Override protected Map<String, String> initialValue() { - return new HashMap<>(); - } - }; - - /** - * Gets the value of either JVM property or environment variable, - * if property is not set. - * - * @param name Property name. - * @param dflt Default value. - * @return JVM property value or environment variable value if - * JVM property is {@code null} or default value if both - * are {@code null}. - */ - public static String getStringProperty(String name, String dflt) { - String ret = getStringProperty0(name); - - if (ret == null) - ret = dflt; - - props.get().put(name, ret); - - return ret; - } - - /** - * Gets the value of either JVM property or environment variable, - * if property is not set. - * - * @param name Property name. - * @return JVM property value or environment variable value if - * JVM property is undefined. Returns {@code null} if - * both JVM property and environment variable are not set. - */ - @Nullable public static String getStringProperty(String name) { - return saveProperty(name, getStringProperty0(name)); - } - - /** - * Helper method for getting property values. - * - * @param name Property name. - * @return JVM property value or environment variable value if - * JVM property is undefined. Returns {@code null} if - * both JVM property and environment variable are not set. - */ - @Nullable private static String getStringProperty0(String name) { - String ret = System.getProperty(name); - - return ret != null ? ret : System.getenv(name); - } - - /** - * Gets the integer value of either JVM property or environment variable, - * if property is not set. - * - * @param name Property name. - * @return JVM property value or environment variable value if - * JVM property is {@code null} or {@code null} if both - * are {@code null}. - */ - @Nullable public static Integer getIntProperty(String name) { - return saveProperty(name, getIntProperty0(name)); - } - - /** - * Gets the integer value of either JVM property or environment variable, - * if property is not set. - * - * @param name Property name. - * @param dflt Default value. - * @return JVM property value or environment variable value if - * JVM property is {@code null} or default value if both - * are {@code null}. - */ - @SuppressWarnings("ConstantConditions") - public static int getIntProperty(String name, int dflt) { - Integer ret = getIntProperty0(name); - - return saveProperty(name, ret != null ? ret : dflt); - } - - /** - * Helper method for getting int properties. - * - * @param name Property name. - * @return JVM property value or environment variable value if - * JVM property is {@code null} or {@code null} if both - * are {@code null}. - */ - @Nullable private static Integer getIntProperty0(String name) { - Integer ret = Integer.getInteger(name); - - if (ret == null) { - String env = System.getenv(name); - - ret = env != null ? Integer.valueOf(env) : null; - } - - return ret; - } - - /** - * Gets the integer value of either JVM property or environment variable, - * if property is not set. - * - * @param name Property name. - * @param dflt Default value. - * @param validClo Value validation closure, which returns {@code null}, if the value - * is valid, and error message, if it's not valid. - * @return JVM property value or environment variable value if - * JVM property is {@code null} or default value if both - * are {@code null}. - * @throws IgniteCheckedException If the value didn't pass the validation. - */ - public static int getIntProperty(String name, int dflt, IgniteClosure<Integer, String> validClo) - throws IgniteCheckedException { - int ret = getIntProperty(name, dflt); - - String errMsg = validClo.apply(ret); - - if (errMsg != null) - throw new IgniteCheckedException("Illegal value for " + name + " parameter: " + errMsg); - - return ret; - } - - /** - * Gets the long value of either JVM property or environment variable, - * if property is not set. - * - * @param name Property name. - * @return JVM property value or environment variable value if - * JVM property is undefined. Returns {@code null} if - * both JVM property and environment variable are not set. - */ - @Nullable public static Long getLongProperty(String name) { - return saveProperty(name, getLongProperty0(name)); - } - - /** - * Gets the long value of either JVM property or environment variable, - * if property is not set. - * - * @param name Property name. - * @param dflt Default value. - * @return JVM property value or environment variable value if - * JVM property is {@code null} or default value if both - * are {@code null}. - */ - @SuppressWarnings("ConstantConditions") - public static long getLongProperty(String name, long dflt) { - Long ret = getLongProperty(name); - - return saveProperty(name, ret != null ? ret : dflt); - } - - /** - * Helper method for getting long property. - * - * @param name Property name. - * @return JVM property value or environment variable value if - * JVM property is undefined. Returns {@code null} if - * both JVM property and environment variable are not set. - */ - @Nullable private static Long getLongProperty0(String name) { - Long ret = Long.getLong(name); - - if (ret == null) { - String env = System.getenv(name); - - ret = env != null ? Long.valueOf(env) : null; - } - - return ret; - } - - /** - * Gets the boolean value of either JVM property or environment variable, - * if property is not set. - * - * @param name Property name. - * @param dflt Default value. - * @return JVM property value or environment variable value if - * JVM property is {@code null} or default value if both - * are {@code null}. - */ - @SuppressWarnings("ConstantConditions") - public static boolean getBooleanProperty(String name, boolean dflt) { - Boolean ret = Boolean.getBoolean(name); - - if (ret == null) { - String env = System.getenv(name); - - ret = env != null ? Boolean.valueOf(env) : null; - } - - return saveProperty(name, ret != null ? ret : dflt); - } - - /** - * Prints a message about undefined JVM property to standard - * error. - * - * @param propName JVM property name. - */ - public static void printErrorUndefined(String propName) { - System.err.println("JVM property " + propName + " should be defined " + - "(use -D" + propName + "=...)"); - } - - /** - * Dumps the properties (name + value), that were retrieved using - * {@code get[type]Property()}. - * - * @param out Output stream to dump properties to. - */ - public static void dumpProperties(PrintStream out) { - for (Map.Entry<String, String> prop : props.get().entrySet()) - out.println(prop.getKey() + ": " + prop.getValue()); - } - - /** - * Helper method for saving a property to thread local for later use in - * {@link #dumpProperties(PrintStream)}. - * - * @param name Property name. - * @param val Property value. - * @return Property value. - */ - @Nullable private static <T> T saveProperty(String name, @Nullable T val) { - props.get().put(name, val != null ? val.toString() : null); - - return val; - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e1d8f69b/modules/hadoop/src/test/java/org/apache/ignite/loadtests/ggfs/GridGgfsNodeStartup.java ---------------------------------------------------------------------- diff --git a/modules/hadoop/src/test/java/org/apache/ignite/loadtests/ggfs/GridGgfsNodeStartup.java b/modules/hadoop/src/test/java/org/apache/ignite/loadtests/ggfs/GridGgfsNodeStartup.java new file mode 100644 index 0000000..341d315 --- /dev/null +++ b/modules/hadoop/src/test/java/org/apache/ignite/loadtests/ggfs/GridGgfsNodeStartup.java @@ -0,0 +1,49 @@ +/* + * 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.loadtests.ggfs; + +import org.apache.ignite.*; +import org.apache.ignite.internal.util.typedef.*; + +import javax.swing.*; + +/** + * Node startup for GGFS performance benchmark. + */ +public class GridGgfsNodeStartup { + /** + * Start up an empty node with specified cache configuration. + * + * @param args Command line arguments, none required. + * @throws IgniteCheckedException If example execution failed. + */ + public static void main(String[] args) throws IgniteCheckedException { + try (Ignite ignored = G.start("config/hadoop/default-config.xml")) { + // Wait until Ok is pressed. + JOptionPane.showMessageDialog( + null, + new JComponent[] { + new JLabel("GridGain started."), + new JLabel("Press OK to stop GridGain.") + }, + "GridGain", + JOptionPane.INFORMATION_MESSAGE + ); + } + } +}