Skip to content

Commit 5693576

Browse files
committed
RDKTV-34659, RDK-55125: Monitor Plugin Sync
Reason for change: bring changes present in WebPlatformForEmbedded/ThunderNanoServicesRDK/R4_4/Monitor plugin as part of rdkcentral/rdkservices/Monitor Plugin Test Procedure: appswitch test as mentioned in RDKTV-34659 Risks: Low Priority: P1 Signed-off-by:Boopathi Vanavarayan <[email protected]>
1 parent 66d0476 commit 5693576

File tree

4 files changed

+214
-337
lines changed

4 files changed

+214
-337
lines changed

Monitor/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ All notable changes to this RDK Service will be documented in this file.
1616

1717
* For more details, refer to [versioning](https://github.com/rdkcentral/rdkservices#versioning) section under Main README.
1818

19+
## [2.0.0] - 2024-12-12
20+
### Changed
21+
- Synced Monitor Plugin with WebPlatformForEmbedded/ThunderNanoServicesRDK/tree/R4_4/Monitor
22+
1923
## [1.0.9] - 2024-07-25
2024
### Changed
2125
- Added the NetworkManager Plugin into MOnitor config list

Monitor/Monitor.cpp

Lines changed: 35 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,26 @@
1919

2020
#include "Monitor.h"
2121

22-
#define API_VERSION_NUMBER_MAJOR 1
22+
#define API_VERSION_NUMBER_MAJOR 2
2323
#define API_VERSION_NUMBER_MINOR 0
24-
#define API_VERSION_NUMBER_PATCH 9
24+
#define API_VERSION_NUMBER_PATCH 0
2525

2626
namespace WPEFramework {
27-
28-
namespace {
29-
30-
static Plugin::Metadata<Plugin::Monitor> metadata(
31-
// Version (Major, Minor, Patch)
32-
API_VERSION_NUMBER_MAJOR, API_VERSION_NUMBER_MINOR, API_VERSION_NUMBER_PATCH,
33-
// Preconditions
34-
{},
35-
// Terminations
36-
{},
37-
// Controls
38-
{}
39-
);
40-
}
41-
4227
namespace Plugin {
4328

44-
SERVICE_REGISTRATION(Monitor, API_VERSION_NUMBER_MAJOR, API_VERSION_NUMBER_MINOR, API_VERSION_NUMBER_PATCH);
29+
namespace {
30+
31+
static Plugin::Metadata<Plugin::Monitor> metadata(
32+
// Version (Major, Minor, Patch)
33+
API_VERSION_NUMBER_MAJOR, API_VERSION_NUMBER_MINOR, API_VERSION_NUMBER_PATCH,
34+
// Preconditions
35+
{},
36+
// Terminations
37+
{},
38+
// Controls
39+
{}
40+
);
41+
}
4542

4643
static Core::ProxyPoolType<Web::JSONBodyType<Core::JSON::ArrayType<Monitor::Data>>> jsonBodyDataFactory(2);
4744
static Core::ProxyPoolType<Web::JSONBodyType<Monitor::Data>> jsonBodyParamFactory(2);
@@ -57,21 +54,24 @@ namespace Plugin {
5754
Core::JSON::ArrayType<Config::Entry>::Iterator index(_config.Observables.Elements());
5855

5956
// Create a list of plugins to monitor..
60-
_monitor->Open(service, index);
57+
_monitor.Open(service, index);
6158

6259
// During the registartion, all Plugins, currently active are reported to the sink.
63-
service->Register(_monitor);
60+
service->Register(&_monitor);
61+
62+
RegisterAll();
6463

6564
// On succes return a name as a Callsign to be used in the URL, after the "service"prefix
6665
return (_T(""));
6766
}
6867

6968
/* virtual */ void Monitor::Deinitialize(PluginHost::IShell* service)
7069
{
70+
UnregisterAll();
7171

72-
_monitor->Close();
72+
service->Unregister(&_monitor);
7373

74-
service->Unregister(_monitor);
74+
_monitor.Close();
7575
}
7676

7777
/* virtual */ string Monitor::Information() const
@@ -106,46 +106,39 @@ namespace Plugin {
106106
if (request.Verb == Web::Request::HTTP_GET) {
107107
// Let's list them all....
108108
if (index.Next() == false) {
109-
if (_monitor->Length() > 0) {
109+
if (_monitor.Length() > 0) {
110110
Core::ProxyType<Web::JSONBodyType<Core::JSON::ArrayType<Monitor::Data>>> response(jsonBodyDataFactory.Element());
111111

112-
_monitor->Snapshot(*response);
113-
#ifndef USE_THUNDER_R4
114-
result->Body(Core::proxy_cast<Web::IBody>(response));
115-
#else
112+
_monitor.Snapshot(*response);
113+
116114
result->Body(Core::ProxyType<Web::IBody>(response));
117-
#endif /* USE_THUNDER_R4 */
118115
}
119116
} else {
120117
MetaData memoryInfo;
118+
bool operational = false;
121119

122120
// Seems we only want 1 name
123-
if (_monitor->Snapshot(index.Current().Text(), memoryInfo) == true) {
121+
if (_monitor.Snapshot(index.Current().Text(), memoryInfo, operational) == true) {
124122
Core::ProxyType<Web::JSONBodyType<Monitor::Data::MetaData>> response(jsonMemoryBodyDataFactory.Element());
125123

126-
*response = memoryInfo;
127-
#ifndef USE_THUNDER_R4
128-
result->Body(Core::proxy_cast<Web::IBody>(response));
129-
#else
124+
*response = Monitor::Data::MetaData(memoryInfo, operational);
125+
130126
result->Body(Core::ProxyType<Web::IBody>(response));
131-
#endif /* USE_THUNDER_R4 */
132127
}
133128
}
134129

135130
result->ContentType = Web::MIME_JSON;
136131
} else if ((request.Verb == Web::Request::HTTP_PUT) && (index.Next() == true)) {
137132
MetaData memoryInfo;
133+
bool operational = false;
138134

139135
// Seems we only want 1 name
140-
if (_monitor->Reset(index.Current().Text(), memoryInfo) == true) {
136+
if (_monitor.Reset(index.Current().Text(), memoryInfo, operational) == true) {
141137
Core::ProxyType<Web::JSONBodyType<Monitor::Data::MetaData>> response(jsonMemoryBodyDataFactory.Element());
142138

143-
*response = memoryInfo;
144-
#ifndef USE_THUNDER_R4
145-
result->Body(Core::proxy_cast<Web::IBody>(response));
146-
#else
139+
*response = Monitor::Data::MetaData(memoryInfo, operational);
140+
147141
result->Body(Core::ProxyType<Web::IBody>(response));
148-
#endif /* USE_THUNDER_R4 */
149142
}
150143

151144
result->ContentType = Web::MIME_JSON;
@@ -161,7 +154,7 @@ namespace Plugin {
161154
restartLimit = body->Restart.Limit;
162155
}
163156
TRACE(Trace::Information, (_T("Sets Restart Limits:[LIMIT:%d, WINDOW:%d]"), restartLimit, restartWindow));
164-
_monitor->Update(observable, restartWindow, restartLimit);
157+
_monitor.Update(observable, restartWindow, restartLimit);
165158
} else {
166159
result->ErrorCode = Web::STATUS_BAD_REQUEST;
167160
result->Message = _T(" could not handle your request.");
@@ -170,4 +163,4 @@ namespace Plugin {
170163
return (result);
171164
}
172165
}
173-
}
166+
}

0 commit comments

Comments
 (0)