/** * Test OOME in service execute. */ @Test public void testServiceExecuteOomError() throws Exception { IgniteEx ignite0 = startGrid(0); IgniteEx ignite1 = startGrid(1); IgniteCache<Integer, Integer> cache1 = ignite1.getOrCreateCache(DEFAULT_CACHE_NAME); awaitPartitionMapExchange(); Integer key = primaryKey(cache1); ignite0.services().deployKeyAffinitySingleton("fail-execute-service", new FailServiceImpl(true), DEFAULT_CACHE_NAME, key); assertFailureState(ignite0, ignite1); }
/** * @param igniteWork Working ignite instance. * @param igniteFail Failed ignite instance. */ private static void assertFailureState(Ignite igniteWork, Ignite igniteFail) throws IgniteInterruptedCheckedException { assertTrue(GridTestUtils.waitForCondition(new GridAbsPredicate() { @Override public boolean apply() { return dummyFailureHandler(igniteFail).failure(); } }, 5000L)); assertFalse(dummyFailureHandler(igniteWork).failure()); }
/** {@inheritDoc} */ @Override protected void afterTest() throws Exception { super.afterTest(); stopAllGrids(); }
/** * Test OOME in IgniteCompute. */ @Test public void testComputeOomError() throws Exception { IgniteEx ignite0 = startGrid(0); IgniteEx ignite1 = startGrid(1); try { IgniteFuture<Boolean> res = ignite0.compute(ignite0.cluster().forNodeId(ignite1.cluster().localNode().id())) .callAsync(new IgniteCallable<Boolean>() { @Override public Boolean call() throws Exception { throw new OutOfMemoryError(); } }); res.get(); } catch (Throwable ignore) { // Expected. } assertFailureState(ignite0, ignite1); }
/** * Test OOME in event listener. */ @Test public void testEventListenerOomError() throws Exception { IgniteEx ignite0 = startGrid(0); IgniteEx ignite1 = startGrid(1); IgniteCache<Integer, Integer> cache0 = ignite0.getOrCreateCache(DEFAULT_CACHE_NAME); IgniteCache<Integer, Integer> cache1 = ignite1.getOrCreateCache(DEFAULT_CACHE_NAME); awaitPartitionMapExchange(); ignite1.events().localListen(new IgnitePredicate<Event>() { @Override public boolean apply(Event evt) { throw new OutOfMemoryError(); } }, EventType.EVT_CACHE_OBJECT_PUT); Integer key = primaryKey(cache1); try { cache0.put(key, key); } catch (Throwable ignore) { // Expected. } assertFailureState(ignite0, ignite1); }
/** * Test OOME in EntryProcessor. */ @Test public void testEntryProcessorOomError() throws Exception { IgniteEx ignite0 = startGrid(0); IgniteEx ignite1 = startGrid(1); IgniteCache<Integer, Integer> cache0 = ignite0.getOrCreateCache(DEFAULT_CACHE_NAME); IgniteCache<Integer, Integer> cache1 = ignite1.getOrCreateCache(DEFAULT_CACHE_NAME); awaitPartitionMapExchange(); Integer key = primaryKey(cache1); cache1.put(key, key); try { IgniteFuture fut = cache0.invokeAsync(key, new EntryProcessor<Integer, Integer, Object>() { @Override public Object process(MutableEntry<Integer, Integer> entry, Object... arguments) throws EntryProcessorException { throw new OutOfMemoryError(); } }); fut.get(); } catch (Throwable ignore) { // Expected. } assertFailureState(ignite0, ignite1); }
/** * Test OOME in service method invocation. */ @Test public void testServiceInvokeOomError() throws Exception { IgniteEx ignite0 = startGrid(0); IgniteEx ignite1 = startGrid(1); IgniteCache<Integer, Integer> cache1 = ignite1.getOrCreateCache(DEFAULT_CACHE_NAME); awaitPartitionMapExchange(); Integer key = primaryKey(cache1); ignite0.services().deployKeyAffinitySingleton("fail-invoke-service", new FailServiceImpl(false), DEFAULT_CACHE_NAME, key); FailService svc = ignite0.services().serviceProxy("fail-invoke-service", FailService.class, false); try { svc.fail(); } catch (Throwable ignore) { // Expected. } assertFailureState(ignite0, ignite1); }