/** {@inheritDoc} */ @Override public boolean isClosed() { kernalGateway.readLockAnyway(); try { return kernalGateway.getState() != GridKernalState.STARTED; } finally { kernalGateway.readUnlock(); } }
/** {@inheritDoc} */ @Override public <K, V> Cache<K, V> getCache(String cacheName) { kernalGateway.readLock(); try { return getCache0(cacheName); } finally { kernalGateway.readUnlock(); } }
GridKernalState state = gw.getState(); if (gw.tryWriteLock(10)) break; assert gw.getState() == STARTED || gw.getState() == STARTING || gw.getState() == DISCONNECTED; gw.setState(STOPPING); gw.writeUnlock(); gw.writeLock(); gw.setState(STOPPED); gw.writeUnlock(); if (gw.getState() == STOPPED) log.debug("Grid is already stopped. Nothing to do."); else
GridFutureAdapter<?> reconnectFut = ctx.gateway().onDisconnected(); assert ctx.gateway().getState() != STARTED : ctx.gateway().getState(); ctx.gateway().writeLock(); ctx.gateway().writeUnlock();
@Override public boolean apply() { return grid.context().gateway().getState() == GridKernalState.STOPPED; } }, getTestTimeout());
/** * <tt>ctx.gateway().readLock()</tt> */ private void guard() { ctx.gateway().readLock(); }
/** * <tt>ctx.gateway().readUnlock()</tt> */ private void unguard() { ctx.gateway().readUnlock(); } }
GridKernalState state = gw.getState(); if (gw.tryWriteLock(10)) break; assert gw.getState() == STARTED || gw.getState() == STARTING || gw.getState() == DISCONNECTED; gw.setState(STOPPING); gw.writeUnlock(); gw.writeLock(); gw.setState(STOPPED); gw.writeUnlock(); if (gw.getState() == STOPPED) log.debug("Grid is already stopped. Nothing to do."); else
GridFutureAdapter<?> reconnectFut = ctx.gateway().onDisconnected(); assert ctx.gateway().getState() != STARTED : ctx.gateway().getState(); ctx.gateway().writeLock(); ctx.gateway().writeUnlock();
/** * */ private void awaitStop(final IgniteEx grid) throws IgniteInterruptedCheckedException { GridTestUtils.waitForCondition(() -> grid.context().gateway().getState() == GridKernalState.STOPPED, STOP_TIMEOUT_MS); }
/** * <tt>ctx.gateway().readLock()</tt> */ protected void guard() { assert ctx != null; ctx.gateway().readLock(); }
/** * <tt>ctx.gateway().readUnlock()</tt> */ private void unguard() { ctx.gateway().readUnlock(); }
/** {@inheritDoc} */ @Override public boolean isPrimaryOrBackup(ClusterNode n, K key) { ctx.gateway().readLock(); try { return isPrimary(n, key) || isBackup(n, key); } finally { ctx.gateway().readUnlock(); } }
/** {@inheritDoc} */ @Override public Iterable<String> getCacheNames() { kernalGateway.readLockAnyway(); try { if (kernalGateway.getState() != GridKernalState.STARTED) throw new IllegalStateException(); Collection<String> res = new ArrayList<>(); for (IgniteCache<?, ?> cache : ignite.context().cache().publicCaches()) res.add(cache.getName()); return Collections.unmodifiableCollection(res); } finally { kernalGateway.readUnlock(); } }
/** * Checks that proxy is in valid state (not closed, restarted or destroyed). * Throws IllegalStateException or CacheRestartingException if proxy is in invalid state. * * @param gate Cache gateway. */ private GridCacheGateway<K, V> checkProxyIsValid(@Nullable GridCacheGateway<K, V> gate, boolean tryRestart) { if (isProxyClosed()) throw new IllegalStateException("Cache has been closed: " + context().name()); boolean isCacheProxy = delegate instanceof IgniteCacheProxyImpl; if (isCacheProxy) ((IgniteCacheProxyImpl) delegate).checkRestart(); if (gate == null) throw new IllegalStateException("Gateway is unavailable. Probably cache has been destroyed, but proxy is not closed."); if (isCacheProxy && tryRestart && gate.isStopped() && context().kernalContext().gateway().getState() == GridKernalState.STARTED) { IgniteCacheProxyImpl proxyImpl = (IgniteCacheProxyImpl) delegate; try { IgniteInternalCache<K, V> cache = context().kernalContext().cache().<K, V>publicJCache(context().name()).internalProxy(); proxyImpl.opportunisticRestart(cache); return gate(); } catch (IgniteCheckedException ice) { // Opportunity didn't work out. } } return gate; }
/** * <tt>ctx.gateway().readLock()</tt> */ private void guard() { ctx.gateway().readLock(); }
/** * <tt>ctx.gateway().readUnlock()</tt> */ private void unguard() { ctx.gateway().readUnlock(); }
/** {@inheritDoc} */ @Override public String latestVersion() { ctx.gateway().readLock(); try { return ctx.cluster().latestVersion(); } finally { ctx.gateway().readUnlock(); } }
/** {@inheritDoc} */ @Override public boolean isClosed() { kernalGateway.readLockAnyway(); try { return kernalGateway.getState() != GridKernalState.STARTED; } finally { kernalGateway.readUnlock(); } }
/** * @throws IgniteInterruptedCheckedException If interrupted. */ private void awaitTopologyChange() throws IgniteInterruptedCheckedException { for (Ignite g : G.allGrids()) { final GridKernalContext ctx = ((IgniteKernal)g).context(); if (ctx.isStopping() || ctx.gateway().getState() == DISCONNECTED || !g.active()) continue; AffinityTopologyVersion topVer = ctx.discovery().topologyVersionEx(); AffinityTopologyVersion exchVer = ctx.cache().context().exchange().readyAffinityVersion(); if (!topVer.equals(exchVer)) { info("Topology version mismatch [node=" + g.name() + ", exchVer=" + exchVer + ", topVer=" + topVer + ']'); GridTestUtils.waitForCondition(new GridAbsPredicate() { @Override public boolean apply() { AffinityTopologyVersion topVer = ctx.discovery().topologyVersionEx(); AffinityTopologyVersion exchVer = ctx.cache().context().exchange().readyAffinityVersion(); return exchVer.equals(topVer); } }, DFLT_TOP_WAIT_TIMEOUT); } } }