Search in sources :

Example 1 with CacheEntryImpl

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;
}
Also used : CacheEntryImpl(org.apache.ignite.internal.processors.cache.CacheEntryImpl) HashMap(java.util.HashMap) Product(org.apache.ignite.tests.pojos.Product) List(java.util.List) LinkedList(java.util.LinkedList) ProductOrder(org.apache.ignite.tests.pojos.ProductOrder) LinkedList(java.util.LinkedList)

Example 2 with CacheEntryImpl

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;
}
Also used : CacheEntryImpl(org.apache.ignite.internal.processors.cache.CacheEntryImpl) LinkedList(java.util.LinkedList) ProductOrder(org.apache.ignite.tests.pojos.ProductOrder)

Example 3 with CacheEntryImpl

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;
}
Also used : CacheEntryImpl(org.apache.ignite.internal.processors.cache.CacheEntryImpl) PersonId(org.apache.ignite.tests.pojos.PersonId) LinkedList(java.util.LinkedList)

Example 4 with CacheEntryImpl

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();
    }
}
Also used : CacheEntryImpl(org.apache.ignite.internal.processors.cache.CacheEntryImpl) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) Map(java.util.Map)

Example 5 with CacheEntryImpl

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);
}
Also used : CacheEntryImpl(org.apache.ignite.internal.processors.cache.CacheEntryImpl)

Aggregations

CacheEntryImpl (org.apache.ignite.internal.processors.cache.CacheEntryImpl)17 Map (java.util.Map)7 ArrayList (java.util.ArrayList)5 CacheStore (org.apache.ignite.cache.store.CacheStore)5 Test (org.junit.Test)5 ClassPathResource (org.springframework.core.io.ClassPathResource)5 List (java.util.List)4 Cache (javax.cache.Cache)4 LinkedList (java.util.LinkedList)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)3 Person (org.apache.ignite.tests.pojos.Person)3 ProductOrder (org.apache.ignite.tests.pojos.ProductOrder)3 Collection (java.util.Collection)2 HashMap (java.util.HashMap)2 Random (java.util.Random)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 Ignite (org.apache.ignite.Ignite)2 IgniteException (org.apache.ignite.IgniteException)2 ClusterNode (org.apache.ignite.cluster.ClusterNode)2