use of org.apache.ignite.internal.IgniteEx in project ignite by apache.
the class CacheRebalancingSelfTest method testRebalanceFuture.
/**
* @throws Exception If failed.
*/
public void testRebalanceFuture() throws Exception {
IgniteEx ig0 = startGrid(0);
startGrid(1);
IgniteCache<Object, Object> cache = ig0.cache(DEFAULT_CACHE_NAME);
IgniteFuture fut1 = cache.rebalance();
fut1.get();
startGrid(2);
IgniteFuture fut2 = cache.rebalance();
assert internalFuture(fut2) != internalFuture(fut1);
fut2.get();
}
use of org.apache.ignite.internal.IgniteEx in project ignite by apache.
the class CacheRebalancingSelfTest method testDisableRebalancing.
/**
* Test local cache size with and without rebalancing in case or topology change.
*
* @throws Exception If failed.
*/
public void testDisableRebalancing() throws Exception {
IgniteEx ig0 = startGrid(0);
IgniteEx ig1 = startGrid(1);
startGrid(2);
ig1.rebalanceEnabled(false);
Random r = new Random();
int totalKeysCnt = 10240;
final Set<Integer> keys = new HashSet<>();
while (keys.size() < totalKeysCnt) keys.add(r.nextInt());
IgniteCache<Integer, Integer> cache = ig0.getOrCreateCache(REBALANCE_TEST_CACHE_NAME);
for (Integer next : keys) cache.put(next, 1);
testLocalCacheSize(ig0, 0, totalKeysCnt);
int before_ig1 = testLocalCacheSize(ig1, 0, totalKeysCnt);
stopGrid(2);
testLocalCacheSize(ig0, totalKeysCnt, null);
testLocalCacheSize(ig1, before_ig1, null);
ig1.rebalanceEnabled(true);
testLocalCacheSize(ig0, totalKeysCnt, null);
testLocalCacheSize(ig1, totalKeysCnt, null);
}
use of org.apache.ignite.internal.IgniteEx in project ignite by apache.
the class AtomicCacheAffinityConfigurationTest method testDefaultAffinity.
/**
* @throws Exception If failed.
*/
public void testDefaultAffinity() throws Exception {
try {
affinityFunction = null;
startGrids(3);
for (int i = 0; i < 3; i++) {
IgniteEx igniteEx = grid(i);
IgniteAtomicLong atomic = igniteEx.atomicLong("test", 0, true);
GridCacheContext cctx = GridTestUtils.getFieldValue(atomic, AtomicDataStructureProxy.class, "ctx");
AffinityFunction aff = cctx.config().getAffinity();
assertNotNull(aff);
}
checkAtomics();
} finally {
stopAllGrids();
}
}
use of org.apache.ignite.internal.IgniteEx in project ignite by apache.
the class AtomicCacheAffinityConfigurationTest method testRendezvousAffinity.
/**
* @throws Exception If failed.
*/
public void testRendezvousAffinity() throws Exception {
try {
affinityFunction = new RendezvousAffinityFunction(false, 10);
startGrids(3);
for (int i = 0; i < 3; i++) {
IgniteEx igniteEx = grid(i);
IgniteAtomicLong atomic = igniteEx.atomicLong("test", 0, true);
GridCacheContext cctx = GridTestUtils.getFieldValue(atomic, AtomicDataStructureProxy.class, "ctx");
AffinityFunction aff = cctx.config().getAffinity();
assertNotNull(aff);
assertEquals(aff.partitions(), affinityFunction.partitions());
assertEquals(aff.getClass(), affinityFunction.getClass());
}
checkAtomics();
} finally {
stopAllGrids();
}
}
use of org.apache.ignite.internal.IgniteEx in project ignite by apache.
the class IgnitePdsCheckpointSimulationWithRealCpDisabledTest method testGetForInitialWrite.
/**
* @throws Exception if failed.
*/
public void testGetForInitialWrite() throws Exception {
IgniteEx ig = startGrid(0);
ig.active(true);
GridCacheSharedContext<Object, Object> shared = ig.context().cache().context();
int cacheId = shared.cache().cache(cacheName).context().cacheId();
GridCacheDatabaseSharedManager dbMgr = (GridCacheDatabaseSharedManager) shared.database();
// Disable integrated checkpoint thread.
dbMgr.enableCheckpoints(false);
PageMemory mem = shared.database().dataRegion(null).pageMemory();
IgniteWriteAheadLogManager wal = shared.wal();
WALPointer start = wal.log(new CheckpointRecord(null));
final FullPageId[] initWrites = new FullPageId[10];
ig.context().cache().context().database().checkpointReadLock();
try {
for (int i = 0; i < initWrites.length; i++) initWrites[i] = new FullPageId(mem.allocatePage(cacheId, 0, PageIdAllocator.FLAG_DATA), cacheId);
// Check getForInitialWrite methods.
for (FullPageId fullId : initWrites) {
long page = mem.acquirePage(fullId.groupId(), fullId.pageId());
try {
long pageAddr = mem.writeLock(fullId.groupId(), fullId.pageId(), page);
try {
DataPageIO.VERSIONS.latest().initNewPage(pageAddr, fullId.pageId(), mem.pageSize());
for (int i = PageIO.COMMON_HEADER_END + DataPageIO.ITEMS_OFF; i < mem.pageSize(); i++) PageUtils.putByte(pageAddr, i, (byte) 0xAB);
PageIO.printPage(pageAddr, mem.pageSize());
} finally {
mem.writeUnlock(fullId.groupId(), fullId.pageId(), page, null, true);
}
} finally {
mem.releasePage(fullId.groupId(), fullId.pageId(), page);
}
}
wal.fsync(null);
} finally {
ig.context().cache().context().database().checkpointReadUnlock();
stopAllGrids(false);
}
ig = startGrid(0);
ig.active(true);
shared = ig.context().cache().context();
dbMgr = (GridCacheDatabaseSharedManager) shared.database();
dbMgr.enableCheckpoints(false);
wal = shared.wal();
try (PartitionMetaStateRecordExcludeIterator it = new PartitionMetaStateRecordExcludeIterator(wal.replay(start))) {
it.next();
for (FullPageId initialWrite : initWrites) {
IgniteBiTuple<WALPointer, WALRecord> tup = it.next();
assertTrue(String.valueOf(tup.get2()), tup.get2() instanceof PageSnapshot);
PageSnapshot snap = (PageSnapshot) tup.get2();
FullPageId actual = snap.fullPageId();
// there are extra tracking pages, skip them
if (TrackingPageIO.VERSIONS.latest().trackingPageFor(actual.pageId(), mem.pageSize()) == actual.pageId()) {
tup = it.next();
assertTrue(tup.get2() instanceof PageSnapshot);
actual = ((PageSnapshot) tup.get2()).fullPageId();
}
assertEquals(initialWrite, actual);
}
}
}
Aggregations