summaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/ContentClusterRemovalValidator.java
blob: 0cc52edf3cc8020fa6e5646cd352a534108ffd01 (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
// Copyright Yahoo. 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.ConfigChangeAction;
import com.yahoo.config.model.deploy.DeployState;
import com.yahoo.vespa.model.VespaModel;
import com.yahoo.config.application.api.ValidationId;
import com.yahoo.vespa.model.content.cluster.ContentCluster;

import java.util.List;

/**
 * Checks that this does not remove a content cluster (or changes its id)
 * as that means losing all data of that cluster.
 *
 * @author bratseth
 */
public class ContentClusterRemovalValidator implements ChangeValidator {

    @Override
    public List<ConfigChangeAction> validate(VespaModel current, VespaModel next, DeployState deployState) {
        for (String currentClusterId : current.getContentClusters().keySet()) {
            ContentCluster nextCluster = next.getContentClusters().get(currentClusterId);
            if (nextCluster == null)
                deployState.validationOverrides().invalid(ValidationId.contentClusterRemoval,
                                  "Content cluster '" + currentClusterId + "' is removed. " +
                                  "This will cause loss of all data in this cluster",
                                  deployState.now());
        }

        return List.of();
    }

}