diff options
author | Valerij Fredriksen <valerij92@gmail.com> | 2019-06-29 15:43:16 +0200 |
---|---|---|
committer | Valerij Fredriksen <valerij92@gmail.com> | 2019-06-30 12:22:06 +0200 |
commit | 916baacba0ae00134d9a198c24cfaee0ae06cde6 (patch) | |
tree | 40d6f919e9b79151327b4d1269a524111884f505 /node-repository | |
parent | 3af1ae8732a211341a8cfe5fff883af7600acd84 (diff) |
Simplify PeriodicApplicationMaintainer
Diffstat (limited to 'node-repository')
2 files changed, 7 insertions, 16 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/PeriodicApplicationMaintainer.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/PeriodicApplicationMaintainer.java index 174591b0836..6ab85e76ba2 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/PeriodicApplicationMaintainer.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/maintenance/PeriodicApplicationMaintainer.java @@ -9,7 +9,6 @@ import com.yahoo.vespa.hosted.provision.NodeRepository; import java.time.Clock; import java.time.Duration; import java.time.Instant; -import java.util.Collections; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; @@ -40,21 +39,24 @@ public class PeriodicApplicationMaintainer extends ApplicationMaintainer { @Override protected boolean canDeployNow(ApplicationId application) { - // Don't deploy if a regular deploy just happened - return getLastDeployTime(application).isBefore(nodeRepository().clock().instant().minus(minTimeBetweenRedeployments)); + return deployer().lastDeployTime(application) + // Don't deploy if a regular deploy just happened + .map(lastDeployTime -> lastDeployTime.isBefore(nodeRepository().clock().instant().minus(minTimeBetweenRedeployments))) + // We only know last deploy time for applications that were deployed on this config server, + // the rest will be deployed on another config server + .orElse(false); } // Returns the applications that need to be redeployed by this config server at this point in time. @Override protected Set<ApplicationId> applicationsNeedingMaintenance() { - if (waitInitially()) return Collections.emptySet(); + if (waitInitially()) return Set.of(); // Collect all deployment times before sorting as deployments may happen while we build the set, breaking // the comparable contract. Stale times are fine as the time is rechecked in ApplicationMaintainer#deployWithLock Map<ApplicationId, Instant> deploymentTimes = nodesNeedingMaintenance().stream() .map(node -> node.allocation().get().owner()) .distinct() - .filter(this::shouldBeDeployedOnThisServer) .filter(this::canDeployNow) .collect(Collectors.toMap(Function.identity(), this::getLastDeployTime)); @@ -64,12 +66,6 @@ public class PeriodicApplicationMaintainer extends ApplicationMaintainer { .collect(Collectors.toCollection(LinkedHashSet::new)); } - // We only know last deploy time for applications that were deployed on this config server, - // the rest will be deployed on another config server - protected boolean shouldBeDeployedOnThisServer(ApplicationId application) { - return deployer().lastDeployTime(application).isPresent(); - } - // TODO: Do not start deploying until some time has gone (ideally only until bootstrap of config server is finished) private boolean waitInitially() { return clock.instant().isBefore(start.plus(minTimeBetweenRedeployments)); diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/PeriodicApplicationMaintainerTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/PeriodicApplicationMaintainerTest.java index 0923d8df71a..211b4a4472f 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/PeriodicApplicationMaintainerTest.java +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/PeriodicApplicationMaintainerTest.java @@ -312,11 +312,6 @@ public class PeriodicApplicationMaintainerTest { : super.nodesNeedingMaintenance(); } - @Override - protected boolean shouldBeDeployedOnThisServer(ApplicationId application) { - return true; - } - } } |