Skip to content

Commit

Permalink
Merge pull request #6017 from bvanav648/Monitor-Plugin-Sync-xumo4
Browse files Browse the repository at this point in the history
RDKTV-34659, RDK-55125: Monitor Plugin Sync
  • Loading branch information
binuinbaraj authored Jan 22, 2025
2 parents 5b170d0 + 3bf349a commit a516bbb
Show file tree
Hide file tree
Showing 4 changed files with 214 additions and 337 deletions.
4 changes: 4 additions & 0 deletions Monitor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ All notable changes to this RDK Service will be documented in this file.

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

## [2.0.0] - 2024-12-12
### Changed
- Synced Monitor Plugin with WebPlatformForEmbedded/ThunderNanoServicesRDK/tree/R4_4/Monitor

## [1.0.9] - 2024-07-25
### Changed
- Added the NetworkManager Plugin into MOnitor config list
Expand Down
77 changes: 35 additions & 42 deletions Monitor/Monitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,26 @@

#include "Monitor.h"

#define API_VERSION_NUMBER_MAJOR 1
#define API_VERSION_NUMBER_MAJOR 2
#define API_VERSION_NUMBER_MINOR 0
#define API_VERSION_NUMBER_PATCH 9
#define API_VERSION_NUMBER_PATCH 0

namespace WPEFramework {

namespace {

static Plugin::Metadata<Plugin::Monitor> metadata(
// Version (Major, Minor, Patch)
API_VERSION_NUMBER_MAJOR, API_VERSION_NUMBER_MINOR, API_VERSION_NUMBER_PATCH,
// Preconditions
{},
// Terminations
{},
// Controls
{}
);
}

namespace Plugin {

SERVICE_REGISTRATION(Monitor, API_VERSION_NUMBER_MAJOR, API_VERSION_NUMBER_MINOR, API_VERSION_NUMBER_PATCH);
namespace {

static Plugin::Metadata<Plugin::Monitor> metadata(
// Version (Major, Minor, Patch)
API_VERSION_NUMBER_MAJOR, API_VERSION_NUMBER_MINOR, API_VERSION_NUMBER_PATCH,
// Preconditions
{},
// Terminations
{},
// Controls
{}
);
}

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

// Create a list of plugins to monitor..
_monitor->Open(service, index);
_monitor.Open(service, index);

// During the registartion, all Plugins, currently active are reported to the sink.
service->Register(_monitor);
service->Register(&_monitor);

RegisterAll();

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

/* virtual */ void Monitor::Deinitialize(PluginHost::IShell* service)
{
UnregisterAll();

_monitor->Close();
service->Unregister(&_monitor);

service->Unregister(_monitor);
_monitor.Close();
}

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

_monitor->Snapshot(*response);
#ifndef USE_THUNDER_R4
result->Body(Core::proxy_cast<Web::IBody>(response));
#else
_monitor.Snapshot(*response);

result->Body(Core::ProxyType<Web::IBody>(response));
#endif /* USE_THUNDER_R4 */
}
} else {
MetaData memoryInfo;
bool operational = false;

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

*response = memoryInfo;
#ifndef USE_THUNDER_R4
result->Body(Core::proxy_cast<Web::IBody>(response));
#else
*response = Monitor::Data::MetaData(memoryInfo, operational);

result->Body(Core::ProxyType<Web::IBody>(response));
#endif /* USE_THUNDER_R4 */
}
}

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

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

*response = memoryInfo;
#ifndef USE_THUNDER_R4
result->Body(Core::proxy_cast<Web::IBody>(response));
#else
*response = Monitor::Data::MetaData(memoryInfo, operational);

result->Body(Core::ProxyType<Web::IBody>(response));
#endif /* USE_THUNDER_R4 */
}

result->ContentType = Web::MIME_JSON;
Expand All @@ -161,7 +154,7 @@ namespace Plugin {
restartLimit = body->Restart.Limit;
}
TRACE(Trace::Information, (_T("Sets Restart Limits:[LIMIT:%d, WINDOW:%d]"), restartLimit, restartWindow));
_monitor->Update(observable, restartWindow, restartLimit);
_monitor.Update(observable, restartWindow, restartLimit);
} else {
result->ErrorCode = Web::STATUS_BAD_REQUEST;
result->Message = _T(" could not handle your request.");
Expand All @@ -170,4 +163,4 @@ namespace Plugin {
return (result);
}
}
}
}
Loading

0 comments on commit a516bbb

Please sign in to comment.