/** {@inheritDoc} */ @Override public boolean isClosed() { kernalGateway.readLockAnyway(); try { return kernalGateway.getState() != GridKernalState.STARTED; } finally { kernalGateway.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(); } }
@Override public boolean apply() { return grid.context().gateway().getState() == GridKernalState.STOPPED; } }, getTestTimeout());
/** * */ private void awaitStop(final IgniteEx grid) throws IgniteInterruptedCheckedException { GridTestUtils.waitForCondition(() -> grid.context().gateway().getState() == GridKernalState.STOPPED, STOP_TIMEOUT_MS); }
/** * 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; }
/** * @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); } } }
/** {@inheritDoc} */ @Override public boolean isClosed() { kernalGateway.readLockAnyway(); try { return kernalGateway.getState() != GridKernalState.STARTED; } finally { kernalGateway.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(); } }
context().kernalContext().gateway().getState() == GridKernalState.STARTED) { IgniteCacheProxyImpl proxyImpl = (IgniteCacheProxyImpl) delegate;