summaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo/vespa/model/content/cluster/EngineFactoryBuilder.java
blob: 374f970739d784d418d0f595883629b590e778ff (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
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.content.cluster;

import com.yahoo.vespa.model.builder.xml.dom.ModelElement;
import com.yahoo.vespa.model.content.engines.*;

/**
 * Creates the correct engine factory from XML.
 */
public class EngineFactoryBuilder {
    public PersistenceEngine.PersistenceFactory build(ModelElement clusterElem, ContentCluster c) {
        ModelElement persistence = clusterElem.getChild("engine");
        if (persistence != null) {
            if (c.getSearch().hasIndexedCluster() && persistence.getChild("proton") == null) {
                throw new IllegalArgumentException("Persistence engine does not allow for indexed search. Please use <proton> as your engine.");
            }

            ModelElement e;
            if ((e = persistence.getChild("vds")) != null) {
                return new VDSEngine.Factory(e);
            } else if (persistence.getChild("proton") != null) {
                return new ProtonEngine.Factory(c.getSearch());
            } else if (persistence.getChild("dummy") != null) {
                return new com.yahoo.vespa.model.content.engines.DummyPersistence.Factory();
            } else if (persistence.getChild("rpc") != null) {
                return new RPCEngine.Factory();
            }
        }

        return new ProtonEngine.Factory(c.getSearch());
    }
}