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

import com.yahoo.config.provision.ApplicationId;
import com.yahoo.vespa.orchestrator.OrchestratorUtil;
import com.yahoo.vespa.orchestrator.controller.ClusterControllerClientFactory;
import com.yahoo.vespa.orchestrator.policy.HostedVespaOrchestration;
import com.yahoo.vespa.orchestrator.policy.OrchestrationParams;
import com.yahoo.vespa.orchestrator.status.ApplicationLock;

import java.time.Clock;

/**
 * @author mpolden
 */
public class ApplicationApiFactory {

    private final OrchestrationParams orchestrationParams;
    private final Clock clock;

    public ApplicationApiFactory(int numberOfConfigServers, int numProxies, int numProxiesAllowedDown,
                                 double numProxiesAllowedDownRatio, Clock clock) {
        this.orchestrationParams = HostedVespaOrchestration.create(numberOfConfigServers, numProxies, numProxiesAllowedDown,
                                                                   numProxiesAllowedDownRatio);
        this.clock = clock;
    }

    public ApplicationApi create(NodeGroup nodeGroup,
                                 ApplicationLock lock,
                                 ClusterControllerClientFactory clusterControllerClientFactory) {
        ApplicationId applicationId = OrchestratorUtil.toApplicationId(lock.getApplicationInstanceReference());
        return new ApplicationApiImpl(nodeGroup, lock, clusterControllerClientFactory,
                                      orchestrationParams.getApplicationParams(applicationId), clock);
    }

}