blob: 9d948ece738a45562bd6330ab5fdd81c9b3665d5 (
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.content;
import com.yahoo.vespa.config.content.FleetcontrollerConfig;
import com.yahoo.vespa.config.search.core.ProtonConfig;
import java.util.Optional;
/**
* Class tracking feed block resource limits used by a component in a content cluster (e.g. cluster controller or content node).
*
* @author geirst
*/
public class ResourceLimits implements FleetcontrollerConfig.Producer, ProtonConfig.Producer {
private final Optional<Double> diskLimit;
private final Optional<Double> memoryLimit;
private ResourceLimits(Builder builder) {
this.diskLimit = builder.diskLimit;
this.memoryLimit = builder.memoryLimit;
}
public Optional<Double> getDiskLimit() {
return diskLimit;
}
public Optional<Double> getMemoryLimit() {
return memoryLimit;
}
@Override
public void getConfig(FleetcontrollerConfig.Builder builder) {
// Note: The resource categories must match the ones used in host info reporting
// between content nodes and cluster controller:
// storage/src/vespa/storage/persistence/filestorage/service_layer_host_info_reporter.cpp
builder.cluster_feed_block_limit.put("memory", memoryLimit.orElse(0.8));
builder.cluster_feed_block_limit.put("disk", diskLimit.orElse(0.75));
builder.cluster_feed_block_limit.put("attribute-address-space", 0.9);
}
@Override
public void getConfig(ProtonConfig.Builder builder) {
if (diskLimit.isPresent()) {
builder.writefilter.disklimit(diskLimit.get());
}
if (memoryLimit.isPresent()) {
builder.writefilter.memorylimit(memoryLimit.get());
}
}
public static class Builder {
private Optional<Double> diskLimit = Optional.empty();
private Optional<Double> memoryLimit = Optional.empty();
public ResourceLimits build() {
return new ResourceLimits(this);
}
public Optional<Double> getDiskLimit() {
return diskLimit;
}
public Builder setDiskLimit(double diskLimit) {
this.diskLimit = Optional.of(diskLimit);
return this;
}
public Optional<Double> getMemoryLimit() {
return memoryLimit;
}
public Builder setMemoryLimit(double memoryLimit) {
this.memoryLimit = Optional.of(memoryLimit);
return this;
}
}
}
|