aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo/vespa/model/clients/Clients.java
blob: 9b33568b61e5577b48b71cc721ec381bb55ff6a9 (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
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.clients;

import com.yahoo.vespa.config.content.LoadTypeConfig;
import com.yahoo.config.model.ConfigModel;
import com.yahoo.config.model.ConfigModelContext;
import com.yahoo.config.model.ConfigModelRepo;
import com.yahoo.config.model.producer.AbstractConfigProducer;
import com.yahoo.documentapi.messagebus.loadtypes.LoadType;
import com.yahoo.documentapi.messagebus.loadtypes.LoadTypeSet;
import com.yahoo.vespa.model.container.ContainerCluster;

import java.util.LinkedList;
import java.util.List;

/**
 * This is the clients plugin for the Vespa model. It is responsible for creating
 * all clients services.
 *
 * @author Gunnar Gauslaa Bergem
 */
public class Clients extends ConfigModel {

    private static final long serialVersionUID = 1L;
    private LoadTypeSet loadTypes = new LoadTypeSet();
    
    public Clients(ConfigModelContext modelContext) {
        super(modelContext);
    }

    public LoadTypeSet getLoadTypes() {
        return loadTypes;
    }

    public void getConfig(LoadTypeConfig.Builder builder) {
        for (LoadType t : loadTypes.getNameMap().values()) {
            if (t != LoadType.DEFAULT) {
                builder.type(getLoadTypeConfig(t));
            }
        }
    }

    private LoadTypeConfig.Type.Builder getLoadTypeConfig(LoadType loadType) {
        LoadTypeConfig.Type.Builder builder = new LoadTypeConfig.Type.Builder();
        builder.name(loadType.getName());
        builder.id(loadType.getId());
        builder.priority(loadType.getPriority().toString());
        return builder;
    }

}