aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo/vespa/model/ConfigProducer.java
blob: b7719e3ab11b6eb9a39c4e39ef5c13f4c5cf228a (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
64
65
66
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model;

import com.yahoo.config.ConfigInstance;
import com.yahoo.config.ConfigInstance.Builder;
import com.yahoo.config.model.producer.UserConfigRepo;

import java.io.PrintStream;
import java.util.List;
import java.util.Map;

/**
 * Interface that should be implemented by all config producing modules
 * in the vespa model.
 *
 * @author gjoranv
 */
public interface ConfigProducer extends com.yahoo.config.ConfigInstance.Producer {

    /** Returns the configId of this ConfigProducer. */
    String getConfigId();

    /** Returns the one and only HostSystem of the root node */
    HostSystem hostSystem();

    /** Returns the user configs of this */
    UserConfigRepo getUserConfigs();
    
    /** Returns this ConfigProducer's children (only 1st level) */
    Map<String,? extends ConfigProducer> getChildren();

    /** Returns a List of all Services that are descendants to this ConfigProducer */
    List<Service> getDescendantServices();

    /**
     * Dump the three of config producers to the specified stream.
     * 
     * @param out The stream to print to, e.g. System.out
     */
    void dump(PrintStream out);

    /**
     * Build config from this and all parent ConfigProducers,
     * such that the root node's config will be added first, and this
     * ConfigProducer's config last in the returned builder.
     *
     * @param builder The builder implemented by the concrete ConfigInstance class
     * @return true if a model config producer was found, so config was applied
     */
    boolean cascadeConfig(Builder builder);

    /**
     * Adds user config override from this ConfigProducer to the existing builder
     *
     * @param builder The ConfigBuilder to add user config overrides.
     * @return true if overrides were added, false if not.
     */
    boolean addUserConfig(ConfigInstance.Builder builder);

    /**
     * check constraints depending on the state of the vespamodel graph.
     * When overriding, you must invoke super.
     */
    void validate() throws Exception;

}