/** * @return {@code True} if local node in disconnected state. */ private boolean isLocalNodeDisconnected() { boolean disconnected = false; if (ignite instanceof IgniteKernal) disconnected = ((IgniteKernal)ignite).context().clientDisconnected(); return disconnected; }
/** {@inheritDoc} */ @Override public IgniteInternalCache<Object, Object> get() { IgniteInternalCache<Object, Object> cache = reference.get(); if (cache == null) { cache = ((IgniteKernal)ignite).getCache(cacheName); if (cache == null) throw new IllegalArgumentException("Cache '" + cacheName + "' for region '" + regionName + "' is not configured."); reference.compareAndSet(null, cache); } return cache; } }
/** * @param g Grid. * @return Near cache. */ @SuppressWarnings({"unchecked"}) private GridNearCacheAdapter<Integer, String> near(Ignite g) { return (GridNearCacheAdapter)((IgniteKernal)g).internalCache(DEFAULT_CACHE_NAME); }
@Override public Void call() throws Exception { int idx = threadIdx.getAndIncrement(); IgniteKernal node = (IgniteKernal)ignite(idx % 3 + 1); IgniteCache<Integer, Integer> cache = node.cache(DEFAULT_CACHE_NAME); while (true) { try { cacheOperations(node, cache); } catch (Exception ignored) { if (node.isStopping()) break; } } return null; } }, 20, "tx-node-stop-thread");
/** * Get data cache for node. * * @param node Node. * @return Data cache. * @throws Exception If failed. */ private GridCacheAdapter dataCache(Ignite node) throws Exception { return ((IgniteKernal)node).internalCache(((IgniteKernal)node).igfsx(IGFS_NAME).configuration() .getDataCacheConfiguration().getName()); }
@Override public void applyx() { // Check that no more entries left in the map. assertNull(g.cache(DEFAULT_CACHE_NAME).get(key)); if (!g.internalCache(DEFAULT_CACHE_NAME).context().deferredDelete()) assertNull(g.internalCache(DEFAULT_CACHE_NAME).map().getEntry(g.internalCache(DEFAULT_CACHE_NAME).context(), g.internalCache(DEFAULT_CACHE_NAME).context().toCacheKeyObject(key))); } });
/** * @param expNodes Expected nodes number. * @param topVer Topology version. * @throws Exception If failed. */ private void checkOrderCounters(int expNodes, AffinityTopologyVersion topVer) throws Exception { List<Ignite> nodes = G.allGrids(); Long order = null; for (Ignite node : nodes) { IgniteKernal node0 = (IgniteKernal)node; if (node0.configuration().isClientMode()) continue; IgniteInternalFuture<?> fut = node0.context().cache().context().exchange().affinityReadyFuture(topVer); if (fut != null) fut.get(); AtomicLong orderCntr = GridTestUtils.getFieldValue(node0.context().cache().context().versions(), "order"); log.info("Order [node=" + node0.name() + ", order=" + orderCntr.get() + ']'); if (order == null) order = orderCntr.get(); else assertEquals(order, (Long)orderCntr.get()); } assertEquals(expNodes, nodes.size()); }
IgniteKernal g0 = (IgniteKernal)g; for (IgniteCacheProxy<?, ?> c : g0.context().cache().jcaches()) { CacheConfiguration cfg = c.context().config(); "], node=" + g0.name() + " cache=" + c.getName(), res); g0.affinity(cfg.getName()).mapPartitionToPrimaryAndBackups(loc.id()); assertTrue(affNodes.contains(g0.localNode())); IgniteKernal remote0 = (IgniteKernal)remote; IgniteCacheProxy<?, ?> remoteC = remote0.context().cache().jcache(cfg.getName()); GridDhtPartitionMap pMap = remoteTop.partitionMap(true).get(((IgniteKernal)g).getLocalNodeId());
ctx.addNodeAttribute(ATTR_REBALANCE_POOL_SIZE, configuration().getRebalanceThreadPoolSize()); ctx.addNodeAttribute(ATTR_DATA_STREAMER_POOL_SIZE, configuration().getDataStreamerThreadPoolSize()); add(ATTR_IPS, (ips.isEmpty() ? "" : ips)); Map<String, ?> userAttrs = configuration().getUserAttributes(); add(ATTR_MACS, (Serializable)userAttrs.get(IgniteNodeAttributes.ATTR_MACS_OVERRIDE)); else add(ATTR_MACS, (macs.isEmpty() ? "" : macs)); add(ATTR_JIT_NAME, U.getCompilerMx() == null ? "" : U.getCompilerMx().getName()); add(ATTR_BUILD_VER, VER_STR); add(ATTR_BUILD_DATE, BUILD_TSTAMP_STR); add(ATTR_MARSHALLER, cfg.getMarshaller().getClass().getName()); add(ATTR_MARSHALLER_USE_DFLT_SUID, getBoolean(IGNITE_OPTIMIZED_MARSHALLER_USE_DEFAULT_SUID, OptimizedMarshaller.USE_DFLT_SUID)); add(ATTR_LATE_AFFINITY_ASSIGNMENT, cfg.isLateAffinityAssignment()); add(ATTR_MARSHALLER_COMPACT_FOOTER, cfg.getBinaryConfiguration() == null ? BinaryConfiguration.DFLT_COMPACT_FOOTER : cfg.getBinaryConfiguration().isCompactFooter()); add(ATTR_MARSHALLER_USE_BINARY_STRING_SER_VER_2, getBoolean(IGNITE_BINARY_MARSHALLER_USE_STRING_SERIALIZATION_VER_2, BinaryUtils.USE_STR_SERIALIZATION_VER_2)); add(ATTR_USER_NAME, System.getProperty("user.name")); add(ATTR_IGNITE_INSTANCE_NAME, igniteInstanceName);
assertEquals(NODES_CNT * 2, grid1.cluster().nodes().size()); assertEquals(NODES_CNT * 2, grid2.cluster().nodes().size()); IgniteCache<Integer, Integer> cache = grid2.cache(CACHE_NAME); GridAffinityProcessor affPrc1 = grid1.context().affinity(); GridAffinityProcessor affPrc2 = grid2.context().affinity();
IgniteDiagnosticPrepareContext ctx = new IgniteDiagnosticPrepareContext(node.getLocalNodeId()); ctx.send(node.context(), new IgniteInClosure<IgniteInternalFuture<String>>() { @Override public void apply(IgniteInternalFuture<String> diagFut) { try {
/** * @throws Exception If failed. */ @Test public void testSystemTxInsideUserTx() throws Exception { Assume.assumeFalse("https://issues.apache.org/jira/browse/IGNITE-10473", MvccFeatureChecker.forcedMvcc()); IgniteKernal ignite = (IgniteKernal)grid(0); IgniteCache<Object, Object> jcache = ignite.cache(DEFAULT_CACHE_NAME); try (Transaction tx = ignite.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) { jcache.get("1"); jcache.put("1", "11"); IgniteInternalCache<Object, Object> utilityCache = ignite.context().cache().utilityCache(); utilityCache.getAndPutIfAbsent("2", "2"); try (GridNearTxLocal itx = utilityCache.txStartEx(PESSIMISTIC, REPEATABLE_READ)) { assertEquals(null, utilityCache.get("1")); assertEquals("2", utilityCache.get("2")); assertEquals(null, utilityCache.get("3")); utilityCache.getAndPut("3", "3"); itx.commit(); } jcache.put("2", "22"); tx.commit(); } checkTransactionsCommitted(); checkEntries(DEFAULT_CACHE_NAME, "1", "11", "2", "22", "3", null); checkEntries(CU.UTILITY_CACHE_NAME, "1", null, "2", "2", "3", "3"); }
/** * @throws Exception If failed. */ @Test public void testSystemCacheOnClientNode() throws Exception { startGrids(2); final IgniteKernal ignite = (IgniteKernal)ignite(1); assertTrue(ignite.configuration().isClientMode()); GridCacheAdapter utilityCache = ((IgniteKernal)ignite(0)).internalCache(CU.UTILITY_CACHE_NAME); Collection<ClusterNode> affNodes = utilityCache.affinity().mapKeyToPrimaryAndBackups(1); assertEquals(1, affNodes.size()); assertTrue(affNodes.contains(ignite(0).cluster().localNode())); } }
IgniteKernal k = (IgniteKernal)g; info(">>>> Entries on node: " + k.getLocalNodeId()); GridCacheAdapter<Object, Object> cache = k.internalCache("partitioned"); ']'); primaryCacheSize += ((IgniteKernal)g).internalCache(CACHE_NAME).primarySize();
/** * UnRegisters the mxbean if registered already. * * @param name Cache name. * @param beanType Mxbean name. */ private void unregisterCacheObject(String name, String beanType) { if(IgniteUtils.IGNITE_MBEANS_DISABLED) return; MBeanServer mBeanSrv = ignite.configuration().getMBeanServer(); Set<ObjectName> registeredObjNames = mBeanSrv.queryNames(getObjectName(name, beanType), null); //should just be one for (ObjectName registeredObjectName : registeredObjNames) { try { mBeanSrv.unregisterMBean(registeredObjectName); } catch (Exception e) { throw new CacheException("Error unregistering object instance " + registeredObjectName + " . Error was " + e.getMessage(), e); } } }
/** * Checks internal iterators maps are cleared. */ private void assertSetIteratorsCleared() { for (int i = 0; i < gridCount(); i++) { IgniteKernal grid = (IgniteKernal) grid(i); for (IgniteCache cache : grid.caches()) { GridCacheQueryManager queries = grid.internalCache(cache.getName()).context().queries(); Map map = GridTestUtils.getFieldValue(queries, GridCacheQueryManager.class, "qryIters"); for (Object obj : map.values()) assertEquals("Iterators not removed for grid " + i, 0, ((Map) obj).size()); } } }
/** * Gets grid instance without waiting its initialization and not throwing any exception. * * @param locNodeId ID of local node the requested grid instance is managing. * @return Grid instance or {@code null}. */ public static IgniteKernal gridxx(UUID locNodeId) { IgniteNamedInstance dfltGrid0 = dfltGrid; if (dfltGrid0 != null) { IgniteKernal g = dfltGrid0.grid(); if (g != null && g.getLocalNodeId().equals(locNodeId)) return g; } for (IgniteNamedInstance grid : grids.values()) { IgniteKernal g = grid.grid(); if (g != null && g.getLocalNodeId().equals(locNodeId)) return g; } return null; }
/** * @param cacheName Cache name. * @return Cache. */ @Nullable private <K, V> IgniteCache<K, V> getCache0(String cacheName) { if (cacheName == null) throw new NullPointerException(); try { return ignite.cache(cacheName); } catch (IllegalArgumentException ignored) { return null; } }