MCPcopy Create free account
hub / github.com/apple/foundationdb / fetcher

Function fetcher

fdbserver/workloads/StatusWorkload.actor.cpp:30–203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28#include "flow/actorcompiler.h" // This must be the last #include.
29
30struct StatusWorkload : TestWorkload {
31 double testDuration, requestsPerSecond;
32 bool enableLatencyBands;
33
34 Future<Void> latencyBandActor;
35
36 PerfIntCounter requests, replies, errors, totalSize;
37 Optional<StatusObject> parsedSchema;
38
39 StatusWorkload(WorkloadContext const& wcx)
40 : TestWorkload(wcx), requests("Status requests issued"), replies("Status replies received"),
41 errors("Status Errors"), totalSize("Status reply size sum") {
42 testDuration = getOption(options, LiteralStringRef("testDuration"), 10.0);
43 requestsPerSecond = getOption(options, LiteralStringRef("requestsPerSecond"), 0.5);
44 enableLatencyBands =
45 getOption(options, LiteralStringRef("enableLatencyBands"), deterministicRandom()->random01() < 0.5);
46 auto statusSchemaStr = getOption(options, LiteralStringRef("schema"), JSONSchemas::statusSchema);
47 if (statusSchemaStr.size()) {
48 json_spirit::mValue schema = readJSONStrictly(statusSchemaStr.toString());
49 parsedSchema = schema.get_obj();
50
51 // This is sort of a hack, but generate code coverage *requirements* for everything in schema
52 schemaCoverageRequirements(parsedSchema.get());
53 }
54 }
55
56 std::string description() const override { return "StatusWorkload"; }
57 Future<Void> setup(Database const& cx) override {
58 if (enableLatencyBands) {
59 latencyBandActor = configureLatencyBands(this, cx);
60 }
61
62 return Void();
63 }
64 Future<Void> start(Database const& cx) override {
65 if (clientId != 0)
66 return Void();
67
68 return success(timeout(fetcher(cx, this), testDuration));
69 }
70 Future<bool> check(Database const& cx) override { return errors.getValue() == 0; }
71
72 void getMetrics(std::vector<PerfMetric>& m) override {
73 if (clientId != 0)
74 return;
75
76 m.push_back(requests.getMetric());
77 m.push_back(replies.getMetric());
78 m.emplace_back(
79 "Average Reply Size", replies.getValue() ? totalSize.getValue() / replies.getValue() : 0, Averaged::False);
80 m.push_back(errors.getMetric());
81 }
82
83 static void schemaCoverageRequirements(StatusObject const& schema, std::string schema_path = std::string()) {
84 try {
85 for (auto& skv : schema) {
86 std::string spath = schema_path + "." + skv.first;
87

Callers 1

startMethod · 0.85

Calls 13

nowFunction · 0.85
AssumeVersionFunction · 0.85
TraceEventClass · 0.85
schemaMatchFunction · 0.85
write_stringFunction · 0.85
getLengthMethod · 0.80
detailMethod · 0.80
getMethod · 0.65
saveFunction · 0.50
protocolVersionMethod · 0.45
presentMethod · 0.45
codeMethod · 0.45

Tested by

no test coverage detected