diff options
Diffstat (limited to 'controller-api')
2 files changed, 55 insertions, 18 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/JobId.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/JobId.java new file mode 100644 index 00000000000..76d848e3d1c --- /dev/null +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/JobId.java @@ -0,0 +1,44 @@ +package com.yahoo.vespa.hosted.controller.api.integration.deployment; + +import com.yahoo.config.provision.ApplicationId; + +import java.util.Objects; + +/** + * Immutable ID of a job that may be run. + * + * @author jonmv + */ +public class JobId { + + private final ApplicationId application; + private final JobType type; + + public JobId(ApplicationId application, JobType type) { + this.application = Objects.requireNonNull(application, "ApplicationId cannot be null!"); + this.type = Objects.requireNonNull(type, "JobType cannot be null!"); + } + + public ApplicationId application() { return application; } + public JobType type() { return type; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + JobId jobId = (JobId) o; + return application.equals(jobId.application) && + type == jobId.type; + } + + @Override + public int hashCode() { + return Objects.hash(application, type); + } + + @Override + public String toString() { + return type.jobName() + " for " + application; + } + +} diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/RunId.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/RunId.java index b4c1876a311..506c0482bca 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/RunId.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/deployment/RunId.java @@ -12,47 +12,40 @@ import java.util.Objects; */ public class RunId { - private final ApplicationId application; + private final JobId jobId; private final TesterId tester; - private final JobType type; private final long number; public RunId(ApplicationId application, JobType type, long number) { - this.application = Objects.requireNonNull(application, "ApplicationId cannot be null!"); + this.jobId = new JobId(application, type); this.tester = TesterId.of(application); - this.type = Objects.requireNonNull(type, "JobType cannot be null!"); if (number <= 0) throw new IllegalArgumentException("Build number must be a positive integer!"); this.number = number; } - public ApplicationId application() { return application; } + public JobId job() { return jobId; } + public ApplicationId application() { return jobId.application(); } public TesterId tester() { return tester; } - public JobType type() { return type; } + public JobType type() { return jobId.type(); } public long number() { return number; } @Override public boolean equals(Object o) { if (this == o) return true; - if ( ! (o instanceof RunId)) return false; - - RunId id = (RunId) o; - - if (number != id.number) return false; - if ( ! application.equals(id.application)) return false; - return type == id.type; + if (o == null || getClass() != o.getClass()) return false; + RunId runId = (RunId) o; + return number == runId.number && + jobId.equals(runId.jobId); } @Override public int hashCode() { - int result = application.hashCode(); - result = 31 * result + type.hashCode(); - result = 31 * result + (int) (number ^ (number >>> 32)); - return result; + return Objects.hash(jobId, number); } @Override public String toString() { - return "run " + number + " of " + type.jobName() + " for " + application; + return "run " + number + " of " + type().jobName() + " for " + application(); } } |