Search in sources :

Example 41 with BuildTask

use of org.jboss.pnc.spi.coordinator.BuildTask in project pnc by project-ncl.

the class BuildProviderImpl method getRunningCount.

@Override
public RunningBuildCount getRunningCount() {
    List<BuildTask> x = buildCoordinator.getSubmittedBuildTasks();
    int waitingForDependencies = 0;
    int running = 0;
    int enqueued = 0;
    for (BuildTask task : x) {
        switch(task.getStatus()) {
            case ENQUEUED:
                enqueued++;
                continue;
            case BUILDING:
                running++;
                continue;
            case WAITING_FOR_DEPENDENCIES:
                waitingForDependencies++;
                continue;
        }
    }
    return new RunningBuildCount(running, enqueued, waitingForDependencies);
}
Also used : BuildTask(org.jboss.pnc.spi.coordinator.BuildTask) RunningBuildCount(org.jboss.pnc.dto.response.RunningBuildCount)

Example 42 with BuildTask

use of org.jboss.pnc.spi.coordinator.BuildTask in project pnc by project-ncl.

the class BuildTriggererImpl method doTriggerBuild.

private BuildSetTask doTriggerBuild(final int buildConfigId, OptionalInt buildConfigurationRevision, BuildOptions buildOptions) throws BuildConflictException, CoreException {
    BuildSetTask buildSetTask;
    if (buildConfigurationRevision.isPresent()) {
        final BuildConfigurationAudited buildConfigurationAudited = buildConfigurationAuditedRepository.queryById(new IdRev(buildConfigId, buildConfigurationRevision.getAsInt()));
        Preconditions.checkArgument(buildConfigurationAudited != null, "Can't find Build Configuration with id=" + buildConfigId + ", rev=" + buildConfigurationRevision.getAsInt());
        buildSetTask = buildCoordinator.build(hibernateLazyInitializer.initializeBuildConfigurationAuditedBeforeTriggeringIt(buildConfigurationAudited), user.currentUser(), buildOptions);
    } else {
        final BuildConfiguration buildConfiguration = buildConfigurationRepository.queryById(buildConfigId);
        Preconditions.checkArgument(buildConfiguration != null, "Can't find Build Configuration with id=" + buildConfigId);
        buildSetTask = buildCoordinator.build(hibernateLazyInitializer.initializeBuildConfigurationBeforeTriggeringIt(buildConfiguration), user.currentUser(), buildOptions);
    }
    logger.info("Started build of Build Configuration {}. Build Tasks: {}", buildConfigId, buildSetTask.getBuildTasks().stream().map(BuildTask::getId).collect(Collectors.joining()));
    return buildSetTask;
}
Also used : BuildConfiguration(org.jboss.pnc.model.BuildConfiguration) BuildConfigurationAudited(org.jboss.pnc.model.BuildConfigurationAudited) BuildTask(org.jboss.pnc.spi.coordinator.BuildTask) BuildSetTask(org.jboss.pnc.spi.coordinator.BuildSetTask) IdRev(org.jboss.pnc.model.IdRev)

Example 43 with BuildTask

use of org.jboss.pnc.spi.coordinator.BuildTask in project pnc by project-ncl.

the class BuildTriggererImpl method doTriggerGroupBuild.

private BuildSetTask doTriggerGroupBuild(final int groupConfigId, Optional<GroupBuildRequest> revs, BuildOptions buildOptions) throws CoreException {
    final BuildConfigurationSet buildConfigurationSet = buildConfigurationSetRepository.queryById(groupConfigId);
    Preconditions.checkArgument(buildConfigurationSet != null, "Can't find configuration with given id=" + groupConfigId);
    List<BuildConfigurationRevisionRef> revisions = revs.map(GroupBuildRequest::getBuildConfigurationRevisions).orElse(Collections.emptyList());
    BuildSetTask buildSetTask = buildCoordinator.build(hibernateLazyInitializer.initializeBuildConfigurationSetBeforeTriggeringIt(buildConfigurationSet), loadAuditedsFromDB(buildConfigurationSet, revisions), user.currentUser(), buildOptions);
    logger.info("Started build of Group Configuration {}. Build Tasks: {}", groupConfigId, buildSetTask.getBuildTasks().stream().map(BuildTask::getId).collect(Collectors.joining()));
    return buildSetTask;
}
Also used : BuildConfigurationSet(org.jboss.pnc.model.BuildConfigurationSet) BuildTask(org.jboss.pnc.spi.coordinator.BuildTask) BuildSetTask(org.jboss.pnc.spi.coordinator.BuildSetTask) BuildConfigurationRevisionRef(org.jboss.pnc.dto.BuildConfigurationRevisionRef)

Aggregations

BuildTask (org.jboss.pnc.spi.coordinator.BuildTask)43 Test (org.junit.Test)23 BuildRecord (org.jboss.pnc.model.BuildRecord)15 BuildSetTask (org.jboss.pnc.spi.coordinator.BuildSetTask)15 Build (org.jboss.pnc.dto.Build)13 BuildConfigurationAudited (org.jboss.pnc.model.BuildConfigurationAudited)13 BuildCoordinator (org.jboss.pnc.spi.coordinator.BuildCoordinator)13 BuildConfiguration (org.jboss.pnc.model.BuildConfiguration)12 BuildOptions (org.jboss.pnc.spi.BuildOptions)12 Logger (org.slf4j.Logger)12 LoggerFactory (org.slf4j.LoggerFactory)12 Inject (javax.inject.Inject)11 BuildConfigurationSet (org.jboss.pnc.model.BuildConfigurationSet)11 CoreException (org.jboss.pnc.spi.exception.CoreException)11 User (org.jboss.pnc.model.User)10 BuildStatusChangedEvent (org.jboss.pnc.spi.events.BuildStatusChangedEvent)10 Date (java.util.Date)9 Set (java.util.Set)9 HashSet (java.util.HashSet)8 List (java.util.List)8