Skip to content

Commit 75fd9a3

Browse files
committed
Extend influencer counts if the resource monitor allows
1 parent ec9b856 commit 75fd9a3

File tree

4 files changed

+17
-16
lines changed

4 files changed

+17
-16
lines changed

include/model/CBucketGatherer.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ class MODEL_EXPORT CBucketGatherer {
168168
//! to gather data.
169169
//! \param[in] numberInfluencers The number of result influencers
170170
//! for which to gather data.
171-
CBucketGatherer(CDataGatherer& dataGatherer, core_t::TTime startTime, std::size_t numberInfluencers);
171+
CBucketGatherer(CDataGatherer& dataGatherer, const SBucketGathererInitData& bucketGathererInitData);
172172

173173
//! Create a copy that will result in the same persisted state as the
174174
//! original. This is effectively a copy constructor that creates a
@@ -474,6 +474,8 @@ class MODEL_EXPORT CBucketGatherer {
474474

475475
//! The influencing field value counts per person and/or attribute.
476476
TSizeSizePrOptionalStrPrUInt64UMapVecQueue m_InfluencerCounts;
477+
478+
TOptionalResourceMonitorCRef m_ResourceMonitor;
477479
};
478480
}
479481
}

lib/model/CBucketGatherer.cc

+10-9
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* limitation.
1010
*/
1111

12+
#include "model/CResourceMonitor.h"
1213
#include <model/CBucketGatherer.h>
1314

1415
#include <core/CLogger.h>
@@ -202,29 +203,29 @@ const std::string CBucketGatherer::EVENTRATE_BUCKET_GATHERER_TAG("a");
202203
const std::string CBucketGatherer::METRIC_BUCKET_GATHERER_TAG("b");
203204

204205
CBucketGatherer::CBucketGatherer(CDataGatherer& dataGatherer,
205-
core_t::TTime startTime,
206-
std::size_t numberInfluencers)
207-
: m_DataGatherer(dataGatherer), m_EarliestTime(startTime), m_BucketStart(startTime),
206+
const SBucketGathererInitData& initData)
207+
: m_DataGatherer(dataGatherer), m_EarliestTime(initData.s_StartTime), m_BucketStart(initData.s_StartTime),
208208
m_PersonAttributeCounts(dataGatherer.params().s_LatencyBuckets,
209209
dataGatherer.params().s_BucketLength,
210-
startTime,
210+
initData.s_StartTime,
211211
TSizeSizePrUInt64UMap(1)),
212212
m_PersonAttributeExplicitNulls(dataGatherer.params().s_LatencyBuckets,
213213
dataGatherer.params().s_BucketLength,
214-
startTime,
214+
initData.s_StartTime,
215215
TSizeSizePrUSet(1)),
216216
m_InfluencerCounts(dataGatherer.params().s_LatencyBuckets + 3,
217217
dataGatherer.params().s_BucketLength,
218-
startTime,
219-
TSizeSizePrOptionalStrPrUInt64UMapVec(numberInfluencers)) {
218+
initData.s_StartTime,
219+
TSizeSizePrOptionalStrPrUInt64UMapVec(initData.s_InfluenceFieldNames.size())),
220+
m_ResourceMonitor(initData.s_ResourceMonitor){
220221
}
221222

222223
CBucketGatherer::CBucketGatherer(bool isForPersistence, const CBucketGatherer& other)
223224
: m_DataGatherer(other.m_DataGatherer),
224225
m_EarliestTime(other.m_EarliestTime), m_BucketStart(other.m_BucketStart),
225226
m_PersonAttributeCounts(other.m_PersonAttributeCounts),
226227
m_PersonAttributeExplicitNulls(other.m_PersonAttributeExplicitNulls),
227-
m_InfluencerCounts(other.m_InfluencerCounts) {
228+
m_InfluencerCounts(other.m_InfluencerCounts), m_ResourceMonitor(other.m_ResourceMonitor) {
228229
if (!isForPersistence) {
229230
LOG_ABORT(<< "This constructor only creates clones for persistence");
230231
}
@@ -293,7 +294,7 @@ bool CBucketGatherer::addEventData(CEventData& data) {
293294
if (influence) {
294295
const std::string& inf = *influence;
295296
canonicalInfluences[i] = inf;
296-
if (count > 0) {
297+
if (count > 0 && m_ResourceMonitor && m_ResourceMonitor->get().areAllocationsAllowed()) {
297298
influencerCounts[i]
298299
.emplace(boost::unordered::piecewise_construct,
299300
boost::make_tuple(pidCid, inf),

lib/model/CEventRateBucketGatherer.cc

+2-3
Original file line numberDiff line numberDiff line change
@@ -729,8 +729,7 @@ void registerMemoryCallbacks() {
729729
CEventRateBucketGatherer::CEventRateBucketGatherer(CDataGatherer& dataGatherer,
730730
const CBucketGatherer::SBucketGathererInitData& initData)
731731
: CBucketGatherer(dataGatherer,
732-
initData.s_StartTime,
733-
initData.s_InfluenceFieldNames.size()),
732+
initData),
734733
m_BeginInfluencingFields(0), m_BeginValueField(0), m_BeginSummaryFields(0) {
735734
this->initializeFieldNames(initData);
736735
this->initializeFeatureData();
@@ -739,7 +738,7 @@ CEventRateBucketGatherer::CEventRateBucketGatherer(CDataGatherer& dataGatherer,
739738
CEventRateBucketGatherer::CEventRateBucketGatherer(CDataGatherer& dataGatherer,
740739
const CBucketGatherer::SBucketGathererInitData& initData,
741740
core::CStateRestoreTraverser& traverser)
742-
: CBucketGatherer(dataGatherer, 0, initData.s_InfluenceFieldNames.size()),
741+
: CBucketGatherer(dataGatherer, initData),
743742
m_BeginInfluencingFields(0), m_BeginValueField(0), m_BeginSummaryFields(0) {
744743
this->initializeFieldNames(initData);
745744
if (traverser.traverseSubLevel(std::bind(&CEventRateBucketGatherer::acceptRestoreTraverser,

lib/model/CMetricBucketGatherer.cc

+2-3
Original file line numberDiff line numberDiff line change
@@ -927,8 +927,7 @@ struct SReleaseMemory {
927927
CMetricBucketGatherer::CMetricBucketGatherer(CDataGatherer& dataGatherer,
928928
const CBucketGatherer::SBucketGathererInitData& initData)
929929
: CBucketGatherer(dataGatherer,
930-
initData.s_StartTime,
931-
initData.s_InfluenceFieldNames.size()),
930+
initData),
932931
m_ValueFieldName(initData.s_ValueFieldName), m_BeginInfluencingFields(0),
933932
m_BeginValueFields(0) {
934933
this->initializeFieldNamesPart1(initData);
@@ -939,7 +938,7 @@ CMetricBucketGatherer::CMetricBucketGatherer(CDataGatherer& dataGatherer,
939938
CMetricBucketGatherer::CMetricBucketGatherer(CDataGatherer& dataGatherer,
940939
const CBucketGatherer::SBucketGathererInitData& initData,
941940
core::CStateRestoreTraverser& traverser)
942-
: CBucketGatherer(dataGatherer, 0, initData.s_InfluenceFieldNames.size()),
941+
: CBucketGatherer(dataGatherer, initData),
943942
m_ValueFieldName(initData.s_ValueFieldName), m_BeginValueFields(0) {
944943
this->initializeFieldNamesPart1(initData);
945944
if (traverser.traverseSubLevel(std::bind(&CMetricBucketGatherer::acceptRestoreTraverser,

0 commit comments

Comments
 (0)