in bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/command/helper/ComponentStageHelper.java [135:181]
private static List<String> getTodoList(List<String> componentNames, List<Command> commands) {
try {
List<String> orderedList =
StackUtils.DAG.getAllNodesList().isEmpty() ? new ArrayList<>() : StackUtils.DAG.topologicalSort();
orderedList.replaceAll(String::toUpperCase);
List<String> componentCommandNames = new ArrayList<>();
for (String componentName : componentNames) {
for (Command command : commands) {
String name =
componentName.toUpperCase() + "-" + command.name().toUpperCase();
componentCommandNames.add(name);
}
}
// Re-order the commands, since order.json does not contain all commands,
// only contains which has dependencies, we need to add the rest to the end.
if (commands.size() == 1) {
orderedList.retainAll(componentCommandNames);
componentCommandNames.removeAll(orderedList);
orderedList.addAll(componentCommandNames);
return orderedList;
} else {
// TODO, order.json currently only contains start/stop dependencies of major components, the situation
// of commands size greater than 1 is only with init/start/prepare commands, we see this as a special
// situation and use special logic for it, should use a better solution in the future.
orderedList.retainAll(componentCommandNames);
componentCommandNames.removeAll(orderedList);
List<String> res = new ArrayList<>();
List<String> commandOrder = List.of("ADD", "CONFIGURE", "INIT", "START", "PREPARE", "CHECK");
for (String command : commandOrder) {
List<String> filtered = componentCommandNames.stream()
.filter(s -> s.endsWith(command))
.toList();
res.addAll(filtered);
if (command.equals("START")) {
res.addAll(orderedList);
}
}
return res;
}
} catch (Exception e) {
throw new ServerException(e);
}
}