aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo/vespa/model/container/search/searchchain/Source.java
blob: 29e587c6453e22b918e7342d8ef50981d0ed6444 (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.container.search.searchchain;

import com.yahoo.component.ComponentId;
import com.yahoo.component.chain.model.ChainSpecification;
import com.yahoo.search.searchchain.model.federation.FederationOptions;
import com.yahoo.config.model.producer.TreeConfigProducer;

import java.util.Arrays;


/**
 * Config producer for source, which is contained in a provider.
 *
 * @author Tony Vaagenes
 */
public class Source extends GenericTarget {

    //Each source group must have exactly one leader, and an arbitrary number of participants
    public enum GroupOption {
        leader,
        participant
    }

    public final GroupOption groupOption;

    public Source(ChainSpecification specWithoutInnerSearchers, FederationOptions federationOptions,
                  GroupOption groupOption) {
        super(specWithoutInnerSearchers, federationOptions);
        this.groupOption = groupOption;
    }

    @Override
    public FederationOptions federationOptions() {
        return super.federationOptions().inherit(getParentProvider().federationOptions());
    }

    @Override
    protected boolean useByDefault() {
        return false;
    }

    public Provider getParentProvider() {
        var parent = getParent();
        while (!(parent instanceof Provider)) {
            parent = parent.getParent();
        }
        return (Provider)parent;
    }

    @Override
    public ChainSpecification getChainSpecification() {
        return super.getChainSpecification().addInherits(
                Arrays.asList(getParentProvider().getComponentId().toSpecification()));
    }

    public ComponentId getGlobalComponentId() {
        return getComponentId().nestInNamespace(
                getParentProvider().getComponentId());
    }
}