summaryrefslogtreecommitdiffstats
path: root/configserver/src/main/java/com/yahoo/vespa/config/server/filedistribution/FileDBHandler.java
blob: 2f9c13587fef37d11ceaf0566c6fa822b5bb5836 (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
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.server.filedistribution;

import com.yahoo.config.FileReference;
import com.yahoo.config.model.api.FileDistribution;
import com.yahoo.vespa.filedistribution.FileDistributionManager;

import java.util.*;

/**
 * Implements invoker of filedistribution using manager with JNI.
 *
 * @author tonytv
 * @author lulf
 * @since 5.1.14
 */
public class FileDBHandler implements FileDistribution {
    private final FileDistributionManager manager;

    public FileDBHandler(FileDistributionManager manager) {
        this.manager = manager;
    }

    @Override
    public void sendDeployedFiles(String hostName, Set<FileReference> fileReferences) {
        List<String> referencesAsString = new ArrayList<>();
        for (FileReference reference : fileReferences) {
            referencesAsString.add(reference.value());
        }
        manager.setDeployedFiles(hostName, referencesAsString);
    }

    @Override
    public void limitSendingOfDeployedFilesTo(Collection<String> hostNames) {
        manager.limitSendingOfDeployedFilesTo(hostNames);
    }

    @Override
    public void removeDeploymentsThatHaveDifferentApplicationId(Collection<String> targetHostnames) {
        manager.removeDeploymentsThatHaveDifferentApplicationId(targetHostnames);
    }

    @Override
    public void reloadDeployFileDistributor() {
        manager.reloadDeployFileDistributor();
    }
}