2017-05-26 04:48:44 +08:00
|
|
|
/*
|
|
|
|
* DDMetrics.actor.cpp
|
|
|
|
*
|
|
|
|
* This source file is part of the FoundationDB open source project
|
|
|
|
*
|
2022-03-22 04:36:23 +08:00
|
|
|
* Copyright 2013-2022 Apple Inc. and the FoundationDB project authors
|
2018-02-22 02:25:11 +08:00
|
|
|
*
|
2017-05-26 04:48:44 +08:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2018-02-22 02:25:11 +08:00
|
|
|
*
|
2017-05-26 04:48:44 +08:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2018-02-22 02:25:11 +08:00
|
|
|
*
|
2017-05-26 04:48:44 +08:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2019-02-18 07:41:16 +08:00
|
|
|
#include "fdbclient/NativeAPI.actor.h"
|
2019-02-18 11:25:16 +08:00
|
|
|
#include "fdbserver/TesterInterface.actor.h"
|
2017-05-26 04:48:44 +08:00
|
|
|
#include "fdbserver/Status.h"
|
|
|
|
#include "fdbserver/QuietDatabase.h"
|
|
|
|
#include "fdbserver/ServerDBInfo.h"
|
2019-02-18 11:18:30 +08:00
|
|
|
#include "fdbserver/workloads/workloads.actor.h"
|
2021-03-11 02:06:03 +08:00
|
|
|
#include "flow/actorcompiler.h" // This must be the last #include.
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
struct DDMetricsWorkload : TestWorkload {
|
|
|
|
double startDelay, ddDone;
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
DDMetricsWorkload(WorkloadContext const& wcx) : TestWorkload(wcx), ddDone(0.0) {
|
|
|
|
startDelay = getOption(options, LiteralStringRef("beginPoll"), 10.0);
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
|
2020-10-05 13:29:07 +08:00
|
|
|
std::string description() const override { return "Data Distribution Metrics"; }
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
ACTOR Future<int> getHighPriorityRelocationsInFlight(Database cx, DDMetricsWorkload* self) {
|
2017-05-26 04:48:44 +08:00
|
|
|
WorkerInterface masterWorker = wait(getMasterWorker(cx, self->dbInfo));
|
|
|
|
|
2018-08-17 01:24:12 +08:00
|
|
|
TraceEvent("GetHighPriorityReliocationsInFlight").detail("Stage", "ContactingMaster");
|
2021-03-11 02:06:03 +08:00
|
|
|
TraceEventFields md = wait(
|
|
|
|
timeoutError(masterWorker.eventLogRequest.getReply(EventLogRequest(LiteralStringRef("MovingData"))), 1.0));
|
2017-05-26 04:48:44 +08:00
|
|
|
int relocations;
|
2019-10-12 08:50:43 +08:00
|
|
|
sscanf(md.getValue("UnhealthyRelocations").c_str(), "%d", &relocations);
|
2017-05-26 04:48:44 +08:00
|
|
|
return relocations;
|
|
|
|
}
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
ACTOR Future<Void> work(Database cx, DDMetricsWorkload* self) {
|
2017-05-26 04:48:44 +08:00
|
|
|
try {
|
2018-06-09 02:11:08 +08:00
|
|
|
TraceEvent("DDMetricsWaiting").detail("StartDelay", self->startDelay);
|
2021-03-11 02:06:03 +08:00
|
|
|
wait(delay(self->startDelay));
|
2021-07-27 10:55:10 +08:00
|
|
|
TraceEvent("DDMetricsStarting").log();
|
2017-05-26 04:48:44 +08:00
|
|
|
state double startTime = now();
|
|
|
|
loop {
|
2021-03-11 02:06:03 +08:00
|
|
|
wait(delay(2.5));
|
|
|
|
int dif = wait(self->getHighPriorityRelocationsInFlight(cx, self));
|
2017-05-26 04:48:44 +08:00
|
|
|
TraceEvent("DDMetricsCheck").detail("DIF", dif);
|
2021-03-11 02:06:03 +08:00
|
|
|
if (dif == 0) {
|
2017-05-26 04:48:44 +08:00
|
|
|
self->ddDone = now() - startTime;
|
|
|
|
return Void();
|
|
|
|
}
|
|
|
|
}
|
2021-03-11 02:06:03 +08:00
|
|
|
} catch (Error& e) {
|
2017-05-26 04:48:44 +08:00
|
|
|
TraceEvent("DDMetricsError").error(e);
|
|
|
|
}
|
|
|
|
return Void();
|
|
|
|
}
|
|
|
|
|
2020-10-05 13:29:07 +08:00
|
|
|
Future<Void> start(Database const& cx) override { return clientId == 0 ? work(cx, this) : Void(); }
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2020-10-05 13:29:07 +08:00
|
|
|
Future<bool> check(Database const& cx) override { return true; }
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2021-09-17 08:42:34 +08:00
|
|
|
void getMetrics(std::vector<PerfMetric>& m) override { m.emplace_back("DDDuration", ddDone, Averaged::False); }
|
2017-05-26 04:48:44 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
WorkloadFactory<DDMetricsWorkload> DDMetricsWorkloadFactory("DDMetrics");
|