/** * Start all input caches in parallel. * * @param startCacheInfos All caches information for start. */ void prepareStartCaches(Collection<StartCacheInfo> startCacheInfos) throws IgniteCheckedException { prepareStartCaches(startCacheInfos, (data, operation) -> { operation.accept(data);// PROXY }); }
/** * Trying to start all input caches in parallel and skip failed caches. * * @param startCacheInfos Caches info for start. * @return Caches which was failed. * @throws IgniteCheckedException if failed. */ Map<StartCacheInfo, IgniteCheckedException> prepareStartCachesIfPossible( Collection<StartCacheInfo> startCacheInfos) throws IgniteCheckedException { HashMap<StartCacheInfo, IgniteCheckedException> failedCaches = new HashMap<>(); prepareStartCaches(startCacheInfos, (data, operation) -> { try { operation.accept(data); } catch (IgniteInterruptedCheckedException e) { throw e; } catch (IgniteCheckedException e) { log.warning("Cache can not be started : cache=" + data.getStartedConfiguration().getName()); failedCaches.put(data, e); } }); return failedCaches; }
/** * @param testAction Action that trigger stop or destroy of caches. */ private void performTest(IgniteThrowableConsumer<Ignite, Void> testAction, String groupName) throws Exception { IgniteEx ig0 = (IgniteEx)startGrids(2); ig0.cluster().active(true); stopGrid(1); loadData(ig0); IgniteEx ig1 = startGrid(1); RebalanceBlockingSPI commSpi = (RebalanceBlockingSPI)ig1.configuration().getCommunicationSpi(); // Complete all futures for groups that we don't need to wait. commSpi.resumeRebalanceFutures.forEach((k, v) -> { if (k != CU.cacheId(groupName)) v.onDone(); }); CountDownLatch latch = commSpi.suspendRebalanceInMiddleLatch.get(CU.cacheId(groupName)); assert latch != null; // Await some middle point rebalance for group. latch.await(); testAction.accept(ig0); // Resume rebalance after action performed. commSpi.resumeRebalanceFutures.get(CU.cacheId(groupName)).onDone(); awaitPartitionMapExchange(true, true, null, true); assertNull(grid(1).context().failure().failureContext()); }