use of org.jboss.pnc.spi.events.BuildStatusChangedEvent in project pnc by project-ncl.
the class DefaultBuildCoordinator method updateBuildTaskStatus.
private void updateBuildTaskStatus(BuildTask task, BuildCoordinationStatus status, String statusDescription) {
BuildCoordinationStatus oldStatus = task.getStatus();
// REJECTED_ALREADY_BUILT -> DONE
if (status.isCompleted() && !oldStatus.isCompleted()) {
markFinished(task, status, statusDescription);
} else {
task.setStatus(status);
task.setStatusDescription(statusDescription);
}
Build build = buildMapper.fromBuildTask(task);
BuildStatusChangedEvent buildStatusChanged = new DefaultBuildStatusChangedEvent(build, BuildStatus.fromBuildCoordinationStatus(oldStatus), BuildStatus.fromBuildCoordinationStatus(status));
log.debug("Updated build task {} status to {}; old coord status: {}, new coord status: {}", task.getId(), buildStatusChanged, oldStatus, status);
userLog.info("Build status updated to {}; previous: {}", status, oldStatus);
BuildStatus oldBuildStatus = BuildStatus.fromBuildCoordinationStatus(oldStatus);
BuildStatus newBuildStatus = BuildStatus.fromBuildCoordinationStatus(status);
if ((oldBuildStatus != newBuildStatus) && !(oldBuildStatus.isFinal() && newBuildStatus.isFinal())) {
// only fire notification when BuildStatus changes
// and avoid firing the notification when old and new statuses are final (NCL-5885)
buildStatusChangedEventNotifier.fire(buildStatusChanged);
log.debug("Fired buildStatusChangedEventNotifier after task {} status update to {}.", task.getId(), status);
}
}
use of org.jboss.pnc.spi.events.BuildStatusChangedEvent in project pnc by project-ncl.
the class BuildStatusNotifications method observeEvent.
public void observeEvent(@Observes BuildStatusChangedEvent event) {
log.debug("Observed new status changed event {}.", event);
// Avoid CDI runtime issue issue NCL-1505
BuildStatusChangedEvent buildStatusChangedEvent = event;
Predicate<BuildCallBack> filterSubscribersMatchingTaskId = (callBackUrl) -> callBackUrl.getBuildTaskId().equals(buildStatusChangedEvent.getBuild().getId());
Set<BuildCallBack> matchingTasks = subscribers.stream().filter(filterSubscribersMatchingTaskId).collect(Collectors.toSet());
matchingTasks.forEach((buildCallBack) -> removeListenersOfCompletedTasks(buildCallBack, buildStatusChangedEvent));
matchingTasks.forEach((buildCallBack) -> buildCallBack.callback(buildStatusChangedEvent));
log.debug("Status changed event processed {}.", event);
}
Aggregations