fdbserver/ClusterController.actor.cpp
// Updates work health signals in `workerHealth` based on `req`.
Updates work health signals in `workerHealth` based on `req`.
Updates work health signals in ` workerHealth ` based on ` req ` .
void updateWorkerHealth(const UpdateWorkerHealthRequest& req) {
		std::string degradedPeersString;
		for (int i = 0; i < req.degradedPeers.size(); ++i) {
			degradedPeersString += (i == 0 ? "" : " ") + req.degradedPeers[i].toString();
		}
		TraceEvent("ClusterControllerUpdateWorkerHealth")
		    .detail("WorkerAddress", req.address)
		    .detail("DegradedPeers", degradedPeersString);
		if (req.degradedPeers.empty()) {
			workerHealth.erase(req.address);
			return;
		}
		double currentTime = now();
		if (workerHealth.find(req.address) == workerHealth.end()) {
			workerHealth[req.address] = {};
			for (const auto& degradedPeer : req.degradedPeers) {
				workerHealth[req.address].degradedPeers[degradedPeer] = { currentTime, currentTime };
			}
			return;
		}
		auto& health = workerHealth[req.address];
		std::unordered_set<NetworkAddress> recoveredPeers;
		for (const auto& [peer, times] : health.degradedPeers) {
			recoveredPeers.insert(peer);
		}
		for (const auto& peer : req.degradedPeers) {
			if (recoveredPeers.find(peer) != recoveredPeers.end()) {
				recoveredPeers.erase(peer);
			}
		}
		for (const auto& peer : recoveredPeers) {
			health.degradedPeers.erase(peer);
		}
		for (const auto& peer : req.degradedPeers) {
			auto it = health.degradedPeers.find(peer);
			if (it == health.degradedPeers.end()) {
				health.degradedPeers[peer] = { currentTime, currentTime };
				continue;
			}
			it->second.lastRefreshTime = currentTime;
		}
	}
void updateWorkerHealth ( const UpdateWorkerHealthRequest & req ) { std :: string degradedPeersString ; for ( int i = 0 ; i < req . degradedPeers . size ( ) ; ++ i ) { degradedPeersString += ( i == 0 ? " " : " " ) + req . degradedPeers [ i ] . toString ( ) ; } TraceEvent ( " " ) . detail ( " " , req . address ) . detail ( " " , degradedPeersString ) ; if ( req . degradedPeers . empty ( ) ) { workerHealth . erase ( req . address ) ; return ; } double currentTime = now ( ) ; if ( workerHealth . find ( req . address ) == workerHealth . end ( ) ) { workerHealth [ req . address ] = { } ; for ( const auto & degradedPeer : req . degradedPeers ) { workerHealth [ req . address ] . degradedPeers [ degradedPeer ] = { currentTime , currentTime } ; } return ; } auto & health = workerHealth [ req . address ] ; std :: unordered_set < NetworkAddress > recoveredPeers ; for ( const auto & [ peer , times ] : health . degradedPeers ) { recoveredPeers . insert ( peer ) ; } for ( const auto & peer : req . degradedPeers ) { if ( recoveredPeers . find ( peer ) != recoveredPeers . end ( ) ) { recoveredPeers . erase ( peer ) ; } } for ( const auto & peer : recoveredPeers ) { health . degradedPeers . erase ( peer ) ; } for ( const auto & peer : req . degradedPeers ) { auto it = health . degradedPeers . find ( peer ) ; if ( it == health . degradedPeers . end ( ) ) { health . degradedPeers [ peer ] = { currentTime , currentTime } ; continue ; } it -> second . lastRefreshTime = currentTime ; } }
Updates work health signals in `workerHealth` based on `req`.
Updates work health signals in ` workerHealth ` based on ` req ` .
// `req.degradedPeers` contains the latest peer performance view from the worker. Clear the worker if the // requested worker doesn't see any degraded peers. // Current `workerHealth` doesn't have any information about the incoming worker. Add the worker into // `workerHealth`. // The incoming worker already exists in `workerHealth`. // First, remove any degraded peers recorded in the `workerHealth`, but aren't in the incoming request. These // machines network performance should have recovered. // Update the worker's degradedPeers.