use of org.apache.ignite.lifecycle.LifecycleEventType in project ignite by apache.
the class GridLifecycleBeanSelfTest method testGetIgnite.
/**
* @throws Exception If failed.
*/
public void testGetIgnite() throws Exception {
final AtomicBoolean done = new AtomicBoolean();
bean = new LifeCycleBaseBean() {
/** */
@IgniteInstanceResource
private Ignite ignite;
@Override
public void onLifecycleEvent(LifecycleEventType evt) {
super.onLifecycleEvent(evt);
if (evt == LifecycleEventType.AFTER_NODE_START) {
Ignite ignite0 = Ignition.ignite(ignite.name());
assertNotNull(ignite0);
assertNotNull(ignite0.cluster().localNode());
done.set(true);
}
}
};
try {
startGrid();
assertTrue(done.get());
} finally {
stopAllGrids();
}
}
use of org.apache.ignite.lifecycle.LifecycleEventType in project ignite by apache.
the class GridCacheDhtPreloadUnloadSelfTest method testUnloadOneBackThreeNodesWithLifeCycleBean.
/** @throws Exception If failed. */
public void testUnloadOneBackThreeNodesWithLifeCycleBean() throws Exception {
preloadMode = SYNC;
backups = 1;
try {
final int cnt = 1000;
lbean = new LifecycleBean() {
@IgniteInstanceResource
private Ignite ignite;
@Override
public void onLifecycleEvent(LifecycleEventType evt) {
if (evt == LifecycleEventType.AFTER_NODE_START) {
IgniteCache<Integer, String> c = ignite.cache(DEFAULT_CACHE_NAME);
if (c.putIfAbsent(-1, "true")) {
populate(ignite.<Integer, String>cache(DEFAULT_CACHE_NAME), cnt);
info(">>> POPULATED GRID <<<");
}
}
}
};
int gridCnt = 3;
for (int i = 0; i < gridCnt; i++) {
startGrid(i);
for (int j = 0; j < i; j++) info("Grid size [i=" + i + ", size=" + grid(j).cache(DEFAULT_CACHE_NAME).localSize() + ']');
}
long wait = 3000;
waitForUnload(gridCnt, cnt, wait);
} finally {
lbean = null;
stopAllGrids();
}
}
use of org.apache.ignite.lifecycle.LifecycleEventType in project ignite by apache.
the class GridCacheDhtPreloadBigDataSelfTest method testLargeObjectsWithLifeCycleBean.
/**
* @throws Exception If failed.
*/
public void testLargeObjectsWithLifeCycleBean() throws Exception {
preloadMode = SYNC;
partitions = 23;
try {
final int cnt = 10000;
lbean = new LifecycleBean() {
@IgniteInstanceResource
private Ignite ignite;
@Override
public void onLifecycleEvent(LifecycleEventType evt) {
if (evt == LifecycleEventType.AFTER_NODE_START) {
IgniteCache<Integer, byte[]> c = ignite.cache(DEFAULT_CACHE_NAME);
if (c.putIfAbsent(-1, new byte[1])) {
populate(c, cnt, KBSIZE);
info(">>> POPULATED GRID <<<");
}
}
}
};
int gridCnt = 3;
for (int i = 0; i < gridCnt; i++) startGrid(i);
for (int i = 0; i < gridCnt; i++) info("Grid size [i=" + i + ", size=" + grid(i).cache(DEFAULT_CACHE_NAME).size() + ']');
Thread.sleep(10000);
for (int i = 0; i < gridCnt; i++) {
IgniteCache<Integer, String> c = grid(i).cache(DEFAULT_CACHE_NAME);
if (backups + 1 <= gridCnt)
assert c.localSize() < cnt;
else
assert c.localSize() == cnt;
}
} finally {
stopAllGrids();
}
}
Aggregations