2828
2929#include < Utilities.h>
3030
31+ #include < boost/algorithm/string/trim.hpp>
32+
3133#include < vector>
3234#include < map>
3335#include < thread>
@@ -87,13 +89,37 @@ class TfSchedulerStfInfo
8789 : mDiscoveryConfig (pDiscoveryConfig),
8890 mConnManager (pConnManager),
8991 mTfBuilderInfo(pTfBuilderInfo),
90- mDroppedStfs(24ULL * 3600 * 88 ), // 1h of running ~ 1MiB size
91- mBuiltTfs(24ULL * 3600 * 88 )
92+ mDroppedStfs(48ULL * 3600 * 88 ), // 1h of running ~ 1MiB size
93+ mDroppedThrottlingStfs(48ULL * 3600 * 88 ),
94+ mBuiltTfs(48ULL * 3600 * 88 )
9295 { }
9396
9497 ~TfSchedulerStfInfo () { }
9598
9699 void start () {
100+ // get parameters
101+
102+ // Build TfPercentage from AliECS
103+ if (mDiscoveryConfig ->status ().partition_params ().param_values ().count (" BuildTfPercentage" ) > 0 ) {
104+ double lTfPercent = 100.0 ;
105+ auto lBuildPercentString = mDiscoveryConfig ->status ().partition_params ().param_values ().at (" BuildTfPercentage" );
106+ boost::algorithm::trim (lBuildPercentString);
107+
108+ try {
109+ if (lBuildPercentString.empty ()) {
110+ throw boost::bad_lexical_cast ();
111+ }
112+ lTfPercent = boost::lexical_cast<double >(lBuildPercentString);
113+
114+ } catch (boost::bad_lexical_cast const &e) {
115+ EDDLOG (" Error while parsing AliECS parameter 'BuildTfPercentage'. str_value={} what={}" , lBuildPercentString, e.what ());
116+ lTfPercent = 100.0 ;
117+ }
118+
119+ mPercentageToBuild = std::clamp (lTfPercent, 0.0 , 100.0 );
120+ IDDLOG (" TfScheduler parameters: BuildTfPercentage={:.4}" , mPercentageToBuild );
121+ }
122+
97123 mStfInfoMap .clear ();
98124
99125 mRunning = true ;
@@ -169,6 +195,7 @@ class TfSchedulerStfInfo
169195
170196 // / Discovery configuration
171197 std::shared_ptr<ConsulTfScheduler> mDiscoveryConfig ;
198+ double mPercentageToBuild = 100.0 ;
172199
173200 // / RPC clients to StfSenders and TfBuilders
174201 TfSchedulerConnManager &mConnManager ;
@@ -202,14 +229,17 @@ class TfSchedulerStfInfo
202229 std::map<std::string, std::uint64_t > mMaxStfIdPerStfSender ;
203230 // total sizes
204231 std::uint64_t mTfSizeTotalScheduled = 0 ;
205- std::uint64_t mTfSizeTotalRejected = 0 ;
232+ std::atomic_uint64_t mTfSizeTotalRejected = 0 ;
206233
207234 std::uint64_t mStaleTfCount = 0 ;
208235 std::uint64_t mScheduledTfs = 0 ;
209236
210237 EventRecorder mDroppedStfs ;
238+ EventRecorder mDroppedThrottlingStfs ;
239+ std::uint64_t mLastThrottledStfId = 0 ;
211240 EventRecorder mBuiltTfs ;
212241
242+
213243 void reset () {
214244 // NOTE: only call when holding mGlobalStfInfoLock
215245 mLastStfId = 0 ;
@@ -227,6 +257,8 @@ class TfSchedulerStfInfo
227257 mTfSizeTotalRejected = 0 ;
228258
229259 mDroppedStfs .reset ();
260+ mDroppedThrottlingStfs .reset ();
261+ mLastThrottledStfId = 0 ;
230262 mBuiltTfs .reset ();
231263
232264 if (!mStfInfoMap .empty ()) {
0 commit comments