IGNITE-8337 Java ThinClient benchmark for yardstick

Signed-off-by: Andrey Gura <ag...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/eea44e2f
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/eea44e2f
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/eea44e2f

Branch: refs/heads/ignite-9273
Commit: eea44e2f7b0a5be7fd184af8047f10610c00b60f
Parents: ca80acb
Author: oleg-ostanin <oosta...@gridagin.com>
Authored: Mon Aug 27 17:58:30 2018 +0300
Committer: Andrey Gura <ag...@apache.org>
Committed: Mon Aug 27 17:58:30 2018 +0300

----------------------------------------------------------------------
 .../yardstick/IgniteThinAbstractBenchmark.java  | 164 +++++++++++++++++++
 .../ignite/yardstick/IgniteThinClient.java      | 146 +++++++++++++++++
 .../cache/IgnitePutAllSimpleBenchmark.java      |  44 +++++
 .../thin/cache/IgniteThinBenchmarkUtils.java    |  95 +++++++++++
 .../cache/IgniteThinCacheAbstractBenchmark.java |  45 +++++
 .../thin/cache/IgniteThinGetBenchmark.java      |  74 +++++++++
 .../thin/cache/IgniteThinGetTxBenchmark.java    |  30 ++++
 .../thin/cache/IgniteThinPutAllBenchmark.java   |  44 +++++
 .../thin/cache/IgniteThinPutAllTxBenchmark.java |  30 ++++
 .../thin/cache/IgniteThinPutBenchmark.java      |  41 +++++
 .../thin/cache/IgniteThinPutGetBenchmark.java   |  46 ++++++
 .../thin/cache/IgniteThinPutTxBenchmark.java    |  30 ++++
 12 files changed, 789 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/eea44e2f/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteThinAbstractBenchmark.java
