blob: ffba56fa17ffab108c431e9e60536e696da940da (
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
|
// 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.filedistribution;
import com.yahoo.cloud.config.filedistribution.FiledistributorrpcConfig;
import com.yahoo.cloud.config.filedistribution.FilereferencesConfig;
import com.yahoo.config.FileReference;
import com.yahoo.vespa.model.ConfigProxy;
import com.yahoo.vespa.model.Host;
import java.util.Collection;
public class FileDistributionConfigProvider {
private final FileDistributor fileDistributor;
private final boolean sendAllFiles;
private final Host host;
public FileDistributionConfigProvider(FileDistributor fileDistributor,
boolean sendAllFiles,
Host host) {
this.fileDistributor = fileDistributor;
this.sendAllFiles = sendAllFiles;
this.host = host;
}
public void getConfig(FiledistributorrpcConfig.Builder builder) {
// If disabled config proxy should act as file distributor, so use config proxy port
int port = ConfigProxy.BASEPORT;
builder.connectionspec("tcp/" + host.getHostname() + ":" + port);
}
public void getConfig(FilereferencesConfig.Builder builder) {
for (FileReference reference : getFileReferences()) {
builder.filereferences(reference.value());
}
}
private Collection<FileReference> getFileReferences() {
if (sendAllFiles) {
return fileDistributor.allFilesToSend();
} else {
return fileDistributor.filesToSendToHost(host);
}
}
}
|