int[] evts = cacheEvents(props.get(IgniteSourceConstants.CACHE_EVENTS)); rmtLsnrId = IgniteGrid.getIgnite().events(IgniteGrid.getIgnite().cluster().forCacheNodes(cacheName)) .remoteListen(locLsnr, rmtLsnr, evts);
/** * Stops the remote listener. */ protected void stopRemoteListen() { if (rmtLsnrId != null) IgniteGrid.getIgnite().events(IgniteGrid.getIgnite().cluster().forCacheNodes(cacheName)) .stopRemoteListen(rmtLsnrId); rmtLsnrId = null; }
/** {@inheritDoc} */ @Override public void cancel() { synchronized (this) { if (!isRunning) return; isRunning = false; if (rmtLsnrId != null && ignite != null) { ignite.events(ignite.cluster().forCacheNodes(cacheName)) .stopRemoteListen(rmtLsnrId); rmtLsnrId = null; } } }
@Override public boolean apply() { ClusterGroup grp = ignite.cluster().forCacheNodes(DEFAULT_CACHE_NAME); return grp.nodes().size() == expNodes; } }, 5000);
@Override public boolean apply() { ClusterGroup grp = client.cluster().forCacheNodes(DEFAULT_CACHE_NAME); return grp.nodes().size() == expNodes; } }, 5000);
@Override public boolean apply() { return ignite(0).cluster().forCacheNodes(cacheName).nodes().size() == 5; } }, 5000);
/** * Starts Ignite source. * * @param filter User defined filter. * @param cacheEvts Converts comma-delimited cache events strings to Ignite internal representation. */ @SuppressWarnings("unchecked") public void start(IgnitePredicate<CacheEvent> filter, int... cacheEvts) { A.notNull(cacheName, "Cache name"); TaskRemoteFilter rmtLsnr = new TaskRemoteFilter(cacheName, filter); try { synchronized (this) { if (isRunning) return; isRunning = true; rmtLsnrId = ignite.events(ignite.cluster().forCacheNodes(cacheName)) .remoteListen(locLsnr, rmtLsnr, cacheEvts); } } catch (IgniteException e) { log.error("Failed to register event listener!", e); throw e; } }
/** * @throws Exception If failed. */ @Test public void testForCacheNodesOnDynamicCacheCreateDestroy() throws Exception { Random rnd = ThreadLocalRandom.current(); final AtomicReference<Exception> ex = new AtomicReference<>(); IgniteInternalFuture fut = runCacheCreateDestroyTask(ex); while (!fut.isDone()) ignite.cluster().forCacheNodes("cache" + rnd.nextInt(16)).nodes(); if (ex.get() != null) throw ex.get(); }
/** * @throws Exception If failed. */ @Test public void testProjectionForWrongCacheName() throws Exception { ClusterGroup prj = ignite.cluster().forCacheNodes("wrong"); assert prj != null; assert prj.nodes().isEmpty(); }
/** * @throws Exception If failed. */ @Test public void testForCacheNodes() throws Exception { ClusterGroup grp = ignite.cluster().forCacheNodes(DEFAULT_CACHE_NAME); assertFalse(grp.nodes().isEmpty()); try { daemon.cluster().forCacheNodes(DEFAULT_CACHE_NAME); } catch (IllegalStateException ignored) { return; } fail(); } }
/** * @throws Exception If failed. */ @Test public void testProjectionForNamedCache() throws Exception { final ClusterGroup prj = ignite.cluster().forCacheNodes(CACHE_NAME); assertNotNull(prj); GridTestUtils.waitForCondition(new GridAbsPredicate() { @Override public boolean apply() { return prj.nodes().size() == 3; } }, 5000); assertEquals("Invalid projection: " + prj.nodes(), 3, prj.nodes().size()); assert !prj.nodes().contains(grid(0).localNode()); assert prj.nodes().contains(grid(1).localNode()); assert prj.nodes().contains(grid(2).localNode()); assert prj.nodes().contains(grid(3).localNode()); assert !prj.nodes().contains(grid(4).localNode()); }
/** * @throws Exception If failed. */ @Test public void testProjectionForDefaultCache() throws Exception { final ClusterGroup prj = ignite.cluster().forCacheNodes(DEFAULT_CACHE_NAME); assertNotNull(prj); GridTestUtils.waitForCondition(new GridAbsPredicate() { @Override public boolean apply() { return prj.nodes().size() == 3; } }, 5000); assertEquals(3, prj.nodes().size()); assertTrue(prj.nodes().contains(grid(0).localNode())); assertFalse(prj.nodes().contains(grid(1).localNode())); assertTrue(prj.nodes().contains(grid(2).localNode())); assertTrue(prj.nodes().contains(grid(3).localNode())); assertFalse(prj.nodes().contains(grid(4).localNode())); }
ignite.events(ignite.cluster().forCacheNodes(DEFAULT_CACHE_NAME)).remoteListen(locLsnr, null, EVT_CACHE_OBJECT_PUT);
Collection<ClusterNode> nodes = node.cluster().forCacheNodes("cache-" + c).nodes();
ClusterGroup grp = client.cluster().forCacheNodes(DEFAULT_CACHE_NAME); ClusterGroup grp = ignite.cluster().forCacheNodes(DEFAULT_CACHE_NAME);
Collection<ClusterNode> nodes = node.cluster().forCacheNodes("cache-" + c).nodes();