use of org.apache.ignite.yardstick.cache.model.SampleValue in project ignite by apache.
the class IgniteGetBenchmark method setUp.
/** {@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\").");
String cacheName = cache().getName();
println(cfg, "Loading data for cache: " + cacheName);
long start = System.nanoTime();
try (IgniteDataStreamer<Object, Object> dataLdr = ignite().dataStreamer(cacheName)) {
for (int i = 0; i < args.preloadAmount(); i++) {
dataLdr.addData(i, new SampleValue(i));
if (i % 100000 == 0) {
if (Thread.currentThread().isInterrupted())
break;
println("Loaded entries: " + i);
}
}
}
println(cfg, "Finished populating query data in " + ((System.nanoTime() - start) / 1_000_000) + " ms.");
}
use of org.apache.ignite.yardstick.cache.model.SampleValue in project ignite by apache.
the class IgniteStreamerBenchmark method setUp.
/**
* {@inheritDoc}
*/
@Override
public void setUp(BenchmarkConfiguration cfg) throws Exception {
super.setUp(cfg);
entries = args.range();
if (entries <= 0)
throw new IllegalArgumentException("Invalid number of entries: " + entries);
if (cfg.threads() != 1)
throw new IllegalArgumentException("IgniteStreamerBenchmark should be run with single thread. " + "Internally it starts multiple threads.");
String cacheNamePrefix = args.streamerCachesPrefix();
if (cacheNamePrefix == null || cacheNamePrefix.isEmpty())
throw new IllegalArgumentException("Streamer caches prefix not set.");
List<String> caches = new ArrayList<>();
for (String cacheName : ignite().cacheNames()) {
if (cacheName.startsWith(cacheNamePrefix))
caches.add(cacheName);
}
if (caches.isEmpty())
throw new IllegalArgumentException("Failed to find for IgniteStreamerBenchmark caches " + "starting with '" + cacheNamePrefix + "'");
BenchmarkUtils.println("Found " + caches.size() + " caches for IgniteStreamerBenchmark: " + caches);
if (args.streamerCacheIndex() >= caches.size()) {
throw new IllegalArgumentException("Invalid streamer cache index: " + args.streamerCacheIndex() + ", there are only " + caches.size() + " caches.");
}
if (args.streamerCacheIndex() + args.streamerConcurrentCaches() > caches.size()) {
throw new IllegalArgumentException("There are no enough caches [cacheIndex=" + args.streamerCacheIndex() + ", concurrentCaches=" + args.streamerConcurrentCaches() + ", totalCaches=" + caches.size() + ']');
}
Collections.sort(caches);
cacheNames = new ArrayList<>(caches.subList(args.streamerCacheIndex(), args.streamerCacheIndex() + args.streamerConcurrentCaches()));
executor = Executors.newFixedThreadPool(args.streamerConcurrentCaches());
BenchmarkUtils.println("IgniteStreamerBenchmark start [cacheIndex=" + args.streamerCacheIndex() + ", concurrentCaches=" + args.streamerConcurrentCaches() + ", entries=" + entries + ", bufferSize=" + args.streamerBufferSize() + ", cachesToUse=" + cacheNames + ']');
if (cfg.warmup() > 0) {
BenchmarkUtils.println("IgniteStreamerBenchmark start warmup [warmupTimeMillis=" + cfg.warmup() + ']');
final long warmupEnd = System.currentTimeMillis() + cfg.warmup();
final AtomicBoolean stop = new AtomicBoolean();
try {
List<Future<Void>> futs = new ArrayList<>();
for (final String cacheName : cacheNames) {
futs.add(executor.submit(new Callable<Void>() {
@Override
public Void call() throws Exception {
Thread.currentThread().setName("streamer-" + cacheName);
BenchmarkUtils.println("IgniteStreamerBenchmark start warmup for cache " + "[name=" + cacheName + ']');
final int KEYS = Math.min(100_000, entries);
int key = 1;
try (IgniteDataStreamer<Object, Object> streamer = ignite().dataStreamer(cacheName)) {
streamer.perNodeBufferSize(args.streamerBufferSize());
while (System.currentTimeMillis() < warmupEnd && !stop.get()) {
for (int i = 0; i < 10; i++) {
streamer.addData(-key++, new SampleValue(key));
if (key >= KEYS)
key = 1;
}
streamer.flush();
}
}
BenchmarkUtils.println("IgniteStreamerBenchmark finished warmup for cache " + "[name=" + cacheName + ']');
return null;
}
}));
}
for (Future<Void> fut : futs) fut.get();
} finally {
stop.set(true);
}
}
}
use of org.apache.ignite.yardstick.cache.model.SampleValue in project ignite by apache.
the class IgniteStreamerBenchmark method test.
/**
* {@inheritDoc}
*/
@Override
public boolean test(Map<Object, Object> map) throws Exception {
BenchmarkUtils.println("IgniteStreamerBenchmark start test.");
long start = System.currentTimeMillis();
final AtomicBoolean stop = new AtomicBoolean();
try {
List<Future<Void>> futs = new ArrayList<>();
for (final String cacheName : cacheNames) {
futs.add(executor.submit(new Callable<Void>() {
@Override
public Void call() throws Exception {
Thread.currentThread().setName("streamer-" + cacheName);
long start = System.currentTimeMillis();
BenchmarkUtils.println("IgniteStreamerBenchmark start load cache [name=" + cacheName + ']');
try (IgniteDataStreamer<Object, Object> streamer = ignite().dataStreamer(cacheName)) {
for (int i = 0; i < entries; i++) {
streamer.addData(i, new SampleValue(i));
if (i > 0 && i % 1000 == 0) {
if (stop.get())
break;
if (i % 100_000 == 0) {
BenchmarkUtils.println("IgniteStreamerBenchmark cache load progress [name=" + cacheName + ", entries=" + i + ", timeMillis=" + (System.currentTimeMillis() - start) + ']');
}
}
}
}
long time = System.currentTimeMillis() - start;
BenchmarkUtils.println("IgniteStreamerBenchmark finished load cache [name=" + cacheName + ", entries=" + entries + ", bufferSize=" + args.streamerBufferSize() + ", totalTimeMillis=" + time + ']');
return null;
}
}));
}
for (Future<Void> fut : futs) fut.get();
} finally {
stop.set(true);
}
long time = System.currentTimeMillis() - start;
BenchmarkUtils.println("IgniteStreamerBenchmark finished [totalTimeMillis=" + time + ", entries=" + entries + ", bufferSize=" + args.streamerBufferSize() + ']');
for (String cacheName : cacheNames) {
BenchmarkUtils.println("Cache size [cacheName=" + cacheName + ", size=" + ignite().cache(cacheName).size() + ']');
}
return false;
}
use of org.apache.ignite.yardstick.cache.model.SampleValue in project ignite by apache.
the class IgniteJdbcStorePutBenchmark method test.
/**
* {@inheritDoc}
*/
@Override
public boolean test(Map<Object, Object> ctx) throws Exception {
int id = nextRandom(args.range());
cache.put(new SampleKey(id), new SampleValue(id));
return true;
}
use of org.apache.ignite.yardstick.cache.model.SampleValue in project ignite by apache.
the class IgniteJdbcStorePutGetTxBenchmark method test.
/**
* {@inheritDoc}
*/
@Override
public boolean test(Map<Object, Object> ctx) throws Exception {
int id = nextRandom(args.range());
Object val = cache.get(new SampleKey(id));
if (val != null)
id = nextRandom(args.range());
cache.put(new SampleKey(id), new SampleValue(id));
return true;
}
Aggregations