aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/test/java/com/yahoo/vespa/model/container/search/searchchain/MockSearchClusters.java
blob: b2ae4e553f5c3595e2cc1440c2370013fa9b8f64 (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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// Copyright Yahoo. 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.config.model.deploy.DeployState;
import com.yahoo.search.config.SchemaInfoConfig;
import com.yahoo.vespa.config.search.AttributesConfig;
import com.yahoo.vespa.config.search.RankProfilesConfig;
import com.yahoo.config.model.producer.AbstractConfigProducerRoot;
import com.yahoo.prelude.fastsearch.DocumentdbInfoConfig;
import com.yahoo.search.config.IndexInfoConfig;
import com.yahoo.vespa.configdefinition.IlscriptsConfig;
import com.yahoo.vespa.model.search.DocumentDatabase;
import com.yahoo.vespa.model.search.SearchCluster;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class MockSearchClusters {

    private static class MockSearchCluster extends SearchCluster {

        public MockSearchCluster(AbstractConfigProducerRoot root, String clusterName, int clusterIndex, boolean isStreaming) {
            super(root, clusterName, clusterIndex);
            streaming = isStreaming;
        }

        private final boolean streaming;

        @Override
        public void deriveFromSchemas(DeployState deployState) { }

        @Override
        public List<DocumentDatabase> getDocumentDbs() {
            return List.of();
        }

        @Override
        public int getRowBits() {
            return 0;
        }

        @Override
        public void defaultDocumentsConfig() {}

        @Override
        public void getConfig(AttributesConfig.Builder builder) {
        }

        @Override
        public void getConfig(DocumentdbInfoConfig.Builder builder) {
        }

        @Override
        public void getConfig(RankProfilesConfig.Builder builder) {
        }

        @Override
        public void getConfig(IndexInfoConfig.Builder builder) {
        }

        @Override
        public void getConfig(IlscriptsConfig.Builder builder) {
        }

        @Override
        public void getConfig(SchemaInfoConfig.Builder builder) {
        }

        @Override
        protected SearchCluster.IndexingMode getIndexingMode() { return streaming ? SearchCluster.IndexingMode.STREAMING : SearchCluster.IndexingMode.REALTIME; }

    }

    public static SearchCluster mockSearchCluster(AbstractConfigProducerRoot root, String clusterName, int clusterIndex, boolean isStreaming) {

        return new MockSearchCluster(root, clusterName, clusterIndex, isStreaming);
    }

    public static Map<String, SearchCluster> twoMockClusterSpecsByName(AbstractConfigProducerRoot root) {
        Map<String, SearchCluster> result = new HashMap<>();
        result.put("cluster1", mockSearchCluster(root, "cluster1", 1, false));
        result.put("cluster2", mockSearchCluster(root, "cluster2", 2, true));
        return result;
    }
}