aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/VespaRestartAction.java
blob: c0b55d856aba98465e2a61e9d217a95a93b978cb (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
60
61
62
63
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.application.validation.change;

import com.yahoo.config.model.api.ConfigChangeRestartAction;
import com.yahoo.config.model.api.ServiceInfo;
import com.yahoo.config.provision.ClusterSpec;

import java.util.List;

/**
 * Represents an action to restart services in order to handle a config change.
 *
 * @author geirst
 */
public class VespaRestartAction extends VespaConfigChangeAction implements ConfigChangeRestartAction {

    private final boolean ignoreForInternalRedeploy;

    public VespaRestartAction(ClusterSpec.Id id, String message) {
        this(id, message, List.of());
    }

    public VespaRestartAction(ClusterSpec.Id id, String message, ServiceInfo service) {
        this(id, message, List.of(service));
    }

    public VespaRestartAction(ClusterSpec.Id id, String message, ServiceInfo services, boolean ignoreForInternalRedeploy) {
        super(id, message, List.of(services));
        this.ignoreForInternalRedeploy = ignoreForInternalRedeploy;
    }

    public VespaRestartAction(ClusterSpec.Id id, String message, List<ServiceInfo> services) {
        super(id, message, services);
        this.ignoreForInternalRedeploy = false;
    }

    @Override
    public VespaConfigChangeAction modifyAction(String newMessage, List<ServiceInfo> newServices, String documentType) {
        return new VespaRestartAction(clusterId(), newMessage, newServices);
    }

    @Override
    public boolean ignoreForInternalRedeploy() {
        return ignoreForInternalRedeploy;
    }

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

        VespaRestartAction that = (VespaRestartAction) o;
        return ignoreForInternalRedeploy == that.ignoreForInternalRedeploy;
    }

    @Override
    public int hashCode() {
        int result = super.hashCode();
        result = 31 * result + (ignoreForInternalRedeploy ? 1 : 0);
        return result;
    }
}