use of com.epam.pipeline.manager.pipeline.PipelineConfigurationManager.WORKER_CMD_TEMPLATE in project cloud-pipeline by epam.
the class CloudPlatformRunner method runConfiguration.
private List<PipelineRun> runConfiguration(Long configurationId, List<RunConfigurationEntry> entries, ResolvedConfiguration resolvedConfigurations) {
SplitConfig splitConfig = new SplitConfig(entries);
RunConfigurationEntry mainEntry = splitConfig.getMain();
List<RunConfigurationEntry> childEntries = splitConfig.getChildEntries();
boolean isMasterNFSServer = pipelineConfigurationManager.hasNFSParameter(mainEntry.getConfiguration()) || childEntries.stream().noneMatch(entry -> pipelineConfigurationManager.hasNFSParameter(entry.getConfiguration()));
boolean nfsStarted = isMasterNFSServer;
PipelineConfiguration mainConfiguration = resolvedConfigurations.getConfiguration(mainEntry.getName());
List<PipelineConfiguration> childConfigurations = childEntries.stream().map(entry -> resolvedConfigurations.getConfiguration(entry.getName())).collect(Collectors.toList());
int masterNodeCount = getNodeCount(mainConfiguration.getNodeCount(), 0);
int totalNodes = childConfigurations.stream().map(PipelineConfiguration::getNodeCount).mapToInt(nodeCount -> getNodeCount(nodeCount, 1)).sum();
totalNodes += masterNodeCount;
log.debug("Running total {} nodes", totalNodes + 1);
mainConfiguration.setNodeCount(totalNodes);
// create master run
List<PipelineRun> masterRun = runConfigurationEntry(mainEntry, mainConfiguration, 1, null, isMasterNFSServer, resolvedConfigurations.getAllAssociatedIds(), configurationId);
List<PipelineRun> launched = new ArrayList<>(masterRun);
String clusterId = String.valueOf(masterRun.get(0).getId());
// create master workers
if (masterNodeCount > 0) {
mainEntry.getConfiguration().setWorkerCmd(WORKER_CMD_TEMPLATE);
launched.addAll(runConfigurationEntry(mainEntry, mainConfiguration, masterNodeCount, clusterId, false, resolvedConfigurations.getAllAssociatedIds(), configurationId));
}
// create all other workers
for (int i = 0; i < childConfigurations.size(); i++) {
PipelineConfiguration childConfig = childConfigurations.get(i);
boolean startNFS = !nfsStarted && pipelineConfigurationManager.hasNFSParameter(childConfig);
nfsStarted = nfsStarted || startNFS;
int copies = getNodeCount(childConfig.getNodeCount(), 1);
launched.addAll(runConfigurationEntry(childEntries.get(i), childConfig, copies, clusterId, startNFS, resolvedConfigurations.getAllAssociatedIds(), configurationId));
}
return launched;
}
Aggregations