/** @throws GridException If failed. */ public void testAffinity() throws GridException { Grid g1 = grid(1); Grid g2 = grid(2); assert caches(g1).size() == 0; assert F.first(caches(g2)).getCacheMode() == PARTITIONED; Map<GridNode, Collection<String>> map = g1.mapKeysToNodes(null, F.asList("1")); assertNotNull(map); assertEquals("Invalid map size: " + map.size(), 1, map.size()); assertEquals(F.first(map.keySet()), g2.localNode()); UUID id1 = g1.mapKeyToNode(null, "2").id(); assertNotNull(id1); assertEquals(g2.localNode().id(), id1); UUID id2 = g1.mapKeyToNode(null, "3").id(); assertNotNull(id2); assertEquals(g2.localNode().id(), id2); }
/** * Starts the local node and checks for presence of log file. Also checks that this is really a * log of a started node. * * @param id Test-local node ID. * @throws Exception If error occurred. */ private void checkOneNode(int id) throws Exception { try (Grid grid = G.start(getConfiguration("grid" + id))) { String id8 = U.id8(grid.localNode().id()); String logPath = "work/log/gridgain-" + id8 + ".log"; File logFile = U.resolveGridGainPath(logPath); assertNotNull("Failed to resolve path: " + logPath, logFile); assertTrue("Log file does not exist: " + logFile, logFile.exists()); String logContent = U.readFileToString(logFile.getAbsolutePath(), "UTF-8"); assertTrue( "Log file does not contain it's node ID: " + logFile, logContent.contains(">>> Local node [ID=" + id8.toUpperCase())); } }