/** * 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(); }
/** * 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); }
/** * @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 public Collection<DataRegionMetrics> dataRegionMetrics() { guard(); try { return ctx.cache().context().database().memoryMetrics(); } finally { unguard(); } }
/** * Get index partition file for specific node and cache. */ private File indexPartition(Ignite ig, String cacheName) { IgniteEx ig0 = (IgniteEx)ig; FilePageStoreManager pageStoreManager = ((FilePageStoreManager) ig0.context().cache().context().pageStore()); return new File(pageStoreManager.cacheWorkDir(false, cacheName), INDEX_FILE_NAME); }
/** * @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 ensureStarted() throws IgniteCheckedException { if (!ctx.clientNode()) { assert mvccEnabled && mvccSupported; if (txLog == null) txLog = new TxLog(ctx, ctx.cache().context().database()); startVacuumWorkers(); if (log.isInfoEnabled()) log.info("Mvcc processor started."); } }
/** * @param mgr Database shared manager. * @throws IgniteCheckedException If failed. */ private void txLogPageStoreInit(IgniteCacheDatabaseSharedManager mgr) throws IgniteCheckedException { assert CU.isPersistenceEnabled(ctx.config()); //noinspection ConstantConditions ctx.cache().context().pageStore().initialize(TX_LOG_CACHE_ID, 1, TX_LOG_CACHE_NAME, mgr.dataRegion(TX_LOG_CACHE_NAME).memoryMetrics()); }
/** * @param ignite Ignite instance. */ private int getPageSize(IgniteEx ignite) { return ignite.context().cache().context().database().pageSize(); }
/** * Change read only mode on all nodes. * * @param readOnly Read only. */ protected void changeClusterReadOnlyMode(boolean readOnly) { for (int idx = 0; idx < SRVS; idx++) { IgniteEx ignite = grid(idx); ignite.context().cache().context().readOnlyMode(readOnly); } } }
@Override public boolean apply() { for (int i = 0; i < SRVS; i++) { if (grid(i).context().cache().context().mvcc().atomicFuturesCount() != 0) return false; } return true; } }, 5000);
@Override public boolean apply() { for (IgniteKernal g : grids) { GridCacheSharedContext<Object, Object> ctx = g.context().cache().context(); int txNum = ctx.tm().idMapSize(); if (txNum != 0) return false; } return true; } }, 10000);
/** * @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));
/** * @param ig Ignite instance. * @return Memory and store. * @throws Exception If failed to initialize the store. */ private PageMemory getMemory(IgniteEx ig) throws Exception { final GridCacheSharedContext<Object, Object> sharedCtx = ig.context().cache().context(); final IgniteCacheDatabaseSharedManager db = sharedCtx.database(); return db.dataRegion(null).pageMemory(); } }
/** * Verifies that expected memory policies are allocated when used doesn't provide any MemoryPolicyConfiguration. */ @Test public void testNoConfigProvided() throws Exception { memCfg = null; IgniteEx ignite = startGrid(0); Collection<DataRegion> allMemPlcs = ignite.context().cache().context().database().dataRegions(); assertEquals(3, allMemPlcs.size()); verifyDefaultAndSystemMemoryPolicies(allMemPlcs); }
/** */ private void verifyKeys(IgniteEx ig, byte keysCnt, String keyPrefix, String valPrefix ) throws IgniteCheckedException { MetaStorage metaStorage = ig.context().cache().context().database().metaStorage(); for (byte i = 0; i < keysCnt; i++) { Serializable val = metaStorage.read(keyPrefix + i); Assert.assertEquals(valPrefix + i, val); } }
/** * @throws Exception If failed. */ @Test public void testWALManagerIterator() throws Exception { IgniteEx ig = grid(); IgniteWriteAheadLogManager wal = ig.context().cache().context().wal(); doTest(wal, wal.replay(null)); }
/** * @param node Node. */ private void checkNoTx(Ignite node) { IgniteTransactions txs = node.transactions(); assertNull(txs.tx()); assertNull(((IgniteKernal)node).context().cache().context().tm().tx()); } }