use of org.apache.ignite.internal.processors.cache.GridCacheAdapter in project ignite by apache.
the class EvictionPolicyFailureHandlerTest method testFailureHandlerShouldNotCallOnRuntimeException.
/**
*/
@Test
public void testFailureHandlerShouldNotCallOnRuntimeException() throws Exception {
IgniteEx node1 = startGrid(0);
IgniteEx node2 = startGrid(1);
GridCacheAdapter<Object, Object> cache = ((IgniteKernal) node2).internalCache(DEFAULT_CACHE_NAME);
Affinity<Object> affinity = cache.affinity();
for (int i = 0; i < 1000; i++) {
if (affinity.isPrimary(node1.localNode(), i))
cache.put(i, 1);
}
for (int i = 0; i < 1000; i++) {
if (affinity.isPrimary(node1.localNode(), (double) i))
cache.put((double) i, 1);
}
assertFalse(cache.map().entrySet(cache.context().cacheId()).stream().anyMatch(e -> e.key().value(null, false) instanceof Double));
assertFalse(nodeFailure.get());
}
use of org.apache.ignite.internal.processors.cache.GridCacheAdapter in project ignite by apache.
the class GridCacheRebalancingSyncSelfTest method checkSupplyContextMapIsEmpty.
/**
* @throws Exception If failed.
*/
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());
}
}
}
}
use of org.apache.ignite.internal.processors.cache.GridCacheAdapter in project ignite by apache.
the class CheckpointFreeListTest method cacheOffheapManager.
/**
* Extract GridCacheOffheapManager for default cache.
*
* @return GridCacheOffheapManager.
*/
private GridCacheOffheapManager cacheOffheapManager() {
GridCacheAdapter<Object, Object> cacheInternal = ((IgniteKernal) ignite(0)).internalCache(CACHE_NAME);
GridCacheAdapter cache0 = (GridCacheAdapter) cacheInternal.cache();
return (GridCacheOffheapManager) cache0.context().group().offheap();
}
use of org.apache.ignite.internal.processors.cache.GridCacheAdapter in project ignite by apache.
the class GridCacheNearEvictionSelfTest method testNearEnabledThreeNodes.
/**
* @throws Exception If failed.
*/
@Test
public void testNearEnabledThreeNodes() throws Exception {
gridCnt = 3;
startGridsMultiThreaded(gridCnt);
try {
final int cnt = 100;
grid(0).compute().broadcast(new IgniteCallable<Object>() {
@IgniteInstanceResource
private Ignite ignite;
@Override
public Object call() throws Exception {
IgniteCache<Integer, String> c = ignite.cache(DEFAULT_CACHE_NAME);
for (int i = 0; i < cnt; i++) c.put(i, Integer.toString(i));
return true;
}
});
for (int i = 0; i < gridCnt; i++) {
final GridCacheAdapter cache = internalCache(i);
final GridCacheAdapter near = near(i);
// Repeatedly check cache sizes because of concurrent cache updates.
assertTrue(GridTestUtils.waitForCondition(new PA() {
@Override
public boolean apply() {
// Every node contains either near, backup, or primary.
return cnt == cache.size() + near.nearSize();
}
}, getTestTimeout()));
int keySize = near(i).nearSize();
assert keySize < cnt : "Key size is not less than count [cnt=" + cnt + ", size=" + keySize + ']';
}
} finally {
stopAllGrids();
}
}
use of org.apache.ignite.internal.processors.cache.GridCacheAdapter in project ignite by apache.
the class InconsistentNodeApplication method run.
/**
* {@inheritDoc}
*/
@Override
protected void run(JsonNode jsonNode) throws Exception {
String cacheName = jsonNode.get("cacheName").asText();
int amount = jsonNode.get("amount").asInt();
int parts = jsonNode.get("parts").asInt();
boolean tx = jsonNode.get("tx").asBoolean();
markInitialized();
waitForActivation();
CacheConfiguration<Integer, Integer> cfg = new CacheConfiguration<>(cacheName);
cfg.setAtomicityMode(tx ? TRANSACTIONAL : ATOMIC);
cfg.setCacheMode(CacheMode.REPLICATED);
cfg.setAffinity(new RendezvousAffinityFunction().setPartitions(parts));
ignite.getOrCreateCache(cfg);
GridCacheVersionManager mgr = ((GridCacheAdapter) ((IgniteEx) ignite).cachex(cacheName).cache()).context().shared().versions();
int cnt = 0;
for (int key = 0; key < amount; key += ThreadLocalRandom.current().nextInt(1, 3)) {
// Random shift.
IgniteInternalCache<?, ?> cache = ((IgniteEx) ignite).cachex(cacheName);
GridCacheAdapter<?, ?> adapter = (GridCacheAdapter) cache.cache();
GridCacheEntryEx entry = adapter.entryEx(key);
boolean init = entry.initialValue(// Incremental value.
new CacheObjectImpl(cnt, null), // Incremental version.
mgr.next(entry.context().kernalContext().discovery().topologyVersion()), 0, 0, false, AffinityTopologyVersion.NONE, GridDrType.DR_NONE, false, false);
assert init : "iterableKey " + key + " already inited";
if (cnt % 1_000 == 0)
log.info("APPLICATION_STREAMED [entries=" + cnt + "]");
cnt++;
}
log.info("APPLICATION_STREAMING_FINISHED [entries=" + cnt + "]");
while (!terminated()) // Keeping node alive.
U.sleep(100);
markFinished();
}
Aggregations