Skip to content

Commit

Permalink
gg-11253: load tests based on SB cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Denis Magda committed Jul 6, 2016
1 parent aabe815 commit f267a30
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 75 deletions.
46 changes: 25 additions & 21 deletions modules/yardstick/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>
Expand All @@ -168,28 +168,10 @@
<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>
Expand All @@ -198,6 +180,28 @@
<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>
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -217,26 +217,34 @@ private void searchCache() throws Exception {
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>());
}
}
}
Expand All @@ -245,31 +253,36 @@ private void searchCache() throws Exception {
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[] {}));
Expand Down Expand Up @@ -857,25 +870,53 @@ private void doScanQuery(IgniteCache<Object, Object> cache) throws Exception {
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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public class ModelUtil {
Identifier.class,
Mark.class,
Integer.class,
UUID.class
UUID.class,
String.class
};

/**
Expand Down Expand Up @@ -146,6 +147,9 @@ public static Object create(Class c, int id) {
break;
case "Person8":
res = new Person8(id);
break;
case "String":
res = String.valueOf(id);
}

return res;
Expand Down

0 comments on commit f267a30

Please sign in to comment.