summaryrefslogtreecommitdiffstats
path: root/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/BuildService.java
blob: e32ad47b180fd3fae2176c51a0a69a32a39b979a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.controller.api.integration;

import java.util.Objects;

/**
 * @author jvenstad
 */
public interface BuildService {

    /**
     * Enqueues a job defined by buildJob in an external build system, and returns the outcome of the enqueue request.
     * This method should return false only when a retry is in order, and true otherwise, e.g., on success, or for
     * invalid jobs.
     */
    boolean trigger(BuildJob buildJob);

    /**
     * Returns whether the given job is currently running.
     */
    boolean isRunning(BuildJob buildJob);


    // TODO jvenstad: Implement with DeploymentTrigger.Job
    class BuildJob {

        private final long projectId;
        private final String jobName;

        public BuildJob(long projectId, String jobName) {
            this.projectId = projectId;
            this.jobName = jobName;
        }

        public long projectId() { return projectId; }
        public String jobName() { return jobName; }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if ( ! (o instanceof BuildJob)) return false;
            BuildJob buildJob = (BuildJob) o;
            return projectId == buildJob.projectId &&
                   Objects.equals(jobName, buildJob.jobName);
        }

        @Override
        public String toString() {
            return jobName + "@" + projectId;
        }

        @Override
        public int hashCode() {
            return Objects.hash(projectId, jobName);
        }

    }

}