aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHåkon Hallingstad <hakon@verizonmedia.com>2020-01-06 10:02:53 +0100
committerHåkon Hallingstad <hakon@verizonmedia.com>2020-01-06 10:02:53 +0100
commit07c2b674e2bc61e004bbaf4b9ab979e056d23320 (patch)
tree06c26acdec95ad31d9a5425d620219e298289dbd
parent31ce2034d1ce8e6826b89adcc12f3009fc460b03 (diff)
Remove Clock
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ControllerMaintenance.java2
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/JobRunner.java11
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTester.java2
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/JobRunnerTest.java12
4 files changed, 12 insertions, 15 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ControllerMaintenance.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ControllerMaintenance.java
index e276bdac35a..e43877cb7e5 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ControllerMaintenance.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ControllerMaintenance.java
@@ -68,7 +68,7 @@ public class ControllerMaintenance extends AbstractComponent {
deploymentMetricsMaintainer = new DeploymentMetricsMaintainer(controller, Duration.ofMinutes(5), jobControl);
applicationOwnershipConfirmer = new ApplicationOwnershipConfirmer(controller, Duration.ofHours(12), jobControl, controller.serviceRegistry().ownershipIssues());
systemUpgrader = new SystemUpgrader(controller, Duration.ofMinutes(1), jobControl);
- jobRunner = new JobRunner(controller, Duration.ofSeconds(90), jobControl, controller.clock());
+ jobRunner = new JobRunner(controller, Duration.ofSeconds(90), jobControl);
osUpgraders = osUpgraders(controller, jobControl);
osVersionStatusUpdater = new OsVersionStatusUpdater(controller, maintenanceInterval, jobControl);
contactInformationMaintainer = new ContactInformationMaintainer(controller, Duration.ofHours(12), jobControl);
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/JobRunner.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/JobRunner.java
index eadb5e8203a..83173fc32a7 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/JobRunner.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/JobRunner.java
@@ -12,7 +12,6 @@ import com.yahoo.vespa.hosted.controller.deployment.StepInfo;
import com.yahoo.vespa.hosted.controller.deployment.StepRunner;
import org.jetbrains.annotations.TestOnly;
-import java.time.Clock;
import java.time.Duration;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@@ -34,21 +33,19 @@ public class JobRunner extends Maintainer {
private final JobController jobs;
private final ExecutorService executors;
private final StepRunner runner;
- private final Clock clock;
- public JobRunner(Controller controller, Duration duration, JobControl jobControl, Clock clock) {
- this(controller, duration, jobControl, Executors.newFixedThreadPool(32), new InternalStepRunner(controller), clock);
+ public JobRunner(Controller controller, Duration duration, JobControl jobControl) {
+ this(controller, duration, jobControl, Executors.newFixedThreadPool(32), new InternalStepRunner(controller));
}
@TestOnly
public JobRunner(Controller controller, Duration duration, JobControl jobControl, ExecutorService executors,
- StepRunner runner, Clock clock) {
+ StepRunner runner) {
super(controller, duration, jobControl);
this.jobs = controller.jobController();
this.jobs.setRunner(this::advance);
this.executors = executors;
this.runner = runner;
- this.clock = clock;
}
@Override
@@ -105,7 +102,7 @@ public class JobRunner extends Maintainer {
StepInfo stepInfo = run.stepInfo(lockedStep.get()).orElseThrow();
if (stepInfo.startTime().isEmpty()) {
- jobs.setStartTimestamp(run.id(), clock.instant(), lockedStep);
+ jobs.setStartTimestamp(run.id(), controller().clock().instant(), lockedStep);
}
runner.run(lockedStep, run.id()).ifPresent(status -> {
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTester.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTester.java
index 6f1483e93b1..5b5c6b61357 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTester.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTester.java
@@ -87,7 +87,7 @@ public class DeploymentTester {
cloud = (MockTesterCloud) tester.controller().jobController().cloud();
var jobControl = new JobControl(tester.controller().curator());
runner = new JobRunner(tester.controller(), Duration.ofDays(1), jobControl,
- JobRunnerTest.inThreadExecutor(), new InternalStepRunner(tester.controller()), tester.clock());
+ JobRunnerTest.inThreadExecutor(), new InternalStepRunner(tester.controller()));
upgrader = new Upgrader(tester.controller(), maintenanceInterval, jobControl, tester.curator());
upgrader.setUpgradesPerMinute(1); // Anything that makes it at least one for any maintenance period is fine.
readyJobsTrigger = new ReadyJobsTrigger(tester.controller(), maintenanceInterval, jobControl);
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/JobRunnerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/JobRunnerTest.java
index 182ff389d9e..74e387ef17e 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/JobRunnerTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/JobRunnerTest.java
@@ -83,7 +83,7 @@ public class JobRunnerTest {
StepRunner stepRunner = (step, id) -> id.type() == stagingTest && step.get() == startTests? Optional.of(error) : Optional.of(running);
Phaser phaser = new Phaser(1);
JobRunner runner = new JobRunner(tester.controller(), Duration.ofDays(1), new JobControl(tester.controller().curator()),
- phasedExecutor(phaser), stepRunner, tester.clock());
+ phasedExecutor(phaser), stepRunner);
TenantAndApplicationId appId = tester.createApplication("tenant", "real", "default").id();
ApplicationId id = appId.defaultInstance();
@@ -115,7 +115,7 @@ public class JobRunnerTest {
JobController jobs = tester.controller().jobController();
Map<Step, RunStatus> outcomes = new EnumMap<>(Step.class);
JobRunner runner = new JobRunner(tester.controller(), Duration.ofDays(1), new JobControl(tester.controller().curator()),
- inThreadExecutor(), mappedRunner(outcomes), tester.clock());
+ inThreadExecutor(), mappedRunner(outcomes));
TenantAndApplicationId appId = tester.createApplication("tenant", "real", "default").id();
ApplicationId id = appId.defaultInstance();
@@ -223,7 +223,7 @@ public class JobRunnerTest {
// Hang during tester deployment, until notified.
CyclicBarrier barrier = new CyclicBarrier(2);
JobRunner runner = new JobRunner(tester.controller(), Duration.ofDays(1), new JobControl(tester.controller().curator()),
- Executors.newFixedThreadPool(32), waitingRunner(barrier), tester.clock());
+ Executors.newFixedThreadPool(32), waitingRunner(barrier));
TenantAndApplicationId appId = tester.createApplication("tenant", "real", "default").id();
ApplicationId id = appId.defaultInstance();
@@ -260,7 +260,7 @@ public class JobRunnerTest {
DeploymentTester tester = new DeploymentTester();
JobController jobs = tester.controller().jobController();
JobRunner runner = new JobRunner(tester.controller(), Duration.ofDays(1), new JobControl(tester.controller().curator()),
- inThreadExecutor(), (id, step) -> Optional.of(running), tester.clock());
+ inThreadExecutor(), (id, step) -> Optional.of(running));
TenantAndApplicationId appId = tester.createApplication("tenant", "real", "default").id();
ApplicationId instanceId = appId.defaultInstance();
@@ -285,7 +285,7 @@ public class JobRunnerTest {
assertTrue(jobs.details(new RunId(instanceId, systemTest, 257)).isPresent());
JobRunner failureRunner = new JobRunner(tester.controller(), Duration.ofDays(1), new JobControl(tester.controller().curator()),
- inThreadExecutor(), (id, step) -> Optional.of(error), tester.clock());
+ inThreadExecutor(), (id, step) -> Optional.of(error));
// Make all but the oldest of the 256 jobs a failure.
for (int i = 0; i < jobs.historyLength() - 1; i++) {
@@ -339,7 +339,7 @@ public class JobRunnerTest {
JobController jobs = tester.controller().jobController();
Map<Step, RunStatus> outcomes = new EnumMap<>(Step.class);
JobRunner runner = new JobRunner(tester.controller(), Duration.ofDays(1), new JobControl(tester.controller().curator()),
- inThreadExecutor(), mappedRunner(outcomes), tester.clock());
+ inThreadExecutor(), mappedRunner(outcomes));
TenantAndApplicationId appId = tester.createApplication("tenant", "real", "default").id();
ApplicationId id = appId.defaultInstance();