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());
}
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());
}
}
Aggregations