use of org.apache.ignite.internal.util.typedef.PA in project ignite by apache.
the class IgniteCacheReadThroughEvictionSelfTest method testReadThroughEvictionPolicy.
/**
* @throws Exception if failed.
*/
public void testReadThroughEvictionPolicy() throws Exception {
Ignite ig = testedGrid();
CacheConfiguration<Object, Object> cc = variationConfig("eviction");
cc.setEvictionPolicy(new FifoEvictionPolicy(1));
cc.setOnheapCacheEnabled(true);
final IgniteCache<Object, Object> cache = ig.createCache(cc);
try {
for (int i = 0; i < KEYS; i++) cache.put(key(i), value(i));
assertTrue(GridTestUtils.waitForCondition(new PA() {
@Override
public boolean apply() {
int size = cache.size(CachePeekMode.ONHEAP);
int offheapSize = cache.size(CachePeekMode.OFFHEAP);
System.out.println("Cache [onHeap=" + size + ", offHeap=" + offheapSize + ']');
return size <= testsCfg.gridCount();
}
}, 30_000));
for (int i = 0; i < KEYS; i++) assertEquals(value(i), cache.get(key(i)));
} finally {
destroyCacheSafe(ig, cc.getName());
}
}
use of org.apache.ignite.internal.util.typedef.PA in project ignite by apache.
the class IgniteCacheReadThroughEvictionSelfTest method waitEmpty.
/**
* @throws Exception if failed.
*/
private void waitEmpty(final String name) throws Exception {
boolean success = GridTestUtils.waitForCondition(new PA() {
@Override
public boolean apply() {
for (Ignite g : G.allGrids()) {
GridCacheAdapter<Object, Object> cache = ((IgniteEx) g).context().cache().internalCache(name);
if (cache == null)
return true;
if (!cache.isEmpty())
return false;
}
return true;
}
}, getTestTimeout());
assertTrue("Failed to wait for the cache to be empty", success);
}
use of org.apache.ignite.internal.util.typedef.PA in project ignite by apache.
the class GridCacheRebalancingSyncSelfTest method checkSupplyContextMapIsEmpty.
/**
* @throws Exception If failed.
*/
@SuppressWarnings("SynchronizationOnLocalVariableOrMethodParameter")
protected void checkSupplyContextMapIsEmpty() throws Exception {
for (Ignite g : G.allGrids()) {
for (GridCacheAdapter c : ((IgniteEx) g).context().cache().internalCaches()) {
Object supplier = U.field(c.preloader(), "supplier");
final Map map = U.field(supplier, "scMap");
GridTestUtils.waitForCondition(new PA() {
@Override
public boolean apply() {
synchronized (map) {
return map.isEmpty();
}
}
}, 15_000);
synchronized (map) {
assertTrue("Map is not empty [cache=" + c.name() + ", node=" + g.name() + ", map=" + map + ']', map.isEmpty());
}
}
}
}
Aggregations