aboutsummaryrefslogtreecommitdiffstats
path: root/orchestrator/src/main/java/com/yahoo/vespa/orchestrator/policy/OrchestrationParams.java
blob: 43065831cbc0b6d5ea5ae11fa6fa918784445604 (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.orchestrator.policy;

import com.yahoo.config.provision.ApplicationId;
import com.yahoo.vespa.applicationmodel.InfrastructureApplication;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/**
 * Parameters controlling orchestration.
 *
 * @author hakonhall
 */
public class OrchestrationParams {
    private final Map<ApplicationId, ApplicationParams> applicationParams;

    public static class Builder {
        private final Map<ApplicationId, ApplicationParams> applicationParams = new HashMap<>();

        public Builder() {}

        public Builder addApplicationParams(InfrastructureApplication application, ApplicationParams params) {
            this.applicationParams.put(application.id(), params);
            return this;
        }

        public OrchestrationParams build() {
            return new OrchestrationParams(applicationParams);
        }
    }

    private OrchestrationParams(Map<ApplicationId, ApplicationParams> applicationParams) {
        this.applicationParams = Map.copyOf(applicationParams);
    }

    public ApplicationParams getApplicationParams(ApplicationId applicationId) {
        return applicationParams.getOrDefault(applicationId, ApplicationParams.getDefault());
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        OrchestrationParams that = (OrchestrationParams) o;
        return applicationParams.equals(that.applicationParams);
    }

    @Override
    public int hashCode() {
        return Objects.hash(applicationParams);
    }
}