Search in sources :

Example 1 with WORKER_CMD_TEMPLATE

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;
}
Also used : PipelineManager(com.epam.pipeline.manager.pipeline.PipelineManager) MessageConstants(com.epam.pipeline.common.MessageConstants) ParameterMapper(com.epam.pipeline.manager.pipeline.ParameterMapper) PipelineRunManager(com.epam.pipeline.manager.pipeline.PipelineRunManager) RequiredArgsConstructor(lombok.RequiredArgsConstructor) SystemPreferences(com.epam.pipeline.manager.preference.SystemPreferences) CollectionUtils(org.apache.commons.collections4.CollectionUtils) ArrayList(java.util.ArrayList) PipelineRun(com.epam.pipeline.entity.pipeline.PipelineRun) MessageHelper(com.epam.pipeline.common.MessageHelper) Service(org.springframework.stereotype.Service) AbstractRunConfigurationEntry(com.epam.pipeline.entity.configuration.AbstractRunConfigurationEntry) RunConfigurationEntry(com.epam.pipeline.entity.configuration.RunConfigurationEntry) PipelineConfiguration(com.epam.pipeline.entity.configuration.PipelineConfiguration) Pipeline(com.epam.pipeline.entity.pipeline.Pipeline) PipelineConfigurationManager(com.epam.pipeline.manager.pipeline.PipelineConfigurationManager) WORKER_CMD_TEMPLATE(com.epam.pipeline.manager.pipeline.PipelineConfigurationManager.WORKER_CMD_TEMPLATE) PreferenceManager(com.epam.pipeline.manager.preference.PreferenceManager) Collection(java.util.Collection) RunConfigurationUtils.getNodeCount(com.epam.pipeline.entity.configuration.RunConfigurationUtils.getNodeCount) Collectors(java.util.stream.Collectors) ResolvedConfiguration(com.epam.pipeline.entity.pipeline.ResolvedConfiguration) NFS_CLUSTER_ROLE(com.epam.pipeline.manager.pipeline.PipelineConfigurationManager.NFS_CLUSTER_ROLE) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) Data(lombok.Data) PipelineStart(com.epam.pipeline.entity.pipeline.run.PipelineStart) Assert(org.springframework.util.Assert) StringUtils(org.springframework.util.StringUtils) PipelineRun(com.epam.pipeline.entity.pipeline.PipelineRun) ArrayList(java.util.ArrayList) AbstractRunConfigurationEntry(com.epam.pipeline.entity.configuration.AbstractRunConfigurationEntry) RunConfigurationEntry(com.epam.pipeline.entity.configuration.RunConfigurationEntry) PipelineConfiguration(com.epam.pipeline.entity.configuration.PipelineConfiguration)

Aggregations

MessageConstants (com.epam.pipeline.common.MessageConstants)1 MessageHelper (com.epam.pipeline.common.MessageHelper)1 AbstractRunConfigurationEntry (com.epam.pipeline.entity.configuration.AbstractRunConfigurationEntry)1 PipelineConfiguration (com.epam.pipeline.entity.configuration.PipelineConfiguration)1 RunConfigurationEntry (com.epam.pipeline.entity.configuration.RunConfigurationEntry)1 RunConfigurationUtils.getNodeCount (com.epam.pipeline.entity.configuration.RunConfigurationUtils.getNodeCount)1 Pipeline (com.epam.pipeline.entity.pipeline.Pipeline)1 PipelineRun (com.epam.pipeline.entity.pipeline.PipelineRun)1 ResolvedConfiguration (com.epam.pipeline.entity.pipeline.ResolvedConfiguration)1 PipelineStart (com.epam.pipeline.entity.pipeline.run.PipelineStart)1 ParameterMapper (com.epam.pipeline.manager.pipeline.ParameterMapper)1 PipelineConfigurationManager (com.epam.pipeline.manager.pipeline.PipelineConfigurationManager)1 NFS_CLUSTER_ROLE (com.epam.pipeline.manager.pipeline.PipelineConfigurationManager.NFS_CLUSTER_ROLE)1 WORKER_CMD_TEMPLATE (com.epam.pipeline.manager.pipeline.PipelineConfigurationManager.WORKER_CMD_TEMPLATE)1 PipelineManager (com.epam.pipeline.manager.pipeline.PipelineManager)1 PipelineRunManager (com.epam.pipeline.manager.pipeline.PipelineRunManager)1 PreferenceManager (com.epam.pipeline.manager.preference.PreferenceManager)1 SystemPreferences (com.epam.pipeline.manager.preference.SystemPreferences)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1