----------------------------------------------------------------------
diff --git 
a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteThinAbstractBenchmark.java
 
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteThinAbstractBenchmark.java
new file mode 100644
index 0000000..4ba595d
--- /dev/null
+++ 
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteThinAbstractBenchmark.java
@@ -0,0 +1,164 @@
+/*
+ * 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.Arrays;
+import java.util.List;
+import java.util.concurrent.ConcurrentLinkedDeque;
+import java.util.concurrent.ThreadLocalRandom;
+import org.apache.ignite.client.ClientCache;
+import org.apache.ignite.client.IgniteClient;
+import org.apache.ignite.yardstick.thin.cache.IgniteThinBenchmarkUtils;
+import org.yardstickframework.BenchmarkConfiguration;
+import org.yardstickframework.BenchmarkDriverAdapter;
+import org.yardstickframework.BenchmarkUtils;
+
+import static org.yardstickframework.BenchmarkUtils.jcommander;
+import static org.yardstickframework.BenchmarkUtils.println;
+
+/**
+ * Abstract class for Thin client benchmarks.
+ */
+public abstract class IgniteThinAbstractBenchmark extends 
BenchmarkDriverAdapter {
+    /** Arguments. */
+    protected final IgniteBenchmarkArguments args = new 
IgniteBenchmarkArguments();
+
+    /** Client. */
+    private ThreadLocal<IgniteClient> client;
+
+    /** Server host addresses queue. */
+    private ConcurrentLinkedDeque<String> servHosts;
+
+    /** {@inheritDoc} */
+    @Override public void setUp(BenchmarkConfiguration cfg) throws Exception {
+        super.setUp(cfg);
+
+        jcommander(cfg.commandLineArguments(), args, "<ignite-driver>");
+
+        String locIp = IgniteThinBenchmarkUtils.getLocalIp(cfg);
+
+        client = new ThreadLocal<IgniteClient>() {
+            @Override protected IgniteClient initialValue() {
+                synchronized (IgniteThinAbstractBenchmark.class) {
+                    try {
+                        if (servHosts == null || servHosts.isEmpty())
+                            setServHosts(cfg);
+
+                        return new IgniteThinClient().start(cfg, 
servHosts.poll());
+                    }
+                    catch (Exception e) {
+                        e.printStackTrace();
+                    }
+
+                    return null;
+                }
+            }
+        };
+
+        println("Custom properties:");
+
+        for (String prop : cfg.customProperties().keySet())
+            println(String.format("%s=%s", prop, 
cfg.customProperties().get(prop)));
+
+        // Create util cache for checking if all driver processes had been 
started.
+        ClientCache<String, String> utilCache = 
client().getOrCreateCache("start-util-cache");
+
+        // Put 'started' message in util cache.
+        utilCache.put(locIp, "started");
+
+        List<String> hostList = IgniteThinBenchmarkUtils.drvHostList(cfg);
+
+        int cnt = 0;
+
+        // Wait for all driver processes to start.
+        while(!checkIfAllClientsStarted(hostList) && cnt++ < 600)
+            Thread.sleep(500L);
+    }
+
+    /**
+     *
+     * @param cfg
+     */
+    private synchronized void setServHosts(BenchmarkConfiguration cfg){
+        BenchmarkUtils.println("Setting serv host queue");
+
+        String[] servHostArr = IgniteThinBenchmarkUtils.servHostArr(cfg);
+
+        servHosts = new ConcurrentLinkedDeque<>(Arrays.asList(servHostArr));
+    }
+
+    /**
+     * Check if all driver processes had been started.
+     *
+     * @param hostList List of driver host addresses.
+     * @return {@code true} if all driver processes had been started or {@code 
false} if not.
+     */
+    private boolean checkIfAllClientsStarted(List<String> hostList){
+        ClientCache<String, String> utilCache = 
client().getOrCreateCache("start-util-cache");
+
+        for(String host : hostList){
+            if(host.equals("localhost"))
+                host = "127.0.0.1";
+
+            String res = utilCache.get(host);
+
+            if (res == null || !res.equals("started"))
+                return false;
+        }
+
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override public void tearDown() throws Exception {
+        if (client.get() != null)
+            client.get().close();
+    }
+
+    /** {@inheritDoc} */
+    @Override public String description() {
+        String desc = BenchmarkUtils.description(cfg, this);
+
+        return desc.isEmpty() ?
+            getClass().getSimpleName() + args.description() + 
cfg.defaultDescription() : desc;
+    }
+
+    /**
+     * @return Client.
+     */
+    protected IgniteClient client() {
+        return client.get();
+    }
+
+    /**
+     * @param max Key range.
+     * @return Next key.
+     */
+    public static int nextRandom(int max) {
+        return ThreadLocalRandom.current().nextInt(max);
+    }
+
+    /**
+     * @param min Minimum key in range.
+     * @param max Maximum key in range.
+     * @return Next key.
+     */
+    protected int nextRandom(int min, int max) {
+        return ThreadLocalRandom.current().nextInt(max - min) + min;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/eea44e2f/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteThinClient.java
----------------------------------------------------------------------
diff --git 
a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteThinClient.java
 
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteThinClient.java
new file mode 100644
index 0000000..96904d5
--- /dev/null
+++ 
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteThinClient.java
@@ -0,0 +1,146 @@
+/*
+ * 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.net.MalformedURLException;
+import java.net.URL;
+import java.util.List;
+import java.util.Map;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.Ignition;
+import org.apache.ignite.client.IgniteClient;
+import org.apache.ignite.configuration.ClientConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.util.IgniteUtils;
+import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteBiTuple;
+import org.apache.ignite.yardstick.io.FileUtils;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.GenericApplicationContext;
+import org.springframework.core.io.UrlResource;
+import org.yardstickframework.BenchmarkConfiguration;
+import org.yardstickframework.BenchmarkUtils;
+
+/**
+ * Thin client.
+ */
+public class IgniteThinClient {
+    /** Thin client. */
+    private IgniteClient client;
+
+    /** */
+    public IgniteThinClient() {
+        // No-op.
+    }
+
+    /**
+     * @param client Use exist ignite client.
+     */
+    public IgniteThinClient(IgniteClient client) {
+        this.client = client;
+    }
+
+    /** {@inheritDoc} */
+    public IgniteClient start(BenchmarkConfiguration cfg, String host) throws 
Exception {
+        IgniteBenchmarkArguments args = new IgniteBenchmarkArguments();
+
+        BenchmarkUtils.jcommander(cfg.commandLineArguments(), args, 
"<ignite-node>");
+
+        IgniteBiTuple<IgniteConfiguration, ? extends ApplicationContext> tup = 
loadConfiguration(args.configuration());
+
+        IgniteConfiguration c = tup.get1();
+
+        assert c != null;
+
+        if (args.cleanWorkDirectory())
+            FileUtils.cleanDirectory(U.workDirectory(c.getWorkDirectory(), 
c.getIgniteHome()));
+
+        ClientConfiguration clCfg = new ClientConfiguration();
+
+        String hostPort = host + ":10800";
+
+        BenchmarkUtils.println(String.format("Using for connection address: 
%s", hostPort));
+
+        clCfg.setAddresses(hostPort);
+
+        client = Ignition.startClient(clCfg);
+
+        return client;
+    }
+
+    /**
+     * @param springCfgPath Spring configuration file path.
+     * @return Tuple with grid configuration and Spring application context.
+     * @throws Exception If failed.
+     */
+    private static IgniteBiTuple<IgniteConfiguration, ? extends 
ApplicationContext> loadConfiguration(String springCfgPath)
+        throws Exception {
+        URL url;
+
+        try {
+            url = new URL(springCfgPath);
+        }
+        catch (MalformedURLException e) {
+            url = IgniteUtils.resolveIgniteUrl(springCfgPath);
+
+            if (url == null) {
+                throw new IgniteCheckedException("Spring XML configuration 
path is invalid: " + springCfgPath +
+                    ". Note that this path should be either absolute or a 
relative local file system path, " +
+                    "relative to META-INF in classpath or valid URL to 
IGNITE_HOME.", e);
+            }
+        }
+
+        GenericApplicationContext springCtx;
+
+        try {
+            springCtx = new GenericApplicationContext();
+
+            new XmlBeanDefinitionReader(springCtx).loadBeanDefinitions(new 
UrlResource(url));
+
+            springCtx.refresh();
+        }
+        catch (BeansException e) {
+            throw new Exception("Failed to instantiate Spring XML application 
context [springUrl=" +
+                url + ", err=" + e.getMessage() + ']', e);
+        }
+
+        Map<String, IgniteConfiguration> cfgMap;
+
+        try {
+            cfgMap = springCtx.getBeansOfType(IgniteConfiguration.class);
+        }
+        catch (BeansException e) {
+            throw new Exception("Failed to instantiate bean [type=" + 
IgniteConfiguration.class + ", err=" +
+                e.getMessage() + ']', e);
+        }
+
+        if (cfgMap == null || cfgMap.isEmpty())
+            throw new Exception("Failed to find ignite configuration in: " + 
url);
+
+        return new IgniteBiTuple<>(cfgMap.values().iterator().next(), 
springCtx);
+    }
+
+    /**
+     * @return Thin client.
+     */
+    public IgniteClient client() {
+        return client;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/eea44e2f/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutAllSimpleBenchmark.java
----------------------------------------------------------------------
diff --git 
a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutAllSimpleBenchmark.java
 
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutAllSimpleBenchmark.java
new file mode 100644
index 0000000..6051fc8
--- /dev/null
+++ 
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutAllSimpleBenchmark.java
@@ -0,0 +1,44 @@
+/*
+ * 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.HashMap;
+import java.util.Map;
+import org.apache.ignite.IgniteCache;
+
+/**
+ * Ignite benchmark that performs put operations.
+ */
+public class IgnitePutAllSimpleBenchmark extends 
IgniteCacheAbstractBenchmark<Integer, Object> {
+    /** {@inheritDoc} */
+    @Override public boolean test(Map<Object, Object> ctx) throws Exception {
+        Map<Integer, Integer> vals = new HashMap<>();
+
+        for (int i = 0; i < 500; i++ )
+            vals.put(i, nextRandom(1000));
+
+        cache().putAll(vals);
+
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected IgniteCache<Integer, Object> cache() {
+        return ignite().cache("atomic");
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/eea44e2f/modules/yardstick/src/main/java/org/apache/ignite/yardstick/thin/cache/IgniteThinBenchmarkUtils.java
----------------------------------------------------------------------
diff --git 
a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/thin/cache/IgniteThinBenchmarkUtils.java
 
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/thin/cache/IgniteThinBenchmarkUtils.java
new file mode 100644
index 0000000..159887a
--- /dev/null
+++ 
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/thin/cache/IgniteThinBenchmarkUtils.java
@@ -0,0 +1,95 @@
+/*
+ * 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.thin.cache;
+
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.net.SocketException;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+import org.yardstickframework.BenchmarkConfiguration;
+
+/**
+ * Thin client benchmark utils.
+ */
+public class IgniteThinBenchmarkUtils {
+    /**
+     * Compute local IP address.
+     *
+     * @param cfg Configuration.
+     * @return local IP address.
+     * @throws SocketException
+     */
+    public static String getLocalIp(BenchmarkConfiguration cfg) throws 
SocketException {
+        List<String> hostList = drvHostList(cfg);
+
+        Enumeration e = NetworkInterface.getNetworkInterfaces();
+
+        while(e.hasMoreElements()) {
+            NetworkInterface n = (NetworkInterface) e.nextElement();
+
+            Enumeration ee = n.getInetAddresses();
+
+            while (ee.hasMoreElements()) {
+                InetAddress i = (InetAddress) ee.nextElement();
+
+                if(hostList.contains(i.getHostAddress()))
+                    return i.getHostAddress();
+            }
+        }
+
+        return null;
+    }
+
+    /**
+     * Creates list of driver host addresses.
+     *
+     * @param cfg Configuration.
+     * @return List of driver host addresses.
+     */
+    public static List<String> drvHostList(BenchmarkConfiguration cfg){
+        String driverHosts = cfg.customProperties().get("DRIVER_HOSTS");
+
+        String[] hostArr = driverHosts.split(",");
+
+        List<String> res = new ArrayList<>(hostArr.length);
+
+        for(String host : hostArr){
+            if(host.equals("localhost"))
+                res.add("127.0.0.1");
+            else
+                res.add(host);
+        }
+
+        return res;
+    }
+
+    /**
+     * Creates array of server host addresses.
+     *
+     * @param cfg Configuration.
+     * @return {@code Array} of server host addresses.
+     */
+    public static String[] servHostArr(BenchmarkConfiguration cfg){
+        String servHosts = cfg.customProperties().get("SERVER_HOSTS");
+
+        return servHosts.split(",");
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/eea44e2f/modules/yardstick/src/main/java/org/apache/ignite/yardstick/thin/cache/IgniteThinCacheAbstractBenchmark.java
----------------------------------------------------------------------
diff --git 
a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/thin/cache/IgniteThinCacheAbstractBenchmark.java
 
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/thin/cache/IgniteThinCacheAbstractBenchmark.java
new file mode 100644
index 0000000..301c29e
--- /dev/null
+++ 
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/thin/cache/IgniteThinCacheAbstractBenchmark.java
@@ -0,0 +1,45 @@
+/*
+ * 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.thin.cache;
+
+import org.apache.ignite.client.ClientCache;
+import org.apache.ignite.yardstick.IgniteThinAbstractBenchmark;
+import org.yardstickframework.BenchmarkConfiguration;
+
+/**
+ *
+ * Abstract class for thin client benchmarks which use cache.
+ */
+public abstract class IgniteThinCacheAbstractBenchmark<K, V> extends 
IgniteThinAbstractBenchmark {
+    /** Cache. */
+    protected ClientCache<K, V> cache;
+
+    /** {@inheritDoc} */
+    @Override public void setUp(BenchmarkConfiguration cfg) throws Exception {
+        super.setUp(cfg);
+
+        cache = cache();
+    }
+
+    /**
+     * Each benchmark must determine which cache will be used.
+     *
+     * @return ClientCache Cache to use.
+     */
+    protected abstract ClientCache<K, V> cache();
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/eea44e2f/modules/yardstick/src/main/java/org/apache/ignite/yardstick/thin/cache/IgniteThinGetBenchmark.java
----------------------------------------------------------------------
diff --git 
a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/thin/cache/IgniteThinGetBenchmark.java
 
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/thin/cache/IgniteThinGetBenchmark.java
new file mode 100644
index 0000000..ad7937b
--- /dev/null
+++ 
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/thin/cache/IgniteThinGetBenchmark.java
@@ -0,0 +1,74 @@
+/*
+ * 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.thin.cache;
+
+import java.util.Map;
+import org.apache.ignite.client.ClientCache;
+import org.apache.ignite.yardstick.cache.model.SampleValue;
+import org.yardstickframework.BenchmarkConfiguration;
+
+import static org.yardstickframework.BenchmarkUtils.println;
+
+/**
+ * Thin client benchmark that performs get operations.
+ */
+public class IgniteThinGetBenchmark extends 
IgniteThinCacheAbstractBenchmark<Integer, Object> {
+    /** {@inheritDoc} */
+    @Override public void setUp(BenchmarkConfiguration cfg) throws Exception {
+        super.setUp(cfg);
+
+        if (args.preloadAmount() > args.range())
+            throw new IllegalArgumentException("Preloading amount (\"-pa\", 
\"--preloadAmount\") " +
+                "must by less then the range (\"-r\", \"--range\").");
+
+        loadSampleValues(cache().getName(), args.preloadAmount());
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean test(Map<Object, Object> ctx) throws Exception {
+        int key = nextRandom(args.range());
+
+        cache().get(key);
+
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected ClientCache<Integer, Object> cache() {
+        return client().cache("atomic");
+    }
+
+    /**
+     * @param cacheName Cache name.
+     * @param cnt Number of entries to load.
+     */
+    private void loadSampleValues(String cacheName, int cnt) {
+        for (int i = 0; i < cnt; i++) {
+            cache.put(i, new SampleValue(i));
+
+            if (i % 100000 == 0) {
+                if (Thread.currentThread().isInterrupted())
+                    break;
+
+                println("Loaded entries [cache=" + cacheName + ", cnt=" + i + 
']');
+            }
+        }
+
+        println("Load entries done [cache=" + cacheName + ", cnt=" + cnt + 
']');
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/eea44e2f/modules/yardstick/src/main/java/org/apache/ignite/yardstick/thin/cache/IgniteThinGetTxBenchmark.java
----------------------------------------------------------------------
diff --git 
a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/thin/cache/IgniteThinGetTxBenchmark.java
 
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/thin/cache/IgniteThinGetTxBenchmark.java
new file mode 100644
index 0000000..601ce63
--- /dev/null
+++ 
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/thin/cache/IgniteThinGetTxBenchmark.java
@@ -0,0 +1,30 @@
+/*
+ * 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.thin.cache;
+
+import org.apache.ignite.client.ClientCache;
+
+/**
+ * Thin client benchmark that performs get operations.
+ */
+public class IgniteThinGetTxBenchmark extends IgniteThinGetBenchmark {
+    /** {@inheritDoc} */
+    @Override protected ClientCache<Integer, Object> cache() {
+        return client().cache("tx");
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/eea44e2f/modules/yardstick/src/main/java/org/apache/ignite/yardstick/thin/cache/IgniteThinPutAllBenchmark.java
----------------------------------------------------------------------
diff --git 
a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/thin/cache/IgniteThinPutAllBenchmark.java
 
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/thin/cache/IgniteThinPutAllBenchmark.java
new file mode 100644
index 0000000..3e17007
--- /dev/null
+++ 
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/thin/cache/IgniteThinPutAllBenchmark.java
@@ -0,0 +1,44 @@
+/*
+ * 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.thin.cache;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.ignite.client.ClientCache;
+
+/**
+ * Thin client benchmark that performs putAll operations.
+ */
+public class IgniteThinPutAllBenchmark extends 
IgniteThinCacheAbstractBenchmark<Integer, Object> {
+    /** {@inheritDoc} */
+    @Override public boolean test(Map<Object, Object> ctx) throws Exception {
+        Map<Integer, Integer> vals = new HashMap<>();
+
+        for (int i = 0; i < 500; i++ )
+            vals.put(i, nextRandom(1000));
+
+        cache().putAll(vals);
+
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected ClientCache<Integer, Object> cache() {
+        return client().cache("atomic");
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/eea44e2f/modules/yardstick/src/main/java/org/apache/ignite/yardstick/thin/cache/IgniteThinPutAllTxBenchmark.java
----------------------------------------------------------------------
diff --git 
a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/thin/cache/IgniteThinPutAllTxBenchmark.java
 
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/thin/cache/IgniteThinPutAllTxBenchmark.java
new file mode 100644
index 0000000..fba3a96
--- /dev/null
+++ 
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/thin/cache/IgniteThinPutAllTxBenchmark.java
@@ -0,0 +1,30 @@
+/*
+ * 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.thin.cache;
+
+import org.apache.ignite.client.ClientCache;
+
+/**
+ * Thin client benchmark that performs putAll operations.
+ */
+public class IgniteThinPutAllTxBenchmark extends IgniteThinPutAllBenchmark {
+    /** {@inheritDoc} */
+    @Override protected ClientCache<Integer, Object> cache() {
+        return client().cache("tx");
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/eea44e2f/modules/yardstick/src/main/java/org/apache/ignite/yardstick/thin/cache/IgniteThinPutBenchmark.java
----------------------------------------------------------------------
diff --git 
a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/thin/cache/IgniteThinPutBenchmark.java
 
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/thin/cache/IgniteThinPutBenchmark.java
new file mode 100644
index 0000000..e8f675b
--- /dev/null
+++ 
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/thin/cache/IgniteThinPutBenchmark.java
@@ -0,0 +1,41 @@
+/*
+ * 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.thin.cache;
+
+import java.util.Map;
+import org.apache.ignite.client.ClientCache;
+import org.apache.ignite.yardstick.cache.model.SampleValue;
+
+/**
+ * Thin client benchmark that performs put operations.
+ */
+public class IgniteThinPutBenchmark extends 
IgniteThinCacheAbstractBenchmark<Integer, Object> {
+    /** {@inheritDoc} */
+    @Override public boolean test(Map<Object, Object> ctx) throws Exception {
+        int key = nextRandom(args.range());
+
+        cache().put(key, new SampleValue(key));
+
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected ClientCache<Integer, Object> cache() {
+        return client().cache("atomic");
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/eea44e2f/modules/yardstick/src/main/java/org/apache/ignite/yardstick/thin/cache/IgniteThinPutGetBenchmark.java
----------------------------------------------------------------------
diff --git 
a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/thin/cache/IgniteThinPutGetBenchmark.java
 
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/thin/cache/IgniteThinPutGetBenchmark.java
new file mode 100644
index 0000000..c40a10c
--- /dev/null
+++ 
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/thin/cache/IgniteThinPutGetBenchmark.java
@@ -0,0 +1,46 @@
+/*
+ * 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.thin.cache;
+
+import java.util.Map;
+import org.apache.ignite.client.ClientCache;
+import org.apache.ignite.yardstick.cache.model.SampleValue;
+
+/**
+ * Thin client benchmark that performs put and get operations.
+ */
+public class IgniteThinPutGetBenchmark extends 
IgniteThinCacheAbstractBenchmark<Integer, Object> {
+    /** {@inheritDoc} */
+    @Override public boolean test(Map<Object, Object> ctx) throws Exception {
+        int key = nextRandom(args.range());
+
+        Object val = cache().get(key);
+
+        if (val != null)
+            key = nextRandom(args.range());
+
+        cache().put(key, new SampleValue(key));
+
+        return true;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected ClientCache<Integer, Object> cache() {
+        return client().cache("atomic");
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/eea44e2f/modules/yardstick/src/main/java/org/apache/ignite/yardstick/thin/cache/IgniteThinPutTxBenchmark.java
----------------------------------------------------------------------
diff --git 
a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/thin/cache/IgniteThinPutTxBenchmark.java
 
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/thin/cache/IgniteThinPutTxBenchmark.java
new file mode 100644
index 0000000..bf05632
--- /dev/null
+++ 
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/thin/cache/IgniteThinPutTxBenchmark.java
@@ -0,0 +1,30 @@
+/*
+ * 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.thin.cache;
+
+import org.apache.ignite.client.ClientCache;
+
+/**
+ * Thin client benchmark that performs put operations.
+ */
+public class IgniteThinPutTxBenchmark extends IgniteThinPutBenchmark {
+    /** {@inheritDoc} */
+    @Override protected ClientCache<Integer, Object> cache() {
+        return client().cache("tx");
+    }
+}

Reply via email to