blob: d7f6fb6c5814179cbf4abe1107ee7af4f61223c1 (
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
80
81
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.content.storagecluster;
import com.yahoo.config.model.api.ModelContext;
import com.yahoo.vespa.config.content.StorFilestorConfig;
import com.yahoo.vespa.model.builder.xml.dom.ModelElement;
import com.yahoo.vespa.model.content.cluster.ContentCluster;
/**
* Serves stor-filestor for storage clusters.
*/
public class FileStorProducer implements StorFilestorConfig.Producer {
public static class Builder {
protected FileStorProducer build(ModelContext.Properties properties, ContentCluster parent, ModelElement clusterElem) {
return new FileStorProducer(properties.featureFlags(), parent, getThreads(clusterElem));
}
private Integer getThreads(ModelElement clusterElem) {
ModelElement tuning = clusterElem.child("tuning");
if (tuning == null) {
return null;
}
ModelElement threads = tuning.child("persistence-threads");
if (threads == null) {
return null;
}
Integer count = threads.integerAttribute("count");
if (count != null) {
return count;
}
// Backward compatible fallback
int numThreads = 0;
for (ModelElement thread : threads.subElements("thread")) {
count = thread.integerAttribute("count");
numThreads += (count == null) ? 1 : count;
}
return numThreads;
}
}
private final Integer numThreads;
private final ContentCluster cluster;
private final int reponseNumThreads;
private final StorFilestorConfig.Response_sequencer_type.Enum responseSequencerType;
private final boolean useAsyncMessageHandlingOnSchedule;
private final boolean asyncApplyBucketDiff;
private static StorFilestorConfig.Response_sequencer_type.Enum convertResponseSequencerType(String sequencerType) {
try {
return StorFilestorConfig.Response_sequencer_type.Enum.valueOf(sequencerType);
} catch (Throwable t) {
return StorFilestorConfig.Response_sequencer_type.Enum.ADAPTIVE;
}
}
public FileStorProducer(ModelContext.FeatureFlags featureFlags, ContentCluster parent, Integer numThreads) {
this.numThreads = numThreads;
this.cluster = parent;
this.reponseNumThreads = featureFlags.defaultNumResponseThreads();
this.responseSequencerType = convertResponseSequencerType(featureFlags.responseSequencerType());
useAsyncMessageHandlingOnSchedule = featureFlags.useAsyncMessageHandlingOnSchedule();
asyncApplyBucketDiff = featureFlags.asyncApplyBucketDiff();
}
@Override
public void getConfig(StorFilestorConfig.Builder builder) {
if (numThreads != null) {
builder.num_threads(numThreads);
}
builder.enable_multibit_split_optimalization(cluster.getPersistence().enableMultiLevelSplitting());
builder.num_response_threads(reponseNumThreads);
builder.response_sequencer_type(responseSequencerType);
builder.use_async_message_handling_on_schedule(useAsyncMessageHandlingOnSchedule);
builder.async_apply_bucket_diff(asyncApplyBucketDiff);
}
}
|