solve some comments

This commit is contained in:
Xiaoxi Wang 2022-06-16 11:07:21 -07:00
parent ed9ca1e3da
commit a311cc28cc
4 changed files with 17 additions and 13 deletions

View File

@ -30,6 +30,7 @@ const KeyRef JSONSchemas::statusSchema = LiteralStringRef(R"statusSchema(
"wiggle_server_addresses": ["127.0.0.1"],
"primary": {
"state": {"$enum":["running", "paused", "unknown"]},
"last_state_change_datetime": "2022-04-02 00:05:05.123 +0000",
"last_state_change_timestamp": 1648857905.123,
"last_round_start_datetime": "2022-04-02 00:05:05.123 +0000",
"last_round_start_timestamp": 1648857905.123,
@ -46,6 +47,7 @@ const KeyRef JSONSchemas::statusSchema = LiteralStringRef(R"statusSchema(
},
"remote": {
"state": {"$enum":["running", "paused", "unknown"]},
"last_state_change_datetime": "2022-04-02 00:05:05.123 +0000",
"last_state_change_timestamp": 1648857905.123,
"last_round_start_datetime": "2022-04-02 00:05:05.123 +0000",
"last_round_start_timestamp": 1648857905.123,

View File

@ -1954,7 +1954,7 @@ public:
teamCollection->server_info.size() <= teamCollection->configuration.storageTeamSize ||
teamCollection->machine_info.size() < teamCollection->configuration.storageTeamSize;
if (takeRest) {
teamCollection->storageWiggler->setState(StorageWiggler::PAUSE);
teamCollection->storageWiggler->setWiggleState(StorageWiggler::PAUSE);
if (teamCollection->configuration.storageMigrationType == StorageMigrationType::GRADUAL) {
TraceEvent(SevWarn, "PerpetualStorageWiggleSleep", teamCollection->distributorId)
.suppressFor(SERVER_KNOBS->PERPETUAL_WIGGLE_DELAY * 4)
@ -2032,7 +2032,7 @@ public:
TEST(true); // paused because cluster is unhealthy
moveFinishFuture = Never();
self->includeStorageServersForWiggle();
self->storageWiggler->setState(StorageWiggler::PAUSE);
self->storageWiggler->setWiggleState(StorageWiggler::PAUSE);
TraceEvent(self->configuration.storageMigrationType == StorageMigrationType::AGGRESSIVE ? SevInfo
: SevWarn,
"PerpetualStorageWigglePause",
@ -2049,7 +2049,7 @@ public:
wait(self->storageWiggler->startWiggle());
auto fv = self->excludeStorageServersForWiggle(id);
moveFinishFuture = fv;
self->storageWiggler->setState(StorageWiggler::RUN);
self->storageWiggler->setWiggleState(StorageWiggler::RUN);
TraceEvent("PerpetualStorageWiggleStart", self->distributorId)
.detail("Primary", self->primary)
.detail("ServerId", id)
@ -5078,7 +5078,7 @@ bool DDTeamCollection::exclusionSafetyCheck(std::vector<UID>& excludeServerIDs)
std::pair<StorageWiggler::State, double> DDTeamCollection::getStorageWigglerState() const {
if (storageWiggler) {
return { storageWiggler->getState(), storageWiggler->lastStateChangeTs };
return { storageWiggler->getWiggleState(), storageWiggler->lastStateChangeTs };
}
return { StorageWiggler::INVALID, 0.0 };
}

View File

@ -390,7 +390,7 @@ struct StorageWiggleMetrics {
};
struct StorageWiggler : ReferenceCounted<StorageWiggler> {
enum State : uint8_t { INVALID = 0, RUN, PAUSE };
enum State : uint8_t { INVALID = 0, RUN = 1, PAUSE = 2 };
AsyncVar<bool> nonEmpty;
DDTeamCollection const* teamCollection;
StorageWiggleMetrics metrics;
@ -401,7 +401,7 @@ struct StorageWiggler : ReferenceCounted<StorageWiggler> {
wiggle_pq;
std::unordered_map<UID, decltype(wiggle_pq)::handle_type> pq_handles;
State _state = State::INVALID;
State wiggleState = State::INVALID;
double lastStateChangeTs = 0.0; // timestamp describes when did the state change
explicit StorageWiggler(DDTeamCollection* collection) : nonEmpty(false), teamCollection(collection){};
@ -415,14 +415,14 @@ struct StorageWiggler : ReferenceCounted<StorageWiggler> {
bool empty() const { return wiggle_pq.empty(); }
Optional<UID> getNextServerId();
State getState() const { return _state; }
void setState(State s) {
if (_state != s) {
_state = s;
State getWiggleState() const { return wiggleState; }
void setWiggleState(State s) {
if (wiggleState != s) {
wiggleState = s;
lastStateChangeTs = g_network->now();
}
}
static std::string getStateStr(State s) {
static std::string getWiggleStateStr(State s) {
switch (s) {
case State::RUN:
return "running";

View File

@ -2814,8 +2814,9 @@ ACTOR Future<JsonBuilderObject> storageWigglerStatsFetcher(Optional<DataDistribu
auto obj = ObjectReader::fromStringRef<StorageWiggleMetrics>(primaryV.get(), IncludeVersion()).toJSON();
if (stateFut.canGet() && stateFut.get().present()) {
auto& reply = stateFut.get().get();
obj["state"] = StorageWiggler::getStateStr(static_cast<StorageWiggler::State>(reply.primary));
obj["state"] = StorageWiggler::getWiggleStateStr(static_cast<StorageWiggler::State>(reply.primary));
obj["last_state_change_timestamp"] = reply.lastStateChangePrimary;
obj["last_state_change_datetime"] = epochsToGMTString(reply.lastStateChangePrimary);
}
res["primary"] = obj;
}
@ -2823,8 +2824,9 @@ ACTOR Future<JsonBuilderObject> storageWigglerStatsFetcher(Optional<DataDistribu
auto obj = ObjectReader::fromStringRef<StorageWiggleMetrics>(remoteV.get(), IncludeVersion()).toJSON();
if (stateFut.canGet() && stateFut.get().present()) {
auto& reply = stateFut.get().get();
obj["state"] = StorageWiggler::getStateStr(static_cast<StorageWiggler::State>(reply.remote));
obj["state"] = StorageWiggler::getWiggleStateStr(static_cast<StorageWiggler::State>(reply.remote));
obj["last_state_change_timestamp"] = reply.lastStateChangeRemote;
obj["last_state_change_datetime"] = epochsToGMTString(reply.lastStateChangeRemote);
}
res["remote"] = obj;
}