void Statsdb::addDocsIndexed ( ) { if ( ! isClockInSync() ) return; // only once per five seconds long now = getTimeLocal(); static long s_lastTime = 0; if ( now - s_lastTime < 5 ) return; s_lastTime = now; long long total = 0LL; static long long s_lastTotal = 0LL; // every 5 seconds update docs indexed count for ( long i = 0 ; i < g_hostdb.m_numHosts ; i++ ) { Host *h = &g_hostdb.m_hosts[i]; // must have something if ( h->m_docsIndexed <= 0 ) return; // add it up total += h->m_docsIndexed; } // divide by # of groups total /= g_hostdb.getNumGroups(); // skip if no change if ( total == s_lastTotal ) return; s_lastTotal = total; // add it if changed though long long nowms = gettimeofdayInMillisecondsGlobal(); addStat ( MAX_NICENESS,"docs_indexed", nowms, nowms, (float)total ); }
void Statsdb::addDocsIndexed ( ) { if ( ! isClockInSync() ) return; if ( g_hostdb.hasDeadHost() ) return; // only host #0 needs this if ( g_hostdb.m_hostId != 0 ) return; // only once per five seconds int32_t now = getTimeLocal(); static int32_t s_lastTime = 0; if ( now - s_lastTime < 5 ) return; int32_t interval = now - s_lastTime; s_lastTime = now; int64_t total = 0LL; static int64_t s_lastTotal = 0LL; // every 5 seconds update docs indexed count for ( int32_t i = 0 ; i < g_hostdb.m_numHosts ; i++ ) { Host *h = &g_hostdb.m_hosts[i]; // must have something if ( h->m_pingInfo.m_totalDocsIndexed <= 0 ) continue; // add it up total += h->m_pingInfo.m_totalDocsIndexed; } // divide by # of groups total /= g_hostdb.getNumHostsPerShard(); // skip if no change if ( total == s_lastTotal ) return; int32_t docsIndexedInInterval = total - s_lastTotal; float docsPerSecond = docsIndexedInInterval / (float)interval; log("build: total docs indexed: %f. docs per second %f %i %i", (float)total, docsPerSecond, docsIndexedInInterval, interval); // add it if changed though int64_t nowms = gettimeofdayInMillisecondsGlobal(); addStat ( MAX_NICENESS,"docs_indexed", nowms, nowms, (float)total ); // Prevent a datapoint which adds all of the docs indexed to date. if( s_lastTotal != 0 ) { addStat ( MAX_NICENESS,"docs_per_second", nowms, nowms, docsPerSecond ); } s_lastTotal = total; }