Add ClientCount to ClusterControllerMetrics (#5748)
This commit is contained in:
parent
0e4a6cc921
commit
507a09893c
|
@ -454,6 +454,7 @@ void ServerKnobs::initialize(Randomize randomize, ClientKnobs* clientKnobs, IsSi
|
|||
init( SIM_SHUTDOWN_TIMEOUT, 10 );
|
||||
init( SHUTDOWN_TIMEOUT, 600 ); if( randomize && BUGGIFY ) SHUTDOWN_TIMEOUT = 60.0;
|
||||
init( MASTER_SPIN_DELAY, 1.0 ); if( randomize && BUGGIFY ) MASTER_SPIN_DELAY = 10.0;
|
||||
init( CC_PRUNE_CLIENTS_INTERVAL, 60.0 );
|
||||
init( CC_CHANGE_DELAY, 0.1 );
|
||||
init( CC_CLASS_DELAY, 0.01 );
|
||||
init( WAIT_FOR_GOOD_RECRUITMENT_DELAY, 1.0 );
|
||||
|
|
|
@ -377,6 +377,7 @@ public:
|
|||
double SIM_SHUTDOWN_TIMEOUT;
|
||||
double SHUTDOWN_TIMEOUT;
|
||||
double MASTER_SPIN_DELAY;
|
||||
double CC_PRUNE_CLIENTS_INTERVAL;
|
||||
double CC_CHANGE_DELAY;
|
||||
double CC_CLASS_DELAY;
|
||||
double WAIT_FOR_GOOD_RECRUITMENT_DELAY;
|
||||
|
|
|
@ -133,6 +133,8 @@ public:
|
|||
int logGenerations;
|
||||
bool cachePopulated;
|
||||
std::map<NetworkAddress, std::pair<double, OpenDatabaseRequest>> clientStatus;
|
||||
Future<Void> clientCounter;
|
||||
int clientCount;
|
||||
|
||||
DBInfo()
|
||||
: clientInfo(new AsyncVar<ClientDBInfo>()), serverInfo(new AsyncVar<ServerDBInfo>()),
|
||||
|
@ -143,7 +145,9 @@ public:
|
|||
EnableLocalityLoadBalance::True,
|
||||
TaskPriority::DefaultEndpoint,
|
||||
LockAware::True)), // SOMEDAY: Locality!
|
||||
unfinishedRecoveries(0), logGenerations(0), cachePopulated(false) {}
|
||||
unfinishedRecoveries(0), logGenerations(0), cachePopulated(false), clientCount(0) {
|
||||
clientCounter = countClients(this);
|
||||
}
|
||||
|
||||
void setDistributor(const DataDistributorInterface& interf) {
|
||||
auto newInfo = serverInfo->get();
|
||||
|
@ -172,6 +176,22 @@ public:
|
|||
}
|
||||
serverInfo->set(newInfo);
|
||||
}
|
||||
|
||||
ACTOR static Future<Void> countClients(DBInfo* self) {
|
||||
loop {
|
||||
wait(delay(SERVER_KNOBS->CC_PRUNE_CLIENTS_INTERVAL));
|
||||
|
||||
self->clientCount = 0;
|
||||
for (auto itr = self->clientStatus.begin(); itr != self->clientStatus.end();) {
|
||||
if (now() - itr->second.first < 2 * SERVER_KNOBS->COORDINATOR_REGISTER_INTERVAL) {
|
||||
self->clientCount += itr->second.second.clientCount;
|
||||
++itr;
|
||||
} else {
|
||||
itr = self->clientStatus.erase(itr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
struct UpdateWorkerList {
|
||||
|
@ -3174,6 +3194,8 @@ public:
|
|||
serverInfo.myLocality = locality;
|
||||
db.serverInfo->set(serverInfo);
|
||||
cx = openDBOnServer(db.serverInfo, TaskPriority::DefaultEndpoint, LockAware::True);
|
||||
|
||||
specialCounter(clusterControllerMetrics, "ClientCount", [this]() { return db.clientCount; });
|
||||
}
|
||||
|
||||
~ClusterControllerData() {
|
||||
|
|
Loading…
Reference in New Issue