Repository: ignite Updated Branches: refs/heads/master 322e61cd1 -> 854357eb4
IGNITE-2952: Add yardstick benchmark for cache load testing. Reviewed and merged by Denis Magda ([email protected]) Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/854357eb Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/854357eb Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/854357eb Branch: refs/heads/master Commit: 854357eb4c5cc2181b9c11262d3c012d1fe8ccc5 Parents: 322e61c Author: Vladislav Pyatkov <[email protected]> Authored: Thu Apr 14 07:57:42 2016 +0300 Committer: Denis Magda <[email protected]> Committed: Thu Apr 14 07:57:42 2016 +0300 ---------------------------------------------------------------------- .../cache/AtomicBinaryOffheapBatchTest.java | 384 +++++++++ .../config/benchmark-cache-load-win.properties | 56 ++ .../config/benchmark-cache-load.properties | 61 ++ .../yardstick/IgniteBenchmarkArguments.java | 14 +- .../IgniteCacheRandomOperationBenchmark.java | 773 +++++++++++++++++++ .../yardstick/cache/load/model/ModelUtil.java | 148 ++++ .../cache/load/model/key/Identifier.java | 106 +++ .../yardstick/cache/load/model/key/Mark.java | 104 +++ .../yardstick/cache/load/model/value/Car.java | 121 +++ .../yardstick/cache/load/model/value/Color.java | 48 ++ .../yardstick/cache/load/model/value/Truck.java | 62 ++ 11 files changed, 1876 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/854357eb/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/AtomicBinaryOffheapBatchTest.java ---------------------------------------------------------------------- diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/AtomicBinaryOffheapBatchTest.java b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/AtomicBinaryOffheapBatchTest.java new file mode 100644 index 0000000..fb2d95d --- /dev/null +++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/AtomicBinaryOffheapBatchTest.java @@ -0,0 +1,384 @@ +/* + * 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.internal.processors.cache; + +import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteDataStreamer; +import org.apache.ignite.binary.BinaryObjectException; +import org.apache.ignite.binary.BinaryReader; +import org.apache.ignite.binary.BinaryWriter; +import org.apache.ignite.binary.Binarylizable; +import org.apache.ignite.cache.CacheAtomicWriteOrderMode; +import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.cache.CacheMemoryMode; +import org.apache.ignite.cache.CacheMode; +import org.apache.ignite.cache.CacheWriteSynchronizationMode; +import org.apache.ignite.cache.query.annotations.QuerySqlField; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.configuration.NearCacheConfiguration; +import org.apache.ignite.internal.binary.BinaryMarshaller; + +import javax.cache.processor.EntryProcessor; +import javax.cache.processor.EntryProcessorException; +import javax.cache.processor.MutableEntry; +import java.util.Map; +import java.util.Set; +import java.util.TreeMap; +import java.util.TreeSet; + +/** + * The test are checking batch operation onto atomic offheap cache with per certain key and value types. + */ +public class AtomicBinaryOffheapBatchTest extends IgniteCacheAbstractTest { + + /** + * Size of batch in operation + */ + public static final int BATCH_SIZE = 500; + + @Override + protected IgniteConfiguration getConfiguration(String gridName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(gridName); + + cfg.setMarshaller(new BinaryMarshaller()); + cfg.setPeerClassLoadingEnabled(false); + + return cfg; + } + + @Override + protected CacheConfiguration cacheConfiguration(String gridName) throws Exception { + CacheConfiguration cfg = super.cacheConfiguration(gridName); + + cfg.setMemoryMode(memoryMode()); + + cfg.setIndexedTypes(Integer.class, Person.class, Integer.class, Organization.class); + + cfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.PRIMARY_SYNC); + + return cfg; + } + + /** {@inheritDoc} */ + @Override + protected int gridCount() { + return 1; + } + + /** {@inheritDoc} */ + @Override + protected CacheMode cacheMode() { + return CacheMode.PARTITIONED; + } + + /** {@inheritDoc} */ + @Override + protected CacheAtomicityMode atomicityMode() { + return CacheAtomicityMode.ATOMIC; + } + + /** {@inheritDoc} */ + @Override + protected NearCacheConfiguration nearConfiguration() { + return null; + } + + /** + * @return Cache memory mode. + */ + protected CacheMemoryMode memoryMode() { + return CacheMemoryMode.OFFHEAP_TIERED; + } + + /** {@inheritDoc} */ + @Override + protected CacheAtomicWriteOrderMode atomicWriteOrderMode() { + return CacheAtomicWriteOrderMode.PRIMARY; + } + + /** + * Test method. + * + * @throws Exception If fail. + */ + public void testBatchOperations() throws Exception { + try (IgniteCache defaultCache = ignite(0).cache(null)) { + loadingCacheAnyDate(); + + for (int cnt = 0; cnt < 200; cnt++) { + Map<Integer, Person> putMap1 = new TreeMap<>(); + for (int i = 0; i < BATCH_SIZE; i++) + putMap1.put(i, new Person(i, i + 1, String.valueOf(i), String.valueOf(i + 1), i / 0.99)); + + defaultCache.putAll(putMap1); + + Map<Integer, Organization> putMap2 = new TreeMap<>(); + for (int i = BATCH_SIZE / 2; i < BATCH_SIZE * 3 / 2; i++) + putMap2.put(i, new Organization(i, String.valueOf(i))); + + defaultCache.putAll(putMap2); + + Set<Integer> keySet = new TreeSet<>(); + + for (int i = 0; i < BATCH_SIZE * 3 / 2; i += 2) + keySet.add(i); + + defaultCache.removeAll(keySet); + + keySet = new TreeSet<>(); + + for (int i = 1; i < BATCH_SIZE * 3 / 2; i += 2) + keySet.add(i); + + defaultCache.invokeAll(keySet, new EntryProcessor() { + @Override + public Object process(MutableEntry entry, Object... arguments) throws EntryProcessorException { + Object value = entry.getValue(); + entry.remove(); + return value; + } + }); + } + } + } + + /** + * Loading date into cache + */ + private void loadingCacheAnyDate() { + try (IgniteDataStreamer streamer = ignite(0).dataStreamer(null)) { + for (int i = 0; i < 30_000; i++) { + if (i % 2 == 0) + streamer.addData(i, new Person(i, i + 1, String.valueOf(i), String.valueOf(i + 1), i / 0.99)); + else + streamer.addData(i, new Organization(i, String.valueOf(i))); + } + } + } + + /** + * Ignite cache value class. + */ + private static class Person implements Binarylizable { + + /** Person ID. */ + @QuerySqlField(index = true) + private int id; + + /** Organization ID. */ + @QuerySqlField(index = true) + private int orgId; + + /** First name (not-indexed). */ + @QuerySqlField + private String firstName; + + /** Last name (not indexed). */ + @QuerySqlField + private String lastName; + + /** Salary. */ + @QuerySqlField(index = true) + private double salary; + + /** + * Constructs empty person. + */ + public Person() { + // No-op. + } + + /** + * Constructs person record. + * + * @param id Person ID. + * @param orgId Organization ID. + * @param firstName First name. + * @param lastName Last name. + * @param salary Salary. + */ + public Person(int id, int orgId, String firstName, String lastName, double salary) { + this.id = id; + this.orgId = orgId; + this.firstName = firstName; + this.lastName = lastName; + this.salary = salary; + } + + /** + * @return Person id. + */ + public int getId() { + return id; + } + + /** + * @param id Person id. + */ + public void setId(int id) { + this.id = id; + } + + /** + * @return Organization id. + */ + public int getOrganizationId() { + return orgId; + } + + /** + * @param orgId Organization id. + */ + public void setOrganizationId(int orgId) { + this.orgId = orgId; + } + + /** + * @return Person first name. + */ + public String getFirstName() { + return firstName; + } + + /** + * @param firstName Person first name. + */ + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + /** + * @return Person last name. + */ + public String getLastName() { + return lastName; + } + + /** + * @param lastName Person last name. + */ + public void setLastName(String lastName) { + this.lastName = lastName; + } + + /** + * @return Salary. + */ + public double getSalary() { + return salary; + } + + /** + * @param salary Salary. + */ + public void setSalary(double salary) { + this.salary = salary; + } + + /** {@inheritDoc} */ + @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException { + writer.writeInt("id", id); + writer.writeInt("orgId", orgId); + writer.writeString("firstName", firstName); + writer.writeString("lastName", lastName); + writer.writeDouble("salary", salary); + } + + /** {@inheritDoc} */ + @Override public void readBinary(BinaryReader reader) throws BinaryObjectException { + id = reader.readInt("id"); + orgId = reader.readInt("orgId"); + firstName = reader.readString("firstName"); + lastName = reader.readString("lastName"); + salary = reader.readDouble("salary"); + } + } + + /** + * Ignite cache value class with indexed field. + */ + private static class Organization implements Binarylizable { + + /** Organization ID. */ + @QuerySqlField(index = true) + private int id; + + /** Organization name. */ + @QuerySqlField(index = true) + private String name; + + /** + * Constructs empty organization. + */ + public Organization() { + // No-op. + } + + /** + * Constructs organization with given ID. + * + * @param id Organization ID. + * @param name Organization name. + */ + public Organization(int id, String name) { + this.id = id; + this.name = name; + } + + /** + * @return Organization id. + */ + public int getId() { + return id; + } + + /** + * @param id Organization id. + */ + public void setId(int id) { + this.id = id; + } + + /** + * @return Organization name. + */ + public String getName() { + return name; + } + + /** + * @param name Organization name. + */ + public void setName(String name) { + this.name = name; + } + + /** {@inheritDoc} */ + @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException { + writer.writeInt("id", id); + writer.writeString("name", name); + } + + /** {@inheritDoc} */ + @Override public void readBinary(BinaryReader reader) throws BinaryObjectException { + id = reader.readInt("id"); + name = reader.readString("name"); + } + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/854357eb/modules/yardstick/config/benchmark-cache-load-win.properties ---------------------------------------------------------------------- diff --git a/modules/yardstick/config/benchmark-cache-load-win.properties b/modules/yardstick/config/benchmark-cache-load-win.properties new file mode 100644 index 0000000..bfe98cf --- /dev/null +++ b/modules/yardstick/config/benchmark-cache-load-win.properties @@ -0,0 +1,56 @@ +# 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. + +:: +:: Contains benchmarks for execute random operation on various caches. +:: + +:: JVM options. +set JVM_OPTS=%JVM_OPTS% -DIGNITE_QUIET=false + +:: Uncomment to enable concurrent garbage collection (GC) if you encounter long GC pauses. +:: set JVM_OPTS=%JVM_OPTS%^ +:: -XX:+UseParNewGC^ +:: -XX:+UseConcMarkSweepGC^ +:: -XX:+UseTLAB^ +:: -XX:NewSize=128m^ +:: -XX:MaxNewSize=128m^ +:: -XX:MaxTenuringThreshold=0^ +:: -XX:SurvivorRatio=1024^ +:: -XX:+UseCMSInitiatingOccupancyOnly^ +:: -XX:CMSInitiatingOccupancyFraction=60 + +:: List of default probes. +BENCHMARK_DEFAULT_PROBES=ThroughputLatencyProbe,PercentileProbe + +:: Packages where the specified benchmark is searched by reflection mechanism. +BENCHMARK_PACKAGES=org.yardstickframework,org.apache.ignite.yardstick + +:: Probe point writer class name. +:: BENCHMARK_WRITER= + +:: Comma-separated list of the hosts to run BenchmarkServers on. 2 nodes on local host are enabled by default. +set SERVER_HOSTS=localhost,localhost + +:: Comma-separated list of the hosts to run BenchmarkDrivers on. 1 node on local host is enabled by default. +set DRIVER_HOSTS=localhost + +:: Remote username. +:: set REMOTE_USER= + +:: Run configuration which contains all benchmarks. +:: Note that each benchmark is set to run for 300 seconds (5 mins) with warm-up set to 60 seconds (1 minute). +set CONFIGS=^ +-cfg %SCRIPT_DIR%\..\config\ignite-localhost-config.xml -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgniteCacheRandomOperationBenchmark -sn IgniteNode -ds atomic-get-1-backup -nn 1 http://git-wip-us.apache.org/repos/asf/ignite/blob/854357eb/modules/yardstick/config/benchmark-cache-load.properties ---------------------------------------------------------------------- diff --git a/modules/yardstick/config/benchmark-cache-load.properties b/modules/yardstick/config/benchmark-cache-load.properties new file mode 100644 index 0000000..ea25a27 --- /dev/null +++ b/modules/yardstick/config/benchmark-cache-load.properties @@ -0,0 +1,61 @@ +# 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. + +# +# Contains benchmarks for ATOMIC cache. +# + +# JVM options. +JVM_OPTS=${JVM_OPTS}" -DIGNITE_QUIET=false" + +# Uncomment to enable concurrent garbage collection (GC) if you encounter long GC pauses. +# JVM_OPTS=${JVM_OPTS}" \ +# -XX:+UseParNewGC \ +# -XX:+UseConcMarkSweepGC \ +# -XX:+UseTLAB \ +# -XX:NewSize=128m \ +# -XX:MaxNewSize=128m \ +# -XX:MaxTenuringThreshold=0 \ +# -XX:SurvivorRatio=1024 \ +# -XX:+UseCMSInitiatingOccupancyOnly \ +# -XX:CMSInitiatingOccupancyFraction=60 \ +#" + +# List of default probes. +# Add DStatProbe or VmStatProbe if your OS supports it (e.g. if running on Linux). +BENCHMARK_DEFAULT_PROBES=ThroughputLatencyProbe,PercentileProbe + +# Packages where the specified benchmark is searched by reflection mechanism. +BENCHMARK_PACKAGES=org.yardstickframework,org.apache.ignite.yardstick + +# Probe point writer class name. +# BENCHMARK_WRITER= + +# Comma-separated list of the hosts to run BenchmarkServers on. 2 nodes on local host are enabled by default. +SERVER_HOSTS=localhost,localhost + +# Comma-separated list of the hosts to run BenchmarkDrivers on. 1 node on local host is enabled by default. +DRIVER_HOSTS=localhost + +# Remote username. +# REMOTE_USER= + +# Number of nodes, used to wait for the specified number of nodes to start. +nodesNum=$((`echo ${SERVER_HOSTS} | tr ',' '\n' | wc -l` + `echo ${DRIVER_HOSTS} | tr ',' '\n' | wc -l`)) + +# Run configuration. +# Note that each benchmark is set to run for 300 seconds (5 mins) with warm-up set to 60 seconds (1 minute). +CONFIGS="\ +-cfg ${SCRIPT_DIR}/../config/ignite-localhost-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgniteCacheRandomOperationBenchmark -sn IgniteNode -ds atomic-get-1-backup" http://git-wip-us.apache.org/repos/asf/ignite/blob/854357eb/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteBenchmarkArguments.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteBenchmarkArguments.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteBenchmarkArguments.java index 36551cc..4531ed3 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteBenchmarkArguments.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteBenchmarkArguments.java @@ -37,6 +37,7 @@ public class IgniteBenchmarkArguments { @Parameter(names = {"-b", "--backups"}, description = "Backups") private int backups; + /** */ @Parameter(names = {"-cfg", "--Config"}, description = "Configuration file") private String cfg = "config/ignite-localhost-config.xml"; @@ -86,7 +87,11 @@ public class IgniteBenchmarkArguments { /** */ @Parameter(names = {"-r", "--range"}, description = "Key range") - private int range = 1_000_000; + public int range = 1_000_000; + + /** */ + @Parameter(names = {"-pa", "--preloadAmount"}, description = "Data pre-loading amount for load tests") + public int preloadAmount = 500_000; /** */ @Parameter(names = {"-j", "--jobs"}, description = "Number of jobs for compute benchmarks") @@ -260,6 +265,13 @@ public class IgniteBenchmarkArguments { } /** + * @return Preload key range, from {@code 0} to this number. + */ + public int preloadAmount() { + return preloadAmount; + } + + /** * @return Configuration file. */ public String configuration() { http://git-wip-us.apache.org/repos/asf/ignite/blob/854357eb/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/IgniteCacheRandomOperationBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/IgniteCacheRandomOperationBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/IgniteCacheRandomOperationBenchmark.java new file mode 100644 index 0000000..9dae7f8 --- /dev/null +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/IgniteCacheRandomOperationBenchmark.java @@ -0,0 +1,773 @@ +/* + * 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.load; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeMap; +import java.util.TreeSet; +import java.util.UUID; +import java.util.concurrent.Callable; +import java.util.concurrent.ThreadLocalRandom; +import javax.cache.processor.EntryProcessor; +import javax.cache.processor.EntryProcessorException; +import javax.cache.processor.MutableEntry; + +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteCompute; +import org.apache.ignite.IgniteDataStreamer; +import org.apache.ignite.IgniteException; +import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.cache.CacheMemoryMode; +import org.apache.ignite.cache.CacheMode; +import org.apache.ignite.cache.CacheTypeMetadata; +import org.apache.ignite.cache.QueryEntity; +import org.apache.ignite.cache.affinity.Affinity; +import org.apache.ignite.cache.query.QueryCursor; +import org.apache.ignite.cache.query.ScanQuery; +import org.apache.ignite.cluster.ClusterGroup; +import org.apache.ignite.cluster.ClusterNode; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.lang.IgniteBiPredicate; +import org.apache.ignite.lang.IgniteRunnable; +import org.apache.ignite.resources.IgniteInstanceResource; +import org.apache.ignite.transactions.TransactionConcurrency; +import org.apache.ignite.transactions.TransactionIsolation; +import org.apache.ignite.yardstick.IgniteAbstractBenchmark; +import org.apache.ignite.yardstick.IgniteBenchmarkUtils; +import org.apache.ignite.yardstick.cache.load.model.ModelUtil; +import org.springframework.util.CollectionUtils; +import org.yardstickframework.BenchmarkConfiguration; + +/** + * Ignite cache random operation benchmark. + */ +public class IgniteCacheRandomOperationBenchmark extends IgniteAbstractBenchmark { + /** */ + public static final int operations = Operation.values().length; + + /** Scan query predicate. */ + private static BenchmarkIgniteBiPredicate igniteBiPredicate = new BenchmarkIgniteBiPredicate(); + + /** Amount partitions. */ + private static final int SCAN_QUERY_PARTITIN_AMOUNT = 10; + + /** List off all available cache. */ + private List<IgniteCache> availableCaches; + + /** List of available transactional cache. */ + private List<IgniteCache> txCaches; + + /** List of affinity cache. */ + private List<IgniteCache> affCaches; + + /** Map cache name on key classes. */ + private Map<String, Class[]> keysCacheClasses; + + /** Map cache name on value classes. */ + private Map<String, Class[]> valuesCacheClasses; + + /** + * Replace value entry processor. + */ + private BenchmarkReplaceValueEntryProcessor replaceEntryProc; + + /** + * Remove entry processor. + */ + private BenchmarkRemoveEntryProcessor removeEntryProc; + + /** {@inheritDoc} */ + @Override public void setUp(BenchmarkConfiguration cfg) throws Exception { + super.setUp(cfg); + + searchCache(); + + preLoading(); + } + + /** {@inheritDoc} */ + @Override public boolean test(Map<Object, Object> map) throws Exception { + if (nextBoolean()) { + executeInTransaction(); + + executeOutOfTx(true); + } + else + executeOutOfTx(false); + + return true; + } + + /** + * @throws Exception If failed. + */ + private void searchCache() throws Exception { + availableCaches = new ArrayList<>(ignite().cacheNames().size()); + txCaches = new ArrayList<>(); + affCaches = new ArrayList<>(); + keysCacheClasses = new HashMap<>(); + valuesCacheClasses = new HashMap<>(); + replaceEntryProc = new BenchmarkReplaceValueEntryProcessor(null); + removeEntryProc = new BenchmarkRemoveEntryProcessor(); + + for (String cacheName : ignite().cacheNames()) { + IgniteCache<Object, Object> cache = ignite().cache(cacheName); + + CacheConfiguration configuration = cache.getConfiguration(CacheConfiguration.class); + + if (isClassDefinedInConfig(configuration)) { + if (configuration.getMemoryMode() == CacheMemoryMode.OFFHEAP_TIERED) { + throw new IgniteException("Off-heap mode is unsupported by the load test due to bugs IGNITE-2982" + + " and IGNITE-2997"); + } + + ArrayList<Class> keys = new ArrayList<>(); + ArrayList<Class> values = new ArrayList<>(); + + if (configuration.getQueryEntities() != null) { + Collection<QueryEntity> entries = configuration.getQueryEntities(); + + for (QueryEntity queryEntity : entries) { + if (queryEntity.getKeyType() != null) { + Class keyClass = getClass().forName(queryEntity.getKeyType()); + + if (ModelUtil.canCreateInstance(keyClass)) + keys.add(keyClass); + else + throw new IgniteException("Class is unknown for the load test. Make sure you " + + "specified its full name [clsName=" + queryEntity.getKeyType() + ']'); + } + + if (queryEntity.getValueType() != null) { + Class valueClass = getClass().forName(queryEntity.getValueType()); + + if (ModelUtil.canCreateInstance(valueClass)) + values.add(valueClass); + else + throw new IgniteException("Class is unknown for the load test. Make sure you " + + "specified its full name [clsName=" + queryEntity.getKeyType() + ']'); + } + } + } + + if (configuration.getTypeMetadata() != null) { + Collection<CacheTypeMetadata> entries = configuration.getTypeMetadata(); + + for (CacheTypeMetadata cacheTypeMetadata : entries) { + if (cacheTypeMetadata.getKeyType() != null) { + Class keyClass = getClass().forName(cacheTypeMetadata.getKeyType()); + + if (ModelUtil.canCreateInstance(keyClass)) + keys.add(keyClass); + else + throw new IgniteException("Class is unknown for the load test. Make sure you " + + "specified its full name [clsName=" + cacheTypeMetadata.getKeyType() + ']'); + } + + if (cacheTypeMetadata.getValueType() != null) { + Class valueClass = getClass().forName(cacheTypeMetadata.getValueType()); + + if (ModelUtil.canCreateInstance(valueClass)) + values.add(valueClass); + else + throw new IgniteException("Class is unknown for the load test. Make sure you " + + "specified its full name [clsName=" + cacheTypeMetadata.getKeyType() + ']'); + } + } + } + + if (keys.size() == 0 || values.size() == 0) + continue; + + keysCacheClasses.put(cacheName, keys.toArray(new Class[] {})); + valuesCacheClasses.put(cacheName, values.toArray(new Class[] {})); + } + + if (configuration.getCacheMode() != CacheMode.LOCAL) + affCaches.add(cache); + + if (configuration.getAtomicityMode() == CacheAtomicityMode.TRANSACTIONAL) + txCaches.add(cache); + + availableCaches.add(cache); + } + } + + /** + * @param configuration Ignite cache configuration. + * @return True if defined. + */ + private boolean isClassDefinedInConfig(CacheConfiguration configuration) { + return (configuration.getIndexedTypes() != null && configuration.getIndexedTypes().length > 0) + || !CollectionUtils.isEmpty(configuration.getQueryEntities()) + || !CollectionUtils.isEmpty(configuration.getTypeMetadata()); + } + + /** + * @throws Exception If fail. + */ + private void preLoading() throws Exception { + if (args.preloadAmount() > args.range()) + throw new IllegalArgumentException("Preloading amount (\"-pa\", \"--preloadAmount\") must by less then the" + + " range (\"-r\", \"--range\")."); + + Thread[] threads = new Thread[availableCaches.size()]; + + for (int i = 0; i < availableCaches.size(); i++) { + final String cacheName = availableCaches.get(i).getName(); + + threads[i] = new Thread() { + @Override public void run() { + try (IgniteDataStreamer dataLdr = ignite().dataStreamer(cacheName)) { + for (int i = 0; i < args.preloadAmount() && !isInterrupted(); i++) + dataLdr.addData(createRandomKey(i, cacheName), createRandomValue(i, cacheName)); + } + } + }; + + threads[i].start(); + } + + for (Thread thread : threads) { + thread.join(); + } + } + + /** + * Building a map that contains mapping of node ID to a list of partitions stored on the node. + * + * @param cacheName Name of Ignite cache. + * @return Node to partitions map. + */ + private Map<UUID, List<Integer>> personCachePartitions(String cacheName) { + // Getting affinity for person cache. + Affinity affinity = ignite().affinity(cacheName); + + // Building a list of all partitions numbers. + List<Integer> randmPartitions = new ArrayList<>(10); + + if (affinity.partitions() <= SCAN_QUERY_PARTITIN_AMOUNT) + for (int i = 0; i < affinity.partitions(); i++) + randmPartitions.add(i); + else { + for (int i = 0; i < SCAN_QUERY_PARTITIN_AMOUNT; i++) { + int partitionNumber; + + do + partitionNumber = nextRandom(affinity.partitions()); + while (randmPartitions.contains(partitionNumber)); + + randmPartitions.add(partitionNumber); + } + } + + Collections.sort(randmPartitions); + + // Getting partition to node mapping. + Map<Integer, ClusterNode> partPerNodes = affinity.mapPartitionsToNodes(randmPartitions); + + // Building node to partitions mapping. + Map<UUID, List<Integer>> nodesToPart = new HashMap<>(); + + for (Map.Entry<Integer, ClusterNode> entry : partPerNodes.entrySet()) { + List<Integer> nodeParts = nodesToPart.get(entry.getValue().id()); + + if (nodeParts == null) { + nodeParts = new ArrayList<>(); + nodesToPart.put(entry.getValue().id(), nodeParts); + } + + nodeParts.add(entry.getKey()); + } + + return nodesToPart; + } + + /** + * @param id Object identifier. + * @param cacheName Name of Ignite cache. + * @return Random object. + */ + private Object createRandomKey(int id, String cacheName) { + Class clazz = randomKeyClass(cacheName); + + return ModelUtil.create(clazz, id); + } + + /** + * @param cacheName Ignite cache name. + * @return Random key class. + */ + private Class randomKeyClass(String cacheName) { + Class[] keys; + + if (keysCacheClasses.containsKey(cacheName)) + keys = keysCacheClasses.get(cacheName); + else + keys = ModelUtil.keyClasses(); + + return keys[nextRandom(keys.length)]; + } + + /** + * @param id Object identifier. + * @param cacheName Name of Ignite cache. + * @return Random object. + */ + private Object createRandomValue(int id, String cacheName) { + Class clazz = randomValueClass(cacheName); + + return ModelUtil.create(clazz, id); + } + + /** + * @param cacheName Ignite cache name. + * @return Random value class. + */ + private Class randomValueClass(String cacheName) { + Class[] values; + + if (valuesCacheClasses.containsKey(cacheName)) + values = valuesCacheClasses.get(cacheName); + else + values = ModelUtil.valueClasses(); + + return values[nextRandom(values.length)]; + } + + /** + * @param withoutTransactionCache Without transaction cache. + * @throws Exception If fail. + */ + private void executeOutOfTx(boolean withoutTransactionCache) throws Exception { + for (IgniteCache cache : availableCaches) { + if (withoutTransactionCache && txCaches.contains(cache)) + continue; + + executeRandomOperation(cache); + } + } + + /** + * @param cache Ignite cache. + * @throws Exception If fail. + */ + private void executeRandomOperation(IgniteCache cache) throws Exception { + switch (Operation.valueOf(nextRandom(operations))) { + case PUT: + doPut(cache); + break; + + case PUT_ALL: + doPutAll(cache); + break; + + case GET: + doGet(cache); + break; + + case GET_ALL: + doGetAll(cache); + break; + + case INVOKE: + doInvoke(cache); + break; + + case INVOKE_ALL: + doInvokeAll(cache); + break; + + case REMOVE: + doRemove(cache); + break; + + case REMOVE_ALL: + doRemoveAll(cache); + break; + + case PUT_IF_ABSENT: + doPutIfAbsent(cache); + break; + + case REPLACE: + doReplace(cache); + break; + + case SCAN_QUERY: + doScanQuery(cache); + } + } + + /** + * Execute operations in transaction. + * + * @throws Exception if fail. + */ + private void executeInTransaction() throws Exception { + IgniteBenchmarkUtils.doInTransaction(ignite().transactions(), + TransactionConcurrency.fromOrdinal(nextRandom(TransactionConcurrency.values().length)), + TransactionIsolation.fromOrdinal(nextRandom(TransactionIsolation.values().length)), + + new Callable<Object>() { + @Override + public Object call() throws Exception { + for (IgniteCache cache : txCaches) + if (nextBoolean()) + executeRandomOperation(cache); + + return null; + } + }); + } + + /** + * @param cache Ignite cache. + * @throws Exception If failed. + */ + private void doPut(IgniteCache cache) throws Exception { + int i = nextRandom(args.range()); + + cache.put(createRandomKey(i, cache.getName()), createRandomValue(i, cache.getName())); + } + + /** + * @param cache Ignite cache. + * @throws Exception If failed. + */ + private void doPutAll(IgniteCache cache) throws Exception { + Map putMap = new TreeMap(); + Class keyCass = randomKeyClass(cache.getName()); + + for (int cnt = 0; cnt < args.batch(); cnt++) { + int i = nextRandom(args.range()); + + putMap.put(ModelUtil.create(keyCass, i), createRandomValue(i, cache.getName())); + } + + cache.putAll(putMap); + } + + /** + * @param cache Ignite cache. + * @throws Exception If failed. + */ + private void doGet(IgniteCache cache) throws Exception { + int i = nextRandom(args.range()); + + cache.get(createRandomKey(i, cache.getName())); + } + + /** + * @param cache Ignite cache. + * @throws Exception If failed. + */ + private void doGetAll(IgniteCache cache) throws Exception { + Set keys = new TreeSet(); + + Class keyClass = randomKeyClass(cache.getName()); + + for (int cnt = 0; cnt < args.batch(); cnt++) { + int i = nextRandom(args.range()); + + keys.add(ModelUtil.create(keyClass, i)); + } + + cache.getAll(keys); + } + + /** + * @param cache Ignite cache. + * @throws Exception If failed. + */ + private void doInvoke(final IgniteCache cache) throws Exception { + final int i = nextRandom(args.range()); + + if (nextBoolean()) + cache.invoke(createRandomKey(i, cache.getName()), replaceEntryProc, + createRandomValue(i + 1, cache.getName())); + else + cache.invoke(createRandomKey(i, cache.getName()), removeEntryProc); + + } + + /** + * Entry processor for local benchmark replace value task. + */ + private static class BenchmarkReplaceValueEntryProcessor implements EntryProcessor, Serializable { + + /** + * New value for update during process by default. + */ + private Object newValue; + + /** + * @param newValue default new value + */ + public BenchmarkReplaceValueEntryProcessor(Object newValue) { + this.newValue = newValue; + } + + @Override + public Object process(MutableEntry entry, Object... arguments) throws EntryProcessorException { + Object newValue = arguments == null || arguments[0] == null ? this.newValue : arguments[0]; + Object oldValue = entry.getValue(); + entry.setValue(newValue); + + return oldValue; + } + } + + /** + * Entry processor for local benchmark remove entry task. + */ + private static class BenchmarkRemoveEntryProcessor implements EntryProcessor, Serializable { + + @Override + public Object process(MutableEntry entry, Object... arguments) throws EntryProcessorException { + Object oldValue = entry.getValue(); + entry.remove(); + + return oldValue; + } + } + + /** + * @param cache Ignite cache. + * @throws Exception If failed. + */ + private void doInvokeAll(final IgniteCache cache) throws Exception { + Map<Object, EntryProcessor> map = new TreeMap<>(); + + Class keyClass = randomKeyClass(cache.getName()); + + for (int cnt = 0; cnt < args.batch(); cnt++) { + int i = nextRandom(args.range()); + Object key = ModelUtil.create(keyClass, i); + + if (nextBoolean()) + map.put(key, + new BenchmarkReplaceValueEntryProcessor(createRandomValue(i + 1, cache.getName()))); + else + map.put(key, removeEntryProc); + } + + cache.invokeAll(map); + } + + /** + * @param cache Ignite cache. + * @throws Exception If failed. + */ + private void doRemove(IgniteCache cache) throws Exception { + int i = nextRandom(args.range()); + + cache.remove(createRandomKey(i, cache.getName())); + } + + /** + * @param cache Ignite cache. + * @throws Exception If failed. + */ + private void doRemoveAll(IgniteCache cache) throws Exception { + Set keys = new TreeSet(); + Class keyClass = randomKeyClass(cache.getName()); + + for (int cnt = 0; cnt < args.batch(); cnt++) { + int i = nextRandom(args.range()); + + keys.add(ModelUtil.create(keyClass, i)); + } + + cache.removeAll(keys); + } + + /** + * @param cache Ignite cache. + * @throws Exception If failed. + */ + private void doPutIfAbsent(IgniteCache cache) throws Exception { + int i = nextRandom(args.range()); + + cache.putIfAbsent(createRandomKey(i, cache.getName()), createRandomValue(i, cache.getName())); + } + + /** + * @param cache Ignite cache. + * @throws Exception If failed. + */ + private void doReplace(IgniteCache cache) throws Exception { + int i = nextRandom(args.range()); + + cache.replace(createRandomKey(i, cache.getName()), + createRandomValue(i, cache.getName()), + createRandomValue(i + 1, cache.getName())); + } + + /** + * @param cache Ignite cache. + * @throws Exception If failed. + */ + private void doScanQuery(IgniteCache cache) throws Exception { + if (!affCaches.contains(cache)) + return; + + Map<UUID, List<Integer>> partitionsMap = personCachePartitions(cache.getName()); + + ScanQueryBroadcastClosure closure = new ScanQueryBroadcastClosure(cache.getName(), partitionsMap); + + ClusterGroup clusterGroup = ignite().cluster().forNodeIds(partitionsMap.keySet()); + + IgniteCompute compute = ignite().compute(clusterGroup); + + compute.broadcast(closure); + } + + /** + * Closure for scan query executing. + */ + private static class ScanQueryBroadcastClosure implements IgniteRunnable { + + /** + * Ignite node. + */ + @IgniteInstanceResource + private Ignite node; + + /** + * Information about partition. + */ + private Map<UUID, List<Integer>> cachePartition; + + /** + * Name of Ignite cache. + */ + private String cacheName; + + /** + * @param cacheName Name of Ignite cache. + * @param cachePartition Partition by node for Ignite cache. + */ + public ScanQueryBroadcastClosure(String cacheName, Map<UUID, List<Integer>> cachePartition) { + this.cachePartition = cachePartition; + this.cacheName = cacheName; + } + + @Override + public void run() { + + IgniteCache cache = node.cache(cacheName); + + // Getting a list of the partitions owned by this node. + List<Integer> myPartitions = cachePartition.get(node.cluster().localNode().id()); + + for (Integer part : myPartitions) { + if (ThreadLocalRandom.current().nextBoolean()) + continue; + + ScanQuery scanQuery = new ScanQuery(); + + scanQuery.setPartition(part); + scanQuery.setFilter(igniteBiPredicate); + + try (QueryCursor cursor = cache.query(scanQuery)) { + for (Object obj : cursor) + ; + } + + } + } + } + + /** + * Scan query predicate class. + */ + private static class BenchmarkIgniteBiPredicate implements IgniteBiPredicate { + + /** + * @param key Cache key. + * @param val Cache value. + * @return true If is hit. + */ + @Override + public boolean apply(Object key, Object val) { + return val.hashCode() % 45 == 0; + } + } + + /** + * @return Nex random boolean value. + */ + protected boolean nextBoolean() { + return ThreadLocalRandom.current().nextBoolean(); + } + + /** + * Cache operation enum. + */ + static enum Operation { + /** Put operation. */ + PUT, + + /** Put all operation. */ + PUT_ALL, + + /** Get operation. */ + GET, + + /** Get all operation. */ + GET_ALL, + + /** Invoke operation. */ + INVOKE, + + /** Invoke all operation. */ + INVOKE_ALL, + + /** Remove operation. */ + REMOVE, + + /** Remove all operation. */ + REMOVE_ALL, + + /** Put if absent operation. */ + PUT_IF_ABSENT, + + /** Replace operation. */ + REPLACE, + + /** Scan query operation. */ + SCAN_QUERY; + + /** + * @param num Number of operation. + * @return Operation. + */ + public static Operation valueOf(int num) { + return values()[num]; + } + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/854357eb/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/model/ModelUtil.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/model/ModelUtil.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/model/ModelUtil.java new file mode 100644 index 0000000..f6d96b3 --- /dev/null +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/model/ModelUtil.java @@ -0,0 +1,148 @@ +/* + * 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.load.model; + +import org.apache.ignite.yardstick.cache.load.model.key.Identifier; +import org.apache.ignite.yardstick.cache.load.model.key.Mark; +import org.apache.ignite.yardstick.cache.load.model.value.Car; +import org.apache.ignite.yardstick.cache.load.model.value.Color; +import org.apache.ignite.yardstick.cache.load.model.value.Truck; +import org.apache.ignite.yardstick.cache.model.Account; +import org.apache.ignite.yardstick.cache.model.Organization; +import org.apache.ignite.yardstick.cache.model.Person; +import org.apache.ignite.yardstick.cache.model.Person1; +import org.apache.ignite.yardstick.cache.model.Person2; +import org.apache.ignite.yardstick.cache.model.Person8; + +import java.util.UUID; + +/** + * Util class for model. + */ +public class ModelUtil { + /** + * Classes of keys. + */ + private static Class[] keyClasses = { + Double.class, + Identifier.class, +// Mark.class, + Integer.class, +// UUID.class + }; + + /** + * Classes of values. + */ + private static Class[] valueClasses = { + Car.class, + Truck.class, + Person.class, + Organization.class, + Account.class, + Person1.class, + Person2.class, + Person8.class + }; + + /** + * @param clazz Checked class. + * @return Result. + */ + public static boolean canCreateInstance(Class clazz) { + for (Class c: keyClasses) { + if (c.equals(clazz)) + return true; + } + + for (Class c: valueClasses) { + if (c.equals(clazz)) + return true; + } + + return false; + } + + /** + * @param c model class + * @param id object id + * @return object from model + */ + public static Object create(Class c, int id) { + Object result = null; + + switch (c.getSimpleName()) { + case "Double": + result = Double.valueOf(id); + break; + case "Identifier": + result = new Identifier(id, "id " + id); + break; + case "Mark": + result = new Mark(id, UUID.nameUUIDFromBytes(Integer.toString(id).getBytes())); + break; + case "Integer": + result = id; + break; + case "UUID": + result = UUID.nameUUIDFromBytes(Integer.toString(id).getBytes()); + break; + case "Car": + int colorCnt = Color.values().length; + result = new Car(id, "Mark " + id, id/2.123 * 100, Color.values()[id % colorCnt]); + break; + case "Truck": + int colors = Color.values().length; + result = new Truck(id, "Mark " + id, id/2.123 * 100, Color.values()[id % colors], id/4.123 * 100); + break; + case "Person": + result = new Person(id, "First Name " + id, "Last Name " + id, id/2.123 * 100); + break; + case "Organization": + result = new Organization(id, "Organization " + id); + break; + case "Account": + result = new Account(id); + break; + case "Person1": + result = new Person1(id); + break; + case "Person2": + result = new Person2(id); + break; + case "Person8": + result = new Person8(id); + } + + return result; + } + + /** + * @return array of key cache classes + */ + public static Class[] keyClasses() { + return keyClasses; + } + + /** + * @return array of value chache classes + */ + public static Class[] valueClasses() { + return valueClasses; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/854357eb/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/model/key/Identifier.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/model/key/Identifier.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/model/key/Identifier.java new file mode 100644 index 0000000..1cb58ba --- /dev/null +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/model/key/Identifier.java @@ -0,0 +1,106 @@ +/* + * 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.load.model.key; + +import java.io.Serializable; + +/** + * Key cache class + */ +public class Identifier implements Comparable<Identifier>, Serializable { + + /** + * Integer identifier + */ + private int id; + + /** + * String identifier + */ + private String code; + + /** + * Empty constructor + */ + public Identifier() { + } + + /** + * @param id identifier + * @param code code + */ + public Identifier(int id, String code) { + this.id = id; + this.code = code; + } + + /** + * @return integer identifier + */ + public int getId() { + + return id; + } + + /** + * @param id integer identifier + */ + public void setId(int id) { + this.id = id; + } + + /** + * @return string identifier + */ + public String getCode() { + return code; + } + + /** + * @param code string identifier + */ + public void setCode(String code) { + this.code = code; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + Identifier that = (Identifier)o; + + if (id != that.id) + return false; + return code != null ? code.equals(that.code) : that.code == null; + + } + + @Override + public int hashCode() { + int result = id; + result = 31 * result + (code != null ? code.hashCode() : 0); + return result; + } + + @Override public int compareTo(Identifier o) { + return id - o.id; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/854357eb/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/model/key/Mark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/model/key/Mark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/model/key/Mark.java new file mode 100644 index 0000000..614df86 --- /dev/null +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/model/key/Mark.java @@ -0,0 +1,104 @@ +/* + * 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.load.model.key; + +import java.io.Serializable; +import java.util.UUID; + +/** + * Cache value class + */ +public class Mark implements Comparable<Mark>, Serializable { + + /** + * Mark identifier + */ + private int id; + + /** + * Mark token + */ + private UUID token; + + /** + * Empty constructor + */ + public Mark() { + } + + /** + * @param id identifier + * @param token token + */ + public Mark(int id, UUID token) { + this.id = id; + this.token = token; + } + + /** + * @return mark identifier + */ + public int getId() { + return id; + } + + /** + * @param id mark identifier + */ + public void setId(int id) { + this.id = id; + } + + /** + * @return mark token + */ + public UUID getToken() { + return token; + } + + /** + * @param token mark token + */ + public void setToken(UUID token) { + this.token = token; + } + + @Override public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + Mark mark = (Mark)o; + + if (id != mark.id) + return false; + return token != null ? token.equals(mark.token) : mark.token == null; + + } + + @Override public int hashCode() { + int result = id; + result = 31 * result + (token != null ? token.hashCode() : 0); + return result; + } + + @Override public int compareTo(Mark o) { + return id - o.id; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/854357eb/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/model/value/Car.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/model/value/Car.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/model/value/Car.java new file mode 100644 index 0000000..3824afa --- /dev/null +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/model/value/Car.java @@ -0,0 +1,121 @@ +/* + * 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.load.model.value; + +import java.io.Serializable; + +/** + * Value cache class + */ +public class Car implements Serializable { + + /** + * Car identifier + */ + int id; + + /** + * Car make + */ + String make; + + /** + * Car weight + */ + double weight; + + /** + * Car color + */ + Color color; + + /** + * Empty constructor + */ + public Car() { + } + + /** + * @param id identifier + * @param make mark of car + * @param weight weight + * @param color car color + */ + public Car(int id, String make, double weight, Color color) { + this.id = id; + this.make = make; + this.weight = weight; + this.color = color; + } + + /** + * @return car identifier + */ + public int getId() { + return id; + } + + /** + * @param id car identifier + */ + public void setId(int id) { + this.id = id; + } + + /** + * @return car make + */ + public String getMake() { + return make; + } + + /** + * @param make car make + */ + public void setMake(String make) { + this.make = make; + } + + /** + * @return car weight + */ + public double getWeight() { + return weight; + } + + /** + * @param weight car weight + */ + public void setWeight(double weight) { + this.weight = weight; + } + + /** + * @return color + */ + public Color getColor() { + return color; + } + + /** + * @param color color + */ + public void setColor(Color color) { + this.color = color; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/854357eb/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/model/value/Color.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/model/value/Color.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/model/value/Color.java new file mode 100644 index 0000000..23e5008 --- /dev/null +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/model/value/Color.java @@ -0,0 +1,48 @@ +/* + * 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.load.model.value; + +import java.io.Serializable; + +/** + * Car color + */ +public enum Color implements Serializable { + + /** + * grey color + */ + GREY, + + /** + * red color + */ + RED, + /** + * gren color + */ + GREEN, + /** + * purple color + */ + PURPLE, + /** + * light blue color + */ + LIGHTBLUE +} http://git-wip-us.apache.org/repos/asf/ignite/blob/854357eb/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/model/value/Truck.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/model/value/Truck.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/model/value/Truck.java new file mode 100644 index 0000000..a89f8b5 --- /dev/null +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/load/model/value/Truck.java @@ -0,0 +1,62 @@ +/* + * 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.load.model.value; + +import java.io.Serializable; + +/** + * Cache value class + */ +public class Truck extends Car implements Serializable { + + /** + * Truck capacity + */ + public double capacity; + + /** + * Empty constructor + */ + public Truck() { + } + + /** + * @param id identifier + * @param make mark of truck + * @param weight weight + * @param capacity capacity + */ + public Truck(int id, String make, double weight, Color color, double capacity) { + super(id, make, weight, color); + this.capacity = capacity; + } + + /** + * @return truck capacity + */ + public double getCapacity() { + return capacity; + } + + /** + * @param capacity truck capacity + */ + public void setCapacity(double capacity) { + this.capacity = capacity; + } +}
