/** {@inheritDoc} */ @Override protected Object executeJob(int gridSize, String type) { log.info(">>> Starting new grid node [currGridSize=" + gridSize + ", arg=" + type + "]"); if (type == null) throw new IllegalArgumentException("Node type to start should be specified."); IgniteConfiguration cfg = getConfig(type); // Generate unique for this VM grid name. String gridName = cfg.getGridName() + " (" + UUID.randomUUID() + ")"; // Update grid name (required to be unique). cfg.setGridName(gridName); // Start new node in current VM. Ignite g = G.start(cfg); log.info( ">>> Grid started [nodeId=" + g.cluster().localNode().id() + ", name='" + g.name() + "']"); return true; }
/** * Example for start/stop node tasks. * * @param args Not used. */ public static void main(String[] args) { String nodeType = "tcp+ssl"; // Start initial node = 1 try (Ignite g = G.start(NODE_CFG.get(nodeType))) { // Change topology. changeTopology(g, 4, 1, nodeType); changeTopology(g, 1, 4, nodeType); // Stop node by id = 0 g.compute().execute(ClientStopNodeTask.class, g.cluster().localNode().id().toString()); // Wait for node stops. // U.sleep(1000); assert G.allGrids().isEmpty(); } catch (Exception e) { System.err.println("Uncaught exception: " + e.getMessage()); e.printStackTrace(System.err); } }