@@ -35,15 +35,50 @@ Error ResourceMonitor::Init(const Config& config, const iam::nodeinfoprovider::N
3535 return AOS_ERROR_WRAP (err);
3636 }
3737
38- mNodeMonitoringData .mNodeID = nodeInfo->mNodeID ;
39- mNodeMonitoringData .mMonitoringData .mPartitions = nodeInfo->mPartitions ;
40- mMaxDMIPS = nodeInfo->mMaxDMIPS ;
41- mMaxMemory = nodeInfo->mTotalRAM ;
38+ for (const auto & partition : nodeInfo->mPartitions ) {
39+ if (auto err = mNodePartitions .EmplaceBack (); !err.IsNone ()) {
40+ return AOS_ERROR_WRAP (err);
41+ }
42+
43+ if (auto err = mNodePartitions .Back ().mName .Assign (partition.mName ); !err.IsNone ()) {
44+ return AOS_ERROR_WRAP (err);
45+ }
46+
47+ if (auto err = mNodePartitions .Back ().mPath .Assign (partition.mPath ); !err.IsNone ()) {
48+ return AOS_ERROR_WRAP (err);
49+ }
50+
51+ if (auto err = mNodePartitions .Back ().mTypes .Assign (partition.mTypes ); !err.IsNone ()) {
52+ return AOS_ERROR_WRAP (err);
53+ }
54+
55+ mNodePartitions .Back ().mTotalSize = partition.mTotalSize ;
56+ }
57+
58+ mNodeMonitoringData .mNodeID = nodeInfo->mNodeID ;
59+ mMaxDMIPS = nodeInfo->mMaxDMIPS ;
60+ mMaxMemory = nodeInfo->mTotalRAM ;
61+
62+ for (const auto & partition : mNodePartitions ) {
63+ if (auto err = mNodeMonitoringData .mMonitoringData .mPartitionsParams .EmplaceBack (); !err.IsNone ()) {
64+ return AOS_ERROR_WRAP (err);
65+ }
66+
67+ auto & param = mNodeMonitoringData .mMonitoringData .mPartitionsParams .Back ();
68+
69+ if (auto err = param.mName .Assign (partition.mName ); !err.IsNone ()) {
70+ return AOS_ERROR_WRAP (err);
71+ }
72+
73+ if (auto err = param.mPath .Assign (partition.mPath ); !err.IsNone ()) {
74+ return AOS_ERROR_WRAP (err);
75+ }
76+ }
4277
4378 assert (mConfig .mPollPeriod > 0 );
4479
45- if (auto err = mAverage .Init (
46- nodeInfo-> mPartitions , mConfig .mAverageWindow .Nanoseconds () / mConfig .mPollPeriod .Nanoseconds ());
80+ if (auto err = mAverage .Init (mNodeMonitoringData . mMonitoringData . mPartitionsParams ,
81+ mConfig .mAverageWindow .Nanoseconds () / mConfig .mPollPeriod .Nanoseconds ());
4782 !err.IsNone ()) {
4883 return AOS_ERROR_WRAP (err);
4984 }
@@ -485,7 +520,7 @@ void ResourceMonitor::NormalizeMonitoringData()
485520
486521 for (const auto & partition : instanceMonitoring.mMonitoringData .mPartitions ) {
487522 if (auto it = nodeMonitoringData.mPartitions .FindIf (
488- [&partition](const PartitionInfoObsolete & p) { return p.mName == partition.mName ; });
523+ [&partition](const auto & p) { return p.mName == partition.mName ; });
489524 it != nodeMonitoringData.mPartitions .end ()) {
490525 it->mUsedSize = Max (it->mUsedSize , partition.mUsedSize );
491526 }
@@ -600,14 +635,12 @@ RetWithError<uint64_t> ResourceMonitor::GetCurrentUsage(
600635
601636RetWithError<uint64_t > ResourceMonitor::GetPartitionTotalSize (const String& name) const
602637{
603- auto it = mNodeMonitoringData .mMonitoringData .mPartitions .FindIf (
604- [&name](const auto & partition) { return partition.mName == name; });
605-
606- if (it == mNodeMonitoringData .mMonitoringData .mPartitions .end ()) {
607- return {0 , ErrorEnum::eNotFound};
638+ if (auto it = mNodePartitions .FindIf ([&name](const auto & partition) { return partition.mName == name; });
639+ it != mNodePartitions .end ()) {
640+ return {it->mTotalSize , ErrorEnum::eNone};
608641 }
609642
610- return {it-> mTotalSize , ErrorEnum::eNone };
643+ return {0 , ErrorEnum::eNotFound };
611644}
612645
613646UniquePtr<ResourceIdentifier> ResourceMonitor::CreateResourceIdentifier (ResourceLevel level, ResourceType type,
0 commit comments