/** {@inheritDoc} */ @Override public void afterBinaryMemoryRestore(IgniteCacheDatabaseSharedManager mgr, GridCacheDatabaseSharedManager.RestoreBinaryState restoreState) throws IgniteCheckedException { boolean hasMvccCaches = ctx.cache().persistentCaches().stream() .anyMatch(c -> c.cacheConfiguration().getAtomicityMode() == TRANSACTIONAL_SNAPSHOT); if (hasMvccCaches) { txLog = new TxLog(ctx, mgr); mvccEnabled = true; } }
/** * Count total number of locked keys on local node. */ private long txLockedKeysNum() { GridCacheMvccManager mvccManager = gridKernalCtx.cache().context().mvcc(); return mvccManager.lockedKeys().size() + mvccManager.nearLockedKeys().size(); }
/** * @return Cache object context. */ private CacheObjectContext objectContext() { if (ctx == null) return null; return ctx.cache().internalCache(cacheName).context().cacheObjectContext(); }
/** * Check whether cache restarting in progress. * * @param ignite Grid. * @param cacheName Cache name to check. * @return {@code true} when cache restarting in progress. */ public static boolean isRestartingCache(IgniteEx ignite, String cacheName) { IgniteCacheProxy<Object, Object> proxy = ignite.context().cache().jcache(cacheName); return proxy instanceof IgniteCacheProxyImpl && ((IgniteCacheProxyImpl) proxy).isRestarting(); } }
/** {@inheritDoc} */ @Override public GridNearTxLocal txStartEx(TransactionConcurrency concurrency, TransactionIsolation isolation) { IgniteTransactionsEx txs = ctx.kernalContext().cache().transactions(); return txs.txStartEx(ctx, concurrency, isolation); }
/** {@inheritDoc} */ @Override public void enableStatistics(boolean enabled) { GridCacheContext<K, V> ctx = getContextSafe(); try { ctx.kernalContext().cache().enableStatistics(Collections.singleton(getName()), enabled); } catch (IgniteCheckedException e) { throw cacheException(e); } }
/** * Get cached affinity for specified topology version. * * @param topVer Topology version. * @return Cached affinity. */ public AffinityAssignment cachedAffinity(AffinityTopologyVersion topVer) { AffinityTopologyVersion lastAffChangeTopVer = ctx.cache().context().exchange().lastAffinityChangedTopologyVersion(topVer); return cachedAffinity(topVer, lastAffChangeTopVer); }
/** * @param cacheName Cache name. */ public boolean walEnabled(String cacheName) { DynamicCacheDescriptor desc = ctx.cache().cacheDescriptor(cacheName); if (desc == null) throw new IgniteException("Cache not found: " + cacheName); return desc.groupDescriptor().walEnabled(); }
/** * @return Affinity info for current topology version. * @throws IgniteCheckedException If failed. */ private AffinityInfo cache() throws IgniteCheckedException { AffinityInfo aff = affinityCache(cacheName, ctx.cache().context().exchange().readyAffinityVersion()); if (aff == null) throw new IgniteException("Failed to find cache (cache was not started " + "yet or cache was already stopped): " + cacheName); return aff; } }
/** {@inheritDoc} */ @Override protected Void run(VisorCacheToggleStatisticsTaskArg arg) { try { ignite.context().cache().enableStatistics(arg.getCacheNames(), arg.getState()); } catch (IgniteCheckedException e) { throw U.convertException(e); } return null; }
/** * @param gridNumber Grid number. * @param cacheName Cache name. * @return Partitions states for given cache name. */ private List<GridDhtPartitionState> getPartitionsStates(int gridNumber, String cacheName) { CacheGroupContext cgCtx = grid(gridNumber).context().cache().cacheGroup(CU.cacheId(cacheName)); GridDhtPartitionTopologyImpl top = (GridDhtPartitionTopologyImpl)cgCtx.topology(); return top.localPartitions().stream() .map(GridDhtLocalPartition::state) .collect(Collectors.toList()); }
/** * @param ignite Ignite. * @return Size of the backup queue. */ private int futuresNum(Ignite ignite) { return ((IgniteKernal)ignite).context().cache().context().mvcc().atomicFutures().size(); }
/** {@inheritDoc} */ @Override public void run() { IgniteInternalCache cache = ignite.context().cache().cache(name); try { cache.context().offheap().preloadPartition(part); } catch (IgniteCheckedException e) { log.error("Failed to preload the partition [cache=" + name + ", partition=" + part + ']', e); throw new IgniteException(e); } } }
/** * @param ignite Ignite instance. */ private int getPageSize(IgniteEx ignite) { return ignite.context().cache().context().database().pageSize(); }
/** * @param node Node. * @param topVer Ready exchange version to wait for before trying to merge exchanges. */ public static void mergeExchangeWaitVersion(Ignite node, long topVer) { ((IgniteEx)node).context().cache().context().exchange().mergeExchangesTestWaitVersion( new AffinityTopologyVersion(topVer, 0), null); }
/** * @param node Node. * @param topVer Ready exchange version to wait for before trying to merge exchanges. */ public static void mergeExchangeWaitVersion(Ignite node, long topVer, List mergedEvts) { ((IgniteEx)node).context().cache().context().exchange().mergeExchangesTestWaitVersion( new AffinityTopologyVersion(topVer, 0), mergedEvts); }
@Override public boolean apply() { try { GridCacheContext cctx = node.context().cache().context().cacheContext(CU.cacheId(DEFAULT_CACHE_NAME)); KeyCacheObject key = cctx.toCacheKeyObject(1); return cctx.offheap().read(cctx, key) == null; } catch (Exception e) { fail(); return false; } } }, 5000));
/** {@inheritDoc} */ @Override protected void afterTest() throws Exception { for (String cacheName : new String[] {DEFAULT_CACHE_NAME, CU.UTILITY_CACHE_NAME}) { IgniteKernal kernal = (IgniteKernal)ignite(0); GridCacheAdapter<Object, Object> cache = kernal.context().cache().internalCache(cacheName); cache.removeAll(F.asList("1", "2", "3")); } }
/** {@inheritDoc} */ @Override public long getNonHeapMemoryUsed() { Collection<GridCacheAdapter<?, ?>> caches = ctx.cache().internalCaches(); long nonHeapUsed = vmMetrics.getNonHeapMemoryUsed(); for (GridCacheAdapter<?, ?> cache : caches) if (cache.context().statisticsEnabled() && cache.context().started() && cache.context().affinity().affinityTopologyVersion().topologyVersion() > 0) nonHeapUsed += cache.metrics0().getOffHeapAllocatedSize(); return nonHeapUsed; }
/** * @param node Node. */ private void checkNoTx(Ignite node) { IgniteTransactions txs = node.transactions(); assertNull(txs.tx()); assertNull(((IgniteKernal)node).context().cache().context().tm().tx()); } }