use of org.apache.ignite.internal.processors.cache.CacheEntryImpl in project ignite by apache.
the class TestsHelper method generateOrdersPerProductEntries.
/** */
public static Map<Long, List<CacheEntryImpl<Long, ProductOrder>>> generateOrdersPerProductEntries(Collection<CacheEntryImpl<Long, Product>> products, int ordersPerProductCount) {
Map<Long, List<CacheEntryImpl<Long, ProductOrder>>> map = new HashMap<>();
for (CacheEntryImpl<Long, Product> entry : products) {
List<CacheEntryImpl<Long, ProductOrder>> orders = new LinkedList<>();
for (long i = 0; i < ordersPerProductCount; i++) {
ProductOrder order = generateRandomOrder(entry.getKey());
orders.add(new CacheEntryImpl<>(order.getId(), order));
}
map.put(entry.getKey(), orders);
}
return map;
}
use of org.apache.ignite.internal.processors.cache.CacheEntryImpl in project ignite by apache.
the class TestsHelper method generateOrderEntries.
/** */
public static Collection<CacheEntryImpl<Long, ProductOrder>> generateOrderEntries() {
Collection<CacheEntryImpl<Long, ProductOrder>> entries = new LinkedList<>();
for (long i = 0; i < BULK_OPERATION_SIZE; i++) {
ProductOrder order = generateRandomOrder(i);
entries.add(new CacheEntryImpl<>(order.getId(), order));
}
return entries;
}
use of org.apache.ignite.internal.processors.cache.CacheEntryImpl in project ignite by apache.
the class TestsHelper method generatePersonIdsPersonsEntries.
/** */
public static Collection<CacheEntryImpl<PersonId, Person>> generatePersonIdsPersonsEntries(int cnt) {
Collection<CacheEntryImpl<PersonId, Person>> entries = new LinkedList<>();
for (int i = 0; i < cnt; i++) {
PersonId id = generateRandomPersonId();
entries.add(new CacheEntryImpl<>(id, generateRandomPerson(id.getPersonNumber())));
}
return entries;
}
use of org.apache.ignite.internal.processors.cache.CacheEntryImpl in project ignite by apache.
the class Worker method execute.
/** */
@SuppressWarnings("unchecked")
private void execute() throws InterruptedException {
testStartTime = System.currentTimeMillis();
log.info("Test execution started");
if (warmup)
log.info("Warm up period started");
warmupStartTime = warmup ? testStartTime : 0;
startTime = !warmup ? testStartTime : 0;
statReportedTime = testStartTime;
long cntr = startPosition;
Object key = TestsHelper.generateLoadTestsKey(cntr);
Object val = TestsHelper.generateLoadTestsValue(cntr);
List<CacheEntryImpl> batchList = new ArrayList<>(TestsHelper.getBulkOperationSize());
Map batchMap = new HashMap(TestsHelper.getBulkOperationSize());
int execTime = TestsHelper.getLoadTestsWarmupPeriod() + TestsHelper.getLoadTestsExecutionTime();
try {
while (true) {
if (System.currentTimeMillis() - testStartTime > execTime)
break;
if (warmup && System.currentTimeMillis() - testStartTime > TestsHelper.getLoadTestsWarmupPeriod()) {
warmupFinishTime = System.currentTimeMillis();
startTime = warmupFinishTime;
statReportedTime = warmupFinishTime;
warmup = false;
log.info("Warm up period completed");
}
if (!batchMode()) {
if (cacheStore != null)
doWork(new CacheEntryImpl(key, val));
else
doWork(key, val);
} else if (batchList.size() == TestsHelper.getBulkOperationSize() || batchMap.size() == TestsHelper.getBulkOperationSize()) {
if (cacheStore != null)
doWork(batchList);
else
doWork(batchMap);
batchMap.clear();
batchList.clear();
}
if (cntr == endPosition)
cntr = startPosition;
else
cntr++;
key = TestsHelper.generateLoadTestsKey(cntr);
val = TestsHelper.generateLoadTestsValue(cntr);
if (batchMode()) {
if (cacheStore != null)
batchList.add(new CacheEntryImpl(key, val));
else
batchMap.put(key, val);
}
reportStatistics();
}
} finally {
warmupFinishTime = warmupFinishTime != 0 ? warmupFinishTime : System.currentTimeMillis();
finishTime = System.currentTimeMillis();
}
}
use of org.apache.ignite.internal.processors.cache.CacheEntryImpl in project ignite by apache.
the class BulkReadWorker method process.
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override
protected void process(CacheStore cacheStore, Collection<CacheEntryImpl> entries) {
keys.clear();
for (CacheEntryImpl entry : entries) keys.add(entry.getKey());
cacheStore.loadAll(keys);
}
Aggregations