use of org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_READ in project ignite by apache.
the class CacheEventSecurityContextTest method checkEvents.
/**
* Executes specified cache operation on each server node and checks events.
*/
private void checkEvents(ConsumerX<Integer> op, boolean withInitVal, Integer... expEvtTypes) throws Exception {
IgniteEx crd = grid("crd");
Set<Integer> evts = Arrays.stream(expEvtTypes).collect(Collectors.toSet());
// TODO Remove the following workaround after resolving IGNITE-13490.
if (ATOMIC_CACHE.equals(cacheName) && evts.size() > 1)
evts.remove(EVT_CACHE_OBJECT_READ);
if (TRANSACTIONAL_CACHE.equals(cacheName) && !(evts.size() == 1 && evts.contains(EVT_CACHE_OBJECT_READ))) {
evts.add(EVT_CACHE_OBJECT_LOCKED);
evts.add(EVT_CACHE_OBJECT_UNLOCKED);
}
List<Integer> keys = testNodes().stream().map(node -> keyForNode(crd.affinity(cacheName), KEY_COUNTER, node)).collect(Collectors.toList());
if (withInitVal)
keys.forEach(key -> crd.cache(cacheName).put(key, "val"));
checkEvents(() -> keys.forEach(op), evts);
}
use of org.apache.ignite.events.EventType.EVT_CACHE_OBJECT_READ in project ignite by apache.
the class ReliabilityTest method testServerCriticalError.
/**
* Test server-side critical error.
*/
@Test
public void testServerCriticalError() throws Exception {
AtomicBoolean failure = new AtomicBoolean();
FailureHandler hnd = (ignite, ctx) -> failure.compareAndSet(false, true);
try (Ignite ignite = startGrid(getConfiguration().setFailureHandler(hnd).setIncludeEventTypes(EVTS_CACHE));
IgniteClient client = startClient(ignite)) {
ClientCache<Object, Object> cache = client.getOrCreateCache(DEFAULT_CACHE_NAME);
cachePut(cache, 0, 0);
String msg = "critical error message";
ignite.events().localListen(e -> {
throw new Error(msg);
}, EVT_CACHE_OBJECT_READ);
GridTestUtils.assertThrowsAnyCause(log, () -> cache.get(0), ClientServerError.class, msg);
assertFalse(failure.get());
// OutOfMemoryError should also invoke failure handler.
ignite.events().localListen(e -> {
throw new OutOfMemoryError(msg);
}, EVT_CACHE_OBJECT_REMOVED);
GridTestUtils.assertThrowsAnyCause(log, () -> cache.remove(0), ClientServerError.class, msg);
assertTrue(GridTestUtils.waitForCondition(failure::get, 1_000L));
}
}
Aggregations