use of com.epam.pipeline.entity.configuration.RunConfiguration in project cloud-pipeline by epam.
the class RunConfigurationManager method create.
@Transactional(propagation = Propagation.REQUIRED)
public RunConfiguration create(RunConfigurationVO configuration) {
RunConfiguration newConfig = runConfigurationMapper.toRunConfiguration(configuration);
validateConfiguration(newConfig);
newConfig.setOwner(authManager.getAuthorizedUser());
return runConfigurationDao.create(newConfig);
}
use of com.epam.pipeline.entity.configuration.RunConfiguration in project cloud-pipeline by epam.
the class FolderManager method loadTree.
public Folder loadTree() {
List<Folder> result = folderDao.loadAllFolders();
List<Pipeline> rootPipelines = pipelineManager.loadRootPipelines();
List<AbstractDataStorage> rootDataStorages = dataStorageManager.loadRootDataStorages();
List<RunConfiguration> rootRunConfigurations = configurationManager.loadRootConfigurations();
Map<String, Integer> rootMetadataEntityCount = metadataEntityManager.loadRootMetadataEntities();
Folder root = new Folder();
root.setChildFolders(result);
if (!CollectionUtils.isEmpty(rootPipelines)) {
root.setPipelines(rootPipelines);
}
if (!CollectionUtils.isEmpty(rootDataStorages)) {
root.setStorages(rootDataStorages);
}
if (!CollectionUtils.isEmpty(rootRunConfigurations)) {
root.setConfigurations(rootRunConfigurations);
}
if (!CollectionUtils.sizeIsEmpty(rootMetadataEntityCount)) {
root.setMetadata(rootMetadataEntityCount);
}
return root;
}
use of com.epam.pipeline.entity.configuration.RunConfiguration in project cloud-pipeline by epam.
the class ConfigurationRunner method runConfiguration.
/**
* Schedules execution of a {@link RunConfiguration} and creates a number
* of associated {@link PipelineRun} instances. Default values of {@link RunConfiguration}
* may be overriden by {@code runConfiguration} parameter. If {@code entitiesIds} or {@code metadataClass}
* are passed method will try to resolve {@link RunConfiguration} parameters according to
* {@link MetadataEntity} instances. For {@code metadataClass} method will try to find
* {@link MetadataEntity} instances in the whole project with matching {@link MetadataClass}.
* For each resolved {@link MetadataEntity} instance a separate {@link PipelineRun} or several ones
* will be created.
*
* @param refreshToken authorization token for Firecloud
* @param runConfiguration to run. Must specify {@code id} parameter of existing in DB
* {@link RunConfiguration} instance. Any other parameter may be specified,
* in this case it will override the same parameter from DB instance.
* For cluster (producing several {@link PipelineRun}) configurations if a list of
* {@link RunConfigurationEntry} is passed in {@code entries} field,
* only entries from this list will be scheduled. If {@code entitiesIds} are specified in
* {@link RunConfigurationWithEntitiesVO} for each entity id a separate run(s)
* of {@link RunConfiguration} will be scheduled. If {@code metadataClass} is set
* a separate run(s) will be scheduled for each {@link MetadataEntity} instance
* with a matching {@link MetadataClass} in current project.
* @param expansionExpression expression to convert actual entities from {@code entitiesIds}
* to required {@code rootEntityId} specified in {@link RunConfigurationEntry}
* @return list of scheduled {@link PipelineRun}
*/
public List<PipelineRun> runConfiguration(String refreshToken, RunConfigurationWithEntitiesVO runConfiguration, String expansionExpression) {
RunConfiguration dbConfiguration = configurationManager.load(runConfiguration.getId());
RunConfiguration configuration = mergeRunConfigurations(dbConfiguration, runConfigurationMapper.toRunConfiguration(runConfiguration));
configurationManager.validateConfiguration(configuration);
configuration.getEntries().forEach(entry -> configurationProvider.assertExecutionEnvironment(entry));
List<Long> entitiesIds = getIdsToProcess(runConfiguration);
return configuration.getEntries().stream().collect(Collectors.groupingBy(AbstractRunConfigurationEntry::getExecutionEnvironment)).entrySet().stream().map(env -> {
AnalysisConfiguration<AbstractRunConfigurationEntry> conf = AnalysisConfiguration.builder().configurationId(configuration.getId()).entries(env.getValue()).entitiesIds(entitiesIds).expansionExpression(expansionExpression).refreshToken(refreshToken).build();
return configurationProvider.runAnalysis(conf);
}).flatMap(Collection::stream).collect(Collectors.toList());
}
use of com.epam.pipeline.entity.configuration.RunConfiguration in project cloud-pipeline by epam.
the class RunConfigurationDaoTest method testCRUD.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void testCRUD() {
// create
RunConfigurationEntry entry = ObjectCreatorUtils.createConfigEntry(TEST_CONFIG_NAME, true, getTestConfig());
RunConfiguration configuration = ObjectCreatorUtils.createConfiguration(TEST_NAME, TEST_DESCRIPTION, null, TEST_OWNER, Collections.singletonList(entry));
RunConfiguration created = runConfigurationDao.create(configuration);
verifyRunConfiguration(configuration, created);
// load
RunConfiguration loaded = runConfigurationDao.load(created.getId());
verifyRunConfiguration(configuration, loaded);
// loadAll
List<RunConfiguration> configurations = runConfigurationDao.loadAll();
Assert.assertEquals(1, configurations.size());
verifyRunConfiguration(configuration, configurations.get(0));
// loadRoot
configurations = runConfigurationDao.loadRootEntities();
Assert.assertEquals(1, configurations.size());
verifyRunConfiguration(configuration, configurations.get(0));
// load with folders
loaded = runConfigurationDao.loadConfigurationWithParents(created.getId());
verifyRunConfiguration(configuration, loaded);
// update
created.setDescription(TEST_DESCRIPTION + TEST_DESCRIPTION);
created.setEntries(Arrays.asList(entry, entry));
runConfigurationDao.update(created);
verifyRunConfiguration(created, runConfigurationDao.load(created.getId()));
// delete
runConfigurationDao.delete(created.getId());
Assert.assertTrue(runConfigurationDao.loadAll().isEmpty());
}
use of com.epam.pipeline.entity.configuration.RunConfiguration in project cloud-pipeline by epam.
the class RunConfigurationDaoTest method shouldLoadRunConfigurationWithFolderTree.
@Test
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Exception.class)
public void shouldLoadRunConfigurationWithFolderTree() {
Folder root = buildFolder(TEST_NAME, null);
root.setParentId(0L);
Folder folder = buildFolder(TEST_NAME_1, root.getId());
folder.setParent(root);
Folder parent = buildFolder(TEST_NAME_2, folder.getId());
parent.setParent(folder);
RunConfigurationEntry entry = ObjectCreatorUtils.createConfigEntry(TEST_CONFIG_NAME, true, getTestConfig());
RunConfiguration configuration = ObjectCreatorUtils.createConfiguration(TEST_NAME, TEST_DESCRIPTION, parent.getId(), TEST_OWNER, Collections.singletonList(entry));
RunConfiguration created = runConfigurationDao.create(configuration);
verifyRunConfiguration(configuration, created);
// load with folders
RunConfiguration loaded = runConfigurationDao.loadConfigurationWithParents(created.getId());
verifyRunConfiguration(configuration, loaded);
verifyFolderTree(parent, loaded.getParent());
}
Aggregations