Search in sources :

Example 1 with CacheInterceptorEntry

use of org.apache.ignite.cache.CacheInterceptorEntry in project ignite by apache.

the class CacheInterceptorPartitionCounterLocalSanityTest method waitAndCheckEvent.

/**
 * @param key Key.
 * @param val Value.
 * @param oldVal Old value.
 * @param rmv Remove operation.
 * @throws Exception If failed.
 */
private void waitAndCheckEvent(Object key, Object val, Object oldVal, boolean rmv) throws Exception {
    BlockingQueue<Cache.Entry<TestKey, TestValue>> evtsQueue = rmv ? afterRmvEvts : afterPutEvts;
    if (val == null && oldVal == null) {
        checkNoEvent(evtsQueue);
        return;
    }
    Cache.Entry<TestKey, TestValue> entry = evtsQueue.poll(5, SECONDS);
    assertNotNull("Failed to wait for event [key=" + key + ", val=" + val + ", oldVal=" + oldVal + ']', entry);
    assertEquals(key, entry.getKey());
    assertEquals(rmv ? oldVal : val, entry.getValue());
    CacheInterceptorEntry interceptorEntry = entry.unwrap(CacheInterceptorEntry.class);
    assertNotNull(interceptorEntry);
    // For local cache partition counter always zero.
    assertEquals(0, interceptorEntry.getPartitionUpdateCounter());
    assertNull(evtsQueue.peek());
}
Also used : CacheInterceptorEntry(org.apache.ignite.cache.CacheInterceptorEntry) MutableEntry(javax.cache.processor.MutableEntry) CacheInterceptorEntry(org.apache.ignite.cache.CacheInterceptorEntry) Cache(javax.cache.Cache) IgniteCache(org.apache.ignite.IgniteCache)

Example 2 with CacheInterceptorEntry

use of org.apache.ignite.cache.CacheInterceptorEntry in project ignite by apache.

the class CacheInterceptorPartitionCounterRandomOperationsTest method waitAndCheckEvent.

/**
 * @param cache Ignite cache.
 * @param partCntrs Partition counters.
 * @param aff Affinity function.
 * @param key Key.
 * @param val Value.
 * @param oldVal Old value.
 * @param rmv Remove operation.
 * @throws Exception If failed.
 */
private void waitAndCheckEvent(IgniteCache<Object, Object> cache, Map<Integer, Long> partCntrs, Affinity<Object> aff, Object key, Object val, Object oldVal, boolean rmv) throws Exception {
    Collection<BlockingQueue<Cache.Entry<TestKey, TestValue>>> entries = getInterceptorQueues(cache, key, rmv);
    assert !entries.isEmpty();
    if (val == null && oldVal == null) {
        checkNoEvent(entries);
        return;
    }
    for (BlockingQueue<Cache.Entry<TestKey, TestValue>> evtsQueue : entries) {
        Cache.Entry<TestKey, TestValue> entry = evtsQueue.poll(5, SECONDS);
        assertNotNull("Failed to wait for event [key=" + key + ", val=" + val + ", oldVal=" + oldVal + ']', entry);
        assertEquals(key, entry.getKey());
        assertEquals(rmv ? oldVal : val, entry.getValue());
        long cntr = partCntrs.get(aff.partition(key));
        CacheInterceptorEntry interceptorEntry = entry.unwrap(CacheInterceptorEntry.class);
        assertNotNull(cntr);
        assertNotNull(interceptorEntry);
        assertEquals(cntr, interceptorEntry.getPartitionUpdateCounter());
        assertNull(evtsQueue.peek());
    }
}
Also used : BlockingQueue(java.util.concurrent.BlockingQueue) CacheInterceptorEntry(org.apache.ignite.cache.CacheInterceptorEntry) MutableEntry(javax.cache.processor.MutableEntry) CacheInterceptorEntry(org.apache.ignite.cache.CacheInterceptorEntry) Cache(javax.cache.Cache) IgniteCache(org.apache.ignite.IgniteCache)

Aggregations

Cache (javax.cache.Cache)2 MutableEntry (javax.cache.processor.MutableEntry)2 IgniteCache (org.apache.ignite.IgniteCache)2 CacheInterceptorEntry (org.apache.ignite.cache.CacheInterceptorEntry)2 BlockingQueue (java.util.concurrent.BlockingQueue)1