aboutsummaryrefslogtreecommitdiffstats
path: root/controller-server
diff options
context:
space:
mode:
authorJon Marius Venstad <jvenstad@yahoo-inc.com>2018-05-04 11:36:09 +0200
committerJon Marius Venstad <jvenstad@yahoo-inc.com>2018-05-04 11:36:09 +0200
commit4bffb2a875d5ba80b777eca04b7e7cf40215bd48 (patch)
tree0cc31d6fe3e6e6ea78d0fe58ffb65d8ae652f2c9 /controller-server
parent2994a77b2df8e3447dd9e3fa0f0eca054fd6f859 (diff)
Increase readability
Diffstat (limited to 'controller-server')
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTrigger.java31
1 files changed, 14 insertions, 17 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTrigger.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTrigger.java
index 69d847406bb..08913155f3f 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTrigger.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTrigger.java
@@ -122,7 +122,8 @@ public class DeploymentTrigger {
else
application = application.withOutstandingChange(Change.of(applicationVersion));
}
- } else {
+ }
+ else {
triggering = application.deploymentJobs().statusOf(report.jobType()).flatMap(JobStatus::lastTriggered)
.orElseThrow(() -> new IllegalStateException("Notified of completion of " + report.jobType().jobName() + " for " +
report.applicationId() + ", but that has neither been triggered nor deployed"));
@@ -286,9 +287,9 @@ public class DeploymentTrigger {
if (change.isPresent())
for (Step step : productionStepsOf(application)) {
Set<JobType> stepJobs = step.zones().stream().map(order::toJob).collect(toSet());
- Map<Instant, List<JobType>> jobsByCompletion = stepJobs.stream().collect(groupingBy(job -> completedAt(change, application, job).orElse(Instant.EPOCH)));
- if (jobsByCompletion.containsKey(Instant.EPOCH)) { // Step incomplete because some jobs remain, trigger those if the previous step was done, or required test steps.
- for (JobType job : jobsByCompletion.get(Instant.EPOCH)) {
+ Map<Instant, List<JobType>> jobsByCompletion = stepJobs.stream().collect(groupingBy(job -> completedAt(change, application, job).orElse(Instant.MAX)));
+ if (jobsByCompletion.containsKey(Instant.MAX)) { // Step incomplete because some jobs remain, trigger those if the previous step was done, or required test steps.
+ for (JobType job : jobsByCompletion.get(Instant.MAX)) {
Versions versions = versions(application, change, deploymentFor(application, job));
if (isTested(application, versions)) {
if (completedAt.isPresent()
@@ -366,7 +367,7 @@ public class DeploymentTrigger {
return lastSuccess.map(JobRun::at);
return deploymentFor(application, jobType)
- .filter(deployment -> !isUpgrade(change, deployment) && isDowngrade(application.change(), deployment))
+ .filter(deployment -> ! isUpgrade(change, deployment) && isDowngrade(application.change(), deployment))
.map(Deployment::at);
}
@@ -403,9 +404,9 @@ public class DeploymentTrigger {
* of the given job run. */
private static boolean sourcesMatchIfPresent(Versions versions, JobRun jobRun) {
return ( ! versions.sourcePlatform.filter(version -> ! version.equals(versions.targetPlatform)).isPresent()
- || versions.sourcePlatform.equals(jobRun.sourcePlatform()))
- && ( ! versions.sourceApplication.filter(version -> ! version.equals(versions.targetApplication)).isPresent()
- || versions.sourceApplication.equals(jobRun.sourceApplication()));
+ || versions.sourcePlatform.equals(jobRun.sourcePlatform()))
+ && ( ! versions.sourceApplication.filter(version -> ! version.equals(versions.targetApplication)).isPresent()
+ || versions.sourceApplication.equals(jobRun.sourceApplication()));
}
private static boolean targetsMatch(Versions versions, JobRun jobRun) {
@@ -425,17 +426,13 @@ public class DeploymentTrigger {
? jobsOf(testStepsOf(application))
: jobsOf(productionStepsOf(application));
- boolean platformComplete = application.change().platform().map(Change::of)
- .map(change -> jobs.stream().allMatch(job -> completedAt(change, application, job).isPresent()))
- .orElse(false);
+ Change change = application.change();
+ if (jobs.stream().allMatch(job -> completedAt(application.change().withoutApplication(), application, job).isPresent()))
+ change = change.withoutPlatform();
- boolean applicationComplete = application.change().application().map(Change::of)
- .map(change -> jobs.stream().allMatch(job -> completedAt(change, application, job).isPresent()))
- .orElse(false);
+ if (jobs.stream().allMatch(job -> completedAt(application.change().withoutPlatform(), application, job).isPresent()))
+ change = change.withoutApplication();
- Change change = application.change();
- if (platformComplete) change = change.withoutPlatform();
- if (applicationComplete) change = change.withoutApplication();
return change;
}