summaryrefslogtreecommitdiff
path: root/src/mongo/db/free_mon
diff options
context:
space:
mode:
authorMark Benvenuto <mark.benvenuto@mongodb.com>2020-05-29 15:04:19 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-06-02 16:33:36 +0000
commitbe78a43c50cde0844d114249cc45b6102b4cd6c8 (patch)
tree5abe8832c9aab20848f8e895bd00141cef240e00 /src/mongo/db/free_mon
parent7e28f4296a04d858a2e3dd84a1e79c9ba59a9568 (diff)
downloadmongo-be78a43c50cde0844d114249cc45b6102b4cd6c8.tar.gz
SERVER-48276 ReplSet Free Monitoring URLs inconsistent
(cherry picked from commit 4ec400290afe55c470cb14fbafb79e9f649d7cb1)
Diffstat (limited to 'src/mongo/db/free_mon')
-rw-r--r--src/mongo/db/free_mon/free_mon_controller.cpp2
-rw-r--r--src/mongo/db/free_mon/free_mon_message.h2
-rw-r--r--src/mongo/db/free_mon/free_mon_processor.cpp34
3 files changed, 23 insertions, 15 deletions
diff --git a/src/mongo/db/free_mon/free_mon_controller.cpp b/src/mongo/db/free_mon/free_mon_controller.cpp
index 7b79d0ff9d8..9517bfd7c95 100644
--- a/src/mongo/db/free_mon/free_mon_controller.cpp
+++ b/src/mongo/db/free_mon/free_mon_controller.cpp
@@ -86,7 +86,7 @@ void FreeMonController::registerServerStartup(RegistrationType registrationType,
}
boost::optional<Status> FreeMonController::registerServerCommand(Milliseconds timeout) {
- auto msg = FreeMonRegisterCommandMessage::createNow(std::vector<std::string>());
+ auto msg = FreeMonRegisterCommandMessage::createNow({std::vector<std::string>(), boost::none});
_enqueue(msg);
if (timeout > Milliseconds::min()) {
diff --git a/src/mongo/db/free_mon/free_mon_message.h b/src/mongo/db/free_mon/free_mon_message.h
index f5857c973a4..42ea7f7f85e 100644
--- a/src/mongo/db/free_mon/free_mon_message.h
+++ b/src/mongo/db/free_mon/free_mon_message.h
@@ -343,7 +343,7 @@ struct FreeMonWaitablePayloadForMessage {
template <>
struct FreeMonWaitablePayloadForMessage<FreeMonMessageType::RegisterCommand> {
- using payload_type = std::vector<std::string>;
+ using payload_type = std::pair<std::vector<std::string>, boost::optional<std::string>>;
};
template <>
diff --git a/src/mongo/db/free_mon/free_mon_processor.cpp b/src/mongo/db/free_mon/free_mon_processor.cpp
index 23e421107cb..9b720707d93 100644
--- a/src/mongo/db/free_mon/free_mon_processor.cpp
+++ b/src/mongo/db/free_mon/free_mon_processor.cpp
@@ -328,7 +328,7 @@ void FreeMonProcessor::doServerRegister(
// If we are asked to register now, then kick off a registration request
const auto regType = msg->getPayload().first;
if (regType == RegistrationType::RegisterOnStart) {
- enqueue(FreeMonRegisterCommandMessage::createNow(msg->getPayload().second));
+ enqueue(FreeMonRegisterCommandMessage::createNow({msg->getPayload().second, boost::none}));
} else {
invariant((regType == RegistrationType::RegisterAfterOnTransitionToPrimary) ||
(regType == RegistrationType::RegisterAfterOnTransitionToPrimaryIfEnabled));
@@ -353,7 +353,8 @@ void FreeMonProcessor::doServerRegister(
// We are standalone or secondary, if we have a registration id, then send a
// registration notification, else wait for the user to register us.
if (state.get().getState() == StorageStateEnum::enabled) {
- enqueue(FreeMonRegisterCommandMessage::createNow(msg->getPayload().second));
+ enqueue(FreeMonRegisterCommandMessage::createNow(
+ {msg->getPayload().second, boost::none}));
}
}
@@ -416,22 +417,26 @@ void FreeMonProcessor::doCommandRegister(Client* client,
FreeMonRegistrationRequest req;
- auto regid = _state->getRegistrationId();
- if (!regid.empty()) {
- req.setId(regid);
+ if (msg->getPayload().second) {
+ req.setId(StringData(msg->getPayload().second.get()));
+ } else {
+ auto regid = _state->getRegistrationId();
+ if (!regid.empty()) {
+ req.setId(regid);
+ }
}
req.setVersion(kMaxProtocolVersion);
req.setLocalTime(client->getServiceContext()->getPreciseClockSource()->now());
- if (!msg->getPayload().empty()) {
+ if (!msg->getPayload().first.empty()) {
// Cache the tags for subsequent retries
- _tags = msg->getPayload();
+ _tags = msg->getPayload().first;
}
if (!_tags.empty()) {
- req.setTags(transformVector(msg->getPayload()));
+ req.setTags(transformVector(msg->getPayload().first));
}
// Collect the data
@@ -698,7 +703,7 @@ void FreeMonProcessor::doAsyncRegisterFail(
// Enqueue a register retry
enqueue(FreeMonRegisterCommandMessage::createWithDeadline(
- _tags, _registrationRetry->getNextDeadline(client)));
+ {_tags, boost::none}, _registrationRetry->getNextDeadline(client)));
}
void FreeMonProcessor::doCommandUnregister(
@@ -861,7 +866,7 @@ void FreeMonProcessor::doAsyncMetricsComplete(
_metricsRetry->reset();
if (resp.getResendRegistration().is_initialized() && resp.getResendRegistration()) {
- enqueue(FreeMonRegisterCommandMessage::createNow(_tags));
+ enqueue(FreeMonRegisterCommandMessage::createNow({_tags, boost::none}));
} else {
// Enqueue next metrics upload
enqueue(FreeMonMessage::createWithDeadline(FreeMonMessageType::MetricsSend,
@@ -917,13 +922,15 @@ void FreeMonProcessor::getStatus(OperationContext* opCtx,
void FreeMonProcessor::doOnTransitionToPrimary(Client* client) {
if (_registerOnTransitionToPrimary == RegistrationType::RegisterAfterOnTransitionToPrimary) {
- enqueue(FreeMonRegisterCommandMessage::createNow(std::vector<std::string>()));
+ enqueue(
+ FreeMonRegisterCommandMessage::createNow({std::vector<std::string>(), boost::none}));
} else if (_registerOnTransitionToPrimary ==
RegistrationType::RegisterAfterOnTransitionToPrimaryIfEnabled) {
readState(client);
if (_state->getState() == StorageStateEnum::enabled) {
- enqueue(FreeMonRegisterCommandMessage::createNow(std::vector<std::string>()));
+ enqueue(FreeMonRegisterCommandMessage::createNow(
+ {std::vector<std::string>(), boost::none}));
}
}
@@ -939,7 +946,8 @@ void FreeMonProcessor::processInMemoryStateChange(const FreeMonStorageState& ori
newState.getState() == StorageStateEnum::enabled) {
// Secondary needs to start registration
- enqueue(FreeMonRegisterCommandMessage::createNow(std::vector<std::string>()));
+ enqueue(FreeMonRegisterCommandMessage::createNow(
+ {std::vector<std::string>(), newState.getRegistrationId().toString()}));
}
}
}