/** * Change topology. * * @param parent Grid to execute tasks on. * @param add New nodes count. * @param rmv Remove nodes count. * @param type Type of nodes to manipulate. */ private static void changeTopology(Ignite parent, int add, int rmv, String type) { Collection<ComputeTaskFuture<?>> tasks = new ArrayList<>(); IgniteCompute comp = parent.compute().withAsync(); // Start nodes in parallel. while (add-- > 0) { comp.execute(ClientStartNodeTask.class, type); tasks.add(comp.future()); } for (ComputeTaskFuture<?> task : tasks) task.get(); // Stop nodes in sequence. while (rmv-- > 0) parent.compute().execute(ClientStopNodeTask.class, type); // Wait for node stops. // U.sleep(1000); Collection<String> gridNames = new ArrayList<>(); for (Ignite g : G.allGrids()) gridNames.add(g.name()); parent.log().info(">>> Available grids: " + gridNames); }