use of org.apache.ignite.cache.CachePeekMode in project ignite by apache.
the class GridCacheAbstractQueueFailoverDataConsistencySelfTest method primaryQueueNode.
/**
* @param queue Queue.
* @return Primary node for queue's header.
* @throws Exception If failed.
*/
private int primaryQueueNode(IgniteQueue queue) throws Exception {
GridCacheContext cctx = GridTestUtils.getFieldValue(queue, "cctx");
GridCacheAffinityManager aff = cctx.affinity();
CachePeekMode[] modes = new CachePeekMode[] { CachePeekMode.ALL };
for (int i = 0; i < gridCount(); i++) {
for (Cache.Entry e : grid(i).context().cache().internalCache(cctx.name()).localEntries(modes)) {
Object key = e.getKey();
if (aff.primaryByKey(grid(i).localNode(), key, AffinityTopologyVersion.NONE) && key instanceof GridCacheQueueHeaderKey)
return i;
}
}
fail("Failed to find primary node for queue header.");
return -1;
}
use of org.apache.ignite.cache.CachePeekMode in project ignite by apache.
the class IgnitePdsCacheRebalancingAbstractTest method testRebalancingWithMixedDataRegionConfigurations.
/**
* Test rebalancing of in-memory cache on the node with mixed data region configurations.
*
* @throws Exception If failed.
*/
@Test
public void testRebalancingWithMixedDataRegionConfigurations() throws Exception {
int entriesCount = 10_000;
Ignite ignite0 = startGrids(2);
ignite0.cluster().active(true);
IgniteCache<Integer, TestValue> cachePds = ignite0.cache(INDEXED_CACHE);
IgniteCache<Integer, TestValue> cacheInMem = ignite0.cache(INDEXED_CACHE_IN_MEMORY);
for (int i = 0; i < entriesCount / 2; i++) {
TestValue value = new TestValue(i, i * 2, i * 3);
cachePds.put(i, value);
cacheInMem.put(i, value);
}
forceCheckpoint();
stopGrid(1);
for (int i = entriesCount / 2; i < entriesCount; i++) {
TestValue value = new TestValue(i, i * 2, i * 3);
cachePds.put(i, value);
cacheInMem.put(i, value);
}
IgniteEx ignite1 = startGrid(1);
awaitPartitionMapExchange();
IgniteInternalCache<Integer, TestValue> cachePds1 = ignite1.cachex(INDEXED_CACHE);
IgniteInternalCache<Integer, TestValue> cacheInMem1 = ignite1.cachex(INDEXED_CACHE_IN_MEMORY);
CachePeekMode[] peekAll = new CachePeekMode[] { CachePeekMode.ALL };
assertEquals(entriesCount, cachePds1.localSize(peekAll));
assertEquals(entriesCount, cacheInMem1.localSize(peekAll));
for (int i = 0; i < entriesCount; i++) {
TestValue value = new TestValue(i, i * 2, i * 3);
assertEquals(value, cachePds1.localPeek(i, peekAll));
assertEquals(value, cacheInMem1.localPeek(i, peekAll));
}
}
Aggregations