gg-11253: load tests based on SB cases
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/f267a304 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/f267a304 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/f267a304 Branch: refs/heads/ignite-1232 Commit: f267a3042d79969405f957301bfb4ad462c7344f Parents: aabe815 Author: Denis Magda <[email protected]> Authored: Wed Jul 6 13:05:14 2016 +0300 Committer: Denis Magda <[email protected]> Committed: Wed Jul 6 13:05:14 2016 +0300 ---------------------------------------------------------------------- modules/yardstick/pom.xml | 46 +++--- .../IgniteCacheRandomOperationBenchmark.java | 147 ++++++++++++------- .../yardstick/cache/load/model/ModelUtil.java | 6 +- 3 files changed, 124 insertions(+), 75 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/f267a304/modules/yardstick/pom.xml ---------------------------------------------------------------------- diff --git a/modules/yardstick/pom.xml b/modules/yardstick/pom.xml index a0f7de5..51d714e 100644 --- a/modules/yardstick/pom.xml +++ b/modules/yardstick/pom.xml @@ -137,7 +137,7 @@ <goal>copy-dependencies</goal> </goals> <configuration> - <outputDirectory>${basedir}/libs</outputDirectory> + <outputDirectory>${basedir}/target/assembly/libs</outputDirectory> <excludeTypes>pom</excludeTypes> </configuration> </execution> @@ -155,7 +155,7 @@ <version>${yardstick.version}</version> <type>zip</type> <classifier>resources</classifier> - <outputDirectory>${basedir}</outputDirectory> + <outputDirectory>${basedir}/target/assembly</outputDirectory> </artifactItem> </artifactItems> </configuration> @@ -168,36 +168,40 @@ <artifactId>maven-jar-plugin</artifactId> <version>2.4</version> <configuration> - <outputDirectory>${basedir}/libs</outputDirectory> + <outputDirectory>${basedir}/target/assembly/libs</outputDirectory> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-clean-plugin</artifactId> - <version>2.5</version> - <configuration> - <filesets> - <fileset> - <directory>${basedir}/bin</directory> - </fileset> - <fileset> - <directory>${basedir}/libs</directory> - <includes> - <include>**/*.jar</include> - </includes> - </fileset> - </filesets> - </configuration> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> <version>2.9.1</version> <configuration> <skip>true</skip> </configuration> </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-antrun-plugin</artifactId> + <version>1.7</version> + <executions> + <execution> + <id>copy-yardstick-cfg-ignite</id> + <goals> + <goal>run</goal> + </goals> + <phase>validate</phase> + <configuration> + <target> + <copy todir="${basedir}/target/assembly/config"> + <fileset dir="${basedir}/config" /> + </copy> + </target> + </configuration> + </execution> + </executions> + </plugin> </plugins> </build> </project> http://git-wip-us.apache.org/repos/asf/ignite/blob/f267a304/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 index e676b38..c2947ba 100644 --- 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 @@ -141,7 +141,7 @@ public class IgniteCacheRandomOperationBenchmark extends IgniteAbstractBenchmark /** {@inheritDoc} */ @Override public void onException(Throwable e) { - BenchmarkUtils.errorHelp(cfg, "The benchmark of random operation failed."); + BenchmarkUtils.error("The benchmark of random operation failed.", e); super.onException(e); } @@ -217,26 +217,34 @@ public class IgniteCacheRandomOperationBenchmark extends IgniteAbstractBenchmark Collection<QueryEntity> entries = configuration.getQueryEntities(); for (QueryEntity queryEntity : entries) { - if (queryEntity.getKeyType() != null) { - Class keyCls = Class.forName(queryEntity.getKeyType()); - - if (ModelUtil.canCreateInstance(keyCls)) - keys.add(keyCls); - 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 valCls = Class.forName(queryEntity.getValueType()); - - if (ModelUtil.canCreateInstance(valCls)) - values.add(valCls); - else - throw new IgniteException("Class is unknown for the load test. Make sure you " + - "specified its full name [clsName=" + queryEntity.getKeyType() + ']'); - - cofigureCacheSqlDescriptor(cacheName, queryEntity, valCls); + try { + if (queryEntity.getKeyType() != null) { + Class keyCls = Class.forName(queryEntity.getKeyType()); + + if (ModelUtil.canCreateInstance(keyCls)) + keys.add(keyCls); + 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 valCls = Class.forName(queryEntity.getValueType()); + + if (ModelUtil.canCreateInstance(valCls)) + values.add(valCls); + else + throw new IgniteException("Class is unknown for the load test. Make sure you " + + "specified its full name [clsName=" + queryEntity.getKeyType() + ']'); + + cofigureCacheSqlDescriptor(cacheName, queryEntity, valCls); + } + } catch (ClassNotFoundException e) { + BenchmarkUtils.println(e.getMessage()); + BenchmarkUtils.println("This can be a BinaryObject. Ignoring exception."); + + if (!cacheSqlDescriptors.containsKey(cacheName)) + cacheSqlDescriptors.put(cacheName, new ArrayList<SqlCacheDescriptor>()); } } } @@ -245,31 +253,36 @@ public class IgniteCacheRandomOperationBenchmark extends IgniteAbstractBenchmark Collection<CacheTypeMetadata> entries = configuration.getTypeMetadata(); for (CacheTypeMetadata cacheTypeMetadata : entries) { - if (cacheTypeMetadata.getKeyType() != null) { - Class keyCls = Class.forName(cacheTypeMetadata.getKeyType()); - - if (ModelUtil.canCreateInstance(keyCls)) - keys.add(keyCls); - 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 valCls = Class.forName(cacheTypeMetadata.getValueType()); - - if (ModelUtil.canCreateInstance(valCls)) - values.add(valCls); - else - throw new IgniteException("Class is unknown for the load test. Make sure you " + - "specified its full name [clsName=" + cacheTypeMetadata.getKeyType() + ']'); + try { + if (cacheTypeMetadata.getKeyType() != null) { + Class keyCls = Class.forName(cacheTypeMetadata.getKeyType()); + + if (ModelUtil.canCreateInstance(keyCls)) + keys.add(keyCls); + 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 valCls = Class.forName(cacheTypeMetadata.getValueType()); + + if (ModelUtil.canCreateInstance(valCls)) + values.add(valCls); + else + throw new IgniteException("Class is unknown for the load test. Make sure you " + + "specified its full name [clsName=" + cacheTypeMetadata.getKeyType() + ']'); + } + } catch (ClassNotFoundException e) { + BenchmarkUtils.println(e.getMessage()); + BenchmarkUtils.println("This can be a BinaryObject. Ignoring exception."); + + if (!cacheSqlDescriptors.containsKey(cacheName)) + cacheSqlDescriptors.put(cacheName, new ArrayList<SqlCacheDescriptor>()); } } } - if (keys.isEmpty() || values.isEmpty()) - continue; - keysCacheClasses.put(cacheName, keys.toArray(new Class[] {})); valuesCacheClasses.put(cacheName, values.toArray(new Class[] {})); @@ -857,26 +870,54 @@ public class IgniteCacheRandomOperationBenchmark extends IgniteAbstractBenchmark private void doSqlQuery(IgniteCache<Object, Object> cache) throws Exception { List<SqlCacheDescriptor> descriptors = cacheSqlDescriptors.get(cache.getName()); - if (descriptors != null && !descriptors.isEmpty()) { - SqlCacheDescriptor randomDesc = descriptors.get(nextRandom(descriptors.size())); + if (descriptors != null) { + Query sq = null; - int id = nextRandom(args.range()); + if (queries.isEmpty()) { + if (!descriptors.isEmpty()) { + SqlCacheDescriptor randomDesc = descriptors.get(nextRandom(descriptors.size())); - Query sq; - if (queries.isEmpty()) - sq = nextBoolean() ? randomDesc.getSqlQuery(id) : randomDesc.getSqlFieldsQuery(id); - else - sq = new SqlFieldsQuery(queries.get(nextRandom(queries.size()))); + int id = nextRandom(args.range()); - try (QueryCursor cursor = cache.query(sq)) { - for (Object obj : cursor) { - // No-op. + sq = nextBoolean() ? randomDesc.getSqlQuery(id) : randomDesc.getSqlFieldsQuery(id); } } + else { + String sql = rendomizeSql(); + + BenchmarkUtils.println(sql); + + sq = new SqlFieldsQuery(sql); + } + + if (sq != null) + try (QueryCursor cursor = cache.query(sq)) { + for (Object obj : cursor) { + // No-op. + } + } } } /** + * @return SQL string. + */ + private String rendomizeSql() { + String sql = queries.get(nextRandom(queries.size())); + + int count = StringUtils.countOccurrencesOf(sql, "%s"); + + Integer[] sub = new Integer[count]; + + for (int i=0; i<count; i++) + sub[i] = nextRandom(args.range()); + + sql = String.format(sql, sub); + + return sql; + } + + /** * @param cache Ignite cache. * @param map Parameters map. * @throws Exception If failed. http://git-wip-us.apache.org/repos/asf/ignite/blob/f267a304/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 index e21e6b4..9268cdd 100644 --- 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 @@ -42,7 +42,8 @@ public class ModelUtil { Identifier.class, Mark.class, Integer.class, - UUID.class + UUID.class, + String.class }; /** @@ -146,6 +147,9 @@ public class ModelUtil { break; case "Person8": res = new Person8(id); + break; + case "String": + res = String.valueOf(id); } return res;
