/** {@inheritDoc} */ @Override public void contextDestroyed(ServletContextEvent evt) { // Stop started grids only. for (String name: igniteInstanceNames) G.stop(name, true); }
/** {@inheritDoc} */ @Override public void destroy() { // Stop started grids only. for (String name: igniteInstanceNames) G.stop(name, true); loaded = false; }
/** {@inheritDoc} */ @Override public boolean stop(boolean cancel) { return G.stop(cancel); }
/** {@inheritDoc} */ @Override public boolean stop(String name, boolean cancel) { return G.stop(name, cancel); }
/** {@inheritDoc} */ @Override public void destroy() throws Exception { if (g != null) { // Do not cancel started tasks, wait for them. G.stop(g.name(), false); } }
/** {@inheritDoc} */ @Override public void run() { CompletableFuture.runAsync(() -> G.stop(igniteInstanceName, cancel)); } }
/** * @throws Exception */ protected void stopNodes() throws Exception { for (int i = 0; i < GRID_COUNT; ++i) stopGrid(i); G.stop("grid_secondary", false); Thread.sleep(500); } /**
/** {@inheritDoc} */ @Override public void close(boolean force) { notifyListenersOnClose(); String gridName = igfs.context().kernalContext().grid().name(); synchronized (REF_CTR_MUX) { Integer cnt = REF_CTRS.get(gridName); if (cnt != null) { // The node was created by this HadoopIgfsWrapper. // The node must be stopped when there are not opened filesystems that are used one. if (cnt > 1) REF_CTRS.put(gridName, cnt - 1); else { REF_CTRS.remove(gridName); G.stop(gridName, false); } } } }
/** * Silent stop grid. * Method doesn't throw any exception. * * @param igniteInstanceName Ignite instance name. * @param log Logger. */ public static void stopGrid(String igniteInstanceName, IgniteLogger log) { try { G.stop(igniteInstanceName, false); } catch (Throwable e) { U.error(log, "Failed to stop grid: " + igniteInstanceName, e); } }
/** * @param ignite Grid. */ private void stopGrid(Ignite ignite) { try { if (ignite != null) G.stop(ignite.name(), true); } catch (Throwable e) { error("Got error when stopping grid.", e); } }
@Nullable @Override public Object call() throws Exception { Ignite g = startGrid("first"); g.events().localListen( new IgnitePredicate<Event>() { @Override public boolean apply(Event evt) { stopLatch.countDown(); return true; } }, EventType.EVT_NODE_JOINED); startLatch.countDown(); stopLatch.await(); G.stop(g.name(), false); return null; } },
@Override public Collection<WeakReference<Object>> call() throws Exception { Collection<WeakReference<Object>> refs = new ArrayList<>(); Ignite g = startGrid(); try { IgniteCache<Integer, TestValue> cache = g.cache(DEFAULT_CACHE_NAME); refs.add(new WeakReference<Object>(cacheContext(cache))); Collection<IgniteFuture<?>> futs = new ArrayList<>(1000); for (int i = 0; i < 1000; i++) { TestValue val = new TestValue(i); refs.add(new WeakReference<Object>(val)); futs.add(cache.putIfAbsentAsync(0, val)); } for (IgniteFuture<?> fut : futs) fut.get(); } finally { G.stop(g.name(), cancel); } return refs; } };
@Override public Collection<WeakReference<Object>> call() throws Exception { Collection<WeakReference<Object>> refs = new ArrayList<>(); Ignite g = startGrid(); try { IgniteCache<Integer, TestValue> cache = g.cache(DEFAULT_CACHE_NAME); refs.add(new WeakReference<Object>(cacheContext(cache))); TestValue val = new TestValue(0); refs.add(new WeakReference<Object>(val)); cache.putIfAbsentAsync(0, val).get(); } finally { G.stop(g.name(), cancel); } return refs; } };
@Override public Collection<WeakReference<Object>> call() throws Exception { Collection<WeakReference<Object>> refs = new ArrayList<>(); Ignite g = startGrid(); try { IgniteCache<Integer, TestValue> cache = g.cache(DEFAULT_CACHE_NAME); refs.add(new WeakReference<Object>(cacheContext(cache))); Map<Integer, TestValue> m = new HashMap<>(); for (int i = 0; i < 10; i++) { TestValue val = new TestValue(i); refs.add(new WeakReference<Object>(val)); m.put(i, val); g.atomicLong("testLong" + i, 0, true).incrementAndGet(); } cache.putAll(m); } finally { G.stop(g.name(), cancel); } return refs; } };
/** * Stops temporary nodes. */ private void stopTempNodes() { Collection<Ignite> toRmv = new ArrayList<>(alive.subList(0, TMP_NODES_CNT)); alive.removeAll(toRmv); // Remove listeners to avoid receiving events from stopping nodes. for (Ignite g : toRmv) g.events().stopLocalListen(lsnr, EventType.EVT_NODE_LEFT, EventType.EVT_NODE_FAILED); for (Iterator<Ignite> itr = toRmv.iterator(); itr.hasNext(); ) { Ignite g = itr.next(); if (g.cluster().localNode().isClient()) { G.stop(g.name(), false); itr.remove(); } } for (Ignite g : toRmv) { assert !g.cluster().localNode().isClient(); G.stop(g.name(), false); } } }
@Override public void run() { try { try (Transaction ignored = g0.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { g0.cache(DEFAULT_CACHE_NAME).get(1); latch.countDown(); Thread.sleep(500); info("Before stop."); G.stop(getTestIgniteInstanceName(1), true); } } catch (Exception e) { error("Error.", e); } } });
@Override public Collection<WeakReference<Object>> call() throws Exception { Collection<WeakReference<Object>> refs = new ArrayList<>(); Ignite g = startGrid(); try { IgniteCache<Integer, TestValue> cache = g.cache(DEFAULT_CACHE_NAME); refs.add(new WeakReference<Object>(cacheContext(cache))); Transaction tx = g.transactions().txStart(); TestValue val = new TestValue(0); refs.add(new WeakReference<Object>(val)); cache.put(0, val); tx.commit(); } finally { G.stop(g.name(), cancel); } return refs; } };
/** * Silent stop grid. * Method doesn't throw any exception. * * @param ignite Grid to stop. * @param log Logger. */ public static void close(Ignite ignite, IgniteLogger log) { if (ignite != null) try { G.stop(ignite.name(), false); } catch (Throwable e) { U.error(log, "Failed to stop grid: " + ignite.name(), e); } }
@Override public Collection<WeakReference<Object>> call() throws Exception { Collection<WeakReference<Object>> refs = new ArrayList<>(); Ignite g = startGrid(); try { IgniteCache<Integer, TestValue> cache = g.cache(DEFAULT_CACHE_NAME); refs.add(new WeakReference<Object>(cacheContext(cache))); Transaction tx = g.transactions().txStart(); for (int i = 0; i < 1000; i++) { TestValue val = new TestValue(i); refs.add(new WeakReference<Object>(val)); cache.putAsync(i, val).get(); } tx.commit(); } finally { G.stop(g.name(), cancel); } return refs; } };