summaryrefslogtreecommitdiffstats
path: root/controller-server
diff options
context:
space:
mode:
authorMartin Polden <mpolden@mpolden.no>2018-08-30 14:14:59 +0200
committerMartin Polden <mpolden@mpolden.no>2018-09-04 13:51:10 +0200
commitbeff857ab52a033a54bf652e8a61dc13c96caf20 (patch)
treed33b59f9909e5c5312f32e5020927d3009a495b1 /controller-server
parentf4b81d662c31f25b2be8964fd22bacf11b60e362 (diff)
Less boxing
Diffstat (limited to 'controller-server')
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/ApplicationVersion.java17
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/Deployment.java4
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/ApplicationSerializer.java2
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/JobControllerApiHandlerHelper.java2
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTriggerTest.java14
5 files changed, 20 insertions, 19 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/ApplicationVersion.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/ApplicationVersion.java
index b3dd46a3e65..703a198be1e 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/ApplicationVersion.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/ApplicationVersion.java
@@ -3,6 +3,7 @@ package com.yahoo.vespa.hosted.controller.application;
import java.util.Objects;
import java.util.Optional;
+import java.util.OptionalLong;
/**
* An application package version, identified by a source revision and a build number.
@@ -16,21 +17,21 @@ public class ApplicationVersion implements Comparable<ApplicationVersion> {
* Used in cases where application version cannot be determined, such as manual deployments (e.g. in dev
* environment)
*/
- public static final ApplicationVersion unknown = new ApplicationVersion(Optional.empty(), Optional.empty());
+ public static final ApplicationVersion unknown = new ApplicationVersion(Optional.empty(), OptionalLong.empty());
// This never changes and is only used to create a valid semantic version number, as required by application bundles
private static final String majorVersion = "1.0";
private final Optional<SourceRevision> source;
- private final Optional<Long> buildNumber;
+ private final OptionalLong buildNumber;
- private ApplicationVersion(Optional<SourceRevision> source, Optional<Long> buildNumber) {
+ private ApplicationVersion(Optional<SourceRevision> source, OptionalLong buildNumber) {
Objects.requireNonNull(source, "source cannot be null");
Objects.requireNonNull(buildNumber, "buildNumber cannot be null");
if (source.isPresent() != buildNumber.isPresent()) {
throw new IllegalArgumentException("both buildNumber and source must be set together");
}
- if (buildNumber.isPresent() && buildNumber.get() <= 0) {
+ if (buildNumber.isPresent() && buildNumber.getAsLong() <= 0) {
throw new IllegalArgumentException("buildNumber must be > 0");
}
this.source = source;
@@ -39,7 +40,7 @@ public class ApplicationVersion implements Comparable<ApplicationVersion> {
/** Create an application package version from a completed build */
public static ApplicationVersion from(SourceRevision source, long buildNumber) {
- return new ApplicationVersion(Optional.of(source), Optional.of(buildNumber));
+ return new ApplicationVersion(Optional.of(source), OptionalLong.of(buildNumber));
}
/** Returns an unique identifier for this version or "unknown" if version is not known */
@@ -47,7 +48,7 @@ public class ApplicationVersion implements Comparable<ApplicationVersion> {
if (isUnknown()) {
return "unknown";
}
- return String.format("%s.%d-%s", majorVersion, buildNumber.get(), abbreviateCommit(source.get().commit()));
+ return String.format("%s.%d-%s", majorVersion, buildNumber.getAsLong(), abbreviateCommit(source.get().commit()));
}
/**
@@ -57,7 +58,7 @@ public class ApplicationVersion implements Comparable<ApplicationVersion> {
public Optional<SourceRevision> source() { return source; }
/** Returns the build number that built this version */
- public Optional<Long> buildNumber() { return buildNumber; }
+ public OptionalLong buildNumber() { return buildNumber; }
/** Returns whether this is unknown */
public boolean isUnknown() {
@@ -93,6 +94,6 @@ public class ApplicationVersion implements Comparable<ApplicationVersion> {
if ( ! buildNumber().isPresent() || ! o.buildNumber().isPresent())
return Boolean.compare(buildNumber().isPresent(), o.buildNumber.isPresent()); // Application package hash sorts first
- return buildNumber().get().compareTo(o.buildNumber().get());
+ return Long.compare(buildNumber().getAsLong(), o.buildNumber().getAsLong());
}
}
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/Deployment.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/Deployment.java
index 0a062427a8a..a2433d223dc 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/Deployment.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/Deployment.java
@@ -68,12 +68,12 @@ public class Deployment {
public DeploymentActivity activity() { return activity; }
/** Returns information about the clusters allocated to this */
- public Map<Id, ClusterInfo> clusterInfo() {
+ public Map<Id, ClusterInfo> clusterInfo() {
return clusterInfo;
}
/** Returns utilization of the clusters allocated to this */
- public Map<Id, ClusterUtilization> clusterUtils() {
+ public Map<Id, ClusterUtilization> clusterUtils() {
return clusterUtils;
}
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/ApplicationSerializer.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/ApplicationSerializer.java
index 763d26834e6..58e0b8dbeec 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/ApplicationSerializer.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/ApplicationSerializer.java
@@ -213,7 +213,7 @@ public class ApplicationSerializer {
private void toSlime(ApplicationVersion applicationVersion, Cursor object) {
if (applicationVersion.buildNumber().isPresent() && applicationVersion.source().isPresent()) {
- object.setLong(applicationBuildNumberField, applicationVersion.buildNumber().get());
+ object.setLong(applicationBuildNumberField, applicationVersion.buildNumber().getAsLong());
toSlime(applicationVersion.source().get(), object.setObject(sourceRevisionField));
}
}
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/JobControllerApiHandlerHelper.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/JobControllerApiHandlerHelper.java
index 620a3514c87..32d62d00e20 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/JobControllerApiHandlerHelper.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/JobControllerApiHandlerHelper.java
@@ -334,7 +334,7 @@ class JobControllerApiHandlerHelper {
private static void applicationVersionToSlime(Cursor versionObject, ApplicationVersion version) {
versionObject.setString("id", version.id());
- versionObject.setLong("build", version.buildNumber().get());
+ versionObject.setLong("build", version.buildNumber().getAsLong());
versionObject.setString("repository", version.source().get().repository());
versionObject.setString("branch", version.source().get().branch());
versionObject.setString("commit", version.source().get().commit());
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTriggerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTriggerTest.java
index f5fc6825960..3b381e21b27 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTriggerTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTriggerTest.java
@@ -375,9 +375,9 @@ public class DeploymentTriggerTest {
// This component completion should remove the older outstanding change, to avoid a later downgrade.
clock.advance(Duration.ofHours(1));
tester.deployAndNotify(application, applicationPackage, true, productionUsWest1);
- assertEquals((Long) BuildJob.defaultBuildNumber, tester.application(application.id()).deploymentJobs().jobStatus()
- .get(productionUsWest1).lastSuccess().get().application().buildNumber().get());
- assertEquals((Long) (BuildJob.defaultBuildNumber + 1), tester.application(application.id()).outstandingChange().application().get().buildNumber().get());
+ assertEquals(BuildJob.defaultBuildNumber, tester.application(application.id()).deploymentJobs().jobStatus()
+ .get(productionUsWest1).lastSuccess().get().application().buildNumber().getAsLong());
+ assertEquals((BuildJob.defaultBuildNumber + 1), tester.application(application.id()).outstandingChange().application().get().buildNumber().getAsLong());
tester.readyJobTrigger().maintain();
assertTrue(tester.buildService().jobs().isEmpty());
@@ -513,14 +513,14 @@ public class DeploymentTriggerTest {
tester.assertRunning(productionUsCentral1, application.id());
assertEquals(v2, app.get().deployments().get(productionUsCentral1.zone(main)).version());
- assertEquals(Long.valueOf(42L), app.get().deployments().get(productionUsCentral1.zone(main)).applicationVersion().buildNumber().get());
+ assertEquals(42, app.get().deployments().get(productionUsCentral1.zone(main)).applicationVersion().buildNumber().getAsLong());
assertNotEquals(triggered, app.get().deploymentJobs().jobStatus().get(productionUsCentral1).lastTriggered().get().at());
// Change has a higher application version than what is deployed -- deployment should trigger.
tester.deployAndNotify(application, applicationPackage, false, productionUsCentral1);
tester.deploy(productionUsCentral1, application, applicationPackage);
assertEquals(v2, app.get().deployments().get(productionUsCentral1.zone(main)).version());
- assertEquals(Long.valueOf(43), app.get().deployments().get(productionUsCentral1.zone(main)).applicationVersion().buildNumber().get());
+ assertEquals(43, app.get().deployments().get(productionUsCentral1.zone(main)).applicationVersion().buildNumber().getAsLong());
// Change is again strictly dominated, and us-central-1 is skipped, even though it is still failing.
tester.clock().advance(Duration.ofHours(2).plus(Duration.ofSeconds(1))); // Enough time for retry
@@ -588,8 +588,8 @@ public class DeploymentTriggerTest {
tester.deployAndNotify(application, true, productionUsEast3);
tester.deployAndNotify(application, true, productionEuWest1);
assertFalse(app.get().change().isPresent());
- assertEquals(43, app.get().deploymentJobs().jobStatus().get(productionEuWest1).lastSuccess().get().application().buildNumber().get().longValue());
- assertEquals(43, app.get().deploymentJobs().jobStatus().get(productionUsEast3).lastSuccess().get().application().buildNumber().get().longValue());
+ assertEquals(43, app.get().deploymentJobs().jobStatus().get(productionEuWest1).lastSuccess().get().application().buildNumber().getAsLong());
+ assertEquals(43, app.get().deploymentJobs().jobStatus().get(productionUsEast3).lastSuccess().get().application().buildNumber().getAsLong());
}
@Test