/** * Starts the background cleanup of old cache entries. * * @param grid Grid. * @param metaCache Meta cache. * @param dataCacheName Data cache name. * @param currentVersions Current versions. */ private void startBackgroundCleanup(Ignite grid, final Cache<CleanupNodeId, UUID> metaCache, final String dataCacheName, final Map<String, EntryProcessorResult<Long>> currentVersions) { if (cleanupFlags.containsKey(dataCacheName)) return; // Current node already performs cleanup. if (!trySetGlobalCleanupFlag(grid, metaCache)) return; cleanupFlags.put(dataCacheName, true); final ClusterGroup dataNodes = grid.cluster().forDataNodes(dataCacheName); IgniteFuture f = grid.compute(dataNodes).broadcastAsync( new RemoveOldEntriesRunnable(dataCacheName, currentVersions)); f.listen(new CleanupCompletionListener(metaCache, dataCacheName)); }
/** * @throws Exception If failed. */ @Test public void testForDataNodes() throws Exception { ClusterGroup grp = ignite.cluster().forDataNodes(DEFAULT_CACHE_NAME); assertFalse(grp.nodes().isEmpty()); try { daemon.cluster().forDataNodes(DEFAULT_CACHE_NAME); } catch (IllegalStateException ignored) { return; } fail(); }
/** * @throws Exception If failed. */ @Test public void testProjectionForDataCaches() throws Exception { ClusterGroup prj = ignite.cluster().forDataNodes(DEFAULT_CACHE_NAME); assert prj != null; assert prj.nodes().size() == 1; assert prj.nodes().contains(grid(0).localNode()); }
/** * @throws Exception If failed. */ @Test public void testCacheFilter() throws Exception { Ignite group1 = startGridsMultiThreaded(3); attrs = F.asMap("group", "data"); Ignite group2 = startGridsMultiThreaded(3, 2); group1.createCache(new CacheConfiguration<>("test-cache"). setNodeFilter(new AttributeNodeFilter("group", "data"))); assertEquals(2, group1.cluster().forDataNodes("test-cache").nodes().size()); assertEquals(2, group2.cluster().forDataNodes("test-cache").nodes().size()); assertEquals(0, group1.cluster().forDataNodes("wrong").nodes().size()); assertEquals(0, group2.cluster().forDataNodes("wrong").nodes().size()); }
assertTrue(pages.get() > ignite().cluster().forDataNodes(DEFAULT_CACHE_NAME).nodes().size());
/** * Starts the background cleanup of old cache entries. * * @param grid Grid. * @param metaCache Meta cache. * @param dataCacheName Data cache name. * @param currentVersions Current versions. */ private void startBackgroundCleanup(Ignite grid, final Cache<CleanupNodeId, UUID> metaCache, final String dataCacheName, final Map<String, EntryProcessorResult<Long>> currentVersions) { if (cleanupFlags.containsKey(dataCacheName)) return; // Current node already performs cleanup. if (!trySetGlobalCleanupFlag(grid, metaCache)) return; cleanupFlags.put(dataCacheName, true); final ClusterGroup dataNodes = grid.cluster().forDataNodes(dataCacheName); IgniteFuture f = grid.compute(dataNodes).broadcastAsync( new RemoveOldEntriesRunnable(dataCacheName, currentVersions)); f.listen(new CleanupCompletionListener(metaCache, dataCacheName)); }