use of org.apache.ignite.internal.IgniteEx in project ignite by apache.
the class IgniteWalRecoveryTest method testHugeCheckpointRecord.
/**
* @throws Exception if failed.
*/
public void testHugeCheckpointRecord() throws Exception {
try {
final IgniteEx ignite = startGrid(1);
ignite.active(true);
for (int i = 0; i < 50; i++) {
CacheConfiguration<Object, Object> ccfg = new CacheConfiguration<>("cache-" + i);
// We can get 'too many open files' with default number of partitions.
ccfg.setAffinity(new RendezvousAffinityFunction(false, 128));
IgniteCache<Object, Object> cache = ignite.getOrCreateCache(ccfg);
cache.put(i, i);
}
final long endTime = System.currentTimeMillis() + 30_000;
IgniteInternalFuture<Long> fut = GridTestUtils.runMultiThreadedAsync(new Callable<Void>() {
@Override
public Void call() throws Exception {
Random rnd = ThreadLocalRandom.current();
while (U.currentTimeMillis() < endTime) {
IgniteCache<Object, Object> cache = ignite.cache("cache-" + rnd.nextInt(50));
cache.put(rnd.nextInt(50_000), rnd.nextInt());
}
return null;
}
}, 16, "put-thread");
while (System.currentTimeMillis() < endTime) {
ignite.context().cache().context().database().wakeupForCheckpoint("test").get();
U.sleep(500);
}
fut.get();
} finally {
stopAllGrids();
}
}
use of org.apache.ignite.internal.IgniteEx in project ignite by apache.
the class IgniteWalRecoveryTest method testWalBig.
/**
* @throws Exception if failed.
*/
public void testWalBig() throws Exception {
IgniteEx ignite = startGrid(1);
ignite.active(true);
IgniteCache<Object, Object> cache = ignite.cache("partitioned");
Random rnd = new Random();
Map<Integer, IndexedObject> map = new HashMap<>();
for (int i = 0; i < 10_000; i++) {
if (i % 1000 == 0)
X.println(" >> " + i);
int k = rnd.nextInt(300_000);
IndexedObject v = new IndexedObject(rnd.nextInt(10_000));
cache.put(k, v);
map.put(k, v);
}
// Check.
for (Integer k : map.keySet()) assertEquals(map.get(k), cache.get(k));
stopGrid(1);
ignite = startGrid(1);
ignite.active(true);
cache = ignite.cache("partitioned");
// Check.
for (Integer k : map.keySet()) assertEquals(map.get(k), cache.get(k));
}
use of org.apache.ignite.internal.IgniteEx in project ignite by apache.
the class IgniteWalRecoveryTest method testMetastorageRemove.
/**
* @throws Exception If fail.
*/
public void testMetastorageRemove() throws Exception {
try {
int cnt = 400;
IgniteEx ignite0 = (IgniteEx) startGrid("node1");
ignite0.active(true);
GridCacheSharedContext<Object, Object> sharedCtx0 = ignite0.context().cache().context();
MetaStorage storage = sharedCtx0.database().metaStorage();
assert storage != null;
for (int i = 0; i < cnt; i++) {
sharedCtx0.database().checkpointReadLock();
try {
storage.putData(String.valueOf(i), new byte[] { 1, 2, 3 });
} finally {
sharedCtx0.database().checkpointReadUnlock();
}
}
for (int i = 0; i < 10; i++) {
sharedCtx0.database().checkpointReadLock();
try {
storage.removeData(String.valueOf(i));
} finally {
sharedCtx0.database().checkpointReadUnlock();
}
}
for (int i = 10; i < cnt; i++) {
byte[] d1 = storage.getData(String.valueOf(i));
assertEquals(3, d1.length);
assertEquals(1, d1[0]);
assertEquals(2, d1[1]);
assertEquals(3, d1[2]);
}
} finally {
stopAllGrids();
}
}
use of org.apache.ignite.internal.IgniteEx in project ignite by apache.
the class IgniteWalRecoveryTest method testMetastorageUpdate.
/**
* @throws Exception If fail.
*/
public void testMetastorageUpdate() throws Exception {
try {
int cnt = 2000;
IgniteEx ignite0 = (IgniteEx) startGrid("node1");
ignite0.active(true);
GridCacheSharedContext<Object, Object> sharedCtx0 = ignite0.context().cache().context();
MetaStorage storage = sharedCtx0.database().metaStorage();
assert storage != null;
for (int i = 0; i < cnt; i++) {
sharedCtx0.database().checkpointReadLock();
try {
storage.putData(String.valueOf(i), new byte[] { 1, 2, 3 });
} finally {
sharedCtx0.database().checkpointReadUnlock();
}
}
for (int i = 0; i < cnt; i++) {
sharedCtx0.database().checkpointReadLock();
try {
storage.putData(String.valueOf(i), new byte[] { 2, 2, 3, 4 });
} finally {
sharedCtx0.database().checkpointReadUnlock();
}
}
for (int i = 0; i < cnt; i++) {
byte[] d1 = storage.getData(String.valueOf(i));
assertEquals(4, d1.length);
assertEquals(2, d1[0]);
assertEquals(2, d1[1]);
assertEquals(3, d1[2]);
}
} finally {
stopAllGrids();
}
}
use of org.apache.ignite.internal.IgniteEx in project ignite by apache.
the class IgniteWalRecoveryTest method testRecoveryLargeNoCheckpoint.
/**
* @throws Exception if failed.
*/
public void testRecoveryLargeNoCheckpoint() throws Exception {
try {
IgniteEx ctrlGrid = startGrid(0);
fork = true;
IgniteEx cacheGrid = startGrid(1);
ctrlGrid.active(true);
ctrlGrid.compute(ctrlGrid.cluster().forRemotes()).run(new LargeLoadRunnable(false));
info("Killing remote process...");
((IgniteProcessProxy) cacheGrid).kill();
final IgniteEx g0 = ctrlGrid;
GridTestUtils.waitForCondition(new PA() {
/**
* {@inheritDoc}
*/
@Override
public boolean apply() {
return g0.cluster().nodes().size() == 1;
}
}, getTestTimeout());
fork = false;
// Now start the grid and verify that updates were restored from WAL.
cacheGrid = startGrid(1);
IgniteCache<Object, Object> cache = cacheGrid.cache("partitioned");
for (int i = 0; i < 1000; i++) {
final long[] data = new long[LARGE_ARR_SIZE];
Arrays.fill(data, i);
final long[] loaded = (long[]) cache.get(i);
Assert.assertArrayEquals(data, loaded);
}
} finally {
stopAllGrids();
}
}
Aggregations