/** * @param loc Enforce local. * @return Local node cluster group. */ private ClusterGroup projection(boolean loc) { GridCacheContext<K, V> ctx = getContextSafe(); if (loc || ctx.isLocal() || ctx.isReplicatedAffinityNode()) return ctx.kernalContext().grid().cluster().forLocal(); if (ctx.isReplicated()) return ctx.kernalContext().grid().cluster().forDataNodes(cacheName).forRandom(); return null; }
/** * Compares checksums between primary and backup partitions of specified caches. * Works properly only on idle cluster - there may be false positive conflict reports if data in cluster is being * concurrently updated. * * @param ig Ignite instance. * @param caches Cache names (if null, all user caches will be verified). * @return Conflicts result. * @throws IgniteException If none caches or node found. */ protected IdleVerifyResultV2 idleVerify(Ignite ig, String... caches) { IgniteEx ig0 = (IgniteEx)ig; Set<String> cacheNames = new HashSet<>(); if (F.isEmpty(caches)) cacheNames.addAll(ig0.cacheNames()); else Collections.addAll(cacheNames, caches); if (cacheNames.isEmpty()) throw new IgniteException("None cache for checking."); ClusterNode node = !ig0.localNode().isClient() ? ig0.localNode() : ig0.cluster().forServers().forRandom().node(); if (node == null) throw new IgniteException("None server node for verification."); VisorIdleVerifyTaskArg taskArg = new VisorIdleVerifyTaskArg(cacheNames); return ig.compute().execute( VisorIdleVerifyTaskV2.class.getName(), new VisorTaskArgument<>(node.id(), taskArg, false) ); }
/** * @throws Exception If failed. */ @Test public void testEmptyGroup() throws Exception { ClusterGroup emptyGrp = ignite.cluster().forAttribute("nonExistent", "val"); assertEquals(0, emptyGrp.forOldest().nodes().size()); assertEquals(0, emptyGrp.forYoungest().nodes().size()); assertEquals(0, emptyGrp.forAttribute("nonExistent2", "val").nodes().size()); assertEquals(0, emptyGrp.forCacheNodes("cacheName").nodes().size()); assertEquals(0, emptyGrp.forClientNodes("cacheName").nodes().size()); assertEquals(0, emptyGrp.forClients().nodes().size()); assertEquals(0, emptyGrp.forDaemons().nodes().size()); assertEquals(0, emptyGrp.forDataNodes("cacheName").nodes().size()); assertEquals(0, emptyGrp.forRandom().nodes().size()); assertEquals(0, emptyGrp.forRemotes().nodes().size()); assertEquals(0, emptyGrp.forServers().nodes().size()); assertEquals(0, emptyGrp.forHost(ignite.cluster().localNode()).nodes().size()); assertEquals(0, emptyGrp.forHost("127.0.0.1").nodes().size()); }
/** * @throws Exception If failed. */ @Test public void testSerializeClosure() throws Exception { Ignite client = ignite(CLIENT); final IgniteCache<Integer, Integer> clientCache = client.createCache(cacheConfiguration(PARTITIONED, ATOMIC)); try { client.compute(client.cluster().forRemotes().forRandom()).call(new IgniteCallable<Object>() { @Override public Object call() throws Exception { clientCache.withKeepBinary(); clientCache.withSkipStore(); return null; } }); } finally { client.destroyCache(DEFAULT_CACHE_NAME); } } }
/** * @param loc Enforce local. * @return Local node cluster group. */ private ClusterGroup projection(boolean loc) { if (loc || ctx.isLocal() || ctx.isReplicatedAffinityNode()) return ctx.kernalContext().grid().cluster().forLocal(); if (ctx.isReplicated()) return ctx.kernalContext().grid().cluster().forDataNodes(ctx.name()).forRandom(); return null; }