/** * 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())); } }
/** * Starts new grid node. * * @param gridName name of new node. * @param springCfg file with spring configuration to use for this node. * @return a grid instance local to new node {@link GridGain#start(GridConfiguration)}. * @throws Exception if node run failed. */ protected Grid startNode(String gridName, File springCfg) throws Exception { assert springCfg != null; ListableBeanFactory springCtx = new FileSystemXmlApplicationContext("file:///" + springCfg.getAbsolutePath()); Map cfgMap = springCtx.getBeansOfType(GridConfiguration.class); assert cfgMap != null; assert !cfgMap.isEmpty(); GridConfiguration cfg = (GridConfiguration) cfgMap.values().iterator().next(); cfg.setGridName(gridName + "-" + getNextNodeNum()); return G.start(cfg); }